Пример #1
0
        /// <summary>
        /// Creates a <see cref="ReflectedClass"/> from a <paramref name="type"/>.
        /// </summary>
        /// <param name="type">Type from which the reflected class will be created.</param>
        public ReflectedClass Create(Type type)
        {
            var reflectedClass = new ReflectedClass();

            reflectedClass.type = type;

            var constructor = this.ResolveConstructor(type);

            if (constructor != null)
            {
                if (constructor.GetParameters().Length == 0)
                {
                    reflectedClass.constructor = MethodUtils.CreateConstructor(type, constructor);
                }
                else
                {
                    reflectedClass.paramsConstructor = MethodUtils.CreateConstructorWithParams(type, constructor);
                    ;
                }
            }

            reflectedClass.constructorParameters = this.ResolveConstructorParameters(constructor);
            reflectedClass.methods    = this.ResolveMethods(type);
            reflectedClass.properties = this.ResolveProperties(type);
            reflectedClass.fields     = this.ResolveFields(type);

            return(reflectedClass);
        }
Пример #2
0
        /// <summary>
        /// Creates a <see cref="ReflectedClass"/> from a <paramref name="type"/>.
        /// </summary>
        /// <param name="type">Type from which the reflected class will be created.</param>
        public ReflectedClass Create(Type type)
        {
            var reflectedClass = new ReflectedClass();

            reflectedClass.type = type;

            var constructor = this.ResolveConstructor(type);
            if (constructor != null) {
                if (constructor.GetParameters().Length == 0) {
                    reflectedClass.constructor = MethodUtils.CreateConstructor(type, constructor);
                } else {
                    reflectedClass.paramsConstructor = MethodUtils.CreateConstructorWithParams(type, constructor);;
                }
            }

            reflectedClass.constructorParameters = this.ResolveConstructorParameters(constructor);
            reflectedClass.postConstructors = this.ResolvePostConstructors(type);
            reflectedClass.properties = this.ResolveProperties(type);
            reflectedClass.fields = this.ResolveFields(type);

            return reflectedClass;
        }