Beispiel #1
0
        public bool Serialize(CimClass cimClass, ClassSerializationOptions options, byte[] buffer, ref int offset)
        {
            int num = 0;

            if (cimClass != null)
            {
                if (buffer != null)
                {
                    if ((long)offset <= (long)((int)buffer.Length))
                    {
                        if ((long)offset == (long)((int)buffer.Length))
                        {
                            buffer = null;
                        }
                    }
                    else
                    {
                        throw new ArgumentOutOfRangeException("offset");
                    }
                }
                else
                {
                    if (offset != 0)
                    {
                        throw new ArgumentNullException("buffer");
                    }
                }
                this.AssertNotDisposed();
                bool     flag      = true;
                MiResult miResult  = MiResult.OK; //TODO: // SerializerMethods.SerializeClass(this._myHandle, options, cimClass.ClassHandle, buffer, offset, out num);
                MiResult miResult1 = miResult;
                switch (miResult1)
                {
                case MiResult.OK:
                {
                    offset = offset + num;
                    flag   = true;
                    return(flag);
                }

                case MiResult.FAILED:
                {
                    if (buffer == null || (long)(offset + num) > (long)((int)buffer.Length))
                    {
                        miResult = MiResult.OK;
                        offset   = offset + num;
                    }
                    flag = false;
                    return(flag);
                }
                }
                CimException.ThrowIfMiResultFailure(miResult);
                return(flag);
            }
            else
            {
                throw new ArgumentNullException("cimClass");
            }
        }
Beispiel #2
0
 public byte[] Serialize(CimClass cimClass, ClassSerializationOptions options)
 {
     unsafe
     {
         if (cimClass != null)
         {
             this.AssertNotDisposed();
             int num = 0;
             this.Serialize(cimClass, options, null, ref num);
             byte[] numArray = new byte[num];
             int    num1     = 0;
             this.Serialize(cimClass, options, numArray, ref num1);
             return(numArray);
         }
         else
         {
             throw new ArgumentNullException("cimClass");
         }
     }
 }
Beispiel #3
0
 /// <summary>
 /// Serializes the <paramref name="cimClass"/>
 /// </summary>
 /// <param name="cimClass">Class to serialize</param>
 /// <param name="options">Serialization options</param>
 /// <returns>Serialized representation of <paramref name="cimClass"/></returns>
 public byte[] Serialize(CimClass cimClass, ClassSerializationOptions options)
 {
     /*
      *  if (cimClass == null)
      *  {
      *      throw new ArgumentNullException("cimClass");
      *  }
      *  this.AssertNotDisposed();
      *
      *  bool dataFitsIntoBuffer;
      *  uint requiredBufferSize = 0;
      *  dataFitsIntoBuffer = Serialize(cimClass, options, null, ref requiredBufferSize);
      *  Debug.Assert(!dataFitsIntoBuffer, "Passing null buffer - data cannot possibly fit into this buffer");
      *
      *  byte[] buffer = new byte[requiredBufferSize];
      *  uint offset = 0;
      *  dataFitsIntoBuffer = Serialize(cimClass, options, buffer, ref offset);
      *  Debug.Assert(dataFitsIntoBuffer, "Newly allocated buffer should fit (1)");
      *  Debug.Assert(buffer.Length == offset, "Newly allocated buffer should fit exactly (2)");
      *
      *  return buffer;
      */
     return(new byte[1]);
 }
Beispiel #4
0
 public bool Serialize(CimClass cimClass, ClassSerializationOptions options, byte[] buffer, ref uint offset)
 {
     /*
      *  if (cimClass == null)
      *  {
      *      throw new ArgumentNullException("cimClass");
      *  }
      *  if (buffer == null)
      *  {
      *      if (offset != 0)
      *      {
      *          throw new ArgumentNullException("buffer");
      *      }
      *  }
      *  else
      *  {
      *      if (offset > buffer.Length) // offset == buffer.Length points outside of buffer, but is ok
      *      {
      *          throw new ArgumentOutOfRangeException("offset");
      *      }
      *      else if (offset == buffer.Length)
      *      {
      *          buffer = null;
      *      }
      *  }
      *  this.AssertNotDisposed();
      *
      *  bool doesDataFitIntoTheBuffer = true;
      *
      *  uint numberOfBytesUsed;
      *  MI_Result result = Native.SerializerMethods.SerializeClass(
      *      this._myHandle,
      *      (UInt32)options,
      *      cimClass.ClassHandle,
      *      buffer,
      *      offset,
      *      out numberOfBytesUsed);
      *  switch (result)
      *  {
      *      case MI_Result.MI_RESULT_FAILED:
      *          if ((buffer == null) || ((offset + numberOfBytesUsed) > buffer.Length))
      *          {
      *              result = MI_Result.MI_RESULT_OK;
      *              offset += numberOfBytesUsed;
      *          }
      *          doesDataFitIntoTheBuffer = false;
      *          return doesDataFitIntoTheBuffer;
      *
      *      case MI_Result.MI_RESULT_OK:
      *          offset += numberOfBytesUsed;
      *          doesDataFitIntoTheBuffer = true;
      *          return doesDataFitIntoTheBuffer;
      *
      *      default:
      *          CimException.ThrowIfMiResultFailure(result);
      *          Debug.Assert(false, "Should throw in the previous statement");
      *          return doesDataFitIntoTheBuffer;
      *  }
      */
     return(false);
 }
Beispiel #5
0
		public byte[] Serialize(CimClass cimClass, ClassSerializationOptions options)
		{
			unsafe
			{
				if (cimClass != null)
				{
					this.AssertNotDisposed();
					int num = 0;
					this.Serialize(cimClass, options, null, ref num);
					byte[] numArray = new byte[num];
					int num1 = 0;
					this.Serialize(cimClass, options, numArray, ref num1);
					return numArray;
				}
				else
				{
					throw new ArgumentNullException("cimClass");
				}
			}
		}
Beispiel #6
0
		public bool Serialize(CimClass cimClass, ClassSerializationOptions options, byte[] buffer, ref int offset)
		{
			int num = 0;
			if (cimClass != null)
			{
				if (buffer != null)
				{
					if ((long)offset <= (long)((int)buffer.Length))
					{
						if ((long)offset == (long)((int)buffer.Length))
						{
							buffer = null;
						}
					}
					else
					{
						throw new ArgumentOutOfRangeException("offset");
					}
				}
				else
				{
					if (offset != 0)
					{
						throw new ArgumentNullException("buffer");
					}
				}
				this.AssertNotDisposed();
				bool flag = true;
                MiResult miResult = MiResult.OK; //TODO: // SerializerMethods.SerializeClass(this._myHandle, options, cimClass.ClassHandle, buffer, offset, out num);
				MiResult miResult1 = miResult;
				switch (miResult1)
				{
					case MiResult.OK:
					{
						offset = offset + num;
						flag = true;
						return flag;
					}
					case MiResult.FAILED:
					{
						if (buffer == null || (long)(offset + num) > (long)((int)buffer.Length))
						{
							miResult = MiResult.OK;
							offset = offset + num;
						}
						flag = false;
						return flag;
					}
				}
				CimException.ThrowIfMiResultFailure(miResult);
				return flag;
			}
			else
			{
				throw new ArgumentNullException("cimClass");
			}
		}