Example #1
0
        private Type[] GetXmlIncludeTypes()
        {
            Type[] includeTypes = null;
            if (this.Parent == null)
            {
                return(includeTypes);
            }

            string sectionName             = this.Parent.Name;
            IXmlIncludeTypeService service = GetService(typeof(IXmlIncludeTypeService)) as IXmlIncludeTypeService;

            Debug.Assert(service != null, "Could not get the IXmlIncludeTypeService.");
            includeTypes = service.GetXmlIncludeTypes(sectionName);
            if (includeTypes == null)
            {
                return(includeTypes);
            }

            INodeCreationService nodeCreationService = GetService(typeof(INodeCreationService)) as INodeCreationService;

            Debug.Assert(nodeCreationService != null, "Could not get the INodeCreationService.");

            // make sure that we actually used these xml include types in the application
            ArrayList usedTypes = new ArrayList();

            foreach (Type includeType in includeTypes)
            {
                Type nodeType = nodeCreationService.GetNodeType(includeType);
                if (nodeType == null)
                {
                    continue;
                }
                if (Hierarchy.ContainsNodeType(nodeType))
                {
                    usedTypes.Add(includeType);
                }
            }
            includeTypes = new Type[usedTypes.Count];
            usedTypes.CopyTo(includeTypes);
            return(includeTypes);
        }