예제 #1
0
        /// <summary>
        /// <para>Gets the registered <see cref="IXmlIncludeTypeService"/>.</para>
        /// </summary>
        /// <param name="serviceProvider">
        /// <para>The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</para>
        /// </param>
        /// <returns>The registered <see cref="IXmlIncludeTypeService"/>.</returns>
        public static IXmlIncludeTypeService GetXmlIncludeTypeService(IServiceProvider serviceProvider)
        {
            IXmlIncludeTypeService xmlIncludeTypeService = serviceProvider.GetService(typeof(IXmlIncludeTypeService)) as IXmlIncludeTypeService;

            Debug.Assert(xmlIncludeTypeService != null, "Could not get the IXmlIncludeTypeService");
            return(xmlIncludeTypeService);
        }
예제 #2
0
        private static void RegisterXmlIncludeTypes(IServiceProvider serviceProvider)
        {
            IXmlIncludeTypeService xmlIncludeTypeService = serviceProvider.GetService(typeof(IXmlIncludeTypeService)) as IXmlIncludeTypeService;

            Debug.Assert(xmlIncludeTypeService != null, "Could not find the IXmlIncludeTypeService");
            xmlIncludeTypeService.AddXmlIncludeType(DistributorSettings.SectionName, typeof(DatabaseSinkData));
        }
        private static void RegisterXmlIncludeTypes(IServiceProvider serviceProvider)
        {
            IXmlIncludeTypeService xmlIncludeTypeService = serviceProvider.GetService(typeof(IXmlIncludeTypeService)) as IXmlIncludeTypeService;

            Debug.Assert(xmlIncludeTypeService != null, "Could not find the IXmlIncludeTypeService");
            xmlIncludeTypeService.AddXmlIncludeType(SecuritySettings.SectionName, typeof(CachingStoreProviderData));
        }
예제 #4
0
        private static void RegisterXmlIncludeTypes(IServiceProvider serviceProvider)
        {
            IXmlIncludeTypeService xmlIncludeTypeService = serviceProvider.GetService(typeof(IXmlIncludeTypeService)) as IXmlIncludeTypeService;

            Debug.Assert(xmlIncludeTypeService != null, "Could not find the IXmlIncludeTypeService");
            xmlIncludeTypeService.AddXmlIncludeType(CacheManagerSettings.SectionName, typeof(SymmetricStorageEncryptionProviderData));
        }
예제 #5
0
 public virtual void SetUp()
 {
     host                         = new ConfigurationDesignHost();
     hierarchyService             = (IUIHierarchyService)host.GetService(typeof(IUIHierarchyService));
     configurationErrorLogService = (IConfigurationErrorLogService)host.GetService(typeof(IConfigurationErrorLogService));
     xmlIncludeTypeService        = (IXmlIncludeTypeService)host.GetService(typeof(IXmlIncludeTypeService));
     nodeCreationService          = (INodeCreationService)host.GetService(typeof(INodeCreationService));
     container                    = (IContainer)host.GetService(typeof(IContainer));
     linkNodeService              = (ILinkNodeService)host.GetService(typeof(ILinkNodeService));
     host.AddService(typeof(IUIService), new MyUIService(this));
     validationErrorsCount    = 0;
     configurationErrorsCount = 0;
     applicationNode          = new ApplicationConfigurationNode(ApplicationData.FromCurrentAppDomain());
     uiHierarchy = CreateHierarchyAndAddToHierarchyService(applicationNode, CreateDefaultConfiguration());
 }
        protected override void ExecuteCore(ConfigurationNode node)
        {
            ConfigurationSectionCollectionNode configurationSectionCollectionNode = CurrentHierarchy.FindNodeByType(typeof(ConfigurationSectionCollectionNode)) as ConfigurationSectionCollectionNode;

            if (configurationSectionCollectionNode == null)
            {
                return;
            }

            IXmlIncludeTypeService service = XmlIncludeTypeService;

            Type[] types = null;
            XmlSerializerTransformerNode transformerNode = null;

            foreach (ConfigurationNode configurationNode in configurationSectionCollectionNode.Nodes)
            {
                transformerNode = CurrentHierarchy.FindNodeByType(configurationNode, typeof(XmlSerializerTransformerNode)) as XmlSerializerTransformerNode;
                if (transformerNode == null)
                {
                    continue;
                }
                types = service.GetXmlIncludeTypes(configurationNode.Name);
                if (types == null)
                {
                    continue;
                }
                ArrayList nodesToRemove = new ArrayList();
                foreach (Type t in types)
                {
                    if (!FindNodTypeToDataTypeMatchRecursive(node, t))
                    {
                        continue;
                    }
                    foreach (XmlIncludeTypeNode xmlIncludeTypeNode in transformerNode.Nodes)
                    {
                        Type includeType = Type.GetType(xmlIncludeTypeNode.TypeName, false, true);
                        if (includeType.Equals(t))
                        {
                            nodesToRemove.Add(xmlIncludeTypeNode);
                        }
                    }
                }
                foreach (ConfigurationNode nodeToRemove in nodesToRemove)
                {
                    nodeToRemove.Remove();
                }
            }
        }
예제 #7
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);
        }
