public void UnionWithoutOverride()
        {
            var contextReplacementSet = new XmlTranslationSet {
                Override = false,
                Items    = new[] {
                    new XmlNamespaceTranslation("contextSourceUrn", "contextTargetUrn"),
                    new XmlNamespaceTranslation("commonSourceUrn", "commonTargetUrn")
                }
            };
            var pipelineReplacementSet = new XmlTranslationSet {
                Items = new[] {
                    new XmlNamespaceTranslation("pipelineSourceUrn", "pipelineTargetUrn"),
                    new XmlNamespaceTranslation("commonSourceUrn", "commonTargetUrn")
                }
            };

            Assert.That(
                contextReplacementSet.Union(pipelineReplacementSet),
                Is.EqualTo(
                    new XmlTranslationSet {
                Override = false,
                Items    = new[] {
                    new XmlNamespaceTranslation("contextSourceUrn", "contextTargetUrn"),
                    new XmlNamespaceTranslation("commonSourceUrn", "commonTargetUrn"),
                    new XmlNamespaceTranslation("pipelineSourceUrn", "pipelineTargetUrn")
                }
            }));
        }
Пример #2
0
 public static string Serialize(XmlTranslationSet translations)
 {
     if (!translations.Items.Any())
     {
         return(null);
     }
     using (var stream = new MemoryStream())
         using (var xmlWriter = XmlWriter.Create(stream, new XmlWriterSettings {
             Encoding = new UTF8Encoding(false), Indent = false, OmitXmlDeclaration = true
         }))
         {
             var xmlSerializer = new XmlSerializer(typeof(XmlTranslationSet));
             xmlSerializer.Serialize(
                 xmlWriter,
                 translations,
                 new XmlSerializerNamespaces(new[] { new XmlQualifiedName("xt", XmlTranslationSet.NAMESPACE) }));
             return(Encoding.UTF8.GetString(stream.ToArray()));
         }
 }