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 - 消息

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

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

1,558个赞,共1,868个帖子。

组: 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位用户喜欢此帖子
Davide Carpi 2016/5/13 05:52:00, Andrey Ivashov 2016/5/14 07:17:00
  • 有新帖
  • 无新帖