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


C# UPnPService.ParseSCPD方法代码示例

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


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

示例1: GenerateServiceFromSCPD

		/// <summary>
		/// Generates a UPnPService object from an SCPD XML
		/// </summary>
		/// <param name="SCPD_XML">XML String</param>
		/// <returns>UPnPService</returns>
		public static UPnPService GenerateServiceFromSCPD(string SCPD_XML)
		{
			UPnPService s = new UPnPService(1);

			s.ParseSCPD(SCPD_XML);
			return(s);
		}
开发者ID:Scannow,项目名称:SWYH,代码行数:12,代码来源:ServiceGenerator.cs

示例2: Generate

		/// <summary>
		/// Generates Device side implementation from SCPD XML
		/// </summary>
		/// <param name="ClassName">Class Name to build</param>
		/// <param name="ns">Namespace to use</param>
		/// <param name="SavePath">Path to save source</param>
		/// <param name="ServiceID">Service ID to use</param>
		/// <param name="ServiceURN">Service URN to use</param>
		/// <param name="SCPD_XML">SCPD XML String</param>
		public static void Generate(String ClassName, String ns, String SavePath, String ServiceID, String ServiceURN, String SCPD_XML)
		{
			UPnPService s = new UPnPService(1);
			DText p = new DText();
			p.ATTRMARK = ":";
			p[0] = ServiceURN;

			string v = p[p.DCOUNT()];
			s.SetVersion(v);
			s.ParseSCPD(SCPD_XML);
			String cl = "\r\n";
			
			StringBuilder cs = new StringBuilder();
			UPnPArgument[] Args;
			UPnPArgument arg;
			UPnPStateVariable[] SV = s.GetStateVariables();

			cs.Append("using Intel.UPNP;" + cl + cl);
			cs.Append("namespace " + ns + cl);
			cs.Append("{\r\n");
			cs.Append("    /// <summary>" + cl);
			cs.Append("    /// Transparent DeviceSide UPnP Service" + cl);
			cs.Append("    /// </summary>" + cl);
			cs.Append("    public class " + ClassName + " : IUPnPService" + cl);
			cs.Append("    {" + cl + cl);
			cs.Append("        // Place your declarations above this line\r\n");
			cs.Append("\r\n");
			cs.Append("        #region AutoGenerated Code Section [Do NOT Modify, unless you know what you're doing]\r\n");
			cs.Append("        //{{{{{ Begin Code Block\r\n");
			cs.Append("\r\n");
			cs.Append("        private _" + ClassName + " _S;\r\n");
			cs.Append("        public static string URN = \"" + ServiceURN + "\";\r\n");
			cs.Append("        public double VERSION\r\n");
			cs.Append("        {\r\n");
			cs.Append("           get\r\n");
			cs.Append("           {\r\n");
			cs.Append("               return(double.Parse(_S.GetUPnPService().Version));\r\n");
			cs.Append("           }\r\n");
			cs.Append("        }\r\n\r\n");

			// Build Enumerations
			Hashtable elist = BuildEnumerations(SV);
			IDictionaryEnumerator el = elist.GetEnumerator();
			VarData vd;
			while(el.MoveNext())
			{
				vd = (VarData)el.Value;
				cs.Append("        public enum Enum_" + vd.VariableName + "\r\n");
				cs.Append("        {\r\n");
				foreach(EnumStruct vs in vd.Enumerations)
				{
					cs.Append("            " + vs.EnumName + ",\r\n");
				}
				cs.Append("        }\r\n");

				cs.Append("        public Enum_" + vd.VariableName + " ");
				if(s.GetStateVariableObject(vd.VariableName).SendEvent==true)
				{
					cs.Append("Evented_");
				}
				cs.Append(vd.VariableName + "\r\n");
				cs.Append("        {\r\n");
				cs.Append("            set\r\n");
				cs.Append("            {\r\n");
				cs.Append("               string v = \"\";\r\n");
				cs.Append("               switch(value)\r\n");
				cs.Append("               {\r\n");
				foreach(EnumStruct vs in vd.Enumerations)
				{
					cs.Append("                  case Enum_" + vd.VariableName + "." + vs.EnumName + ":\r\n");
					cs.Append("                     v = \"" + vs.EnumValue + "\";\r\n");
					cs.Append("                     break;\r\n");
				}
				cs.Append("               }\r\n");
				cs.Append("               _S.SetStateVariable(\"" + vd.VariableName + "\",v);\r\n");
				cs.Append("            }\r\n");
				cs.Append("            get\r\n");
				cs.Append("            {\r\n");
				cs.Append("               Enum_" + vd.VariableName + " RetVal = 0;\r\n");
				cs.Append("               string v = (string)_S.GetStateVariable(\"" + vd.VariableName + "\");\r\n");
				cs.Append("               switch(v)\r\n");
				cs.Append("               {\r\n");
				foreach(EnumStruct vs in vd.Enumerations)
				{
					cs.Append("                  case \"" + vs.EnumValue + "\":\r\n");
					cs.Append("                     RetVal = Enum_" + vd.VariableName + "." + vs.EnumName + ";\r\n");
					cs.Append("                     break;\r\n");
				}
				cs.Append("               }\r\n");
				cs.Append("               return(RetVal);\r\n");
				cs.Append("           }\r\n");
//.........这里部分代码省略.........
开发者ID:Scannow,项目名称:SWYH,代码行数:101,代码来源:ServiceGenerator.cs

示例3: GenerateCP

		/// <summary>
		/// Generates Control Point Implementation
		/// </summary>
		/// <param name="ClassName">Class Name to generate</param>
		/// <param name="ns">Namespace to use</param>
		/// <param name="SavePath">Path to save source</param>
		/// <param name="ServiceURN">Service URN to use</param>
		/// <param name="SCPD_XML">SCPD XML</param>
		public static void GenerateCP(String ClassName, String ns, String SavePath, String ServiceURN, String SCPD_XML)
		{
			string urn = ServiceURN.Substring(0,
				ServiceURN.LastIndexOf(":")) + ":";

			UPnPService s = new UPnPService(1);
			DText p = new DText();
			ArrayList tlist = new ArrayList();

			s.ParseSCPD(SCPD_XML);
			String cl = "\r\n";
			
			StringBuilder cs = new StringBuilder();
			UPnPArgument[] Args;
			UPnPArgument arg;
			UPnPStateVariable[] SV = s.GetStateVariables();
			Hashtable elist = BuildEnumerations(SV);

			cs.Append("using System;\r\n");
			cs.Append("using System.Collections;\r\n");
			cs.Append("using System.Threading;\r\n");
			cs.Append("using Intel.Utilities;\r\n");
			cs.Append("using Intel.UPNP;" + cl + cl);
			cs.Append("namespace " + ns + cl);
			cs.Append("{\r\n");
			cs.Append("    /// <summary>" + cl);
			cs.Append("    /// Transparent ClientSide UPnP Service" + cl);
			cs.Append("    /// </summary>" + cl);
			cs.Append("    public class " + ClassName + "\r\n");
			cs.Append("    {" + cl);
			cs.Append("       private Hashtable UnspecifiedTable = Hashtable.Synchronized(new Hashtable());\r\n");
			cs.Append("       internal UPnPService _S;\r\n\r\n");
			cs.Append("       public UPnPService GetUPnPService()\r\n");
			cs.Append("       {\r\n");
			cs.Append("            return(_S);\r\n");
			cs.Append("       }\r\n");
			cs.Append("       public static string SERVICE_NAME = \"" + urn + "\";\r\n");
			cs.Append("       public double VERSION\r\n");
			cs.Append("       {\r\n");
			cs.Append("           get\r\n");
			cs.Append("           {\r\n");
			cs.Append("               return(double.Parse(_S.Version));\r\n");
			cs.Append("           }\r\n");
			cs.Append("       }\r\n\r\n");

			foreach(UPnPStateVariable v in SV)
			{
				if(v.SendEvent==true)
				{
					cs.Append("       public delegate void StateVariableModifiedHandler_" + v.Name + "(" + ClassName + " sender, ");
					if(elist.ContainsKey(v.Name)==true)
					{
						cs.Append("Enum_" + v.Name + " NewValue");
					}
					else
					{
						cs.Append(v.GetNetType().FullName + " NewValue");
					}
					cs.Append(");\r\n");
					cs.Append("       private WeakEvent OnStateVariable_"+v.Name+"_Event = new WeakEvent();"+cl);				
					cs.Append("       public event StateVariableModifiedHandler_" + v.Name + " OnStateVariable_" + v.Name + "\r\n");
					cs.Append("       {"+cl);
					cs.Append("			add{OnStateVariable_"+v.Name+"_Event.Register(value);}"+cl);
					cs.Append("			remove{OnStateVariable_"+v.Name+"_Event.UnRegister(value);}"+cl);
					cs.Append("       }"+cl);
					cs.Append("       protected void " + v.Name + "_ModifiedSink(UPnPStateVariable Var, object NewValue)\r\n");
					cs.Append("       {\r\n");
					cs.Append("            OnStateVariable_" + v.Name + "_Event.Fire(this, "+v.Name+");"+cl);
					cs.Append("       }\r\n");
				}
			}
			cs.Append("       public delegate void SubscribeHandler(" + ClassName + " sender, bool Success);\r\n");
			cs.Append("       public event SubscribeHandler OnSubscribe;\r\n");
			
			// Build Events/Delegates
			foreach(UPnPAction A in s.Actions)
			{
				cs.Append("       public delegate void Delegate_OnResult_" + A.Name + "(" + ClassName + " sender, ");
				foreach(UPnPArgument _arg in A.ArgumentList)
				{
					if(_arg.IsReturnValue==false)
					{
						if(_arg.RelatedStateVar.AllowedStringValues==null)
						{
							cs.Append(_arg.RelatedStateVar.GetNetType().FullName + " ");
						}
						else
						{
							cs.Append("Enum_" + _arg.RelatedStateVar.Name + " ");
						}
						cs.Append(_arg.Name + ", ");
					}
//.........这里部分代码省略.........
开发者ID:Scannow,项目名称:SWYH,代码行数:101,代码来源:ServiceGenerator.cs


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