public Task Write(XmlElement xml, MetadataPublicationContext target)
        {
            if (xml == null)
            {
                throw new ArgumentNullException("xmlElement");
            }

            if (target == null)
            {
                throw new ArgumentNullException("target");
            }

            if (!this.CanWrite(target))
            {
                return(Task.CompletedTask);
            }

            var writer = new StreamWriter(target.TargetStream);

            using (var w = XmlWriter.Create(writer, new XmlWriterSettings {
                Encoding = Encoding.UTF8
            }))
            {
                xml.WriteTo(w);
            }
            return(Task.CompletedTask);
        }
 protected abstract bool CanWrite(MetadataPublicationContext target);
 protected override bool CanWrite(MetadataPublicationContext target)
 {
     return((target.MetadataPublishProtocol & MetadataPublicationProtocol.Http) == MetadataPublicationProtocol.Http);
 }
示例#4
0
 public Task Write(XmlElement xml, MetadataPublicationContext target)
 {
     this._action(xml);
     return(Task.CompletedTask);
 }