Exemplo n.º 1
0
        public StylerService(IStylerOptions options)
        {
            this.xmlEscapingService          = new XmlEscapingService();
            this.documentManipulationService = new DocumentManipulationService(options);

            var indentService            = new IndentService(options);
            var markupExtensionFormatter = new MarkupExtensionFormatter(options.NoNewLineMarkupExtensions.ToList());
            var attributeInfoFactory     = new AttributeInfoFactory(new MarkupExtensionParser(), new AttributeOrderRules(options));
            var attributeInfoFormatter   = new AttributeInfoFormatter(markupExtensionFormatter, indentService);

            this.documentProcessors = new Dictionary <XmlNodeType, IDocumentProcessor>
            {
                // { XmlNodeType.None, null },
                { XmlNodeType.Element, new ElementDocumentProcessor(options, attributeInfoFactory, attributeInfoFormatter, indentService) },
                // { XmlNodeType.Attribute, null },
                { XmlNodeType.Text, new TextDocumentProcessor(indentService) },
                { XmlNodeType.CDATA, new CDATADocumentProcessor(indentService) },
                // { XmlNodeType.EntityReference, null },
                // { XmlNodeType.Entity, null },
                { XmlNodeType.ProcessingInstruction, new ProcessInstructionDocumentProcessor(indentService) },
                { XmlNodeType.Comment, new CommentDocumentProcessor(options, indentService) },
                // { XmlNodeType.Document, null },
                // { XmlNodeType.DocumentType, null },
                // { XmlNodeType.DocumentFragment, null },
                // { XmlNodeType.Notation, null },
                { XmlNodeType.Whitespace, new WhitespaceDocumentProcessor() },
                { XmlNodeType.SignificantWhitespace, new SignificantWhitespaceDocumentProcessor() },
                { XmlNodeType.EndElement, new EndElementDocumentProcessor(options, indentService) },
                // { XmlNodeType.EndEntity, null },
                // ignoring xml declarations for Xamarin support
                { XmlNodeType.XmlDeclaration, new XmlDeclarationDocumentProcessor() }
            };
        }
Exemplo n.º 2
0
        private void ApplyOptions(IList <string> ignoredNamespacesPrefixes, bool ignoreDesignTimeReferencePrefix)
        {
            var indentService            = new IndentService(options);
            var markupExtensionFormatter = new MarkupExtensionFormatter(options.NoNewLineMarkupExtensions.ToList());
            var attributeInfoFactory     = new AttributeInfoFactory(new MarkupExtensionParser(), new AttributeOrderRules(options), ignoredNamespacesPrefixes, ignoreDesignTimeReferencePrefix);
            var attributeInfoFormatter   = new AttributeInfoFormatter(markupExtensionFormatter, indentService);

            this.documentProcessors = new Dictionary <XmlNodeType, IDocumentProcessor>
            {
                // { XmlNodeType.None, null },
                { XmlNodeType.Element, new ElementDocumentProcessor(options, xamlLanguageOptions, attributeInfoFactory, attributeInfoFormatter, indentService, xmlEscapingService) },
                // { XmlNodeType.Attribute, null },
                { XmlNodeType.Text, new TextDocumentProcessor(indentService) },
                { XmlNodeType.CDATA, new CDATADocumentProcessor(indentService) },
                // { XmlNodeType.EntityReference, null },
                // { XmlNodeType.Entity, null },
                { XmlNodeType.ProcessingInstruction, new ProcessInstructionDocumentProcessor(indentService) },
                { XmlNodeType.Comment, new CommentDocumentProcessor(options, indentService) },
                // { XmlNodeType.Document, null },
                // { XmlNodeType.DocumentType, null },
                // { XmlNodeType.DocumentFragment, null },
                // { XmlNodeType.Notation, null },
                { XmlNodeType.Whitespace, new WhitespaceDocumentProcessor() },
                { XmlNodeType.SignificantWhitespace, new SignificantWhitespaceDocumentProcessor() },
                { XmlNodeType.EndElement, new EndElementDocumentProcessor(options, indentService) },
                // { XmlNodeType.EndEntity, null },
                // ignoring xml declarations for Xamarin support
                { XmlNodeType.XmlDeclaration, new XmlDeclarationDocumentProcessor() }
            };
        }
Exemplo n.º 3
0
 public ElementDocumentProcessor(IStylerOptions options, AttributeInfoFactory attributeInfoFactory, AttributeInfoFormatter attributeInfoFormatter, IndentService indentService)
 {
     _options = options;
     _attributeInfoFactory   = attributeInfoFactory;
     _attributeInfoFormatter = attributeInfoFormatter;
     _indentService          = indentService;
     _noNewLineElementsList  = options.NoNewLineElements.ToList();
 }
Exemplo n.º 4
0
 public ElementDocumentProcessor(
     IStylerOptions options,
     AttributeInfoFactory attributeInfoFactory,
     AttributeInfoFormatter attributeInfoFormatter,
     IndentService indentService)
 {
     this.options = options;
     this.attributeInfoFactory   = attributeInfoFactory;
     this.attributeInfoFormatter = attributeInfoFormatter;
     this.indentService          = indentService;
     this.noNewLineElementsList  = options.NoNewLineElements.ToList();
     this.firstLineAttributes    = options.FirstLineAttributes.ToList();
 }