示例#1
0
        internal MI_Result DeserializeClass(
            MI_SerializerFlags flags,
            IntPtr serializedBuffer,
            UInt32 serializedBufferLength,
            MI_Class parentClass,
            string serverName,
            string namespaceName,
            IntPtr classObjectNeeded,
            IntPtr classObjectNeededContext,
            out UInt32 serializedBufferRead,
            out MI_Class classObject,
            out MI_Instance cimErrorDetails
            )
        {
            MI_Class    classObjectLocal     = MI_Class.NewIndirectPtr();
            MI_Instance cimErrorDetailsLocal = MI_Instance.NewIndirectPtr();

            MI_Result resultLocal = this.commonFT.DeserializeClass(this,
                                                                   flags,
                                                                   serializedBuffer,
                                                                   serializedBufferLength,
                                                                   parentClass,
                                                                   serverName,
                                                                   namespaceName,
                                                                   classObjectNeeded,
                                                                   classObjectNeededContext,
                                                                   out serializedBufferRead,
                                                                   classObjectLocal,
                                                                   cimErrorDetailsLocal);

            classObject     = classObjectLocal;
            cimErrorDetails = cimErrorDetailsLocal;
            return(resultLocal);
        }
示例#2
0
        internal MI_Result SerializeClass(
            MI_SerializerFlags flags,
            MI_Class classObject,
            out byte[] clientBuffer
            )
        {
            clientBuffer = null;
            UInt32    spaceNeeded = 0;
            MI_Result resultLocal = this.ft.SerializeClass(this,
                                                           flags,
                                                           classObject,
                                                           IntPtr.Zero,
                                                           0,
                                                           out spaceNeeded);

            if (resultLocal == MI_Result.MI_RESULT_OK || (resultLocal == MI_Result.MI_RESULT_FAILED && spaceNeeded != 0))
            {
                UInt32 spaceUsed;
                IntPtr clientBufferLocal = Marshal.AllocHGlobal((IntPtr)spaceNeeded);
                resultLocal = this.ft.SerializeClass(this,
                                                     flags,
                                                     classObject,
                                                     clientBufferLocal,
                                                     spaceNeeded,
                                                     out spaceUsed);
                if (clientBufferLocal != IntPtr.Zero)
                {
                    clientBuffer = new byte[spaceNeeded];
                    Marshal.Copy(clientBufferLocal, clientBuffer, 0, (int)spaceNeeded);
                    Marshal.FreeHGlobal(clientBufferLocal);
                }
            }

            return(resultLocal);
        }
示例#3
0
        internal MI_Result SerializeClass(
            MI_SerializerFlags flags,
            MI_Class classObject,
            IntPtr clientBuffer,
            UInt32 clientBufferLength,
            out UInt32 clientBufferNeeded
            )
        {
            MI_Result resultLocal = this.ft.SerializeClass(this,
                                                           flags,
                                                           classObject,
                                                           clientBuffer,
                                                           clientBufferLength,
                                                           out clientBufferNeeded);

            return(resultLocal);
        }
示例#4
0
        internal MI_Result SerializeInstance(
            MI_SerializerFlags flags,
            MI_Instance instanceObject,
            IntPtr clientBuffer,
            UInt32 clientBufferLength,
            out UInt32 clientBufferNeeded
            )
        {
            MI_Result resultLocal = this.ft.SerializeInstance(this,
                                                              flags,
                                                              instanceObject,
                                                              clientBuffer,
                                                              clientBufferLength,
                                                              out clientBufferNeeded);

            return(resultLocal);
        }
