LinqBridge (Linq for C# 3.0 and .Net 2.0)

LinqBridge (Linq for C# 3.0 and .Net 2.0) - Using Linq for .Net 2.0 applications - Messages

#1 Posted: 2016/5/13 04:59:18
Вячеслав Мезенцев

Вячеслав Мезенцев

1,532 likes in 1,838 posts.

Group: Moderator

Usefull thing for developers who use .Net 2.0. I used this library in the DISLIN project.

It allows you to add extensions to standard classes (without using System.Core):

using System;
using System.Reflection;


namespace DISNet
{
    public static class Extensions
    {
        public static bool IsExtern( this MethodInfo method )
        {
            return method.GetMethodBody() == null && method.IsStatic && method.IsPublic;
        }
    }
}

// ...

public static void Initialize()
{
    TermsHandled = new TermInfo[ 0 ];
    var info = new List<TermInfo>();

    var type = typeof( dislin );

    foreach ( var method in type.GetMethods().Where( method => method.IsExtern() ) )
    {
        try
        {
            var item = GetTermInfo( method );

            info.Add( item );
        }
        catch ( Exception ex )
        {
            Logger.LogError( "[Manager.Initialize()] " + ex.Message );
        }
    }

    TermsHandled = info.ToArray();
}

Links:

1. LinqBridge.
Russia ☭ forever, Viacheslav N. Mezentsev
2 users liked this post
Davide Carpi 2016/5/13 05:52:00, Andrey Ivashov 2016/5/14 07:17:00
  • New Posts
  • No New Posts