Esempio n. 1
0
		// define a Parameter's Style
		public int DefPara(int nStyle)
		{
			Param param = null;
			if ( nStyle != Param.STYLE_BUFF
				&& nStyle != Param.STYLE_INT
				&& nStyle != Param.STYLE_LONG ) 
			{
				Debug.Assert(false, "style error");
				return -1;  // style error
			}
	
			param = new Param();
			if (param == null) 
			{
				Debug.Assert(false, "new Param object fail ...");
				return -1;
			}
			this.Add(param);

			param.m_nStyle = nStyle;
	
			return 0;
		}
Esempio n. 2
0
		// Int32
		//  Add a long to ParaTable
		public int ParaLong(Int32 lValue)
		{
			Param param = new Param();
			this.Add(param);

			param.m_nStyle = Param.STYLE_LONG;
			param.m_lValue = lValue;
			return 4;
		}
Esempio n. 3
0
		//  Add a Buffer to ParaTable
		public int ParaBuff(byte [] baBuffer,
			int lLen)
        {
			Debug.Assert(baBuffer != null, "baBuffer参数不能为空");
			Debug.Assert(lLen >= 0, "lLen参数值不能为0或负数");

			Param param = new Param();
			this.Add(param);

			param.m_nStyle = Param.STYLE_BUFF;
			param.m_lValue = lLen;

			param.m_baValue = new byte [Math.Max(lLen, 4096)];
            if (param.m_baValue == null) 
			{
				Debug.Assert(false, "分配缓冲区失败");
                return -1;
			}

			Array.Copy(baBuffer, 0, param.m_baValue, 0, lLen);
			return lLen;
		}
Esempio n. 4
0
		// Int32
		//*  Add an integer to ParaTable
		public int ParaInt(Int32 nValue)
		{
			Param param = new Param();
			if (param == null) 
			{
				Debug.Assert(false, "new Param object fail");
				return -1;
			}
			this.Add(param);

			param.m_nStyle = Param.STYLE_INT;
			param.m_lValue = nValue;
			return 2;
		}