Ejemplo n.º 1
0
        ///<summary>
        ///</summary>
        ///<param name="adapter"></param>
        ///<returns></returns>
        public static List<ChildGroupDescriptor> GetChildGroupsReferences(GroupAdapter adapter)
        {
            Type adapterType = adapter.GetType();
            Type componentType = adapter.ComponentType;
            List<ChildGroupDescriptor> descriptors = new List<ChildGroupDescriptor>();

            foreach (MemberInfo memberInfo in adapterType.GetMembers())
            {
                var attributes = Core.Reflection.CoreReflector.GetMemberAttributes<ChildCollectionAttribute>(memberInfo);

                if (null != attributes && attributes.Count > 0)
                {
                    ChildCollectionAttribute attribute = attributes[0];
                    MemberInfo mi = null;
                    if (!string.IsNullOrEmpty(attribute.TargetContainer)) {
                        MemberInfo[] list = componentType.GetMember(attribute.TargetContainer);
                        if (list.Length > 0)
                            mi = list[0];
                    }
                    
                    ChildGroupDescriptor descriptor = new ChildGroupDescriptor
                    {
                        Attribute = attribute,
                        CollectionMemberInfo = memberInfo,
                        TargetContainerMemberInfo = mi
                    };
                    descriptors.Insert(0, descriptor);
                }
            }

            return descriptors;
        }
Ejemplo n.º 2
0
        ///<summary>
        ///</summary>
        ///<param name="adapter"></param>
        ///<returns></returns>
        public static List <ChildGroupDescriptor> GetChildGroupsReferences(GroupAdapter adapter)
        {
            Type adapterType   = adapter.GetType();
            Type componentType = adapter.ComponentType;
            List <ChildGroupDescriptor> descriptors = new List <ChildGroupDescriptor>();

            foreach (MemberInfo memberInfo in adapterType.GetMembers())
            {
                var attributes = Core.Reflection.CoreReflector.GetMemberAttributes <ChildCollectionAttribute>(memberInfo);

                if (null != attributes && attributes.Count > 0)
                {
                    ChildCollectionAttribute attribute = attributes[0];
                    MemberInfo mi = null;
                    if (!string.IsNullOrEmpty(attribute.TargetContainer))
                    {
                        MemberInfo[] list = componentType.GetMember(attribute.TargetContainer);
                        if (list.Length > 0)
                        {
                            mi = list[0];
                        }
                    }

                    ChildGroupDescriptor descriptor = new ChildGroupDescriptor
                    {
                        Attribute                 = attribute,
                        CollectionMemberInfo      = memberInfo,
                        TargetContainerMemberInfo = mi
                    };
                    descriptors.Insert(0, descriptor);
                }
            }

            return(descriptors);
        }