private MI_PropertyDecl(MI_Flags flags, UInt32 code, string name, IntPtr qualifiers, UInt32 numQualifiers, MI_Type type, string className, UInt32 subscript, UInt32 offset, string origin, string propagator, IntPtr value) { this.AllocateQualifierDecl( flags, code, name, qualifiers, numQualifiers, type, className, subscript, offset, origin, propagator, value); }
internal static MI_PropertyDecl NewDirectPtr(MI_Flags flags, UInt32 code, string name, IntPtr qualifiers, UInt32 numQualifiers, MI_Type type, string className, UInt32 subscript, UInt32 offset, string origin, string propagator, IntPtr value) { return(new MI_PropertyDecl( flags, code, name, qualifiers, numQualifiers, type, className, subscript, offset, origin, propagator, value)); }
private void AllocateQualifierDecl(MI_Flags flags, UInt32 code, string name, IntPtr qualifiers, UInt32 numQualifiers, MI_Type type, string className, UInt32 subscript, UInt32 offset, string origin, string propagator, IntPtr value) { var dest = new MI_PropertyDeclMembers(); dest.flags = flags; dest.code = code; dest.name = MI_PlatformSpecific.StringToPtr(name); dest.qualifiers = qualifiers; dest.numQualifiers = numQualifiers; dest.type = type; dest.className = MI_PlatformSpecific.StringToPtr(className); dest.subscript = subscript; dest.offset = offset; dest.origin = MI_PlatformSpecific.StringToPtr(origin); dest.propagator = MI_PlatformSpecific.StringToPtr(propagator); dest.value = value; this.ptr = Marshal.AllocHGlobal(MI_PropertyDeclMembersSize); Marshal.StructureToPtr(dest, this.ptr, false); }
internal MI_Result GetElementAt( UInt32 index, out string name, out MI_Value value, out bool valueExists, out MI_Type type, out string referenceClass, out MI_QualifierSet qualifierSet, out MI_Flags flags ) { MI_String nameLocal = MI_String.NewIndirectPtr(); MI_String referenceClassLocal = MI_String.NewIndirectPtr(); MI_Value valueLocal = new MI_Value(); MI_QualifierSet qualifierSetLocal = MI_QualifierSet.NewDirectPtr(); MI_Result resultLocal = this.ft.GetElementAt(this, index, nameLocal, valueLocal, out valueExists, out type, referenceClassLocal, qualifierSetLocal, out flags); name = nameLocal.Value; referenceClass = referenceClassLocal.Value; value = valueLocal; qualifierSet = qualifierSetLocal; return(resultLocal); }
internal static MI_QualifierDecl NewDirectPtr(string name, MI_Type type, MI_Flags scope, MI_Flags flavor, UInt32 subscript, bool value) { return(new MI_QualifierDecl(name, type, scope, flavor, subscript, value)); }
private MI_QualifierDecl(string name, MI_Type type, MI_Flags scope, MI_Flags flavor, UInt32 subscript, IntPtr value) { this.AllocateQualifierDecl(name, type, scope, flavor, subscript, value); }
internal MI_Result GetMethodReturnType( out MI_Type returnType, MI_QualifierSet qualifierSet ) { MI_Result resultLocal = this.ft.GetMethodReturnType(this, out returnType, qualifierSet); return(resultLocal); }
private MI_QualifierDecl(string name, MI_Type type, MI_Flags scope, MI_Flags flavor, UInt32 subscript, bool value) { var valuePtr = Marshal.AllocHGlobal(Marshal.SizeOf <Byte>()); Marshal.WriteByte(valuePtr, (byte)(value ? 1 : 0)); this.AllocateQualifierDecl(name, type, scope, flavor, subscript, valuePtr); }
internal MI_Result SetCustomOption( string optionName, MI_Type valueType, MI_Value value, bool mustComply, MI_OperationOptionsFlags flags ) { MI_Result resultLocal = this.ft.SetCustomOption(this, optionName, valueType, value, mustComply, flags); return(resultLocal); }
internal MI_Result GetOption( string optionName, MI_Value value, out MI_Type type, out UInt32 index, out UInt32 flags ) { MI_Result resultLocal = this.ft.GetOption(this, optionName, value, out type, out index, out flags); return(resultLocal); }
internal static void ThrowIfMismatchedType(MI_Type type, object managedValue) { // TODO: Implement this /* * MI_Value throwAway; * memset(&throwAway, 0, sizeof(MI_Value)); * IEnumerable<DangerousHandleAccessor^>^ dangerousHandleAccesorsFromConversion = nullptr; * try * { * dangerousHandleAccesorsFromConversion = ConvertToMiValue(type, managedValue, &throwAway); * } * finally * { * ReleaseMiValue(type, &throwAway, dangerousHandleAccesorsFromConversion); * } */ }
internal MI_Result GetElement( string name, out MI_Value value, out MI_Type type, out MI_Flags flags, out UInt32 index ) { MI_Value valueLocal = new MI_Value(); MI_Result resultLocal = this.ft.GetElement(this, name, valueLocal, out type, out flags, out index); value = valueLocal; return(resultLocal); }
private void AllocateQualifierDecl(string name, MI_Type type, MI_Flags scope, MI_Flags flavor, UInt32 subscript, IntPtr value) { var dest = new MI_QualifierDeclMembers(); dest.name = MI_PlatformSpecific.StringToPtr(name); dest.type = type; dest.scope = (UInt32)scope; dest.flavor = (UInt32)flavor; dest.subscript = subscript; dest.value = value; this.ptr = Marshal.AllocHGlobal(MI_QualifierDeclMembersSize); Marshal.StructureToPtr(dest, this.ptr, false); }
internal MI_Result GetQualifier( string name, out MI_Type qualifierType, out MI_Flags qualifierFlags, out MI_Value qualifierValue, out UInt32 index ) { MI_Value qualifierValueLocal = new MI_Value(); MI_Result resultLocal = this.ft.GetQualifier(this, name, out qualifierType, out qualifierFlags, qualifierValueLocal, out index); qualifierValue = qualifierValueLocal; return(resultLocal); }
internal MI_Result AddElement( string name, MI_Value value, MI_Type type, MI_Flags flags ) { if (value != null && value.Type.HasValue && value.Type != type) { throw new InvalidCastException(); } MI_Result resultLocal = this.ft.AddElement(this, name, value, type, flags); return(resultLocal); }
internal MI_Result SetElementAt( UInt32 index, MI_Value value, MI_Type type, MI_Flags flags ) { if (value != null && value.Type.HasValue && value.Type != type) { throw new InvalidCastException(); } MI_Result resultLocal = this.ft.SetElementAt(this, index, value, type, flags); return(resultLocal); }
internal MI_Result GetOptionAt( UInt32 index, out string optionName, MI_Value value, out MI_Type type, out UInt32 flags ) { MI_String optionNameLocal = MI_String.NewIndirectPtr(); MI_Result resultLocal = this.ft.GetOptionAt(this, index, optionNameLocal, value, out type, out flags); optionName = optionNameLocal.Value; return(resultLocal); }
internal MI_Result GetElementAt( UInt32 index, out string name, out MI_Value value, out MI_Type type, out MI_Flags flags ) { MI_Value valueLocal = new MI_Value(); MI_String nameLocal = MI_String.NewIndirectPtr(); MI_Result resultLocal = this.ft.GetElementAt(this, index, nameLocal, valueLocal, out type, out flags); value = valueLocal; name = nameLocal.Value; return(resultLocal); }
internal MI_Result GetParameter( string name, out MI_Type parameterType, out string referenceClass, out MI_QualifierSet qualifierSet, out UInt32 index ) { MI_String referenceClassLocal = MI_String.NewIndirectPtr(); MI_QualifierSet qualifierSetLocal = MI_QualifierSet.NewDirectPtr(); MI_Result resultLocal = this.ft.GetParameter(this, name, out parameterType, referenceClassLocal, qualifierSetLocal, out index); referenceClass = referenceClassLocal.Value; qualifierSet = qualifierSetLocal; return(resultLocal); }
internal MI_Result GetQualifierAt( UInt32 index, out string name, out MI_Type qualifierType, out MI_Flags qualifierFlags, out MI_Value qualifierValue ) { MI_String nameLocal = MI_String.NewIndirectPtr(); MI_Value qualifierValueLocal = new MI_Value(); MI_Result resultLocal = this.ft.GetQualifierAt(this, index, nameLocal, out qualifierType, out qualifierFlags, qualifierValueLocal); name = nameLocal.Value; qualifierValue = qualifierValueLocal; return(resultLocal); }
public TestMIProperty(MI_Value value, MI_Type type, MI_Flags flags) { this.actualValue = value; this.Type = type; this.Flags = flags; }
internal object GetValue(MI_Type type) { switch (type) { case MI_Type.MI_BOOLEAN: return(this.Boolean); case MI_Type.MI_UINT8: return(this.Uint8); case MI_Type.MI_SINT8: return(this.Sint8); case MI_Type.MI_UINT16: return(this.Uint16); case MI_Type.MI_SINT16: return(this.Sint16); case MI_Type.MI_UINT32: return(this.Uint32); case MI_Type.MI_SINT32: return(this.Sint32); case MI_Type.MI_UINT64: return(this.Uint64); case MI_Type.MI_SINT64: return(this.Sint64); case MI_Type.MI_REAL32: return(this.Real32); case MI_Type.MI_REAL64: return(this.Real64); case MI_Type.MI_CHAR16: return(this.Char16); case MI_Type.MI_DATETIME: return(this.Datetime); case MI_Type.MI_STRING: return(this.String); case MI_Type.MI_REFERENCE: return(this.Reference); case MI_Type.MI_INSTANCE: return(this.Instance); case MI_Type.MI_BOOLEANA: return(this.BooleanA); case MI_Type.MI_UINT8A: return(this.Uint8A); case MI_Type.MI_SINT8A: return(this.Sint8A); case MI_Type.MI_UINT16A: return(this.Uint16A); case MI_Type.MI_SINT16A: return(this.Sint16A); case MI_Type.MI_UINT32A: return(this.Uint32A); case MI_Type.MI_SINT32A: return(this.Sint32A); case MI_Type.MI_UINT64A: return(this.Uint64A); case MI_Type.MI_SINT64A: return(this.Sint64A); case MI_Type.MI_REAL32A: return(this.Real32A); case MI_Type.MI_REAL64A: return(this.Real64A); case MI_Type.MI_CHAR16A: return(this.Char16A); case MI_Type.MI_DATETIMEA: return(this.DatetimeA); case MI_Type.MI_STRINGA: return(this.StringA); case MI_Type.MI_REFERENCEA: return(this.ReferenceA); case MI_Type.MI_INSTANCEA: return(this.InstanceA); default: throw new ArgumentOutOfRangeException(); } }
internal static object ConvertFromNativeLayer( MI_Value value, MI_Type type, MI_Flags flags, CimInstance parent = null, bool clone = false) { if ((flags & MI_Flags.MI_FLAG_NULL) == MI_Flags.MI_FLAG_NULL) { return(null); } if (type == MI_Type.MI_INSTANCE || type == MI_Type.MI_REFERENCE) { CimInstance instance = new CimInstance( clone ? value.Instance.Clone() : value.Instance); if (parent != null) { instance.SetCimSessionComputerName(parent.GetCimSessionComputerName()); instance.SetCimSessionInstanceId(parent.GetCimSessionInstanceId()); } return(instance); } else if (type == MI_Type.MI_INSTANCEA || type == MI_Type.MI_REFERENCEA) { CimInstance[] arrayOfInstances = new CimInstance[value.InstanceA.Length]; for (int i = 0; i < value.InstanceA.Length; i++) { MI_Instance h = value.InstanceA[i]; if (h == null) { arrayOfInstances[i] = null; } else { arrayOfInstances[i] = new CimInstance( clone ? h.Clone() : h); if (parent != null) { arrayOfInstances[i].SetCimSessionComputerName(parent.GetCimSessionComputerName()); arrayOfInstances[i].SetCimSessionInstanceId(parent.GetCimSessionInstanceId()); } } } return(arrayOfInstances); } else if (type == MI_Type.MI_DATETIME) { return(value.Datetime.ConvertFromNativeLayer()); } else if (type == MI_Type.MI_DATETIMEA) { int length = value.DatetimeA.Length; object[] arrayOfDatetimes = new object[length]; for (int i = 0; i < length; i++) { arrayOfDatetimes[i] = value.DatetimeA[i].ConvertFromNativeLayer(); } return(arrayOfDatetimes); } else { return(value.GetValue(type)); } }
public static CimType ToCimType(this MI_Type miType) { switch (miType) { case MI_Type.MI_BOOLEAN: return(CimType.Boolean); case MI_Type.MI_UINT8: return(CimType.UInt8); case MI_Type.MI_SINT8: return(CimType.SInt8); case MI_Type.MI_UINT16: return(CimType.UInt16); case MI_Type.MI_SINT16: return(CimType.SInt16); case MI_Type.MI_UINT32: return(CimType.UInt32); case MI_Type.MI_SINT32: return(CimType.SInt32); case MI_Type.MI_UINT64: return(CimType.UInt64); case MI_Type.MI_SINT64: return(CimType.SInt64); case MI_Type.MI_REAL32: return(CimType.Real32); case MI_Type.MI_REAL64: return(CimType.Real64); case MI_Type.MI_CHAR16: return(CimType.Char16); case MI_Type.MI_DATETIME: return(CimType.DateTime); case MI_Type.MI_STRING: return(CimType.String); case MI_Type.MI_REFERENCE: return(CimType.Reference); case MI_Type.MI_INSTANCE: return(CimType.Instance); case MI_Type.MI_BOOLEANA: return(CimType.BooleanArray); case MI_Type.MI_UINT8A: return(CimType.UInt8Array); case MI_Type.MI_SINT8A: return(CimType.SInt8Array); case MI_Type.MI_UINT16A: return(CimType.UInt16Array); case MI_Type.MI_SINT16A: return(CimType.SInt16Array); case MI_Type.MI_UINT32A: return(CimType.UInt32Array); case MI_Type.MI_SINT32A: return(CimType.SInt32Array); case MI_Type.MI_UINT64A: return(CimType.UInt64Array); case MI_Type.MI_SINT64A: return(CimType.SInt64Array); case MI_Type.MI_REAL32A: return(CimType.Real32Array); case MI_Type.MI_REAL64A: return(CimType.Real64Array); case MI_Type.MI_CHAR16A: return(CimType.Char16Array); case MI_Type.MI_DATETIMEA: return(CimType.DateTimeArray); case MI_Type.MI_STRINGA: return(CimType.StringArray); case MI_Type.MI_REFERENCEA: return(CimType.ReferenceArray); case MI_Type.MI_INSTANCEA: return(CimType.InstanceArray); default: Debug.Assert(false, "Unrecognized or unsupported value of MI_Type"); throw new ArgumentOutOfRangeException("miType"); } }