当前位置: 首页>>代码示例>>C#>>正文


C# UPnPDevice.AddDevice方法代码示例

本文整理汇总了C#中OpenSource.UPnP.UPnPDevice.AddDevice方法的典型用法代码示例。如果您正苦于以下问题:C# UPnPDevice.AddDevice方法的具体用法?C# UPnPDevice.AddDevice怎么用?C# UPnPDevice.AddDevice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OpenSource.UPnP.UPnPDevice的用法示例。


在下文中一共展示了UPnPDevice.AddDevice方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ParseDeviceList

        private static void ParseDeviceList(String XML, int startLine, ref UPnPDevice RetVal)
        {
            StringReader MyString = new StringReader(XML);
            XmlTextReader XMLDoc = new XmlTextReader(MyString);
            UPnPDevice EmbeddedDevice = null;
            int embededLine;

            try
            {
                XMLDoc.Read();
                XMLDoc.MoveToContent();

                if (XMLDoc.LocalName == "deviceList")
                {
                    XMLDoc.Read();
                    XMLDoc.MoveToContent();

                    while (XMLDoc.LocalName != "deviceList" && !XMLDoc.EOF)
                    {
                        if (XMLDoc.LocalName == "device")
                        {
                            EmbeddedDevice = new UPnPDevice();
                            EmbeddedDevice.IsRoot = false;
                            EmbeddedDevice.BaseURL = RetVal.BaseURL;
                            embededLine = XMLDoc.LineNumber;
                            //ParseDevice("<device>\r\n" + XMLDoc.ReadInnerXml() + "</device>", startLine + embededLine, ref EmbeddedDevice);
                            ParseDevice(XMLDoc.ReadOuterXml(), startLine + embededLine, ref EmbeddedDevice);
                            RetVal.AddDevice(EmbeddedDevice);
                        }
                        if (!XMLDoc.IsStartElement() && XMLDoc.LocalName != "deviceList")
                        {
                            XMLDoc.Read();
                            XMLDoc.MoveToContent();
                        }
                    }
                }
            }
            catch (XMLParsingException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw new XMLParsingException("Invalid DeviceList XML near line ", (startLine + XMLDoc.LineNumber), XMLDoc.LinePosition, ex);
            }
        }
开发者ID:genielabs,项目名称:intel-upnp-dlna,代码行数:46,代码来源:UPnPDevice.cs

示例2: ParseDeviceList

        private static void ParseDeviceList(String XML, ref UPnPDevice RetVal)
        {
            StringReader MyString = new StringReader(XML);
            XmlTextReader XMLDoc = new XmlTextReader(MyString);
            UPnPDevice EmbeddedDevice = null;

            XMLDoc.Read();
            XMLDoc.MoveToContent();

            if (XMLDoc.LocalName == "deviceList")
            {
                XMLDoc.Read();
                XMLDoc.MoveToContent();

                while (XMLDoc.LocalName != "deviceList" && !XMLDoc.EOF)
                {
                    if (XMLDoc.LocalName == "device")
                    {
                        EmbeddedDevice = new UPnPDevice();
                        EmbeddedDevice.IsRoot = false;
                        EmbeddedDevice.BaseURL = RetVal.BaseURL;
                        ParseDevice("<device>\r\n" + XMLDoc.ReadInnerXml() + "</device>", ref EmbeddedDevice);
                        RetVal.AddDevice(EmbeddedDevice);
                    }
                    if (!XMLDoc.IsStartElement() && XMLDoc.LocalName != "deviceList")
                    {
                        XMLDoc.Read();
                        XMLDoc.MoveToContent();
                    }
                }
            }
        }
开发者ID:nothingmn,项目名称:UPnP-for-C---Intel-,代码行数:32,代码来源:UPnPDevice.cs

