コード例 #1
0
        public async Task MemberMapPropertyCodeBuilderTest()
        {
            var         source      = @"
    public interface IA
    {
        Regulus.Remote.Property<int> Property1{get;}
    }
    namespace NS1
    {
        
        
        public class C1
        {
        }
        
        public interface IB
        {
            Regulus.Remote.Property<C1> Property1{get;}
        }
    }

";
            var         tree        = CSharpSyntaxTree.ParseText(source);
            Compilation compilation = tree.Compilation();

            var builder = new MemberMapCodeBuilder(compilation);

            NUnit.Framework.Assert.AreEqual(@"typeof(global::IA).GetProperty(""Property1""),typeof(global::NS1.IB).GetProperty(""Property1"")", builder.PropertyInfosCode);
        }
コード例 #2
0
        public async Task MemberMapMethodCodeBuilderTest()
        {
            var         source      = @"
public interface IA
    {
        Regulus.Remote.Value<int> Method1(int a1,int a2);
    }
namespace NS1
{
    
    
public interface IB
    {
        Regulus.Remote.Value<int> Method1(int a1,int a2);
        Regulus.Remote.Value<int> Method2();
    }
}

";
            var         tree        = CSharpSyntaxTree.ParseText(source);
            Compilation compilation = tree.Compilation();
            //new Regulus.Utility.Reflection.TypeMethodCatcher((System.Linq.Expressions.Expression<System.Action<global::IA,int,int>>)((ins,_1,_2) => ins.Method(_1,_2))).Method,new Regulus.Utility.Reflection.TypeMethodCatcher((System.Linq.Expressions.Expression<System.Action<global::NS1.IB,int,int>>)((ins,_1,_2) => ins.Method(_1,_2))).Method
            var builder = new MemberMapCodeBuilder(compilation);

            NUnit.Framework.Assert.AreEqual("new Regulus.Utility.Reflection.TypeMethodCatcher((System.Linq.Expressions.Expression<System.Action<global::IA,int,int>>)((ins,_1,_2) => ins.Method1(_1,_2))).Method,new Regulus.Utility.Reflection.TypeMethodCatcher((System.Linq.Expressions.Expression<System.Action<global::NS1.IB,int,int>>)((ins,_1,_2) => ins.Method1(_1,_2))).Method,new Regulus.Utility.Reflection.TypeMethodCatcher((System.Linq.Expressions.Expression<System.Action<global::NS1.IB>>)((ins) => ins.Method2())).Method", builder.MethodInfosCode);
        }
コード例 #3
0
        public async Task MemberMapInterfaceCodeBuilderTest()
        {
            var         source      = @"
public interface IA
    {
        
    }
namespace NS1
{
    
    public class C1{}
public interface IB
    {
       
    }
}

";
            var         tree        = CSharpSyntaxTree.ParseText(source);
            Compilation compilation = tree.Compilation();

            var builder = new MemberMapCodeBuilder(compilation);

            NUnit.Framework.Assert.AreEqual(@"new System.Tuple<System.Type, System.Func<Regulus.Remote.IProvider>>(typeof(global::IA),()=>new Regulus.Remote.TProvider<global::IA>()),new System.Tuple<System.Type, System.Func<Regulus.Remote.IProvider>>(typeof(global::NS1.IB),()=>new Regulus.Remote.TProvider<global::NS1.IB>())", builder.InterfacesCode);
        }
コード例 #4
0
        public async Task MemberMapEventCodeBuilderTest()
        {
            var         source      = @"
public interface IA
    {
        event System.Action Event1;
    }
namespace NS1
{
    
    public class C1{}
public interface IB
    {
        event System.Action<C1,string> Event1;
    }
}

";
            var         tree        = CSharpSyntaxTree.ParseText(source);
            Compilation compilation = tree.Compilation();

            var builder = new MemberMapCodeBuilder(compilation);

            NUnit.Framework.Assert.AreEqual(@"typeof(global::IA).GetEvent(""Event1""),typeof(global::NS1.IB).GetEvent(""Event1"")", builder.EventInfosCode);
        }