示例#1
0
 public static SyncFeedEntryLink CreateSchemaLink(string href)
 {
     SyncFeedEntryLink result = new SyncFeedEntryLink();
     result.Href = href;
     result.LinkRel = GetRelString(RelEnum.schema);
     result.Title = "Schema";
     result.LinkType = GetTypeString(LinkTypeEnum.xml);
     return result;
 }
示例#2
0
        public static SyncFeedEntryLink FindLinkByPayloadPath(SyncFeedEntryLink[] links, string payloadPath)
        {
            foreach(SyncFeedEntryLink link in links)
            {
                if (link.PayloadPath.Equals(payloadPath))
                    return link;
            }

            return null;
        }
示例#3
0
        public static SyncFeedEntryLink CreateSchemaLink(string href)
        {
            SyncFeedEntryLink result = new SyncFeedEntryLink();

            result.Href     = href;
            result.LinkRel  = GetRelString(RelEnum.schema);
            result.Title    = "Schema";
            result.LinkType = GetTypeString(LinkTypeEnum.xml);
            return(result);
        }
示例#4
0
        public static SyncFeedEntryLink CreateSelfLink(string href)
        {
            SyncFeedEntryLink result = new SyncFeedEntryLink();

            result.Href     = href;
            result.LinkRel  = GetRelString(RelEnum.self);
            result.Title    = "self";
            result.LinkType = GetTypeString(LinkTypeEnum.entry);
            return(result);
        }
示例#5
0
 public static SyncFeedEntryLink CreateRelatedLink(string href, string title ,string payloadPath, string uuid)
 {
     SyncFeedEntryLink result = new SyncFeedEntryLink();
     result.Href = href;
     result.LinkRel = GetRelString(RelEnum.related);
     result.Title = title;
     result.LinkType = GetTypeString(LinkTypeEnum.entry);
     result.PayloadPath = payloadPath;
     result.Uuid = uuid;
     return result;
 }
示例#6
0
        public static SyncFeedEntryLink CreateRelatedLink(string href, string title, string payloadPath, string uuid)
        {
            SyncFeedEntryLink result = new SyncFeedEntryLink();

            result.Href        = href;
            result.LinkRel     = GetRelString(RelEnum.related);
            result.Title       = title;
            result.LinkType    = GetTypeString(LinkTypeEnum.entry);
            result.PayloadPath = payloadPath;
            result.Uuid        = uuid;
            return(result);
        }
示例#7
0
        public object Clone()
        {
            SyncFeedEntryLink clone = new SyncFeedEntryLink();

            clone.Href        = this.Href;
            clone.LinkRel     = this.LinkRel;
            clone.LinkType    = this.LinkType;
            clone.PayloadPath = this.PayloadPath;
            clone.Title       = this.Title;
            clone.Uuid        = this.Uuid;
            return(clone);
        }
