Sage.Integration.Northwind.Feeds.SyncFeedEntry.WriteXml C# (CSharp) Метод

WriteXml() публичный Метод

public WriteXml ( System writer, FeedType feedType ) : void
writer System
feedType FeedType
Результат void
        public void WriteXml(System.Xml.XmlWriter writer, FeedType feedType)
        {
            writer.WriteStartElement("entry", Namespaces.atomNamespace);
            // id
            writer.WriteElementString("id", Namespaces.atomNamespace, this.Id);
            // title
            writer.WriteElementString("title", Namespaces.atomNamespace, this.Title);

            // uuid
            if (this.IsUuidSet)
                writer.WriteElementString("uuid", Namespaces.syncNamespace, this.Uuid.ToString());

            foreach (SyncFeedEntryLink link in this.SyncLinks)
            {
                writer.WriteStartElement("link", Namespaces.atomNamespace);
                if (!String.IsNullOrEmpty(link.LinkRel))
                    writer.WriteAttributeString("rel", link.LinkRel);
                if (!String.IsNullOrEmpty(link.LinkType))
                    writer.WriteAttributeString( "type",  link.LinkType);
                if (!String.IsNullOrEmpty(link.Href))
                    writer.WriteAttributeString( "href",  link.Href);
                if (!String.IsNullOrEmpty(link.Title))
                    writer.WriteAttributeString( "title",  link.Title);
                if (!String.IsNullOrEmpty(link.PayloadPath ))
                    writer.WriteAttributeString(Namespaces.sdataPrefix, "payloadPath", Namespaces.sdataNamespace, link.PayloadPath);
                if (!String.IsNullOrEmpty(link.Uuid))
                    writer.WriteAttributeString(Namespaces.syncPrefix, "uuid", Namespaces.syncNamespace, link.Uuid);
                writer.WriteEndElement();
            }

            switch (feedType)
            {
                case FeedType.Resource:
                    break;
                case FeedType.SyncSource:
                    //<!-- Per-Resource Synchronization State -->
                    System.Xml.Serialization.XmlSerializer syncStateSerializer = new System.Xml.Serialization.XmlSerializer(typeof(SyncState));
                    syncStateSerializer.Serialize(writer, this.SyncState);
                    if (!String.IsNullOrEmpty(this.HttpMethod))
                        writer.WriteElementString("httpMethod", Namespaces.sdataHttpNamespace, this.HttpMethod);
                    break;
                case FeedType.SyncTarget:
                    writer.WriteElementString("httpStatus", Namespaces.sdataHttpNamespace, Convert.ToInt32(this.HttpStatusCode).ToString());
                    writer.WriteElementString("httpMessage", Namespaces.sdataHttpNamespace, this.HttpMessage);
                    writer.WriteElementString("location", Namespaces.sdataHttpNamespace, this.HttpLocation);
                    writer.WriteElementString("httpMethod", Namespaces.sdataHttpNamespace, this.HttpMethod);

                    break;
                case FeedType.Linked:
                case FeedType.LinkedSingle:
                    System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(LinkedElement));
                    serializer.Serialize(writer, this.Linked);

                    break;
            }
            // Content ??
            // links  ??

            if (null != this.HttpETag)
                writer.WriteElementString("etag", Namespaces.sdataHttpNamespace, this.HttpETag);

            //<!-- XML payload -->
            if (this.Payload != null)
            {
                System.Xml.Serialization.XmlSerializer serializer;
                //if (this.Payload is TradingAccountPayload)
                serializer = new System.Xml.Serialization.XmlSerializer(this.Payload.GetType());
                //else
                    //serializer = new System.Xml.Serialization.XmlSerializer(typeof(PayloadBase));
                serializer.Serialize(writer, this.Payload);
            }
            writer.WriteEndElement();
        }