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


C# UPnPDevice.GetRootDeviceXML方法代码示例

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


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

示例1: PopulateDeviceStructs

        protected static void PopulateDeviceStructs(CodeProcessor cs, UPnPDevice d)
        {
            foreach(UPnPDevice ed in d.EmbeddedDevices)
            {
                PopulateDeviceStructs(cs,ed);
            }
            cs.Append("struct UPnP_Device_"+d.User2.ToString()+" UPnP_Device_"+d.User2.ToString()+"_Impl = "+cs.NewLine);
            cs.Append("{"+cs.NewLine);
            foreach(UPnPService s in d.Services)
            {
                cs.Append("	&UPnP_Service_"+((ServiceGenerator.ServiceConfiguration)s.User).Name+"_Impl,"+cs.NewLine);
            }
            cs.Append(cs.NewLine);
            foreach(UPnPDevice ed in d.EmbeddedDevices)
            {
                cs.Append("	&UPnP_Device_"+ed.User2.ToString()+"_Impl,"+cs.NewLine);
            }
            cs.Append("	NULL,"+cs.NewLine); // Friendly
            if (d.ParentDevice==null)
            {
                cs.Append("	NULL,"+cs.NewLine+"	NULL,"+cs.NewLine); //UDN, Serial
            }
            cs.Append(" NULL,"+cs.NewLine); //Manufacturer
            cs.Append(" NULL,"+cs.NewLine); //ManufacturerURL
            cs.Append(" NULL,"+cs.NewLine); //ModelDescription
            cs.Append(" NULL,"+cs.NewLine); //ModelName
            cs.Append(" NULL,"+cs.NewLine); //ModelNumber
            cs.Append(" NULL,"+cs.NewLine); //ModelURL
            cs.Append(" NULL,"+cs.NewLine); //Product Code

            UPnPDevice[] embeddedDevices = d.EmbeddedDevices;
            UPnPService[] services = d.Services;

            d.EmbeddedDevices = new UPnPDevice[0];
            d.Services = new UPnPService[0];

            string xmlString;

            if (d.ParentDevice==null)
                {byte[] xml;
                xml = d.GetRootDeviceXML(null);
                xmlString = (new UTF8Encoding()).GetString(xml);
            }
            else
            {
                StringBuilder sb = new StringBuilder();
                StringWriter SW = new StringWriter(sb);
                XmlTextWriter XDoc = new XmlTextWriter(SW);
                (new UPnPDebugObject(d)).InvokeNonStaticMethod("GetNonRootDeviceXML",new object[2]{null,XDoc});
                SW.Flush();
                xmlString = sb.ToString();
            }
            string stringX;
            int stringXLen;
            InjectCompressedString(out stringX,out stringXLen,xmlString,cs.NewLine);

            cs.Append("	"+stringX+","+cs.NewLine);
            cs.Append("	"+stringXLen.ToString()+","+cs.NewLine);
            cs.Append("	"+xmlString.Length.ToString()+","+cs.NewLine);
            if (d.ParentDevice==null)
            {
                cs.Append("	NULL,"+cs.NewLine);
            }
            cs.Append("	NULL"+cs.NewLine);
            cs.Append("};"+cs.NewLine);

            d.EmbeddedDevices = embeddedDevices;
            d.Services = services;
        }
开发者ID:amadare,项目名称:DeveloperToolsForUPnP,代码行数:69,代码来源:DeviceObjectGenerator.cs

