Sage.SData.Client.Extensions.SDataPayload.Load C# (CSharp) Method

Load() public method

public Load ( XPathNavigator source, XmlNamespaceManager manager ) : bool
source System.Xml.XPath.XPathNavigator
manager System.Xml.XmlNamespaceManager
return bool
        public bool Load(XPathNavigator source, XmlNamespaceManager manager)
        {
            //------------------------------------------------------------
            //	Validate parameter
            //------------------------------------------------------------
            Guard.ArgumentNotNull(source, "source");

            //------------------------------------------------------------
            //	Attempt to extract syndication information
            //------------------------------------------------------------
            ResourceName = source.LocalName;
            Namespace = source.NamespaceURI;

            string value;
            Key = source.TryGetAttribute("key", Framework.Common.SData.Namespace, out value) ? value : null;
            Uri = source.TryGetAttribute("uri", Framework.Common.SData.Namespace, out value) && !string.IsNullOrEmpty(value) ? new Uri(value) : null;
            Uuid = source.TryGetAttribute("uuid", Framework.Common.SData.Namespace, out value) && !string.IsNullOrEmpty(value) ? new Guid(value) : (Guid?) null;
            Descriptor = source.TryGetAttribute("descriptor", Framework.Common.SData.Namespace, out value) ? value : null;
            Lookup = source.TryGetAttribute("lookup", Framework.Common.SData.Namespace, out value) ? value : null;
            IsDeleted = source.TryGetAttribute("isDeleted", Framework.Common.SData.Namespace, out value) && !string.IsNullOrEmpty(value) ? XmlConvert.ToBoolean(value) : (bool?) null;

            return source.SelectChildren(XPathNodeType.Element)
                .Cast<XPathNavigator>()
                .GroupBy(item => item.LocalName)
                .All(group => LoadItem(group.Key, group, manager));
        }

Usage Example

        public static SDataPayload LoadPayload(string xml)
        {
            var payload = new SDataPayload();

            using (var strReader = new StringReader(xml))
            using (var xmlReader = XmlReader.Create(strReader))
            {
                var doc = new XPathDocument(xmlReader);
                var source = doc.CreateNavigator();
                var manager = new XmlNamespaceManager(source.NameTable);
                source.MoveToFirstChild();
                payload.Load(source, manager);
            }

            return payload;
        }
All Usage Examples Of Sage.SData.Client.Extensions.SDataPayload::Load