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


C# UPnPService.GetStateVariables方法代码示例

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


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

示例1: BuildCertToolFiles_Service

        private void BuildCertToolFiles_Service(UPnPService s, DirectoryInfo outputDir)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("<scpd>");

            sb.Append("<serviceStateTable>");
            foreach(UPnPStateVariable v in s.GetStateVariables())
            {
                sb.Append("<stateVariable>");
                sb.Append("<name>"+v.Name+"</name>");
                sb.Append("<sendEventsAttribute>");
                if (v.SendEvent)
                {
                    sb.Append("yes");
                }
                else
                {
                    sb.Append("no");
                }
                sb.Append("</sendEventsAttribute>");
                sb.Append("<dataType>"+v.ValueType+"</dataType>");
                if (v.AllowedStringValues!=null && v.AllowedStringValues.Length>0)
                {
                    sb.Append("<allowedValueList>");
                    foreach(string av in v.AllowedStringValues)
                    {
                        sb.Append("<allowedValue>"+av+"</allowedValue>");
                    }
                    sb.Append("</allowedValueList>");
                }
                sb.Append("</stateVariable>");
            }
            sb.Append("</serviceStateTable>");

            if (s.Actions.Count>0)
            {
                sb.Append("<actionList>");
                foreach(UPnPAction a in s.Actions)
                {
                    sb.Append("<action>");
                    sb.Append("<name>"+a.Name+"</name>");
                    if (a.ArgumentList.Length>0)
                    {
                        sb.Append("<argumentList>");
                        foreach(UPnPArgument ag in a.ArgumentList)
                        {
                            sb.Append("<argument>");
                            sb.Append("<name>"+ag.Name+"</name>");
                            sb.Append("<direction>"+ag.Direction+"</direction>");
                            sb.Append("<relatedStateVariable>"+ag.RelatedStateVar.Name+"</relatedStateVariable>");
                            sb.Append("</argument>");
                        }
                        sb.Append("</argumentList>");
                    }
                    sb.Append("</action>");
                }
                sb.Append("</actionList>");
            }

            sb.Append("</scpd>");

            StreamWriter W;
            DText d = new DText();
            d.ATTRMARK = ":";
            d[0] = s.ServiceURN;

            W = File.CreateText(outputDir.FullName + "\\" + d[4] + s.Version.ToString() + ".xml");
            W.Write(sb.ToString());
            W.Close();
        }
开发者ID:amadare,项目名称:DeveloperToolsForUPnP,代码行数:70,代码来源:CodeGenerationForm.cs

示例2: GetCPlusPlusAbstraction_H_Service

        protected static string GetCPlusPlusAbstraction_H_Service(string WC, UPnPService s)
        {
            string WC2 = SourceCodeRepository.GetTextBetweenTags(WC,"//{{{Service_Begin}}}","//{{{Service_End}}}");
            string WC3;

            foreach(UPnPStateVariable V in s.GetStateVariables())
            {
                if (V.SendEvent)
                {
                    WC3 = SourceCodeRepository.GetTextBetweenTags(WC2,"//{{{Service_Events_BEGIN}}}","//{{{Service_Events_END}}}");
                    WC3 = WC3.Replace("{{{VARNAME}}}",V.Name);
                    WC3 = WC3.Replace("{{{PARAMDEF}}}",EmbeddedCGenerator.ToCTypeFromStateVar(V));
                    WC2 = SourceCodeRepository.InsertTextBeforeTag(WC2,"//{{{Service_Events_BEGIN}}}",WC3);
                }
            }
            WC2 = SourceCodeRepository.RemoveAndClearTag("//{{{Service_Events_BEGIN}}}","//{{{Service_Events_END}}}",WC2);

            WC2 = WC2.Replace("{{{SERVICE}}}","UPnP_Service_"+((ServiceGenerator.ServiceConfiguration)s.User).Name);
            WC2 = WC2.Replace("{{{DEVICE}}}","UPnP_Device_"+s.ParentDevice.User2.ToString());
            StringBuilder sb = new StringBuilder();
            foreach(UPnPAction a in s.Actions)
            {
                sb.Append("virtual void "+a.Name+"(void *session");
                foreach(UPnPArgument arg in a.Arguments)
                {
                    if (arg.Direction=="in")
                    {
                        sb.Append(", "+EmbeddedCGenerator.ToCTypeFromArg(arg));
                    }
                }
                sb.Append(");\r\n");
            }
            WC2 = WC2.Replace("//{{{Service_VirtualMethods}}}",sb.ToString());

            sb = new StringBuilder();
            foreach(UPnPAction a in s.Actions)
            {
                sb.Append("void Response_"+a.Name+"(void *session");
                foreach(UPnPArgument arg in a.Arguments)
                {
                    if (arg.Direction=="out")
                    {
                        sb.Append(", "+EmbeddedCGenerator.ToCTypeFromArg(arg));
                    }
                }
                sb.Append(");\r\n");
                if (((ServiceGenerator.ServiceConfiguration)s.User).Actions_Fragmented.Contains(a))
                {
                    sb.Append("	void Response_Async_"+a.Name+"(void *session, char* ArgName, char *ArgValue, int ArgValueLength, int ArgStart, int ArgDone, int ResponseDone);\r\n");
                }
            }
            WC2 = WC2.Replace("//{{{Service_VirtualMethods_Response}}}",sb.ToString());
            return(WC2);
        }
