예제 #1
0
        public IView Run()
        {
            var type = AssemblyModel.GetCtsType(Context, Namespace, TypeName);

            return(new EventView
            {
                Type = type,
                Event = type.Events.First(e => e.Name == EventName)
            });
        }
        public IView Run()
        {
            var type = AssemblyModel.GetCtsType(Context, Namespace, TypeName);

            return(new MethodView
            {
                Type = type,
                Methods = type.Methods.FindAll(m => m.Name == MethodName)
            });
        }
        public IView Run()
        {
            var type = AssemblyModel.GetCtsType(Context, Namespace, TypeName);

            return(new PropertyView
            {
                Type = type,
                Property = type.Properties.First(e => e.Name == PropertyName)
            });
        }
        public IView Run()
        {
            var type = AssemblyModel.GetCtsType(Context, Namespace, TypeName);

            return(new ConstructorView
            {
                Type = type,
                Constructors = type.Contructors
            });
        }
        public IView Run()
        {
            var type = AssemblyModel.GetCtsType(Context, Namespace, TypeName);

            //TODO: check if field does not exists throws exception
            return(new FieldView
            {
                Type = type,
                Field = type.Fields.First(e => e.Name == FieldName)
            });
        }
예제 #6
0
        public IView Run()
        {
            var type = AssemblyModel.GetCtsType(Context, Namespace, TypeName);

            return(new TypeView {
                Type = type,
                Constructors = type.Contructors,
                Events = type.Events,
                Fields = type.Fields,
                Methods = type.Methods,
                Properties = type.Properties
            });
        }
        public void GetTypeContextModel()
        {
            var  asm     = Assembly.LoadFrom(@"..\..\..\Test\ContextTest1\Microsoft.VisualBasic.dll");
            Type asmType = asm.GetType("Microsoft.VisualBasic.CompilerServices.IncompleteInitialization");

            AssemblyModel.AddContext("ContextTest1", @"..\..\..\Test\ContextTest1");

            var ns   = AssemblyModel.FindNamespace("Microsoft.VisualBasic.CompilerServices");
            var type = AssemblyModel.GetCtsType("ContextTest1", "Microsoft.VisualBasic.CompilerServices", "IncompleteInitialization");

            Assert.IsNotNull(type);
            Assert.AreEqual("Microsoft.VisualBasic.CompilerServices", type.Namespace.Name);
            Assert.AreEqual("ContextTest1", type.Assembly.Context.Name);
            Assert.AreEqual(3, type.Contructors.Count);
            Assert.AreEqual(0, type.Events.Count);
            Assert.AreEqual(0, type.Fields.Count);
            Assert.AreEqual("Microsoft.VisualBasic.CompilerServices.IncompleteInitialization", type.FullName);
            Assert.AreEqual(16, type.Methods.Count);
            Assert.AreEqual(7, type.Properties.Count);

            foreach (var fieldInfo in asmType.GetFields())
            {
                var info = fieldInfo;
                var ctor = type.Fields.Find(s => s.Name == info.Name);

                Assert.IsNotNull(ctor);
                Assert.AreEqual(info.Name, ctor.Name);
                Assert.AreEqual(info.FieldType.Name, ctor.Type.Name);
            }
            foreach (var propertyInfo in asmType.GetProperties())
            {
                var info = propertyInfo;
                var ctor = type.Properties.Find(s => s.Name == info.Name);

                Assert.IsNotNull(ctor);
                Assert.AreEqual(info.Name, ctor.Name);
                Assert.AreEqual(info.PropertyType.Name, ctor.Type.Name);
            }

            foreach (var constructorInfo in asmType.GetConstructors())
            {
                var info = constructorInfo;
                var ctor =
                    type.Contructors.Find(s => s.Name == info.Name);

                Assert.IsNotNull(ctor);
                Assert.AreEqual(constructorInfo.Name, ctor.Name);
            }
            foreach (var methodInfo in asmType.GetMethods())
            {
                var info  = methodInfo;
                var lmtor =
                    type.Methods.FindAll(s => (s.Name == info.Name) &&
                                         (s.Parameters.Count == info.GetParameters().Count()));

                var info2 = methodInfo;
                var mtor  = lmtor.Find(s => s.Parameters.TrueForAll(
                                           t => info2.GetParameters().ToList().Find(p => p.ParameterType.Name == t.Type.Name) != null));


                Assert.IsNotNull(mtor);
                Assert.AreEqual(methodInfo.Name, mtor.Name);
                Assert.AreEqual(methodInfo.GetParameters().Count(), mtor.Parameters.Count);
                Assert.AreEqual(methodInfo.ReturnType.Name, mtor.Return.Name);

                foreach (var parameterInfo in methodInfo.GetParameters())
                {
                    var info1 = parameterInfo;
                    var ptor  =
                        mtor.Parameters.Find(s => s.Name == info1.Name);

                    Assert.IsNotNull(ptor);
                    Assert.AreEqual(parameterInfo.Name, ptor.Name);
                    Assert.AreEqual(parameterInfo.ParameterType.Name, ptor.Type.Name);
                }
            }
        }