Exemplo n.º 1
0
        private static DocumentNode RewriteTypeReferences(
            IReadOnlyList <ISchemaInfo> schemas,
            DocumentNode document)
        {
            DocumentNode current           = document;
            var          referenceRewriter = new TypeReferenceRewriter();

            foreach (ISchemaInfo schema in schemas)
            {
                current = referenceRewriter.RewriteSchema(current, schema.Name);
            }

            return(current);
        }
Exemplo n.º 2
0
        private IReadOnlyList <ISchemaInfo> CreateSchemaInfos()
        {
            List <SchemaInfo> original = _schemas
                                         .Select(t => new SchemaInfo(t.Key,
                                                                     PrepareSchemaDocument(t.Value, t.Key)))
                                         .ToList();

            if (_docRewriters.Count == 0 && _typeRewriters.Count == 0)
            {
                return(original);
            }

            var rewritten         = new List <SchemaInfo>();
            var referenceRewriter = new TypeReferenceRewriter();

            foreach (SchemaInfo schemaInfo in original)
            {
                DocumentNode current = schemaInfo.Document;
                current = RewriteDocument(schemaInfo, current);
                current = RewriteTypes(schemaInfo, current);

                if (current == schemaInfo.Document)
                {
                    rewritten.Add(schemaInfo);
                }
                else
                {
                    current = referenceRewriter.RewriteSchema(
                        current, schemaInfo.Name);

                    rewritten.Add(new SchemaInfo(
                                      schemaInfo.Name,
                                      current));
                }
            }

            return(rewritten);
        }