Ejemplo n.º 1
0
        public override void Initialize()
        {
            var schemaFileNames           = Context.Configuration.SchemaFileNames;
            var schemaDependencyFileNames = Context.Configuration.SchemaDependencyFileNames;
            var allFileNames = schemaFileNames.Union(schemaDependencyFileNames,
                                                     StringComparer.OrdinalIgnoreCase);

            try
            {
                SchemaSet = XmlSchemaSetBuilder.Build(allFileNames);
            }
            catch (Exception ex)
            {
                throw ExceptionBuilder.ErrorBuildingSchemaSet(ex);
            }

            _schemaDependencyFiles = new HashSet <string>(schemaDependencyFileNames, StringComparer.OrdinalIgnoreCase);

            _objectParents = new Dictionary <XmlSchemaObject, HashSet <XmlSchemaObject> >();
            var parentFinderNew = new ParentFinder(SchemaSet, _objectParents);

            parentFinderNew.Traverse(SchemaSet);

            _typeUsages = new Dictionary <XmlSchemaType, HashSet <XmlSchemaObject> >();
            var typeUsageFinder = new TypeUsageFinder(SchemaSet, _typeUsages);

            typeUsageFinder.Traverse(SchemaSet);

            var rootSchemaFinder = new NamespaceRootSchemaFinder(_schemaDependencyFiles);

            rootSchemaFinder.Traverse(SchemaSet);
            _namespaceRootSchemas = rootSchemaFinder.GetRootSchemas();

            var rootElementFinder = new NamespaceRootElementFinder(SchemaSet);

            rootElementFinder.Traverse(SchemaSet);
            _namespaceRootElements = rootElementFinder.GetRootElements();

            RemoveDependencySchemaObjects(_namespaceRootSchemas);
            RemoveDependencySchemaObjects(_namespaceRootElements);
        }
Ejemplo n.º 2
0
        public override void Initialize()
        {
            var schemaFileNames = Context.Configuration.SchemaFileNames;
            var schemaDependencyFileNames = Context.Configuration.SchemaDependencyFileNames;
            var allFileNames = schemaFileNames.Union(schemaDependencyFileNames, StringComparer.OrdinalIgnoreCase);

            try
            {
                SchemaSet = XmlSchemaSetBuilder.Build(allFileNames);
            }
            catch (Exception ex)
            {
                throw ExceptionBuilder.ErrorBuildingSchemaSet(ex);
            }

            _schemaDependencyFiles = new HashSet<string>(schemaDependencyFileNames, StringComparer.OrdinalIgnoreCase);

            _objectParents = new Dictionary<XmlSchemaObject, HashSet<XmlSchemaObject>>();
            var parentFinderNew = new ParentFinder(SchemaSet, _objectParents);
            parentFinderNew.Traverse(SchemaSet);

            _typeUsages = new Dictionary<XmlSchemaType, HashSet<XmlSchemaObject>>();
            var typeUsageFinder = new TypeUsageFinder(SchemaSet, _typeUsages);
            typeUsageFinder.Traverse(SchemaSet);

            var rootSchemaFinder = new NamespaceRootSchemaFinder(_schemaDependencyFiles);
            rootSchemaFinder.Traverse(SchemaSet);
            _namespaceRootSchemas = rootSchemaFinder.GetRootSchemas();

            var rootElementFinder = new NamespaceRootElementFinder(SchemaSet);
            rootElementFinder.Traverse(SchemaSet);
            _namespaceRootElements = rootElementFinder.GetRootElements();

            RemoveDependencySchemaObjects(_namespaceRootSchemas);
            RemoveDependencySchemaObjects(_namespaceRootElements);
        }