示例2: BuildDeviceStructs

        protected static void BuildDeviceStructs(CodeProcessor cs, UPnPDevice d)
        {
            foreach(UPnPDevice ed in d.EmbeddedDevices)
            {
                BuildDeviceStructs(cs,ed);
            }
            cs.Append("struct UPnP_Device_"+d.User2.ToString()+cs.NewLine);
            cs.Append("{"+cs.NewLine);
            foreach(UPnPService s in d.Services)
            {
                cs.Append("	struct UPnP_Service_"+((ServiceGenerator.ServiceConfiguration)s.User).Name+" *"+((ServiceGenerator.ServiceConfiguration)s.User).Name+";"+cs.NewLine);
            }
            cs.Append(cs.NewLine);
            foreach(UPnPDevice ed in d.EmbeddedDevices)
            {
                cs.Append("	struct UPnP_Device_"+ed.User2.ToString()+" *UPnP_Device_"+ed.User2.ToString()+";"+cs.NewLine);
            }
            cs.Append("	const char *FriendlyName;"+cs.NewLine);
            if (d.ParentDevice==null)
            {
                cs.Append("	const char *UDN;"+cs.NewLine);
                cs.Append("	const char *Serial;"+cs.NewLine);
            }
            cs.Append(" const char *Manufacturer;"+cs.NewLine);
            cs.Append(" const char *ManufacturerURL;"+cs.NewLine);
            cs.Append(" const char *ModelDescription;"+cs.NewLine);
            cs.Append(" const char *ModelName;"+cs.NewLine);
            cs.Append(" const char *ModelNumber;"+cs.NewLine);
            cs.Append(" const char *ModelURL;"+cs.NewLine);
            cs.Append("	const char *ProductCode;"+cs.NewLine);

            UPnPDevice[] embeddedDevices = d.EmbeddedDevices;
            UPnPService[] services = d.Services;

            d.EmbeddedDevices = new UPnPDevice[0];
            d.Services = new UPnPService[0];

            byte[] xml;
            if (d.Root)
            {
                xml = d.GetRootDeviceXML(null);
            }
            else
            {
                xml = (byte[])(new UPnPDebugObject(d)).InvokeNonStaticMethod("GetRootDeviceXML",new object[1]{null});
            }
            UTF8Encoding U = new UTF8Encoding();
            string xmlString = U.GetString(xml);
            string stringX;
            int stringXLen;
            InjectCompressedString(out stringX,out stringXLen,xmlString,cs.NewLine);
            d.EmbeddedDevices = embeddedDevices;
            d.Services = services;

            cs.Append("	char Reserved["+stringXLen.ToString()+"];"+cs.NewLine);
            cs.Append("	int ReservedXL;"+cs.NewLine);
            cs.Append("	int ReservedUXL;"+cs.NewLine);

            cs.Append("	void *User;"+cs.NewLine);
            if (d.ParentDevice==null)
            {
                cs.Append("	void *MicrostackToken;"+cs.NewLine);
            }
            cs.Append("};"+cs.NewLine);
        }
开发者ID:amadare,项目名称:DeveloperToolsForUPnP,代码行数:65,代码来源:DeviceObjectGenerator.cs

示例3: BuildDeviceDescription

        private void BuildDeviceDescription(CodeProcessor cs, UPnPDevice device)
        {
            UTF8Encoding U = new UTF8Encoding();
            string deviceDescription = (new UTF8Encoding().GetString(device.GetRootDeviceXML(new IPEndPoint(new IPAddress(0x0100007F), 80))));

            for (int i = 0; i < 40; i++) deviceDescription = deviceDescription.Replace("\r\n ", "\r\n");
            deviceDescription = deviceDescription.Replace("\r\n", "");
            //deviceDescription = deviceDescription;

            //			if (this.BasicHTTP)
            //			{
            //				deviceDescription = "HTTP/1.0 200  OK\r\nCONTENT-TYPE:  text/xml\r\nServer: " + UseSystem + ", UPnP/1.0, MicroStack/" + UseVersion + "\r\n\r\n" + deviceDescription;
            //			}

            byte[] deviceDescriptionX = OpenSource.Utilities.StringCompressor.CompressString(deviceDescription);

            cs.Append("const int " + this.pc_methodPrefix + "DeviceDescriptionTemplateLengthUX = " + U.GetByteCount(deviceDescription).ToString() + ";" + cl);
            cs.Append("const int " + this.pc_methodPrefix + "DeviceDescriptionTemplateLength = " + deviceDescriptionX.Length.ToString() + ";" + cl);
            cs.Append("const char " + this.pc_methodPrefix + "DeviceDescriptionTemplate[" + deviceDescriptionX.Length.ToString() + "]={" + cl);
            bool _first = true;
            int _ctr = 0;
            foreach (byte b in deviceDescriptionX)
            {
                if (_first == false)
                {
                    cs.Append(",");
                }
                else
                {
                    _first = false;
                }
                string hx = b.ToString("X");
                cs.Append("0x");
                if (hx.Length == 1) { cs.Append("0"); }
                cs.Append(hx);

                ++_ctr;
                if (_ctr % 20 == 0)
                {
                    cs.Append("\r\n");
                }
            }
            cs.Append("};\r\n");
        }
开发者ID:evolution124,项目名称:Developer-Tools-for-UPnP-Technologies,代码行数:44,代码来源:EmbeddedCGenerator.cs


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