public static string ToCTypeFromStateVar_Dispatch(UPnPStateVariable V)
 {
     if (V.ComplexType == null)
     {
         string RetVal = V.Name;
         if (Static_ToCType(V.GetNetType().ToString()) == "unsigned char*")
         {
             RetVal += ", " + V.Name + "Length";
         }
         return (RetVal);
     }
     else
     {
         return (V.Name);
     }
 }
        public static string ToCTypeFromStateVar_Serialize(string InVar, string InVarLength, string OK, string LibPrefix, UPnPStateVariable A)
        {
            StringBuilder cs = new StringBuilder();

            if (OK != "")
            {
                OK = OK + " = ";
            }

            switch (A.GetNetType().FullName)
            {
                case "System.DateTime":
                    cs.Append("	" + A.Name + " = " + LibPrefix + "Time_Parse(" + InVar + ");" + cl);
                    break;
                case "System.SByte":
                case "System.Int16":
                case "System.Int32":
                    cs.Append("	" + OK + LibPrefix + "GetLong(" + InVar + ", " + InVarLength + ", (long*)&" + A.Name + ");" + cl);
                    break;
                case "System.Byte":
                case "System.UInt16":
                case "System.UInt32":
                    cs.Append("	" + OK + LibPrefix + "GetULong(" + InVar + ", " + InVarLength + ", (unsigned long*)&" + A.Name + ");" + cl);
                    break;
                case "System.Boolean":
                    if (OK != "")
                    {
                        cs.Append(OK + "0;" + cl);
                    }
                    cs.Append("	if (" + InVarLength + "==4)" + cl);
                    cs.Append("	{" + cl);
                    cs.Append("		if (strncasecmp(" + InVar + ", \"true\", 4)==0)" + cl);
                    cs.Append("		{" + cl);
                    if (OK != "")
                    {
                        cs.Append(OK + "1;" + cl);
                    }
                    cs.Append("			" + A.Name + " = 1;" + cl);
                    cs.Append("		}" + cl);
                    cs.Append("	}" + cl);
                    cs.Append("	if (" + InVarLength + " == 5)" + cl);
                    cs.Append("	{" + cl);
                    cs.Append("		if (strncasecmp(" + InVar + ", \"false\", 5)==0)" + cl);
                    cs.Append("		{" + cl);
                    if (OK != "")
                    {
                        cs.Append(OK + "1;" + cl);
                    }
                    cs.Append("			" + A.Name + " = 0;" + cl);
                    cs.Append("		}" + cl);
                    cs.Append("	}" + cl);
                    cs.Append("	if (" + InVarLength + " == 1)" + cl);
                    cs.Append("	{" + cl);
                    cs.Append("		if (memcmp(" + InVar + ", \"0\", 1) == 0)" + cl);
                    cs.Append("		{" + cl);
                    if (OK != "")
                    {
                        cs.Append(OK + "1;" + cl);
                    }
                    cs.Append("			" + A.Name + " = 0;" + cl);
                    cs.Append("		}" + cl);
                    cs.Append("		if (memcmp(" + InVar + ", \"1\", 1) == 0)" + cl);
                    cs.Append("		{" + cl);
                    if (OK != "")
                    {
                        cs.Append(OK + "1;" + cl);
                    }
                    cs.Append("			" + A.Name + " = 1;" + cl);
                    cs.Append("		}" + cl);
                    cs.Append("	}" + cl);
                    break;
                case "System.Byte[]":
                    cs.Append(A.Name + "Length = " + LibPrefix + "Base64Decode(" + InVar + ", " + InVarLength + ", &" + A.Name + ");" + cl);
                    break;
                case "System.Uri":
                case "System.String":
                default:
                    if (A.ComplexType == null)
                    {
                        cs.Append("	" + A.Name + "Length = " + LibPrefix + "InPlaceXmlUnEscape(" + InVar + ");" + cl);
                        cs.Append("	" + A.Name + " = " + InVar + ";" + cl);
                    }
                    else
                    {
                        cs.Append(cl + "//ToDo: DeviceBuilder needs to be modified to include a ComplexTypeParsre here!");
                    }
                    break;
            }
            return (cs.ToString());
        }
 public static string ToCTypeFromStateVar(UPnPStateVariable V)
 {
     if (V.ComplexType == null)
     {
         string RetVal = Static_ToCType(V.GetNetType().ToString()) + " " + V.Name;
         if (Static_ToCType(V.GetNetType().ToString()) == "unsigned char*")
         {
             RetVal += ", int " + V.Name + "Length";
         }
         return (RetVal);
     }
     else
     {
         return ("struct " + V.ComplexType.Name_LOCAL + "* " + V.Name);
     }
 }