Пример #1
0
        public StylerService(IStylerOptions options)
        {
            _xmlEscapingService = new XmlEscapingService();
            _documentManipulationService = new DocumentManipulationService(options);

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

            _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()}
            };
        }
 public ElementDocumentProcessor(IStylerOptions options, AttributeInfoFactory attributeInfoFactory, AttributeInfoFormatter attributeInfoFormatter, IndentService indentService)
 {
     _options = options;
     _attributeInfoFactory = attributeInfoFactory;
     _attributeInfoFormatter = attributeInfoFormatter;
     _indentService = indentService;
     _noNewLineElementsList = options.NoNewLineElements.ToList();
 }
 public ProcessInstructionDocumentProcessor(IndentService indentService)
 {
     _indentService = indentService;
 }
 public void TestNormalize(string sourceText, string expected)
 {
     var indentService = new IndentService(true, 4);
     var result = indentService.Normalize(sourceText);
     Assert.That(result, Is.EqualTo(expected));
 }
 public TextDocumentProcessor(IndentService indentService)
 {
     _indentService = indentService;
 }
 public CommentDocumentProcessor(IStylerOptions options, IndentService indentService)
 {
     _options = options;
     _indentService = indentService;
 }
 public AttributeInfoFormatter(MarkupExtensionFormatter formatter, IndentService indentService)
 {
     _formatter = formatter;
     _indentService = indentService;
 }
 public CDATADocumentProcessor(IndentService indentService)
 {
     _indentService = indentService;
 }
 public EndElementDocumentProcessor(IStylerOptions options,IndentService indentService)
 {
     _indentService = indentService;
     _options = options;
 }