public void RefResolveMethodOneParamter_string_Int()
        {
            MethodInfo methodInfo = typeof(SampleCls).ResolveMethod("GetCount", new Type[] { typeof(string) }, new MethodParameter[] {
                MethodParameter.CreateGeneric <string>(true),
                MethodParameter.Create <int>()
            });

            Assert.IsNotNull(methodInfo);
            Assert.AreEqual("GetCount", methodInfo.Name);
            Assert.AreEqual(2, methodInfo.GetParameters().Length);
            Assert.AreEqual(true, methodInfo.GetParameters()[0].ParameterType.IsByRef);
            Assert.AreEqual(typeof(string), methodInfo.GetParameters()[0].ParameterType.GetElementType());

            Assert.AreEqual(typeof(int), methodInfo.GetParameters()[1].ParameterType);
        }
        public static void WriteElement(MethodGenerator g, string dtoMemberName, Type elementType, Action loadValue)
        {
            var method = typeof(IDTOWriter).ResolveMethod("WriteElement",
                                                          new Type[] { elementType },
                                                          MethodParameter.Create <string>(),
                                                          MethodParameter.Create <bool>(),
                                                          MethodParameter.CreateGeneric(elementType));
            var prmIndex = SerializationArgs.WriterIndex;

            g.Call(method, () =>
            {
                g.LoadParameter(prmIndex);
                g.Load(dtoMemberName);
                g.Load(IsPrimitive(elementType));
                loadValue();
            });
        }
        public void GenericResolveMethod_Generic_TwoParament()
        {
            MethodInfo methodInfo = typeof(SampleCls).ResolveMethod("GetCount", 2
                                                                    , new MethodParameter[] { MethodParameter.CreateGeneric(), MethodParameter.CreateGeneric() });

            Assert.IsNotNull(methodInfo);
            Assert.AreEqual("GetCount", methodInfo.Name);
            Assert.AreEqual(2, methodInfo.GetParameters().Length);
            Assert.AreEqual("T1", methodInfo.GetParameters()[0].ParameterType.Name);
            Assert.AreEqual("T2", methodInfo.GetParameters()[1].ParameterType.Name);

            Assert.AreEqual(2, methodInfo.GetGenericArguments().Length);
        }
        public void GenericResolveMethodOneParamterArgumentInheritSame_One_Int_String()
        {
            MethodInfo methodInfo = typeof(SampleInheritCls).ResolveMethod("GetCount", new Type[] { typeof(int) }
                                                                           , new MethodParameter[] { MethodParameter.CreateGeneric <int>(), MethodParameter.Create <string>() });

            Assert.IsNotNull(methodInfo);
            Assert.AreEqual("GetCount", methodInfo.Name);
            Assert.AreEqual(2, methodInfo.GetParameters().Length);
            Assert.AreEqual(typeof(int), methodInfo.GetParameters()[0].ParameterType);
            Assert.AreEqual(typeof(string), methodInfo.GetParameters()[1].ParameterType);

            SampleInheritCls cls  = new SampleInheritCls();
            string           text = (string)methodInfo.Invoke(cls, new object[] { 1, string.Empty });

            Assert.AreEqual("SampleInheritCls", text);
        }
        public void GenericResolveMethodOneParamterArgument_One_Int_String()
        {
            MethodInfo methodInfo = typeof(SampleCls).ResolveMethod("GetCount", new Type[] { typeof(int) }
                                                                    , new MethodParameter[] { MethodParameter.CreateGeneric <int>(), MethodParameter.Create <string>() });

            Assert.IsNotNull(methodInfo);
            Assert.AreEqual("GetCount", methodInfo.Name);
            Assert.AreEqual(2, methodInfo.GetParameters().Length);
            Assert.AreEqual(typeof(int), methodInfo.GetParameters()[0].ParameterType);
            Assert.AreEqual(typeof(string), methodInfo.GetParameters()[1].ParameterType);

            Assert.AreEqual(1, methodInfo.GetGenericArguments().Length);
            Assert.AreEqual(typeof(int), methodInfo.GetGenericArguments()[0]);
        }