Exemplo n.º 1
0
        private Dictionary <string, ReflectedInteceptor> CreateReflectionInterceptors(T instance)
        {
            Dictionary <string, PropertyInfo> objProperties = PropertyUtil.GetPropertiesForClass(instance);

            Dictionary <string, ReflectedInteceptor> result = new Dictionary <string, ReflectedInteceptor>();

            if (Tracer.IsDebugEnabled)
            {
                List <string> stringPropertyNames = new List <string>(objProperties.Keys.Count);
                foreach (string pName in objProperties.Keys)
                {
                    string propertyName = this.PropertyPrefix + pName;
                    stringPropertyNames.Add(propertyName);
                }

                Tracer.DebugFormat("Creating reflection interceptors for Class instance {0}, Generating Properties = {1}", instance.GetType().Name, PropertyUtil.ToString(stringPropertyNames));
            }

            foreach (string key in objProperties.Keys)
            {
                string       propertyName = this.PropertyPrefix + key;
                PropertyInfo info         = objProperties[key];
                if (!CanReflect(info))
                {
                    continue;
                }
                //MethodInfo propGetter = info.GetGetMethod();
                Interceptor?reflectedInterceptor = CreateReflectedInterceptor(info);
                if (reflectedInterceptor != null)
                {
                    Interceptor         i  = (Interceptor)reflectedInterceptor;
                    ReflectedInteceptor ri = new ReflectedInteceptor()
                    {
                        ReflectedProperty = info,
                        BaseInterceptor   = i,
                    };
                    result.Add(propertyName, ri);
                }
            }

            return(result);
        }
Exemplo n.º 2
0
        private static object ParseReflectedValue(PropertyInfo info, string value)
        {
            Type targetType = info.PropertyType;

            return(PropertyUtil.ConvertType(targetType, value));
        }