예제 #8
0
        protected override void ExecuteCore(ConfigurationNode node)
        {
            ConfigurationSectionCollectionNode configurationSectionCollectionNode = node.Hierarchy.FindNodeByType(typeof(ConfigurationSectionCollectionNode)) as ConfigurationSectionCollectionNode;

            if (configurationSectionCollectionNode == null)
            {
                return;
            }

            IXmlIncludeTypeService service = GetService(typeof(IXmlIncludeTypeService)) as IXmlIncludeTypeService;

            Type[] types = null;
            XmlSerializerTransformerNode transformerNode = null;

            foreach (ConfigurationNode configurationNode in configurationSectionCollectionNode.Nodes)
            {
                transformerNode = node.Hierarchy.FindNodeByType(configurationNode, typeof(XmlSerializerTransformerNode)) as XmlSerializerTransformerNode;
                if (transformerNode == null)
                {
                    continue;
                }
                types = service.GetXmlIncludeTypes(configurationNode.Name);
                if (types == null)
                {
                    continue;
                }
                foreach (Type t in types)
                {
                    INodeCreationService nodeCreationService = (INodeCreationService)GetService(typeof(INodeCreationService));
                    if (!nodeCreationService.DoesNodeTypeMatchDataType(nodeType, t))
                    {
                        continue;
                    }
                    if (node.Hierarchy.FindNodeByName(transformerNode, t.Name) == null)
                    {
                        transformerNode.Nodes.Add(new XmlIncludeTypeNode(new XmlIncludeTypeData(t.Name, t.AssemblyQualifiedName)));
                    }
                }
            }
        }
예제 #9
0
        public void AssertCanGetAllServices()
        {
            IContainer container = Host.GetService(typeof(IContainer)) as IContainer;

            Assert.IsNotNull(container);
            IComponentChangeService changeService = Host.GetService(typeof(IComponentChangeService)) as IComponentChangeService;

            Assert.IsNotNull(changeService);
            INodeNameCreationService nodeNameCreationService = Host.GetService(typeof(INodeNameCreationService)) as INodeNameCreationService;

            Assert.IsNotNull(nodeNameCreationService);
            INameCreationService nameCreationService = Host.GetService(typeof(INameCreationService)) as INameCreationService;

            Assert.IsNotNull(nameCreationService);
            IUIHierarchyService hierarchyService = Host.GetService(typeof(IUIHierarchyService)) as IUIHierarchyService;

            Assert.IsNotNull(hierarchyService);
            IDictionaryService dictionaryService = Host.GetService(typeof(IDictionaryService)) as IDictionaryService;

            Assert.IsNotNull(dictionaryService);
            IConfigurationErrorLogService configurationErrorLogService = Host.GetService(typeof(IConfigurationErrorLogService)) as IConfigurationErrorLogService;

            Assert.IsNotNull(configurationErrorLogService);
            INodeCreationService nodeCreationService = Host.GetService(typeof(INodeCreationService)) as INodeCreationService;

            Assert.IsNotNull(nodeCreationService);
            IXmlIncludeTypeService xmlIncludeTypeService = Host.GetService(typeof(IXmlIncludeTypeService)) as IXmlIncludeTypeService;

            Assert.IsNotNull(xmlIncludeTypeService);
            ILinkNodeService linkNodeService = Host.GetService(typeof(ILinkNodeService)) as ILinkNodeService;

            Assert.IsNotNull(linkNodeService);
            IMenuContainerService menuContainerService = Host.GetService(typeof(IMenuContainerService)) as IMenuContainerService;

            Assert.IsNotNull(menuContainerService);
        }
예제 #10
0
        private static void RegisterXmlIncludeTypes(IServiceProvider serviceProvider)
        {
            IXmlIncludeTypeService xmlIncludeTypeService = ServiceHelper.GetXmlIncludeTypeService(serviceProvider);

            xmlIncludeTypeService.AddXmlIncludeType(ExceptionHandlingSettings.SectionName, typeof(LoggingExceptionHandlerData));
        }
예제 #11
0
        private static void RegisterXmlIncludeTypes(IServiceProvider serviceProvider)
        {
            IXmlIncludeTypeService xmlIncludeTypeService = ServiceHelper.GetXmlIncludeTypeService(serviceProvider);

            xmlIncludeTypeService.AddXmlIncludeType(SecuritySettings.SectionName, typeof(DbAuthenticationProviderData));
        }
 public virtual void SetUp()
 {
     host = new ConfigurationDesignHost();
     hierarchyService = (IUIHierarchyService)host.GetService(typeof(IUIHierarchyService));
     configurationErrorLogService = (IConfigurationErrorLogService)host.GetService(typeof(IConfigurationErrorLogService));
     xmlIncludeTypeService = (IXmlIncludeTypeService)host.GetService(typeof(IXmlIncludeTypeService));
     nodeCreationService = (INodeCreationService)host.GetService(typeof(INodeCreationService));
     container = (IContainer)host.GetService(typeof(IContainer));
     linkNodeService = (ILinkNodeService)host.GetService(typeof(ILinkNodeService));
     host.AddService(typeof(IUIService), new MyUIService(this));
     validationErrorsCount = 0;
     configurationErrorsCount = 0;
     applicationNode = new ApplicationConfigurationNode(ApplicationData.FromCurrentAppDomain());
     uiHierarchy = CreateHierarchyAndAddToHierarchyService(applicationNode, CreateDefaultConfiguration());
 }