public IEnumerable <CimClass> DeserializeClasses(byte[] serializedData, ref uint offset, IEnumerable <CimClass> classes, OnClassNeeded onClassNeededCallback, GetIncludedFileContent getIncludedFileCallback) { return(DeserializeClasses(serializedData, ref offset, classes, null, null, onClassNeededCallback, getIncludedFileCallback)); }
public IEnumerable <CimInstance> DeserializeInstances( byte[] serializedData, ref uint offset, IEnumerable <CimClass> cimClasses, OnClassNeeded onClassNeededCallback, GetIncludedFileContent getIncludedFileCallback) { List <CimInstance> instancelist = new List <CimInstance>(); MI_Instance[] instanceHandles = DeserializeInstanceHandle(serializedData, ref offset, cimClasses, onClassNeededCallback, getIncludedFileCallback); foreach (MI_Instance handle in instanceHandles) { instancelist.Add(new CimInstance(handle)); } return(instancelist); }
public IEnumerable <CimClass> DeserializeClasses(byte[] serializedData, ref uint offset, IEnumerable <CimClass> classes, string computerName, string namespaceName, OnClassNeeded onClassNeededCallback, GetIncludedFileContent getIncludedFileCallback) { MI_Class[] classHandles = DeserializeClassHandle( serializedData, ref offset, classes, computerName, namespaceName, onClassNeededCallback, getIncludedFileCallback); List <CimClass> classlist = new List <CimClass>(); foreach (MI_Class handle in classHandles) { classlist.Add(new CimClass(handle)); } return(classlist); }
internal MI_Class[] DeserializeClassHandle( byte[] serializedData, ref uint offset, IEnumerable <CimClass> cimClasses, string computerName, string namespaceName, OnClassNeeded onClassNeededCallback, GetIncludedFileContent getIncludedFileCallback) { if (serializedData == null) { throw new ArgumentNullException("serializedData"); } else if (offset >= serializedData.Length) { throw new ArgumentOutOfRangeException("offset"); } else if (getIncludedFileCallback != null) { // Need the definition for the callbacks throw new NotImplementedException(); } else if (offset != 0) { // Need to internally handle the offset as the native calls // have no knowledge of this right now throw new NotImplementedException(); } this.AssertNotDisposed(); MI_Class[] nativeClassHandles = null; if (cimClasses != null) { nativeClassHandles = cimClasses.Select(cimClass => cimClass.ClassHandle).ToArray(); } UInt32 inputBufferUsed; MI_Instance cimError; MI_ExtendedArray classArray; MI_OperationOptions nativeOption = GetOperationOptions().OperationOptionsHandle; //MI_DeserializerCallbacks callbacks = new MI_DeserializerCallbacks(); //if (onClassNeededCallback != null) callbacks.ClassObjectNeededCallback = CreateClassObjectNeededCallbackDelegate(onClassNeededCallback); //if (getIncludedFileCallback != null) callbacks.GetIncludedFileBufferCallback = CreateGetIncludedFileBufferCallback(getIncludedFileCallback); MI_DeserializerCallbacks callbacks = new MI_DeserializerCallbacks(); if (onClassNeededCallback != null) { callbacks.classObjectNeeded = CreateClassObjectNeededCallbackDelegate(onClassNeededCallback); } MI_Result result = this._myHandle.DeserializeClassArray( MI_SerializerFlags.None, nativeOption, callbacks, serializedData, nativeClassHandles, computerName, namespaceName, out inputBufferUsed, out classArray, out cimError); CimException.ThrowIfMiResultFailure(result, cimError); MI_Class[] deserializedClasses = classArray.ReadAsManagedPointerArray(MI_Class.NewFromDirectPtr); MI_Class[] resultClasses = deserializedClasses.CloneMIArray(); classArray.Delete(); offset += inputBufferUsed; return(resultClasses); }
public IEnumerable <CimInstance> DeserializeInstances(byte[] serializedData, ref uint offset, OnClassNeeded onClassNeededCallback, GetIncludedFileContent getIncludedFileCallback) { return(this.DeserializeInstances(serializedData, ref offset, null, onClassNeededCallback, getIncludedFileCallback)); }
internal MI_Instance[] DeserializeInstanceHandle( byte[] serializedData, ref uint offset, IEnumerable <CimClass> cimClasses, OnClassNeeded onClassNeededCallback, GetIncludedFileContent getIncludedFileCallback) { if (serializedData == null) { throw new ArgumentNullException("serializedData"); } else if (offset >= serializedData.Length) { throw new ArgumentOutOfRangeException("offset"); } else if (offset != 0) { // Need to implement this in our layer as it is not // handled by the underlying API throw new NotImplementedException(); } else if (getIncludedFileCallback != null) { // Still need to add the native definitions of these callbacks throw new NotImplementedException(); } this.AssertNotDisposed(); MI_Class[] nativeClassHandles = null; if (cimClasses != null) { nativeClassHandles = cimClasses.Select(cimClass => cimClass.ClassHandle).ToArray(); } UInt32 inputBufferUsed; MI_Instance cimError; MI_ExtendedArray instanceArray; MI_OperationOptions nativeOption = GetOperationOptions().OperationOptionsHandle; // TODO: Add definitions for these callbacks //if (getIncludedFileCallback != null) callbacks.GetIncludedFileBufferCallback = CreateGetIncludedFileBufferCallback(getIncludedFileCallback); MI_DeserializerCallbacks callbacks = new MI_DeserializerCallbacks(); if (onClassNeededCallback != null) { callbacks.classObjectNeeded = CreateClassObjectNeededCallbackDelegate(onClassNeededCallback); } MI_Result result = this._myHandle.DeserializeInstanceArray( MI_SerializerFlags.None, nativeOption, callbacks, serializedData, nativeClassHandles, out inputBufferUsed, out instanceArray, out cimError); CimException.ThrowIfMiResultFailure(result, cimError); MI_Instance[] deserializedInstances = instanceArray.ReadAsManagedPointerArray(MI_Instance.NewFromDirectPtr); MI_Instance[] resultInstances = deserializedInstances.CloneMIArray(); instanceArray.Delete(); offset += inputBufferUsed; return(resultInstances); }