private void TypeCheckIntegral(CodeProcessor cs, UPnPArgument args)
        {
            UPnPDebugObject obj = new UPnPDebugObject(args.RelatedStateVar.GetNetType());
            switch (args.RelatedStateVar.GetNetType().FullName)
            {
                case "System.SByte":
                case "System.Int16":
                case "System.Int32":
                    cs.Append("	OK = " + pc_methodLibPrefix + "GetLong(p_" + args.Name + ",p_" + args.Name + "Length, &TempLong);" + cl);
                    break;
                case "System.Byte":
                case "System.UInt16":
                case "System.UInt32":
                    cs.Append("	OK = " + pc_methodLibPrefix + "GetULong(p_" + args.Name + ",p_" + args.Name + "Length, &TempULong);" + cl);
                    break;
            }
            cs.Append("	if (OK!=0)" + cl);
            cs.Append("	{" + cl);
            if (Configuration.ExplicitErrorEncoding == true)
            {
                cs.Append("		" + pc_methodPrefix + "Response_Error(ReaderObject,402,\"Argument[" + args.Name + "] illegal value\");" + cl);
            }
            else
            {
                cs.Append("		" + pc_methodPrefix + "Response_Error(ReaderObject,402,\"Illegal value\");" + cl);
            }
            cs.Append("		return;" + cl);
            cs.Append("	}" + cl);

            bool endtag = false;
            switch (args.RelatedStateVar.GetNetType().FullName)
            {
                case "System.SByte":
                case "System.Int16":
                case "System.Int32":
                    if (args.RelatedStateVar.Minimum == null && args.RelatedStateVar.Maximum == null)
                    {
                        // No need to check anything since this is without bounds.
                    }
                    else
                    {
                        // Check lower and upper bounds.
                        endtag = true;
                        cs.Append("	else" + cl);
                        cs.Append("	{" + cl);
                        if (!Configuration.DynamicObjectModel)
                        {
                            cs.Append("		if (!(TempLong>=");
                            if (args.RelatedStateVar.Minimum != null)
                            {
                                cs.Append("(long)0x" + ToHex(args.RelatedStateVar.Minimum));
                            }
                            else
                            {
                                cs.Append("(long)0x" + ToHex(obj.GetStaticField("MinValue")));
                            }
                            cs.Append(" && TempLong<=");
                            if (args.RelatedStateVar.Maximum != null)
                            {
                                cs.Append("(long)0x" + ToHex(args.RelatedStateVar.Maximum));
                            }
                            else
                            {
                                cs.Append("(long)0x" + ToHex(obj.GetStaticField("MaxValue")));
                            }
                            cs.Append("))" + cl);
                        }
                        else
                        {
                            string vIdent = DeviceObjectGenerator.GetStateVariableIdentifier(args.RelatedStateVar);

                            cs.Append("	OK = 0;" + cs.NewLine);
                            cs.Append("	if (" + vIdent + "->MinMaxStep[0]!=NULL)" + cs.NewLine);
                            cs.Append("	{" + cs.NewLine);
                            cs.Append("		" + pc_methodLibPrefix + "GetLong(" + vIdent + "->MinMaxStep[0],(int)strlen(" + vIdent + "->MinMaxStep[0]), &TempLong2);" + cl);
                            cs.Append("		if (TempLong<TempLong2){OK=1;}" + cs.NewLine);
                            cs.Append("	}" + cs.NewLine);
                            cs.Append("	if (" + vIdent + "->MinMaxStep[1]!=NULL)" + cs.NewLine);
                            cs.Append("	{" + cs.NewLine);
                            cs.Append("		" + pc_methodLibPrefix + "GetLong(" + vIdent + "->MinMaxStep[1],(int)strlen(" + vIdent + "->MinMaxStep[1]), &TempLong2);" + cl);
                            cs.Append("		if (TempLong>TempLong2){OK=1;}" + cs.NewLine);
                            cs.Append("	}" + cs.NewLine);
                            cs.Append("	if (OK!=0)" + cs.NewLine);
                        }
                        cs.Append("		{" + cl);
                        if (Configuration.ExplicitErrorEncoding == true)
                        {
                            cs.Append("		  " + pc_methodPrefix + "Response_Error(ReaderObject,402,\"Argument[" + args.Name + "] out of Range\");" + cl);
                        }
                        else
                        {
                            cs.Append("		  " + pc_methodPrefix + "Response_Error(ReaderObject,402,\"Illegal value\");" + cl);
                        }
                        cs.Append("		  return;" + cl);
                        cs.Append("		}" + cl);
                    }
                    break;
                case "System.Byte":
                case "System.UInt16":
                case "System.UInt32":
                    if (args.RelatedStateVar.Minimum == null && args.RelatedStateVar.Maximum == null)
                    {
                        // No need to check anything since this is an int without bounds.
                    }
                    else
                    {
                        endtag = true;
                        cs.Append("	else" + cl);
                        cs.Append("	{" + cl);
                        if (!this.Configuration.DynamicObjectModel)
                        {
                            cs.Append("		if (!(TempULong>=");
                            if (args.RelatedStateVar.Minimum != null)
                            {
                                cs.Append("(unsigned long)0x" + ToHex(args.RelatedStateVar.Minimum));
                            }
                            else
                            {
                                cs.Append("(unsigned long)0x" + ToHex(obj.GetStaticField("MinValue")));
                            }
                            cs.Append(" && TempULong<=");
                            if (args.RelatedStateVar.Maximum != null)
                            {
                                cs.Append("(unsigned long)0x" + ToHex(args.RelatedStateVar.Maximum));
                            }
                            else
                            {
                                cs.Append("(unsigned long)0x" + ToHex(obj.GetStaticField("MaxValue")));
                            }
                            cs.Append("))" + cl);
                        }
                        else
                        {
                            string vIdent = DeviceObjectGenerator.GetStateVariableIdentifier(args.RelatedStateVar);

                            cs.Append("	OK = 0;" + cs.NewLine);
                            cs.Append("	if (" + vIdent + "->MinMaxStep[0]!=NULL)" + cs.NewLine);
                            cs.Append("	{" + cs.NewLine);
                            cs.Append("		" + pc_methodLibPrefix + "GetULong(" + vIdent + "->MinMaxStep[0],(int)strlen(" + vIdent + "->MinMaxStep[0]), &TempULong2);" + cl);
                            cs.Append("		if (TempULong<TempULong2){OK=1;}" + cs.NewLine);
                            cs.Append("	}" + cs.NewLine);
                            cs.Append("	if (" + vIdent + "->MinMaxStep[1]!=NULL)" + cs.NewLine);
                            cs.Append("	{" + cs.NewLine);
                            cs.Append("		" + pc_methodLibPrefix + "GetULong(" + vIdent + "->MinMaxStep[1],(int)strlen(" + vIdent + "->MinMaxStep[1]), &TempULong2);" + cl);
                            cs.Append("		if (TempULong>TempULong2){OK=1;}" + cs.NewLine);
                            cs.Append("	}" + cs.NewLine);
                            cs.Append("	if (OK!=0)" + cs.NewLine);
                        }
                        cs.Append("		{" + cl);
                        if (Configuration.ExplicitErrorEncoding == true)
                        {
                            cs.Append("		  " + pc_methodPrefix + "Response_Error(ReaderObject,402,\"Argument[" + args.Name + "] out of Range\");" + cl);
                        }
                        else
                        {
                            cs.Append("		  " + pc_methodPrefix + "Response_Error(ReaderObject,402,\"Illegal value\");" + cl);
                        }
                        cs.Append("		  return;" + cl);
                        cs.Append("		}" + cl);
                    }
                    break;
            }

            switch (args.RelatedStateVar.GetNetType().FullName)
            {
                case "System.SByte":
                case "System.Int16":
                case "System.Int32":
                    cs.Append("	_" + args.Name + " = (" + ToCType(args.RelatedStateVar.GetNetType().FullName) + ")TempLong;" + cl);
                    break;
                case "System.Byte":
                case "System.UInt16":
                case "System.UInt32":
                    cs.Append("	_" + args.Name + " = (" + ToCType(args.RelatedStateVar.GetNetType().FullName) + ")TempULong;" + cl);
                    break;
            }
            if (endtag == true) cs.Append(" }" + cl);
        }
        private void TypeCheckIntegral(CodeProcessor cs, UPnPArgument args)
        {
            UPnPDebugObject obj = new UPnPDebugObject(args.RelatedStateVar.GetNetType());
            switch(args.RelatedStateVar.GetNetType().FullName)
            {
                case "System.SByte":
                case "System.Int16":
                case "System.Int32":
                    cs.Append("	OK = "+pc_methodLibPrefix+"GetLong(p_" + args.Name + ",p_" + args.Name + "Length, &TempLong);"+cl);
                    break;
                case "System.Byte":
                case "System.UInt16":
                case "System.UInt32":
                    cs.Append("	OK = "+pc_methodLibPrefix+"GetULong(p_" + args.Name + ",p_" + args.Name + "Length, &TempULong);"+cl);
                    break;
            }
            cs.Append("	if (OK != 0)"+cl);
            cs.Append("	{"+cl);
            cs.Append("		"+pc_methodPrefix+"Response_Error(ReaderObject, 402, \"Argument[" + args.Name + "] illegal value\");"+cl);
            cs.Append("		return;"+cl);
            cs.Append("	}"+cl);

            bool endtag = false;
            switch(args.RelatedStateVar.GetNetType().FullName)
            {
                case "System.SByte":
                case "System.Int16":
                case "System.Int32":
                    if ((args.RelatedStateVar.GetNetType().FullName == "System.Int32") && (args.RelatedStateVar.Minimum==null && args.RelatedStateVar.Maximum==null))
                    {
                        // No need to check anything since this is an int without bounds.
                    }
                    else
                    {
                        // Check lower and upper bounds.
                        endtag = true;
                        cs.Append("	else"+cl);
                        cs.Append("	{"+cl);
                        cs.Append("		if (!(TempLong >= ");
                        if (args.RelatedStateVar.Minimum!=null)
                        {
                            cs.Append("(long)0x" + ToHex(args.RelatedStateVar.Minimum));
                        }
                        else
                        {
                            cs.Append("(long)0x" + ToHex(obj.GetStaticField("MinValue")));
                        }
                        cs.Append(" && TempLong <= ");
                        if (args.RelatedStateVar.Maximum!=null)
                        {
                            cs.Append("(long)0x"+ToHex(args.RelatedStateVar.Maximum));
                        }
                        else
                        {
                            cs.Append("(long)0x"+ToHex(obj.GetStaticField("MaxValue")));
                        }
                        cs.Append("))"+cl);
                        cs.Append("		{"+cl);
                        cs.Append("		  "+pc_methodPrefix+"Response_Error(ReaderObject, 402, \"Argument[" + args.Name + "] out of Range\");"+cl);
                        cs.Append("		  return;"+cl);
                        cs.Append("		}"+cl);
                    }
                    break;
                case "System.Byte":
                case "System.UInt16":
                case "System.UInt32":
                    if ((args.RelatedStateVar.GetNetType().FullName == "System.UInt32") && (args.RelatedStateVar.Minimum==null && args.RelatedStateVar.Maximum==null))
                    {
                        // No need to check anything since this is an int without bounds.
                    }
                    else
                    {
                        endtag = true;
                        cs.Append("	else"+cl);
                        cs.Append("	{"+cl);
                        cs.Append("		if (!(TempULong >= ");
                        if (args.RelatedStateVar.Minimum!=null)
                        {
                            cs.Append("(unsigned long)0x"+ToHex(args.RelatedStateVar.Minimum));
                        }
                        else
                        {
                            cs.Append("(unsigned long)0x"+ToHex(obj.GetStaticField("MinValue")));
                        }
                        cs.Append(" && TempULong<=");
                        if (args.RelatedStateVar.Maximum!=null)
                        {
                            cs.Append("(unsigned long)0x"+ToHex(args.RelatedStateVar.Maximum));
                        }
                        else
                        {
                            cs.Append("(unsigned long)0x"+ToHex(obj.GetStaticField("MaxValue")));
                        }
                        cs.Append("))"+cl);
                        cs.Append("		{"+cl);
                        cs.Append("		  "+pc_methodPrefix+"Response_Error(ReaderObject, 402, \"Argument[" + args.Name + "] out of Range\");"+cl);
                        cs.Append("		  return;"+cl);
                        cs.Append("		}"+cl);
                    }
                    break;
            }

            switch(args.RelatedStateVar.GetNetType().FullName)
            {
                case "System.SByte":
                case "System.Int16":
                case "System.Int32":
                    cs.Append("	_" + args.Name + " = (" + ToCType(args.RelatedStateVar.GetNetType().FullName) + ")TempLong;"+cl);
                    break;
                case "System.Byte":
                case "System.UInt16":
                case "System.UInt32":
                    cs.Append("	_" + args.Name + " = (" + ToCType(args.RelatedStateVar.GetNetType().FullName) + ")TempULong;"+cl);
                    break;
            }
            if (endtag == true) cs.Append(" }"+cl);
        }