Esempio n. 1
0
        /// <summary>
        /// Serializes the <paramref name="cimInstance"/>
        /// </summary>
        /// <param name="cimInstance">Instance to serialize</param>
        /// <param name="options">Serialization options</param>
        /// <returns>Serialized representation of <paramref name="cimInstance"/></returns>
        public byte[] Serialize(CimInstance cimInstance, InstanceSerializationOptions options)
        {
            // TODO: Add Serializer support

            /*
             *  if (cimInstance == null)
             *  {
             *      throw new ArgumentNullException("cimInstance");
             *  }
             *  this.AssertNotDisposed();
             *
             *  bool dataFitsIntoBuffer;
             *  uint requiredBufferSize = 0;
             *  dataFitsIntoBuffer = Serialize(cimInstance, 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(cimInstance, 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]);
        }
Esempio n. 2
0
 public bool Serialize(CimInstance cimInstance, InstanceSerializationOptions options, byte[] buffer, ref uint offset)
 {
     /*
      *  if (cimInstance == null)
      *  {
      *      throw new ArgumentNullException("cimInstance");
      *  }
      *  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.SerializeInstance(
      *      this._myHandle,
      *      (UInt32)options,
      *      cimInstance.InstanceHandle,
      *      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);
 }
Esempio n. 3
0
        public bool Serialize(CimInstance cimInstance, InstanceSerializationOptions options, byte[] buffer, ref int offset)
        {
            int num = 0;

            if (cimInstance != 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.SerializeInstance(this._myHandle, options, cimInstance.InstanceHandle, 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("cimInstance");
            }
        }
Esempio n. 4
0
		public bool Serialize(CimInstance cimInstance, InstanceSerializationOptions options, byte[] buffer, ref int offset)
		{
			int num = 0;
			if (cimInstance != 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.SerializeInstance(this._myHandle, options, cimInstance.InstanceHandle, 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("cimInstance");
			}
		}
Esempio n. 5
0
 public byte[] Serialize(CimInstance cimInstance, InstanceSerializationOptions options)
 {
     unsafe
     {
         if (cimInstance != null)
         {
             this.AssertNotDisposed();
             int num = 0;
             this.Serialize(cimInstance, options, null, ref num);
             byte[] numArray = new byte[num];
             int    num1     = 0;
             this.Serialize(cimInstance, options, numArray, ref num1);
             return(numArray);
         }
         else
         {
             throw new ArgumentNullException("cimInstance");
         }
     }
 }
Esempio n. 6
0
		public byte[] Serialize(CimInstance cimInstance, InstanceSerializationOptions options)
		{
			unsafe
			{
				if (cimInstance != null)
				{
					this.AssertNotDisposed();
					int num = 0;
					this.Serialize(cimInstance, options, null, ref num);
					byte[] numArray = new byte[num];
					int num1 = 0;
					this.Serialize(cimInstance, options, numArray, ref num1);
					return numArray;
				}
				else
				{
					throw new ArgumentNullException("cimInstance");
				}
			}
		}