Пример #1
0
		public CallbackTarget( ConfigurationAttribute ca, MethodInfo methodInfo ) : base( ca )
		{
			dispatcher = new MethodDispatcher( new MethodInvoker( methodInfo, ca.RequiredParameters ) );
		}
Пример #2
0
		public ElementTarget( ConfigurationAttribute ca )
		{
			XmlNodePath = ca.XmlNodePath;
			KeyPresenceRequirement = ca.KeyPresenceRequirement;
		}
Пример #3
0
        /// <summary>
        /// Construct a new ConfigurationMap for the given type. This involves reflecting
        /// on the given type to find all static and instance members carrying
        /// the <see cref="ConfigurationAttribute"/>.
        /// </summary>
        public ConfigurationMap(Type type)
        {
            // find instance members tagged for configuration
            IList memberAttributeInfos = Reflector.FindMembers(Reflector.InstanceCriteria, type, false, typeof(ConfigurationAttribute));

            foreach (MemberAttributeInfo mai in memberAttributeInfos)
            {
                ConfigurationAttribute ca = mai.Attributes[0] as ConfigurationAttribute;
                switch (mai.MemberInfo.MemberType)
                {
                case MemberTypes.Method:
                    CallbackTarget target = null;
                    if (instanceOverloads.ContainsKey(ca.XmlNodePath))
                    {
                        target = instanceOverloads[ca.XmlNodePath] as CallbackTarget;
                    }
                    if (target != null)
                    {
                        target.AddCallbackMethod(mai.MemberInfo as MethodInfo, ca.RequiredParameters);
                    }
                    else
                    {
                        target = new CallbackTarget(ca, mai.MemberInfo as MethodInfo);
                        instanceTargets.Add(target);
                        instanceOverloads[ca.XmlNodePath] = target;
                    }
                    break;

                case MemberTypes.Field:
                    instanceTargets.Add(new FieldTarget(ca, mai.MemberInfo as FieldInfo));
                    break;

                case MemberTypes.Property:
                    instanceTargets.Add(new PropertyTarget(ca, mai.MemberInfo as PropertyInfo));
                    break;

                default:
                    Check.LogError(LogCategories.Metadata, "Unknown configuration target type for member {0} on class {1}.", mai.MemberInfo.Name, type);
                    break;
                }
            }
            // find static members tagged for configuration
            memberAttributeInfos = Reflector.FindMembers(Reflector.StaticCriteria, type, false, typeof(ConfigurationAttribute));
            foreach (MemberAttributeInfo mai in memberAttributeInfos)
            {
                ConfigurationAttribute ca = mai.Attributes[0] as ConfigurationAttribute;
                switch (mai.MemberInfo.MemberType)
                {
                case MemberTypes.Method:
                    CallbackTarget target = null;
                    if (staticOverloads.ContainsKey(ca.XmlNodePath))
                    {
                        target = staticOverloads[ca.XmlNodePath] as CallbackTarget;
                    }
                    if (target != null)
                    {
                        target.AddCallbackMethod(mai.MemberInfo as MethodInfo, ca.RequiredParameters);
                    }
                    else
                    {
                        target = new CallbackTarget(ca, mai.MemberInfo as MethodInfo);
                        staticTargets.Add(target);
                        staticOverloads[ca.XmlNodePath] = target;
                    }
                    break;

                case MemberTypes.Field:
                    staticTargets.Add(new FieldTarget(ca, mai.MemberInfo as FieldInfo));
                    break;

                case MemberTypes.Property:
                    staticTargets.Add(new PropertyTarget(ca, mai.MemberInfo as PropertyInfo));
                    break;

                default:
                    Check.LogError(LogCategories.Metadata, "Unknown configuration target type for member {0} on class {1}.", mai.MemberInfo.Name, type);
                    break;
                }
            }
        }
Пример #4
0
 public ElementTarget(ConfigurationAttribute ca)
 {
     XmlNodePath            = ca.XmlNodePath;
     KeyPresenceRequirement = ca.KeyPresenceRequirement;
 }
Пример #5
0
		public PropertyTarget( ConfigurationAttribute ca, PropertyInfo propertyInfo ) : base( ca )
		{
			PropertyInfo = propertyInfo;
		}
Пример #6
0
 public FieldTarget(ConfigurationAttribute ca, FieldInfo fieldInfo) : base(ca)
 {
     FieldInfo = fieldInfo;
 }
Пример #7
0
		public FieldTarget( ConfigurationAttribute ca, FieldInfo fieldInfo ) : base( ca )
		{
			FieldInfo = fieldInfo;
		}
Пример #8
0
 public PropertyTarget(ConfigurationAttribute ca, PropertyInfo propertyInfo) : base(ca)
 {
     PropertyInfo = propertyInfo;
 }
Пример #9
0
 public CallbackTarget(ConfigurationAttribute ca, MethodInfo methodInfo) : base(ca)
 {
     dispatcher = new MethodDispatcher(new MethodInvoker(methodInfo, ca.RequiredParameters));
 }