示例#5
0
        internal MI_Result DeserializeClassArray(
            MI_SerializerFlags flags,
            MI_OperationOptions options,
            MI_DeserializerCallbacks deserializerCallbacks,
            IntPtr serializedBuffer,
            UInt32 serializedBufferLength,
            MI_Class[] classDefinitions,
            string serverName,
            string namespaceName,
            out UInt32 serializedBufferRead,
            out MI_ExtendedArray classes,
            out MI_Instance cimErrorDetails)
        {
            if (!MI_SerializationFormat.MOF.Equals(this.format, StringComparison.OrdinalIgnoreCase))
            {
                throw new NotImplementedException();
            }

            MI_Class.ArrayPtr classPtrs            = MI_Class.GetPointerArray(classDefinitions);
            MI_Instance       cimErrorDetailsLocal = MI_Instance.NewIndirectPtr();
            MI_ExtendedArray  classesLocal         = MI_ExtendedArray.NewIndirectPtr();
            MI_ExtendedArray  classDetailsArray    = MI_ExtendedArray.NewDirectPtr(classPtrs.Ptrs);

            MI_DeserializerCallbacks.MI_DeserializerCallbacksNative nativeCallbacks = deserializerCallbacks.GetNativeCallbacks(this.format);

            classes = null;

            var resLocal = this.ft.DeserializeClassArray_MOF(
                this,
                flags,
                options,
                nativeCallbacks,
                serializedBuffer,
                serializedBufferLength,
                classDetailsArray,
                serverName,
                namespaceName,
                out serializedBufferRead,
                classesLocal,
                cimErrorDetailsLocal);

            cimErrorDetails = cimErrorDetailsLocal;
            classes         = classesLocal;

            return(resLocal);
        }
示例#6
0
        internal MI_Result DeserializeClassArray(
            MI_SerializerFlags flags,
            MI_OperationOptions options,
            MI_DeserializerCallbacks deserializerCallbacks,
            byte[] serializedBuffer,
            MI_Class[] classDefinitions,
            string serverName,
            string namespaceName,
            out UInt32 serializedBufferRead,
            out MI_ExtendedArray classes,
            out MI_Instance cimErrorDetails)
        {
            if (!MI_SerializationFormat.MOF.Equals(this.format, StringComparison.OrdinalIgnoreCase))
            {
                throw new NotImplementedException();
            }

            if (serializedBuffer == null || serializedBuffer.Length == 0)
            {
                throw new InvalidOperationException();
            }

            IntPtr clientBuffer = Marshal.AllocHGlobal(serializedBuffer.Length);

            try
            {
                Marshal.Copy(serializedBuffer, 0, clientBuffer, serializedBuffer.Length);
                return(this.DeserializeClassArray(
                           flags,
                           options,
                           deserializerCallbacks,
                           clientBuffer,
                           (uint)serializedBuffer.Length,
                           classDefinitions,
                           serverName,
                           namespaceName,
                           out serializedBufferRead,
                           out classes,
                           out cimErrorDetails));
            }
            finally
            {
                Marshal.FreeHGlobal(clientBuffer);
            }
        }
示例#7
0
        internal MI_Result DeserializeClass(
            MI_SerializerFlags flags,
            byte[] serializedBuffer,
            MI_Class parentClass,
            string serverName,
            string namespaceName,
            IntPtr classObjectNeeded,
            IntPtr classObjectNeededContext,
            out UInt32 serializedBufferRead,
            out MI_Class classObject,
            out MI_Instance cimErrorDetails
            )
        {
            if (serializedBuffer == null || serializedBuffer.Length == 0)
            {
                throw new InvalidOperationException();
            }

            IntPtr clientBuffer = Marshal.AllocHGlobal(serializedBuffer.Length);

            try
            {
                Marshal.Copy(serializedBuffer, 0, clientBuffer, serializedBuffer.Length);
                return(this.DeserializeClass(flags,
                                             clientBuffer,
                                             (uint)serializedBuffer.Length,
                                             parentClass,
                                             serverName,
                                             namespaceName,
                                             classObjectNeeded,
                                             classObjectNeededContext,
                                             out serializedBufferRead,
                                             out classObject,
                                             out cimErrorDetails));
            }
            finally
            {
                Marshal.FreeHGlobal(clientBuffer);
            }
        }