示例#8
0
        public void ReadXml(System.Xml.XmlReader reader, Type payloadType)
        {
            GuidConverter guidConverter = new GuidConverter();
            if ((reader.NodeType == System.Xml.XmlNodeType.Element)
                && (reader.LocalName == "entry")
                && (reader.NamespaceURI == Namespaces.atomNamespace))
            {
                bool reading = true;
                while (reading)
                {
                    if (reader.NodeType == System.Xml.XmlNodeType.Element)
                    {
                        switch (reader.LocalName)
                        {
                            case "title":
                                reading = reader.Read();
                                if (reader.NodeType == System.Xml.XmlNodeType.Text)
                                    this.Title = reader.Value;
                                break;
                            case "id":
                                reading = reader.Read();
                                if (reader.NodeType == System.Xml.XmlNodeType.Text)
                                    this.Id = reader.Value;
                                break;

                            case "uuid":
                                reading = reader.Read();
                                if (reader.NodeType == System.Xml.XmlNodeType.Text)
                                {
                                    string uuidString = reader.Value;

                                    this.Uuid = (Guid)guidConverter.ConvertFromString(uuidString);
                                }
                                break;

                            case "httpStatus":
                                reading = reader.Read();
                                if (reader.NodeType == System.Xml.XmlNodeType.Text)
                                    this.HttpStatusCode = (HttpStatusCode)Enum.Parse(typeof(HttpStatusCode), reader.Value);
                                break;

                            case "httpMessage":
                                reading = reader.Read();
                                if (reader.NodeType == System.Xml.XmlNodeType.Text)
                                    this.HttpMessage = reader.Value;
                                break;

                            case "location":
                                reading = reader.Read();
                                if (reader.NodeType == System.Xml.XmlNodeType.Text)
                                    this.HttpLocation = reader.Value;
                                break;

                            case "httpMethod":
                                reading = reader.Read();
                                if (reader.NodeType == System.Xml.XmlNodeType.Text)
                                    this.HttpMethod = reader.Value;
                                break;

                            case "payload":
                                System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(payloadType);
                                object obj = serializer.Deserialize(reader);
                                if (obj is PayloadBase)
                                    this.Payload = obj as PayloadBase;
                                break;

                            case "syncState":
                                System.Xml.Serialization.XmlSerializer syncStateSerializer = new System.Xml.Serialization.XmlSerializer(typeof(SyncState));
                                object obj1 = syncStateSerializer.Deserialize(reader);
                                if (obj1 is SyncState)
                                    this.SyncState = obj1 as SyncState;
                                break;
                            case "link":

                                if (reader.HasAttributes)
                                {
                                    SyncFeedEntryLink link = new SyncFeedEntryLink();
                                    while (reader.MoveToNextAttribute())
                                    {
                                        if (reader.LocalName.Equals("payloadpath", StringComparison.InvariantCultureIgnoreCase))
                                            link.PayloadPath = reader.Value;
                                        if (reader.LocalName.Equals("rel", StringComparison.InvariantCultureIgnoreCase))
                                            link.LinkRel = reader.Value;
                                        if (reader.LocalName.Equals("type", StringComparison.InvariantCultureIgnoreCase))
                                            link.LinkType = reader.Value;
                                        if (reader.LocalName.Equals("title", StringComparison.InvariantCultureIgnoreCase))
                                            link.Title = reader.Value;
                                        if (reader.LocalName.Equals("uuid", StringComparison.InvariantCultureIgnoreCase))
                                            link.Uuid = reader.Value;
                                        if (reader.LocalName.Equals("href", StringComparison.InvariantCultureIgnoreCase))
                                            link.Href = reader.Value;
                                    }

                                    this.SyncLinks.Add(link);

                                }
                                break;
                            case "linked":
                                System.Xml.Serialization.XmlSerializer linkedSerializer = new System.Xml.Serialization.XmlSerializer(typeof(LinkedElement));
                                object linkedObj = linkedSerializer.Deserialize(reader);
                                if (linkedObj is LinkedElement)
                                    this.Linked = linkedObj as LinkedElement;
                                break;

                            default:
                                reading = reader.Read();
                                break;
                        }

                    }
                    else
                    {
                        if ((reader.NodeType == System.Xml.XmlNodeType.EndElement)
                            && (reader.LocalName == "entry"))
                            reading = false;
                        else
                            reading = reader.Read();
                    }
                }
            }
        }
        public void ReadXml(System.Xml.XmlReader reader, Type payloadType)
        {
            GuidConverter guidConverter = new GuidConverter();

            if ((reader.NodeType == System.Xml.XmlNodeType.Element) &&
                (reader.LocalName == "entry") &&
                (reader.NamespaceURI == Namespaces.atomNamespace))
            {
                bool reading = true;
                while (reading)
                {
                    if (reader.NodeType == System.Xml.XmlNodeType.Element)
                    {
                        switch (reader.LocalName)
                        {
                        case "title":
                            reading = reader.Read();
                            if (reader.NodeType == System.Xml.XmlNodeType.Text)
                            {
                                this.Title = reader.Value;
                            }
                            break;

                        case "id":
                            reading = reader.Read();
                            if (reader.NodeType == System.Xml.XmlNodeType.Text)
                            {
                                this.Id = reader.Value;
                            }
                            break;

                        case "uuid":
                            reading = reader.Read();
                            if (reader.NodeType == System.Xml.XmlNodeType.Text)
                            {
                                string uuidString = reader.Value;

                                this.Uuid = (Guid)guidConverter.ConvertFromString(uuidString);
                            }
                            break;

                        case "httpStatus":
                            reading = reader.Read();
                            if (reader.NodeType == System.Xml.XmlNodeType.Text)
                            {
                                this.HttpStatusCode = (HttpStatusCode)Enum.Parse(typeof(HttpStatusCode), reader.Value);
                            }
                            break;

                        case "httpMessage":
                            reading = reader.Read();
                            if (reader.NodeType == System.Xml.XmlNodeType.Text)
                            {
                                this.HttpMessage = reader.Value;
                            }
                            break;

                        case "location":
                            reading = reader.Read();
                            if (reader.NodeType == System.Xml.XmlNodeType.Text)
                            {
                                this.HttpLocation = reader.Value;
                            }
                            break;

                        case "httpMethod":
                            reading = reader.Read();
                            if (reader.NodeType == System.Xml.XmlNodeType.Text)
                            {
                                this.HttpMethod = reader.Value;
                            }
                            break;

                        case "payload":
                            System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(payloadType);
                            object obj = serializer.Deserialize(reader);
                            if (obj is PayloadBase)
                            {
                                this.Payload = obj as PayloadBase;
                            }
                            break;

                        case "syncState":
                            System.Xml.Serialization.XmlSerializer syncStateSerializer = new System.Xml.Serialization.XmlSerializer(typeof(SyncState));
                            object obj1 = syncStateSerializer.Deserialize(reader);
                            if (obj1 is SyncState)
                            {
                                this.SyncState = obj1 as SyncState;
                            }
                            break;

                        case "link":

                            if (reader.HasAttributes)
                            {
                                SyncFeedEntryLink link = new SyncFeedEntryLink();
                                while (reader.MoveToNextAttribute())
                                {
                                    if (reader.LocalName.Equals("payloadpath", StringComparison.InvariantCultureIgnoreCase))
                                    {
                                        link.PayloadPath = reader.Value;
                                    }
                                    if (reader.LocalName.Equals("rel", StringComparison.InvariantCultureIgnoreCase))
                                    {
                                        link.LinkRel = reader.Value;
                                    }
                                    if (reader.LocalName.Equals("type", StringComparison.InvariantCultureIgnoreCase))
                                    {
                                        link.LinkType = reader.Value;
                                    }
                                    if (reader.LocalName.Equals("title", StringComparison.InvariantCultureIgnoreCase))
                                    {
                                        link.Title = reader.Value;
                                    }
                                    if (reader.LocalName.Equals("uuid", StringComparison.InvariantCultureIgnoreCase))
                                    {
                                        link.Uuid = reader.Value;
                                    }
                                    if (reader.LocalName.Equals("href", StringComparison.InvariantCultureIgnoreCase))
                                    {
                                        link.Href = reader.Value;
                                    }
                                }

                                this.SyncLinks.Add(link);
                            }
                            break;

                        case "linked":
                            System.Xml.Serialization.XmlSerializer linkedSerializer = new System.Xml.Serialization.XmlSerializer(typeof(LinkedElement));
                            object linkedObj = linkedSerializer.Deserialize(reader);
                            if (linkedObj is LinkedElement)
                            {
                                this.Linked = linkedObj as LinkedElement;
                            }
                            break;


                        default:
                            reading = reader.Read();
                            break;
                        }
                    }
                    else
                    {
                        if ((reader.NodeType == System.Xml.XmlNodeType.EndElement) &&
                            (reader.LocalName == "entry"))
                        {
                            reading = false;
                        }
                        else
                        {
                            reading = reader.Read();
                        }
                    }
                }
            }
        }
示例#10
0
 public static SyncFeedEntryLink CreateSelfLink(string href)
 {
     SyncFeedEntryLink result = new SyncFeedEntryLink();
     result.Href = href;
     result.LinkRel = GetRelString(RelEnum.self);
     result.Title = "self";
     result.LinkType = GetTypeString(LinkTypeEnum.entry);
     return result;
 }
示例#11
0
 public object Clone()
 {
     SyncFeedEntryLink clone = new SyncFeedEntryLink();
     clone.Href = this.Href;
     clone.LinkRel = this.LinkRel;
     clone.LinkType = this.LinkType;
     clone.PayloadPath = this.PayloadPath;
     clone.Title = this.Title;
     clone.Uuid = this.Uuid;
     return clone;
 }