コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
 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));
 }
コード例 #4
0
 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);
 }
コード例 #5
0
 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);
 }
コード例 #6
0
 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));
 }
コード例 #7
0
        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);
        }
コード例 #8
0
ファイル: MIValueTests.cs プロジェクト: madewokherd/MMI
        public void ValuesNullCanBeUsed()
        {
            foreach (MI_Type type in Enum.GetValues(typeof(MI_Type)))
            {
                string propertyName = type.ToString() + "_Null";
                var    res          = this.instance.AddElement(propertyName, MI_Value.Null, type, MI_Flags.MI_FLAG_NULL);
                MIAssert.Succeeded(res, "Expect add element to succeed for {0}", propertyName);

                MI_Value returnedValue = null;
                MI_Type  elementType;
                MI_Flags elementFlags = 0;
                UInt32   elementIndex = 0;
                res = instance.GetElement(propertyName, out returnedValue, out elementType, out elementFlags, out elementIndex);
                MIAssert.Succeeded(res, "Expect to get element by name");
                var testproperty = new TestMIProperty(returnedValue, elementType, elementFlags);
                MIAssert.MIPropertiesEqual(new TestMIProperty(this.value, type, MI_Flags.MI_FLAG_NULL), testproperty, propertyName);
            }
        }
コード例 #9
0
        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);
        }
コード例 #10
0
ファイル: MI_Instance.cs プロジェクト: madewokherd/MMI
        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);
        }
コード例 #11
0
        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);
        }
コード例 #12
0
ファイル: MIValueTests.cs プロジェクト: madewokherd/MMI
        private void TestValueRoundtrip()
        {
            Assert.True(this.value.Type.HasValue, "Expect value to have a value before calling helper");
            string propertyName = this.value.Type.ToString();
            var    res          = this.instance.AddElement(propertyName, this.value, this.value.Type.Value, MI_Flags.MI_FLAG_BORROW);

            MIAssert.Succeeded(res, "Expect add element to succeed");

            MI_Value returnedValue = null;
            MI_Type  elementType;
            MI_Flags elementFlags = 0;
            UInt32   elementIndex = 0;

            res = instance.GetElement(propertyName, out returnedValue, out elementType, out elementFlags, out elementIndex);
            MIAssert.Succeeded(res, "Expect to get element by name");
            var testproperty = new TestMIProperty(returnedValue, elementType, elementFlags);

            MIAssert.MIPropertiesEqual(new TestMIProperty(this.value, this.value.Type.Value, MI_Flags.None), testproperty, propertyName);
        }
コード例 #13
0
ファイル: MI_Instance.cs プロジェクト: madewokherd/MMI
        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);
        }
コード例 #14
0
ファイル: MI_Instance.cs プロジェクト: madewokherd/MMI
        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);
        }
コード例 #15
0
ファイル: MI_Instance.cs プロジェクト: madewokherd/MMI
        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);
        }
コード例 #16
0
        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);
        }
コード例 #17
0
 public static CimFlags ToCimFlags(this MI_Flags miFlags)
 {
     return((CimFlags)miFlags);
 }
コード例 #18
0
ファイル: TestMIProperty.cs プロジェクト: madewokherd/MMI
 public TestMIProperty(MI_Value value, MI_Type type, MI_Flags flags)
 {
     this.actualValue = value;
     this.Type        = type;
     this.Flags       = flags;
 }
コード例 #19
0
        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));
            }
        }