开发者ID:amadare,项目名称:DeveloperToolsForUPnP,代码行数:54,代码来源:DeviceObjectGenerator.cs

示例3: GenerateStateVariableLookupTable_Service

        protected static void GenerateStateVariableLookupTable_Service(UPnPService s, Hashtable t)
        {
            Hashtable lookupTable = new Hashtable();
            t[s] = lookupTable;

            int i=0;

            foreach(UPnPStateVariable v in s.GetStateVariables())
            {
                StringBuilder sb = new StringBuilder();
                StringWriter SW = new StringWriter(sb);
                XmlTextWriter X = new XmlTextWriter(SW);

                UPnPDebugObject dobj = new UPnPDebugObject(v);
                dobj.InvokeNonStaticMethod("GetStateVariableXML",new object[1]{X});

                lookupTable[v] = new object[3]{i,sb.Length,sb.ToString()};
                i+=sb.Length;
            }
        }
开发者ID:amadare,项目名称:DeveloperToolsForUPnP,代码行数:20,代码来源:DeviceObjectGenerator.cs

示例4: BuildEventParser

        private void BuildEventParser(CodeProcessor cs, UPnPService s, string urn, string name)
        {
            bool eventedservice = false;
            foreach(UPnPStateVariable V in s.GetStateVariables())
            {
                if (V.SendEvent) eventedservice = true;
            }

            if (urn.StartsWith("urn:schemas-upnp-org:"))
            {
                // Standard Service
                urn = urn.Substring(urn.LastIndexOf(":")+1);
            }
            else
            {
                // Proprietary Service
                urn = urn.Replace(":","_");
                urn = urn.Replace("-","_");
                urn = urn.Replace(".","_");
            }

            cs.Append("void "+this.pc_methodPrefix+urn+"_EventSink(char* buffer, int bufferlength, struct UPnPService *service)"+cl);
            cs.Append("{"+cl);
            cs.Append("	struct "+this.pc_methodLibPrefix+"XMLNode *xml,*rootXML;"+cl);
            if (eventedservice == true)
            {
                cs.Append("	char *tempString;"+cl);
                cs.Append("	int tempStringLength;"+cl);
            }
            cs.Append("	int flg,flg2;"+cl);
            cs.Append(cl);

            bool placeLong = false;
            bool placeULong = false;
            foreach(UPnPStateVariable V in s.GetStateVariables())
            {
                if (V.SendEvent)
                {
                    cs.Append("	"+ToCType(V.GetNetType().FullName)+" "+V.Name+" = 0;"+cl);
                    if (V.GetNetType()==typeof(byte[]))
                    {
                        cs.Append("	int " + V.Name+"Length;"+cl);
                    }
                    switch(V.GetNetType().FullName)
                    {
                        case "System.SByte":
                        case "System.Int16":
                        case "System.Int32":
                            placeLong = true;
                            break;
                        case "System.Byte":
                        case "System.UInt16":
                        case "System.UInt32":
                            placeULong = true;
                            break;
                    }
                }
            }
            if (placeLong == true) cs.Append(" long TempLong;"+cl);
            if (placeULong == true) cs.Append(" unsigned long TempULong;"+cl);

            cs.Append(cl);
            cs.Comment("Parse SOAP");
            cs.Append("	rootXML = xml = "+this.pc_methodLibPrefix+"ParseXML(buffer, 0, bufferlength);"+cl);
            cs.Append("	"+this.pc_methodLibPrefix+"ProcessXMLNodeList(xml);"+cl);
            cs.Append(cl);

            cs.Append("while(xml != NULL)"+cl);
            cs.Append("{"+cl);
            cs.Append("	if (xml->NameLength == 11 && memcmp(xml->Name, \"propertyset\", 11)==0)"+cl);
            cs.Append("	{"+cl);
            cs.Append("		if (xml->Next->StartTag != 0)"+cl);
            cs.Append("		{"+cl);
            cs.Append("			flg = 0;"+cl);
            cs.Append("			xml = xml->Next;"+cl);
            cs.Append("			while(flg==0)"+cl);
            cs.Append("			{"+cl);
            cs.Append("				if (xml->NameLength == 8 && memcmp(xml->Name, \"property\", 8)==0)"+cl);
            cs.Append("				{"+cl);
            cs.Append("					xml = xml->Next;"+cl);
            cs.Append("					flg2 = 0;"+cl);
            cs.Append("					while(flg2==0)"+cl);
            cs.Append("					{"+cl);

            foreach(UPnPStateVariable V in s.GetStateVariables())
            {
                if (V.SendEvent)
                {
                    cs.Append("					if (xml->NameLength == "+V.Name.Length.ToString()+" && memcmp(xml->Name, \""+V.Name+"\", "+V.Name.Length.ToString()+") == 0)"+cl);
                    cs.Append("					{"+cl);
                    cs.Append("						tempStringLength = "+this.pc_methodLibPrefix+"ReadInnerXML(xml,&tempString);"+cl);

                    if (ToCType(V.GetNetType().FullName)=="char*")
                    {
                        cs.Append("							tempString[tempStringLength] = '\\0';"+cl);
                        cs.Append("							"+V.Name+" = tempString;"+cl);
                    }
                    else
                    {
                        switch(V.GetNetType().FullName)
//.........这里部分代码省略.........
开发者ID:amadare,项目名称:DeveloperToolsForUPnP,代码行数:101,代码来源:CPEmbeddedCGenerator.cs


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