예제 #1
0
        /// <summary>
        /// Gets the <see cref="InjectAttribute"/> on properties.
        /// </summary>
        /// <param myName="memberInfo">The <see cref="MemberInfo"/>.</param>
        /// <returns>The attribute</returns>
        public static InjectAttribute GetInjectAttribute(MemberInfo memberInfo)
        {
            InjectAttribute attribute = Attribute.GetCustomAttribute(memberInfo, typeof(InjectAttribute), true) as InjectAttribute;

            if (attribute != null)
            {
                attribute.Name = attribute.Name ?? memberInfo.Name;
            }
            return(attribute);
        }
예제 #2
0
        /// <summary>
        /// Usually the implementation will look in the configuration property
        /// of the model or the service interface, or the implementation looking for
        /// something.
        /// </summary>
        /// <param name="kernel">The kernel instance</param>
        /// <param name="model">The component model</param>
        public void ProcessModel(IKernel kernel, ComponentModel model)
        {
            PropertyInfo[] properties = model.Implementation.GetProperties(BINDING_FLAGS_SET);

            IDictionary <InjectAttribute, PropertyInfo>       inMembers       = new Dictionary <InjectAttribute, PropertyInfo>();
            IDictionary <InjectEntityAttribute, PropertyInfo> inEntityMembers = new Dictionary <InjectEntityAttribute, PropertyInfo>();

            for (int i = 0; i < properties.Length; i++)
            {
                InjectAttribute injectAttribute = AttributeUtil.GetInjectAttribute(properties[i]);
                if (injectAttribute != null)
                {
                    inMembers.Add(injectAttribute, properties[i]);
                }

                InjectEntityAttribute injectEntityAttribute = AttributeUtil.GetInjectEntityAttribute(properties[i]);
                if (injectEntityAttribute != null)
                {
                    inEntityMembers.Add(injectEntityAttribute, properties[i]);
                }
            }
            model.ExtendedProperties[InMembers]       = inMembers;
            model.ExtendedProperties[InEntityMembers] = inEntityMembers;
        }