示例#8
0
        internal MI_Result NewDeserializer(
            MI_SerializerFlags flags,
            string format,
            out MI_Deserializer deserializer
            )
        {
            MI_Deserializer deserializerLocal = MI_Deserializer.NewDirectPtr(format);

            MI_Result resultLocal;

#if !_LINUX
            if (MI_SerializationFormat.XML.Equals(format, StringComparison.Ordinal))
            {
                resultLocal = this.ft.NewDeserializer(this,
                                                      flags,
                                                      format,
                                                      deserializerLocal);
            }
            else if (MI_SerializationFormat.MOF.Equals(format, StringComparison.Ordinal))
            {
                resultLocal = NativeMethods.MI_Application_NewDeserializer_Mof(this,
                                                                               flags,
                                                                               format,
                                                                               deserializerLocal);
            }
            else
            {
                throw new NotImplementedException();
            }
#else
            resultLocal = this.ft.NewDeserializer(this,
                                                  flags,
                                                  format,
                                                  deserializerLocal);
#endif

            deserializer = deserializerLocal;
            return(resultLocal);
        }
示例#9
0
        private MI_Result DeserializeInstance(
            MI_SerializerFlags flags,
            IntPtr serializedBuffer,
            UInt32 serializedBufferLength,
            MI_Class[] classObjects,
            MI_Deserializer_ClassObjectNeededNative classObjectNeeded,
            IntPtr classObjectNeededContext,
            out UInt32 serializedBufferRead,
            out MI_Instance instanceObject,
            out MI_Instance cimErrorDetails
            )
        {
            if (classObjectNeededContext != IntPtr.Zero)
            {
                throw new NotImplementedException();
            }

            MI_Instance instanceObjectLocal  = MI_Instance.NewIndirectPtr();
            MI_Instance cimErrorDetailsLocal = MI_Instance.NewIndirectPtr();

            MI_Class.ArrayPtr classArrayPtr = MI_Class.GetPointerArray(classObjects);

            MI_Result resultLocal = this.commonFT.DeserializeInstance(this,
                                                                      flags,
                                                                      serializedBuffer,
                                                                      serializedBufferLength,
                                                                      classArrayPtr.Ptrs,
                                                                      (uint)classObjects.Length,
                                                                      classObjectNeeded,
                                                                      IntPtr.Zero,
                                                                      out serializedBufferRead,
                                                                      instanceObjectLocal,
                                                                      cimErrorDetailsLocal);

            instanceObject  = instanceObjectLocal;
            cimErrorDetails = cimErrorDetailsLocal;
            return(resultLocal);
        }
示例#10
0
        internal MI_Result DeserializeInstance(
            MI_SerializerFlags flags,
            byte[] serializedBuffer,
            MI_Class[] classObjects,
            MI_Deserializer_ClassObjectNeeded classObjectNeeded,
            out UInt32 serializedBufferRead,
            out MI_Instance instanceObject,
            out MI_Instance cimErrorDetails
            )
        {
            if (serializedBuffer == null || serializedBuffer.Length == 0)
            {
                throw new InvalidOperationException();
            }

            MI_Deserializer_ClassObjectNeededNative nativeCallback = MI_DeserializerCallbacks.GetNativeClassObjectNeededCallback(this.format, classObjectNeeded);

            IntPtr clientBuffer = Marshal.AllocHGlobal(serializedBuffer.Length);

            try
            {
                Marshal.Copy(serializedBuffer, 0, clientBuffer, serializedBuffer.Length);
                return(this.DeserializeInstance(flags,
                                                clientBuffer,
                                                (UInt32)(serializedBuffer.Length),
                                                classObjects,
                                                nativeCallback,
                                                IntPtr.Zero,
                                                out serializedBufferRead,
                                                out instanceObject,
                                                out cimErrorDetails));
            }
            finally
            {
                Marshal.FreeHGlobal(clientBuffer);
            }
        }
示例#11
0
 internal static extern MI_Result MI_Application_NewDeserializer_Mof(
     MI_Application.DirectPtr application,
     MI_SerializerFlags flags,
     [MarshalAs(UnmanagedType.LPWStr)] string format,
     MI_Deserializer.DirectPtr serializer
     );