示例3: MediaServerDevice

        /// <summary>
        /// Constructor instantiates a properly behaving UPnP-AV
        /// MediaServer device that has a root container.
        /// </summary>
        /// <param name="info">general information about the MediaServer like manufacturer info</param>
        /// <param name="isRootDevice">true if the MediaServer has no parent UPnP device</param>
        /// <param name="enableHttpContentServing">
        /// True, if the MediaServer should support the <see cref="MediaResource.AUTOMAPFILE"/>
        /// convention.
        /// </param>
        /// <param name="initialSourceProtocolInfoSet">
        /// Comma separated value list of protocolInfo strings for this MediaServer as a source.
        /// "HTTP-GET:*:*:*" is also allowed, indicating that any HTTP-GET resource is supported on the server.
        /// Generally, this value should be true unless the application logic for the
        /// MediaServer will always create resource objects with fully pathed URIs that are
        /// accessible from the UPNP network.
        /// </param>
        /// <param name="initialSinkProtocolInfoSet">
        /// Comma separated value list of protocolInfo strings for this MediaServer as a sink.
        /// This should generally be blank although it may be possible to eventually 
        /// migrate this implementation to behave both as a MediaRenderer and a MediaServer,
        /// although there may be subtleties that make such a device impossible.
        /// </param>
        public MediaServerDevice(
			DeviceInfo info,
			UPnPDevice parent,
			bool enableHttpContentServing,
			string initialSourceProtocolInfoSet,
			string initialSinkProtocolInfoSet
			)
        {
            // enable HTTP webserving of HTTP-GET resource/content?
            this.EnableHttp = enableHttpContentServing;

            // Wire up the delegate and weak event used when an HTTP transfer should be
            // removed from the server's list.
            // When an HTTP transfer completes it's progress info still needs to be
            // available for GetTransferProgress action for at least 30 seconds.
            // LifeTimeMonitor will delay the removal for such a time, and then
            // execute the delegate.
            this.LTMDelegate = new LifeTimeMonitor.LifeTimeHandler(this.Sink_OnExpired);
            this.m_LFT.OnExpired += LTMDelegate;

            // Create the UPnP device object - no servics are attached yet
            if (parent == null)
            {
                this.Device = UPnPDevice.CreateRootDevice(info.CacheTime, 1.0, info.LocalRootDirectory);
                if(info.CustomUDN!="")
                {
                    this.Device.UniqueDeviceName = info.CustomUDN;
                }
            }
            else
            {
                Guid udn = System.Guid.NewGuid();
                this.Device = UPnPDevice.CreateEmbeddedDevice(1.0, udn.ToString());
                parent.AddDevice(this.Device);
            }

            // transfer basic info about the device, like serial #, manufacturer, etc.
            this.Device.HasPresentation = false;
            this.Device.StandardDeviceType = "MediaServer";

            this.Device.FriendlyName		= info.FriendlyName;
            this.Device.Manufacturer		= info.Manufacturer;
            this.Device.ManufacturerURL	= info.ManufacturerURL;
            this.Device.ModelName			= info.ModelName;
            this.Device.ModelDescription	= info.ModelDescription;
            if (info.ModelURL != null)
            {
                try
                {
                    this.Device.ModelURL			= new Uri(info.ModelURL);
                }
                catch
                {
                    this.Device.ModelURL = null;
                }
            }
            this.Device.ModelNumber		= info.ModelNumber;

            if (info.INMPR03)
            {
                this.Device.AddCustomFieldInDescription("INMPR03", "1.0", "");
            }

            this.ConnectionManager = new DvConnectionManager();
            this.ContentDirectory = new DvContentDirectory();

            // Set periodic behavior for the moderated state variables.
            // Only state variables that do not overwrite a pending
            // value need an accumulator.
            //
            this.ContentDirectory.ModerationDuration_SystemUpdateID = 2;
            this.ContentDirectory.ModerationDuration_ContainerUpdateIDs = 2;
            this.ContentDirectory.Accumulator_ContainerUpdateIDs = new Accumulator_ContainerUpdateIDs();

            // Determine whether the application logic actually
            // wants control points to have access to content management
            // related methods. If not, then remove those actions.
//.........这里部分代码省略.........
开发者ID:amadare,项目名称:DeveloperToolsForUPnP,代码行数:101,代码来源:MediaServerDevice.cs

示例4: BuildDevice

        private UPnPDevice BuildDevice(TreeNode node, UPnPDevice parentDevice)
        {
            if (node.Tag == null || node.Tag.GetType() != typeof(UPnPDevice)) return null;

            UPnPDevice device = (UPnPDevice)node.Tag;
            UPnPDevice dev;

            if (parentDevice == null)
            {
                dev = UPnPDevice.CreateRootDevice(600, 1.0, "");
                dev.SerialNumber = "0000001";
                dev.User = device.User;
                dev.Icon = ((ServiceGenerator.Configuration)device.User).IconImageSM;
                dev.Icon2 = ((ServiceGenerator.Configuration)device.User).IconImageLG;
            }
            else
            {
                dev = UPnPDevice.CreateEmbeddedDevice(1.0, System.Guid.NewGuid().ToString());
                dev.User = device.User;
            }

            dev.FriendlyName = device.FriendlyName;
            dev.DeviceURN = device.DeviceURN;
            dev.Manufacturer = device.Manufacturer;
            dev.ManufacturerURL = device.ManufacturerURL;
            dev.ModelDescription = device.ModelDescription;
            dev.ModelName = device.ModelName;
            dev.ModelNumber = device.ModelNumber;
            dev.ProductCode = device.ProductCode;
            dev.SerialNumber = device.SerialNumber;

            foreach (TreeNode n in node.Nodes)
            {
                if (n.Tag != null && n.Tag.GetType() == typeof(UPnPService))
                {
                    dev.AddService((UPnPService)n.Tag);
                }
            }

            foreach (TreeNode n in node.Nodes)
            {
                if (n.Tag != null && n.Tag.GetType() == typeof(UPnPDevice))
                {
                    BuildDevice(n, dev);
                }
            }

            if (parentDevice != null) parentDevice.AddDevice(dev);

            return dev;
        }
开发者ID:evolution124,项目名称:Developer-Tools-for-UPnP-Technologies,代码行数:51,代码来源:MainForm.cs

示例5: ParseDeviceList

        /// <summary>
        /// Parses the embedded devices from a device xml
        /// </summary>
        /// <param name="XML">The xml document to parse the devices from</param>
        /// <param name="RetVal">The owning-UPnP device to which the parsed devices will be added as embedded devices</param>
        private static void ParseDeviceList(String XML, ref UPnPDevice RetVal)
        {
            StringReader MyString = new StringReader(XML);
            XmlTextReader XMLDoc = new XmlTextReader(MyString);
            UPnPDevice EmbeddedDevice = null;

            XMLDoc.Read();
            XMLDoc.MoveToContent();

            if (XMLDoc.LocalName == "deviceList")
            {
                XMLDoc.Read();
                XMLDoc.MoveToContent();

                while (XMLDoc.LocalName != "deviceList" && !XMLDoc.EOF)
                {
                    if (XMLDoc.LocalName == "device")
                    {
                        EmbeddedDevice = new UPnPDevice();
                        EmbeddedDevice.IsRoot = false;
                        EmbeddedDevice.BaseURL = RetVal.BaseURL;
                        string devicexml = "Failed to read the xml element for the embedded Device from the parent Device XML";
                        // TODO: DONE Resilience case 6 - wrap in try-catch
                        try
                        {
                            devicexml = "<device>\r\n" + XMLDoc.ReadInnerXml() + "</device>";
                            ParseDevice(devicexml, ref EmbeddedDevice);
                            // TODO: DONE Resilience case 6 - only add if it is not null
                            if (EmbeddedDevice != null)
                            {
                                RetVal.AddDevice(EmbeddedDevice);
                            }
                        }
                        catch (Exception e)
                        {
                            OpenSource.Utilities.EventLogger.Log(null, System.Diagnostics.EventLogEntryType.Error, "Invalid EmbeddedDevice XML");
                            OpenSource.Utilities.EventLogger.Log(e, "XML content: \r\n" + devicexml);
                            OpenSource.Utilities.EventLogger.Log(null, System.Diagnostics.EventLogEntryType.Warning, "Dropping failed Embedded Device and commencing parsing remainder of device");
                        }
                    }
                    if (!XMLDoc.IsStartElement() && XMLDoc.LocalName != "deviceList")
                    {
                        XMLDoc.Read();
                        XMLDoc.MoveToContent();
                    }
                }
            }
        }
开发者ID:Tieske,项目名称:Developer-Tools-for-UPnP-Technologies,代码行数:53,代码来源:UPnPDevice.cs


注:本文中的OpenSource.UPnP.UPnPDevice.AddDevice方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。