1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
4 
5 using System.Collections.Generic;
6 
7 namespace System.ServiceModel.Syndication.Tests
8 {
9     [Flags]
10     public enum XmlDiffOption
11     {
12         None = 0x0,
13         IgnoreEmptyElement = 0x1,
14         IgnoreWhitespace = 0x2,
15         IgnoreComments = 0x4,
16         IgnoreAttributeOrder = 0x8,
17         IgnoreNS = 0x10,
18         IgnorePrefix = 0x20,
19         IgnoreDTD = 0x40,
20         IgnoreChildOrder = 0x80,
21         InfosetComparison = 0xB,     //sets IgnoreEmptyElement, IgnoreWhitespace and IgnoreAttributeOrder
22         CDataAsText = 0x100,
23         NormalizeNewline = 0x200, // ignores newlines in text nodes only
24         ConcatenateAdjacentTextNodes = 0x400, // treats adjacent text nodes as a single node
25         TreatWhitespaceTextAsWSNode = 0x800, // if a text node contains only whitespaces, it will be considered a whitespace node
26         ParseAttributeValuesAsQName = 0x1000, // <a xmlns:p1="n1" t="p1:foo"/> will be treated the same as <a xmlns:p2="n1" t="p2:foo"/>
27         DontWriteMatchingNodesToOutput = 0x2000, // output will only contain different nodes
28         DontWriteAnythingToOutput = 0x4000, // output will not contain anything (needed for very large XML docs, which could trigger OOM)
29         IgnoreEmptyTextNodes = 0x8000, // empty text nodes (sometimes produced by the binary reader) are ignored
30         WhitespaceAsText = 0x10000, // consider whitespace nodes as text nodes
31     }
32 
33     public class XmlDiffAdvancedOptions
34     {
35         private string _ignoreNodesExpr;
36         private string _ignoreValuesExpr;
37         private string _ignoreChildOrderExpr;
38         private IDictionary<string, string> _addedNamespaces;
39 
XmlDiffAdvancedOptions()40         public XmlDiffAdvancedOptions()
41         {
42             _addedNamespaces = new Dictionary<string, string>();
43         }
44 
45         public string IgnoreNodesExpr
46         {
47             get
48             {
49                 return _ignoreNodesExpr;
50             }
51             set
52             {
53                 _ignoreNodesExpr = value;
54             }
55         }
56 
57         public string IgnoreValuesExpr
58         {
59             get
60             {
61                 return _ignoreValuesExpr;
62             }
63             set
64             {
65                 _ignoreValuesExpr = value;
66             }
67         }
68 
69         public string IgnoreChildOrderExpr
70         {
71             get
72             {
73                 return _ignoreChildOrderExpr;
74             }
75             set
76             {
77                 _ignoreChildOrderExpr = value;
78             }
79         }
80 
AddNamespace(string prefix, string uri)81         public void AddNamespace(string prefix, string uri)
82         {
83             _addedNamespaces[prefix] = uri;
84         }
85 
HadAddedNamespace()86         public bool HadAddedNamespace()
87         {
88             return 0 != _addedNamespaces.Count;
89         }
90 
91         public IDictionary<string, string> AddedNamespaces
92         {
93             get { return _addedNamespaces; }
94         }
95     }
96 }
97