コード例 #1
0
        private void OnPropertyReceived(object sender, PropertyContent e)
        {
            switch (e.Name)
            {
            case "LastChange":

                var lastChangeXml = XElement.Parse(e.Value);


                var instanceNode =
                    lastChangeXml.Descendants(XName.Get("InstanceID", "urn:schemas-upnp-org:metadata-1-0/AVT/"))
                    .SingleOrDefault();


                if (instanceNode != null && LastChangedPropertiesReceived != null)
                {
                    var lastChangedProperties = new Dictionary <string, string>();
                    foreach (var childNode in instanceNode.Descendants())
                    {
                        var name  = childNode.Name.LocalName;
                        var value =
                            childNode.Attribute("val").Value;
                        lastChangedProperties.Add(name, value);
                    }
                    LastChangedPropertiesReceived(this, new LastChangedPropertiesContent
                    {
                        Properties            = e.Properties,
                        LastChangedProperties = lastChangedProperties
                    });
                }
                break;

            default:
                Log.Logger.Information("Unhandled property: " + e.Name + ": " + e.Value);
                break;
            }
        }
        private void OnPropertyReceived(object sender, PropertyContent e)
        {
            switch (e.Name)
            {
                case "LastChange":

                    var lastChangeXml = XElement.Parse(e.Value);


                    var instanceNode =
                        lastChangeXml.Descendants(XName.Get("InstanceID", "urn:schemas-upnp-org:metadata-1-0/AVT/"))
                            .SingleOrDefault();


                    if (instanceNode != null && LastChangedPropertiesReceived != null)
                    {
                        var lastChangedProperties = new Dictionary<string, string>();
                        foreach (var childNode in instanceNode.Descendants())
                        {
                            var name = childNode.Name.LocalName;
                            var value =
                                childNode.Attribute("val").Value;
                            lastChangedProperties.Add(name, value);
                        }
                        LastChangedPropertiesReceived(this, new LastChangedPropertiesContent
                        {
                            Properties = e.Properties,
                            LastChangedProperties = lastChangedProperties
                        });
                    }
                    break;

                default:
                    Log.Logger.Information("Unhandled property: " + e.Name + ": " + e.Value);
                    break;
            }
        }