private static DocumentNode MergeSchemas(
            IDescriptorContext context,
            IDictionary <NameString, DocumentNode> schemas)
        {
            var merger = new SchemaMerger();

            foreach (NameString name in schemas.Keys)
            {
                merger.AddSchema(name, schemas[name]);
            }

            foreach (MergeTypeRuleFactory handler in context.GetTypeMergeRules())
            {
                merger.AddTypeMergeRule(handler);
            }

            foreach (MergeDirectiveRuleFactory handler in context.GetDirectiveMergeRules())
            {
                merger.AddDirectiveMergeRule(handler);
            }

            foreach (IDocumentRewriter rewriter in context.GetDocumentRewriter())
            {
                merger.AddDocumentRewriter(rewriter);
            }

            foreach (ITypeRewriter rewriter in context.GetTypeRewriter())
            {
                merger.AddTypeRewriter(rewriter);
            }

            return(merger.Merge());
        }