コード例 #1
0
        public void Add(string propertyName, object propertyValue, CimType propertyType)
        {
            if (propertyName == null)
            {
                throw new ArgumentNullException("propertyName");
            }
            if (this.parent.GetType() == typeof(ManagementObject))
            {
                throw new InvalidOperationException();
            }
            int  type    = (int)propertyType;
            bool isArray = false;

            if ((propertyValue != null) && propertyValue.GetType().IsArray)
            {
                isArray = true;
                type   |= 0x2000;
            }
            object pVal      = PropertyData.MapValueToWmiValue(propertyValue, propertyType, isArray);
            int    errorCode = this.parent.wbemObject.Put_(propertyName, 0, ref pVal, type);

            if (errorCode < 0)
            {
                if ((errorCode & 0xfffff000L) == 0x80041000L)
                {
                    ManagementException.ThrowWithExtendedInfo((ManagementStatus)errorCode);
                }
                else
                {
                    Marshal.ThrowExceptionForHR(errorCode);
                }
            }
        }
コード例 #2
0
 internal CimPropertyStandalone(string name, object value, CimType cimType, CimFlags flags)
 {
     this._name    = name;
     this._cimType = cimType;
     this._flags   = flags;
     this.Value    = value;
 }
コード例 #3
0
        public void Add(string propertyName, CimType propertyType, bool isArray)
        {
            if (propertyName == null)
            {
                throw new ArgumentNullException(propertyName);
            }
            if (this.parent.GetType() == typeof(ManagementObject))
            {
                throw new InvalidOperationException();
            }
            int type = (int)propertyType;

            if (isArray)
            {
                type |= 0x2000;
            }
            object pVal      = DBNull.Value;
            int    errorCode = this.parent.wbemObject.Put_(propertyName, 0, ref pVal, type);

            if (errorCode < 0)
            {
                if ((errorCode & 0xfffff000L) == 0x80041000L)
                {
                    ManagementException.ThrowWithExtendedInfo((ManagementStatus)errorCode);
                }
                else
                {
                    Marshal.ThrowExceptionForHR(errorCode);
                }
            }
        }
コード例 #4
0
        public override void SetPropertyValue(PSAdaptedProperty adaptedProperty, object value)
        {
            if (adaptedProperty == null)
            {
                throw new ArgumentNullException("adaptedProperty");
            }
            if (!this.IsSettable(adaptedProperty))
            {
                throw new SetValueException("ReadOnlyCIMProperty", null, CimInstanceTypeAdapterResources.ReadOnlyCIMProperty, new object[] { adaptedProperty.Name });
            }
            CimProperty tag  = adaptedProperty.Tag as CimProperty;
            object      obj2 = value;

            if (obj2 != null)
            {
                Type    dotNetType;
                CimType cimType = tag.CimType;
                if (cimType == CimType.DateTime)
                {
                    dotNetType = typeof(object);
                }
                else if (cimType == CimType.DateTimeArray)
                {
                    dotNetType = typeof(object[]);
                }
                else
                {
                    dotNetType = CimConverter.GetDotNetType(tag.CimType);
                }
                obj2 = Adapter.PropertySetAndMethodArgumentConvertTo(value, dotNetType, CultureInfo.InvariantCulture);
            }
            tag.Value = obj2;
        }
コード例 #5
0
        /// <summary>
        /// Gets the according C# type
        /// </summary>
        /// <param name="type">The original type</param>
        /// <returns>The C# type</returns>
        private string GetType(CimType type)
        {
            switch (type)
            {
            case CimType.Char16:
                return("char");

            case CimType.Real64:
                return("double");

            case CimType.Real32:
                return("Single");

            case CimType.SInt8:
                return("sbyte");

            case CimType.SInt16:
                return("short");

            case CimType.SInt32:
                return("int");

            case CimType.SInt64:
                return("long");

            case CimType.UInt8:
                return("byte");

            default:
                return(type.ToString());
            }
        }
コード例 #6
0
        /// <summary>
        /// <para>Adds a new <see cref='System.Management.PropertyData'/> with the specified value and CIM type.</para>
        /// </summary>
        /// <param name='propertyName'>The name of the property.</param>
        /// <param name='propertyValue'>The value of the property (which can be null).</param>
        /// <param name='propertyType'>The CIM type of the property.</param>
        /// <remarks>
        ///    <para> Properties can only be added to class definitions, not 
        ///       to instances. This method is only valid when invoked on a <see cref='System.Management.PropertyDataCollection'/>
        ///       in
        ///       a <see cref='System.Management.ManagementClass'/>.</para>
        /// </remarks>
        public void Add(string propertyName, object propertyValue, CimType propertyType)
        {
            if (null == propertyName)
                throw new ArgumentNullException(nameof(propertyName));

            if (parent.GetType() == typeof(ManagementObject)) //can't add properties to instance
                throw new InvalidOperationException();

            int wmiCimType = (int)propertyType;
            bool isArray = false;

            if ((null != propertyValue) && propertyValue.GetType().IsArray)
            {
                isArray = true;
                wmiCimType = (wmiCimType | (int)tag_CIMTYPE_ENUMERATION.CIM_FLAG_ARRAY);
            }

            object wmiValue = PropertyData.MapValueToWmiValue(propertyValue, propertyType, isArray);

            int status = parent.wbemObject.Put_(propertyName, 0, ref wmiValue, wmiCimType);

            if (status < 0)
            {
                if ((status & 0xfffff000) == 0x80041000)
                    ManagementException.ThrowWithExtendedInfo((ManagementStatus)status);
                else
                    Marshal.ThrowExceptionForHR(status, WmiNetUtilsHelper.GetErrorInfo_f());
            }
        }
コード例 #7
0
ファイル: PropertySet.cs プロジェクト: mikem8361/runtime
        /// <summary>
        /// <para>Adds a new <see cref='System.Management.PropertyData'/> with no assigned value.</para>
        /// </summary>
        /// <param name='propertyName'>The name of the property.</param>
        /// <param name='propertyType'>The CIM type of the property.</param>
        /// <param name='isArray'><see langword='true'/> to specify that the property is an array type; otherwise, <see langword='false'/>.</param>
        /// <remarks>
        ///    <para> Properties can only be added to class definitions, not
        ///       to instances. This method is only valid when invoked on a <see cref='System.Management.PropertyDataCollection'/>
        ///       in
        ///       a <see cref='System.Management.ManagementClass'/>.</para>
        /// </remarks>
        public void Add(string propertyName, CimType propertyType, bool isArray)
        {
            if (null == propertyName)
            {
                throw new ArgumentNullException(propertyName);
            }

            if (parent.GetType() == typeof(ManagementObject)) //can't add properties to instance
            {
                throw new InvalidOperationException();
            }

            int wmiCimType = (int)propertyType;

            if (isArray)
            {
                wmiCimType |= (int)tag_CIMTYPE_ENUMERATION.CIM_FLAG_ARRAY;
            }

            object dummyObj = System.DBNull.Value;

            int status = parent.wbemObject.Put_(propertyName, 0, ref dummyObj, wmiCimType);

            if (status < 0)
            {
                if ((status & 0xfffff000) == 0x80041000)
                {
                    ManagementException.ThrowWithExtendedInfo((ManagementStatus)status);
                }
                else
                {
                    Marshal.ThrowExceptionForHR(status, WmiNetUtilsHelper.GetErrorInfo_f());
                }
            }
        }
コード例 #8
0
ファイル: CimType.cs プロジェクト: billmoling/wbemtools
        /// <summary>
        /// Converts a nullable CimType to a string
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static string CimTypeToStr(CimType? type)
        {
            if (type == null)
                throw new Exception("Not implemented yet");

            return CimTypeToStr((CimType) type);
        }
 public void Add(string propertyName, object propertyValue, CimType propertyType)
 {
     if (propertyName == null)
     {
         throw new ArgumentNullException("propertyName");
     }
     if (this.parent.GetType() == typeof(ManagementObject))
     {
         throw new InvalidOperationException();
     }
     int type = (int) propertyType;
     bool isArray = false;
     if ((propertyValue != null) && propertyValue.GetType().IsArray)
     {
         isArray = true;
         type |= 0x2000;
     }
     object pVal = PropertyData.MapValueToWmiValue(propertyValue, propertyType, isArray);
     int errorCode = this.parent.wbemObject.Put_(propertyName, 0, ref pVal, type);
     if (errorCode < 0)
     {
         if ((errorCode & 0xfffff000L) == 0x80041000L)
         {
             ManagementException.ThrowWithExtendedInfo((ManagementStatus) errorCode);
         }
         else
         {
             Marshal.ThrowExceptionForHR(errorCode);
         }
     }
 }
 public void Add(string propertyName, CimType propertyType, bool isArray)
 {
     if (propertyName == null)
     {
         throw new ArgumentNullException(propertyName);
     }
     if (this.parent.GetType() == typeof(ManagementObject))
     {
         throw new InvalidOperationException();
     }
     int type = (int) propertyType;
     if (isArray)
     {
         type |= 0x2000;
     }
     object pVal = DBNull.Value;
     int errorCode = this.parent.wbemObject.Put_(propertyName, 0, ref pVal, type);
     if (errorCode < 0)
     {
         if ((errorCode & 0xfffff000L) == 0x80041000L)
         {
             ManagementException.ThrowWithExtendedInfo((ManagementStatus) errorCode);
         }
         else
         {
             Marshal.ThrowExceptionForHR(errorCode);
         }
     }
 }
コード例 #11
0
 private static Type TypeFromCimType(CimType cimType, bool handleObjectAsGuid)
 {
     if (cimType == CimType.Object && handleObjectAsGuid)
     {
         return(typeof(Guid));
     }
     return(TypeFromCimType(cimType));
 }
コード例 #12
0
        private static Microsoft.Management.Infrastructure.CimType Transform(CimType type)
        {
            switch (type)
            {
            case CimType.None:
                return(Microsoft.Management.Infrastructure.CimType.Unknown);

            case CimType.SInt16:
                return(Microsoft.Management.Infrastructure.CimType.SInt16);

            case CimType.SInt32:
                return(Microsoft.Management.Infrastructure.CimType.SInt32);

            case CimType.Real32:
                return(Microsoft.Management.Infrastructure.CimType.Real32);

            case CimType.Real64:
                return(Microsoft.Management.Infrastructure.CimType.Real64);

            case CimType.String:
                return(Microsoft.Management.Infrastructure.CimType.String);

            case CimType.Boolean:
                return(Microsoft.Management.Infrastructure.CimType.Boolean);

            case CimType.Object:
                return(Microsoft.Management.Infrastructure.CimType.Instance);

            case CimType.SInt8:
                return(Microsoft.Management.Infrastructure.CimType.SInt8);

            case CimType.UInt8:
                return(Microsoft.Management.Infrastructure.CimType.UInt8);

            case CimType.UInt16:
                return(Microsoft.Management.Infrastructure.CimType.UInt16);

            case CimType.UInt32:
                return(Microsoft.Management.Infrastructure.CimType.UInt32);

            case CimType.SInt64:
                return(Microsoft.Management.Infrastructure.CimType.SInt64);

            case CimType.UInt64:
                return(Microsoft.Management.Infrastructure.CimType.UInt64);

            case CimType.DateTime:
                return(Microsoft.Management.Infrastructure.CimType.DateTime);

            case CimType.Reference:
                return(Microsoft.Management.Infrastructure.CimType.Reference);

            case CimType.Char16:
                return(Microsoft.Management.Infrastructure.CimType.Char16);
            }

            return(Microsoft.Management.Infrastructure.CimType.Unknown);
        }
コード例 #13
0
        internal static CimType GetCimTypeFromDotNetValueOrThrowAnException(object dotNetValue)
        {
            CimType cimType = GetCimTypeFromDotNetValue(dotNetValue);

            if (cimType == CimType.Unknown)
            {
                throw new ArgumentException(Strings.DotNetValueToCimTypeConversionNotPossible);
            }
            return(cimType);
        }
コード例 #14
0
        internal static object CloneManagedObject(object managedValue, CimType type)
        {
            if (managedValue != null &&
                (type == CimType.Reference || type == CimType.Instance))
            {
                throw new NotImplementedException();
            }

            return(managedValue);
        }
コード例 #15
0
        internal CimPropertyStandalone(string name, object value, CimType cimType, CimFlags flags)
        {
            Debug.Assert(name != null, "Caller should verify name != null");

            this._name    = name;
            this._cimType = cimType;
            this._flags   = flags;

            this.Value           = value;
            this.IsValueModified = false;
        }
コード例 #16
0
        public static System.Type ConvertCimType(CimType ctValue)
        {
            System.Type tReturnVal = null;
            switch (ctValue)
            {
                case CimType.Boolean:
                    tReturnVal = typeof(System.Boolean);
                    break;
                case CimType.Char16:
                    tReturnVal = typeof(System.String);
                    break;
                case CimType.DateTime:
                    tReturnVal = typeof(System.DateTime);
                    break;
                case CimType.Object:
                    tReturnVal = typeof(System.Object);
                    break;
                case CimType.Real32:
                    tReturnVal = typeof(System.Decimal);
                    break;
                case CimType.Real64:
                    tReturnVal = typeof(System.Decimal);
                    break;
                case CimType.Reference:
                    tReturnVal = typeof(System.Object);
                    break;
                case CimType.SInt16:
                    tReturnVal = typeof(System.Int16);
                    break;
                case CimType.SInt32:
                    tReturnVal = typeof(System.Int32);
                    break;
                case CimType.SInt8:
                    tReturnVal = typeof(System.Int16);
                    break;
                case CimType.String:
                    tReturnVal = typeof(System.String);
                    break;
                case CimType.UInt16:
                    tReturnVal = typeof(System.UInt16);
                    break;
                case CimType.UInt32:
                    tReturnVal = typeof(System.UInt32);
                    break;
                case CimType.UInt64:
                    tReturnVal = typeof(System.UInt64);
                    break;
                case CimType.UInt8:
                    tReturnVal = typeof(System.UInt16);
                    break;
            }

            return tReturnVal;
        }
コード例 #17
0
        private static CimType GetCimTypeFromDotNetValue(object dotNetValue)
        {
            if (dotNetValue != null)
            {
                CimType cimType = CimTypeConverter.GetCimType(dotNetValue.GetType());
                if (cimType != CimType.None)
                {
                    return(cimType);
                }
            }

            return(CimType.None);
        }
コード例 #18
0
        internal static CimType GetCimTypeFromDotNetValueOrThrowAnException(object dotNetValue)
        {
            CimType cimTypeFromDotNetValue = CimTypeConverter.GetCimTypeFromDotNetValue(dotNetValue);

            if (cimTypeFromDotNetValue != CimType.None)
            {
                return(cimTypeFromDotNetValue);
            }
            else
            {
                throw new ArgumentException("DotNetValueToCimTypeConversionNotPossible");
            }
        }
コード例 #19
0
ファイル: wmihelper.cs プロジェクト: oturan-boga/nt5src
        public static string[] GetOperators(CimType CimType)
        {
            ArrayList retArray = new ArrayList(10);

            switch (CimType)
            {
            case (CimType.Boolean):
            {
                retArray.Add("=");
                retArray.Add("<>");
                break;
            }

            case (CimType.Char16):

            case (CimType.DateTime):
            case (CimType.Real32):
            case (CimType.Real64):
            case (CimType.SInt16):
            case (CimType.SInt32):
            case (CimType.SInt64):
            case (CimType.SInt8):
            case (CimType.UInt16):
            case (CimType.UInt32):
            case (CimType.UInt64):
            case (CimType.UInt8):
            case (CimType.Reference):
            case (CimType.String):
            {
                retArray.Add("=");
                retArray.Add("<>");
                retArray.Add(">");
                retArray.Add("<");
                retArray.Add(">=");
                retArray.Add("<=");
                break;
            }

            case (CimType.Object):
            {
                retArray.Add("ISA");
                break;
            }


            default:
                break;
            }

            return((string[])retArray.ToArray(typeof(string)));
        }
コード例 #20
0
        public static MiResult AddElement(InstanceHandle handle, string name, object obj, object par, MiFlags miFlags)
        {
            NativeCimInstance   instance   = CimNativeApi.MarshalledObject.FromPointer <NativeCimInstance>(handle.DangerousGetHandle());
            NativeCimProperties properties = NativeCimPropertiesHelper.Deserialize(instance.Properties);

            CimType type = CimConverter.GetCimType(obj.GetType());

            properties.Add(new NativeCimProperty {
                Name = name, Type = type, Origin = "client", IsArray = false, IsLocal = false, Value = obj
            });
            instance.Properties = NativeCimPropertiesHelper.Serialize(properties);
            handle.DangerousSetHandle((IntPtr)CimNativeApi.MarshalledObject.Create <NativeCimInstance>(instance));
            return(MiResult.OK);
        }
コード例 #21
0
 internal static void SetCustomOption(CimOperationOptions operationOptions, string optionName, object optionValue)
 {
     if (optionValue != null)
     {
         object  cim     = CimValueConverter.ConvertFromDotNetToCim(optionValue);
         CimType cimType = CimConverter.GetCimType(CimValueConverter.GetCimType(optionValue.GetType()));
         operationOptions.SetCustomOption(optionName, cim, cimType, false);
         return;
     }
     else
     {
         return;
     }
 }
コード例 #22
0
        /// <summary>
        /// Retrieve the reference object or reference array object.
        /// The returned object has to be either CimInstance or CImInstance[] type,
        /// if not thrown exception.
        /// </summary>
        /// <param name="value"></param>
        /// <param name="referenceType">Output the cimtype of the value, either Reference or ReferenceArray.</param>
        /// <returns></returns>
        protected object GetReferenceOrReferenceArrayObject(object value, ref CimType referenceType)
        {
            PSReference cimReference = value as PSReference;

            if (cimReference != null)
            {
                object      baseObject  = GetBaseObject(cimReference.Value);
                CimInstance cimInstance = baseObject as CimInstance;
                if (cimInstance == null)
                {
                    return(null);
                }

                referenceType = CimType.Reference;
                return(cimInstance);
            }
            else
            {
                object[] cimReferenceArray = value as object[];
                if (cimReferenceArray == null)
                {
                    return(null);
                }
                else if (!(cimReferenceArray[0] is PSReference))
                {
                    return(null);
                }

                CimInstance[] cimInstanceArray = new CimInstance[cimReferenceArray.Length];
                for (int i = 0; i < cimReferenceArray.Length; i++)
                {
                    PSReference tempCimReference = cimReferenceArray[i] as PSReference;
                    if (tempCimReference == null)
                    {
                        return(null);
                    }

                    object baseObject = GetBaseObject(tempCimReference.Value);
                    cimInstanceArray[i] = baseObject as CimInstance;
                    if (cimInstanceArray[i] == null)
                    {
                        return(null);
                    }
                }

                referenceType = CimType.ReferenceArray;
                return(cimInstanceArray);
            }
        }
コード例 #23
0
        public static CimType GetCimType(Type dotNetType)
        {
            CimType cimType = CimType.Unknown;

            if (dotNetType != null)
            {
                Type[] interfaces = dotNetType.GetInterfaces();
                Type   type       = interfaces.SingleOrDefault <Type>((Type i) => {
                    if (!i.IsGenericType)
                    {
                        cimType = CimType.Unknown;
                        return(false);
                    }
                    else
                    {
                        return(i.GetGenericTypeDefinition().Equals(typeof(IList <>)));
                    }
                }
                                                                      );
                if (type == null)
                {
                    if (!CimConverter._dotNetTypeToScalarCimType.TryGetValue(dotNetType, out cimType))
                    {
                        return(CimType.Unknown);
                    }
                    else
                    {
                        return(cimType);
                    }
                }
                else
                {
                    Type genericArguments = type.GetGenericArguments()[0];
                    if (!CimConverter._dotNetTypeToArrayCimType.TryGetValue(genericArguments, out cimType))
                    {
                        return(CimType.Unknown);
                    }
                    else
                    {
                        return(cimType);
                    }
                }
            }
            else
            {
                throw new ArgumentNullException("dotNetType");
            }
        }
コード例 #24
0
        internal static MI_Value ConvertToNativeLayer(object value, CimType cimType)
        {
            var cimInstance = value as CimInstance;

            if (cimInstance != null)
            {
                MI_Value retval = new MI_Value();
                retval.Instance = cimInstance.InstanceHandle;
                return(retval);
            }

            var arrayOfCimInstances = value as CimInstance[];

            if (arrayOfCimInstances != null)
            {
                MI_Instance[] arrayOfInstanceHandles = new MI_Instance[arrayOfCimInstances.Length];
                for (int i = 0; i < arrayOfCimInstances.Length; i++)
                {
                    CimInstance inst = arrayOfCimInstances[i];
                    if (inst == null)
                    {
                        arrayOfInstanceHandles[i] = null;
                    }
                    else
                    {
                        arrayOfInstanceHandles[i] = inst.InstanceHandle;
                    }
                }

                MI_Value retval = new MI_Value();
                retval.InstanceA = arrayOfInstanceHandles;
                return(retval);
            }

            // TODO: What to do with Unknown types? Ignore? Uncomment and remove return line immediately below.
            return(CimProperty.ConvertToNativeLayer(value, cimType));

            /*
             * if (cimType != CimType.Unknown)
             * {
             * return CimProperty.ConvertToNativeLayer(value, cimType);
             * }
             * else
             * {
             * return value;
             * }
             */
        }
コード例 #25
0
 protected virtual void RegisterSystemProperty(string name, CimType type, int flavor)
 {
     if (_propInfos.ContainsKey(name))
     {
         _systemPropInfos[name] = new UnixWbemPropertyInfo {
             Name = name, Type = type, Flavor = flavor
         }
     }
     ;
     else
     {
         _systemPropInfos.Add(name, new UnixWbemPropertyInfo {
             Name = name, Type = type, Flavor = flavor
         });
     }
 }
コード例 #26
0
        private static Type TypeFromCimType(CimType cimType)
        {
            switch (cimType)
            {
            case CimType.Boolean:
                return(typeof(bool));

            case CimType.Object:
                return(typeof(object));

            case CimType.String:
                return(typeof(string));

            case CimType.DateTime:
                return(typeof(DateTime));

            case CimType.Real32:
                return(typeof(float));

            case CimType.Real64:
                return(typeof(double));

            case CimType.SInt16:
                return(typeof(short));

            case CimType.SInt32:
                return(typeof(int));

            case CimType.SInt64:
                return(typeof(long));

            case CimType.UInt16:
                return(typeof(ushort));

            case CimType.UInt8:
                return(typeof(byte));

            case CimType.UInt32:
                return(typeof(uint));

            case CimType.UInt64:
                return(typeof(ulong));

            default:
                return(typeof(object));
            }
        }
コード例 #27
0
        internal static string CimTypeToTypeNameDisplayString(CimType cimType)
        {
            switch (cimType)
            {
            case CimType.DateTime:
            case CimType.Instance:
            case CimType.Reference:
            case CimType.DateTimeArray:
            case CimType.InstanceArray:
            case CimType.ReferenceArray:
                return("CimInstance#" + cimType.ToString());

            default:
                return(ToStringCodeMethods.Type(
                           CimConverter.GetDotNetType(cimType)));
            }
        }
コード例 #28
0
ファイル: ClassBuilder.cs プロジェクト: simonferquel/simcim
        private static TypeSyntax ResolveType(CimType cimType, string referenceClassName, bool isNotNull, IDictionary <string, CimTypeDeclaration> typeRepo, out bool isCimObject, out bool isNullableValueType, out bool isEnumerable, out TypeSyntax enumeratedType)
        {
            isEnumerable        = false;
            isCimObject         = false;
            isNullableValueType = false;
            enumeratedType      = null;
            switch (cimType)
            {
            case Microsoft.Management.Infrastructure.CimType.Instance:
            case Microsoft.Management.Infrastructure.CimType.Reference:
                if (referenceClassName != null)
                {
                    return(SyntaxFactory.ParseTypeName(typeRepo.CSharpNameOrCimInstance(referenceClassName, out isCimObject)));
                }
                return(SyntaxFactory.ParseTypeName("CimInstance"));

            case Microsoft.Management.Infrastructure.CimType.InstanceArray:
            case Microsoft.Management.Infrastructure.CimType.ReferenceArray:
                isEnumerable = true;
                if (referenceClassName != null)
                {
                    enumeratedType = SyntaxFactory.ParseTypeName(typeRepo.CSharpNameOrCimInstance(referenceClassName, out isCimObject));
                    return(SyntaxHelper.EnumerableOf(enumeratedType));
                }
                enumeratedType = SyntaxFactory.ParseTypeName("CimInstance");
                return(SyntaxHelper.EnumerableOf(enumeratedType));

            default:
                var type = CimConverter.GetDotNetType(cimType);
                if (cimType == CimType.DateTime)
                {
                    type = typeof(DateTime);
                }
                if (cimType == CimType.DateTimeArray)
                {
                    type = typeof(DateTime[]);
                }
                if (type.IsValueType && !isNotNull)
                {
                    isNullableValueType = true;
                    return(SyntaxFactory.ParseTypeName(type.FullName + "?"));
                }
                return(SyntaxFactory.ParseTypeName(type.FullName));
            }
        }
コード例 #29
0
        internal static void SetCustomOption(
            CimOperationOptions operationOptions,
            string optionName,
            object optionValue,
            CimSensitiveValueConverter cimSensitiveValueConverter)
        {
            Dbg.Assert(!string.IsNullOrWhiteSpace(optionName), "Caller should verify optionName != null");

            if (optionValue is null)
            {
                return;
            }

            object  cimValue = cimSensitiveValueConverter.ConvertFromDotNetToCim(optionValue);
            CimType cimType  = CimConverter.GetCimType(CimSensitiveValueConverter.GetCimType(optionValue.GetType()));

            operationOptions.SetCustomOption(optionName, cimValue, cimType, mustComply: false);
        }
コード例 #30
0
        public static bool CanConvertTo(string value, CimType type)
        {
            var canConvert = type switch
            {
                CimType.String => true,
                CimType.StringArray => CanConvertToArray <string>(value),

                CimType.Boolean => bool.TryParse(value, out _),
                CimType.BooleanArray => CanConvertToArray <bool>(value),

                CimType.Char16 => char.TryParse(value, out _),
                CimType.Char16Array => CanConvertToArray <char>(value),

                CimType.DateTime => DateTime.TryParse(value, out _),
                CimType.DateTimeArray => CanConvertToArray <DateTime>(value),

                CimType.Real32 => float.TryParse(value, out _),
                CimType.Real32Array => CanConvertToArray <float>(value),
                CimType.Real64 => double.TryParse(value, out _),
                CimType.Real64Array => CanConvertToArray <double>(value),

                CimType.SInt64 => long.TryParse(value, out _),
                CimType.SInt64Array => CanConvertToArray <long>(value),
                CimType.SInt32 => int.TryParse(value, out _),
                CimType.SInt32Array => CanConvertToArray <int>(value),
                CimType.SInt16 => short.TryParse(value, out _),
                CimType.SInt16Array => CanConvertToArray <short>(value),
                CimType.SInt8 => sbyte.TryParse(value, out _),
                CimType.SInt8Array => CanConvertToArray <sbyte>(value),

                CimType.UInt64 => ulong.TryParse(value, out _),
                CimType.UInt64Array => CanConvertToArray <ulong>(value),
                CimType.UInt32 => uint.TryParse(value, out _),
                CimType.UInt32Array => CanConvertToArray <uint>(value),
                CimType.UInt16 => ushort.TryParse(value, out _),
                CimType.UInt16Array => CanConvertToArray <ushort>(value),
                CimType.UInt8 => byte.TryParse(value, out _),
                CimType.UInt8Array => CanConvertToArray <byte>(value),

                _ => false,
            };

            return(canConvert);
        }
コード例 #31
0
ファイル: WmiConvert.cs プロジェクト: kzu/dotnetopensrc
        /// <summary>
        /// Provides conversion.
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static Type WmiToClr(CimType type)
        {
            return(typeof(string));

            //TODO: complete conversion.
            switch (type)
            {
            case CimType.Boolean:
                return(typeof(bool));

            case CimType.Char16:
                return(typeof(string));

            case CimType.DateTime:
                return(typeof(DateTime));

            case CimType.Real32:
                return(typeof(float));

            case CimType.Real64:
            case CimType.UInt64:
                return(typeof(decimal));

            case CimType.Reference:
            case CimType.Object:
            case CimType.String:
                return(typeof(string));

            case CimType.SInt8:
                return(typeof(short));

            case CimType.SInt16:
            case CimType.SInt32:
            case CimType.UInt8:
            case CimType.UInt16:
                return(typeof(int));

            case CimType.SInt64:
                return(typeof(long));

            default:
                return(typeof(string));
            }
        }
コード例 #32
0
        /// <summary>
        /// Sets a custom server or CIM provider option
        /// </summary>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="optionName"/> is <c>null</c></exception>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="optionName"/> or <paramref name="optionValue"/> is <c>null</c></exception>
        public void SetCustomOption(string optionName, object optionValue, CimType cimType, bool mustComply)
        {
            if (string.IsNullOrWhiteSpace(optionName))
            {
                throw new ArgumentNullException("optionName");
            }
            if (optionValue == null)
            {
                throw new ArgumentNullException("optionValue");
            }
            this.AssertNotDisposed();

            MI_Value nativeLayerValue;

            try
            {
                nativeLayerValue = ValueHelpers.ConvertToNativeLayer(optionValue, cimType);
                ValueHelpers.ThrowIfMismatchedType(cimType.FromCimType(), nativeLayerValue);
            }
            catch (InvalidCastException e)
            {
                throw new ArgumentException(e.Message, "optionValue", e);
            }
            catch (FormatException e)
            {
                throw new ArgumentException(e.Message, "optionValue", e);
            }
            catch (ArgumentException e)
            {
                throw new ArgumentException(e.Message, "optionValue", e);
            }

            MI_OperationOptionsFlags flags = MI_OperationOptionsFlags.Unused;
            MI_Result result = this.OperationOptionsHandleOnDemand.SetCustomOption(
                optionName,
                cimType.FromCimType(),
                nativeLayerValue,
                mustComply,
                flags);

            CimException.ThrowIfMiResultFailure(result);
        }
コード例 #33
0
        public static CimType GetCimType(Type dotNetType)
        {
            CimType cimType = CimType.None;

            if (dotNetType != null)
            {
                if (!CimTypeConverter._dotNetTypeToScalarCimType.TryGetValue(dotNetType, out cimType))
                {
                    return(CimType.None);
                }
                else
                {
                    return(cimType);
                }
            }
            else
            {
                throw new ArgumentNullException("dotNetType");
            }
        }
コード例 #34
0
        internal static object ConvertToNativeLayer(object value, CimType cimType)
        {
            CimInstance cimInstance = value as CimInstance;

            if (cimInstance == null)
            {
                CimInstance[] cimInstanceArray = value as CimInstance[];
                if (cimInstanceArray == null)
                {
                    if (cimType != CimType.Unknown)
                    {
                        return(CimProperty.ConvertToNativeLayer(value, cimType));
                    }
                    else
                    {
                        return(value);
                    }
                }
                else
                {
                    InstanceHandle[] instanceHandle = new InstanceHandle[(int)cimInstanceArray.Length];
                    for (int i = 0; i < (int)cimInstanceArray.Length; i++)
                    {
                        CimInstance cimInstance1 = cimInstanceArray[i];
                        if (cimInstance1 != null)
                        {
                            instanceHandle[i] = cimInstance1.InstanceHandle;
                        }
                        else
                        {
                            instanceHandle[i] = null;
                        }
                    }
                    return(instanceHandle);
                }
            }
            else
            {
                return(cimInstance.InstanceHandle);
            }
        }
コード例 #35
0
		public void Add (string propertyName, CimType propertyType, bool isArray)
		{
			throw new NotImplementedException ();
		}
コード例 #36
0
ファイル: PropertyData.cs プロジェクト: nickchal/pash
		internal static object MapWmiValueToValue(object wmiValue, CimType type, bool isArray)
		{
			object managementBaseObject = null;
			if (DBNull.Value != wmiValue && wmiValue != null)
			{
				if (!isArray)
				{
					CimType cimType = type;
					switch (cimType)
					{
						case CimType.Object:
						{
							managementBaseObject = new ManagementBaseObject(new IWbemClassObjectFreeThreaded(Marshal.GetIUnknownForObject(wmiValue)));
							break;
						}
						case CimType.SInt16 | CimType.Real32 | CimType.String:
						case CimType.SInt16 | CimType.SInt32 | CimType.Real32 | CimType.Real64 | CimType.Boolean | CimType.String | CimType.Object:
						case CimType.UInt8:
						{
							managementBaseObject = wmiValue;
							break;
						}
						case CimType.SInt8:
						{
							managementBaseObject = (sbyte)((short)wmiValue);
							break;
						}
						case CimType.UInt16:
						{
							managementBaseObject = (ushort)(wmiValue);
							break;
						}
						case CimType.UInt32:
						{
							managementBaseObject = (uint)(wmiValue);
							break;
						}
						case CimType.SInt64:
						{
							managementBaseObject = wmiValue is long ? (long)wmiValue : Convert.ToInt64((string)wmiValue, (IFormatProvider)CultureInfo.CurrentCulture.GetFormat(typeof(long)));
							break;
						}
						case CimType.UInt64:
						{
							managementBaseObject = wmiValue is ulong ? (ulong)wmiValue : Convert.ToUInt64((string)wmiValue, (IFormatProvider)CultureInfo.CurrentCulture.GetFormat(typeof(ulong)));
							break;
						}
						default:
						{
							if (cimType == CimType.Char16)
							{
								managementBaseObject = (char)((ushort)((short)wmiValue));
								break;
							}
							else
							{
								managementBaseObject = wmiValue;
								break;
							}
						}
					}
				}
				else
				{
					Array arrays = (Array)wmiValue;
					int length = arrays.Length;
					CimType cimType1 = type;
					switch (cimType1)
					{
						case CimType.Object:
						{
							managementBaseObject = new ManagementBaseObject[length];
							for (int i = 0; i < length; i++)
							{
								((ManagementBaseObject[])managementBaseObject)[i] = new ManagementBaseObject(new IWbemClassObjectFreeThreaded(Marshal.GetIUnknownForObject(arrays.GetValue(i))));
							}
							break;
						}
						case CimType.SInt16 | CimType.Real32 | CimType.String:
						case CimType.SInt16 | CimType.SInt32 | CimType.Real32 | CimType.Real64 | CimType.Boolean | CimType.String | CimType.Object:
						case CimType.UInt8:
						{
							managementBaseObject = wmiValue;
							break;
						}
						case CimType.SInt8:
						{
							managementBaseObject = new sbyte[length];
							for (int j = 0; j < length; j++)
							{
								((sbyte[])managementBaseObject)[j] = (sbyte)((short)arrays.GetValue(j));
							}
							break;
						}
						case CimType.UInt16:
						{
							managementBaseObject = new ushort[length];
							for (int k = 0; k < length; k++)
							{
								((ushort[])managementBaseObject)[k] = (ushort)((int)arrays.GetValue(k));
							}
							break;
						}
						case CimType.UInt32:
						{
							managementBaseObject = new uint[length];
							for (int l = 0; l < length; l++)
							{
								((uint[])managementBaseObject)[l] = (uint)arrays.GetValue(l);
							}
							break;
						}
						case CimType.SInt64:
						{
							managementBaseObject = new long[length];
							for (int m = 0; m < length; m++)
							{
								((long[])managementBaseObject)[m] = Convert.ToInt64((string)arrays.GetValue(m), (IFormatProvider)CultureInfo.CurrentCulture.GetFormat(typeof(long)));
							}
							break;
						}
						case CimType.UInt64:
						{
							managementBaseObject = new ulong[length];
							for (int n = 0; n < length; n++)
							{
								((ulong[])managementBaseObject)[n] = Convert.ToUInt64((string)arrays.GetValue(n), (IFormatProvider)CultureInfo.CurrentCulture.GetFormat(typeof(ulong)));
							}
							break;
						}
						default:
						{
							if (cimType1 == CimType.Char16)
							{
								managementBaseObject = new char[length];
								for (int o = 0; o < length; o++)
								{
									((char[])managementBaseObject)[o] = (char)((ushort)((short)arrays.GetValue(o)));
								}
								break;
							}
							else
							{
								managementBaseObject = wmiValue;
								break;
							}
						}
					}
				}
			}
			return managementBaseObject;
		}
コード例 #37
0
 internal CimMethodStreamedResult(string parameterName, object parameterValue, CimType parameterType)
 {
     this.ParameterName = parameterName;
     this.ItemValue = parameterValue;
     this.ItemType = parameterType;
 }
コード例 #38
0
ファイル: PropertyData.cs プロジェクト: nickchal/pash
		internal static object MapValueToWmiValue(object val, CimType type, bool isArray)
		{
			object value = DBNull.Value;
			CultureInfo invariantCulture = CultureInfo.InvariantCulture;
			if (val != null)
			{
				if (!isArray)
				{
					CimType cimType = type;
					switch (cimType)
					{
						case CimType.SInt16:
						{
							value = Convert.ToInt16(val, (IFormatProvider)invariantCulture.GetFormat(typeof(short)));
							break;
						}
						case CimType.SInt32:
						{
							value = Convert.ToInt32(val, (IFormatProvider)invariantCulture.GetFormat(typeof(int)));
							break;
						}
						case CimType.Real32:
						{
							value = Convert.ToSingle(val, (IFormatProvider)invariantCulture.GetFormat(typeof(float)));
							break;
						}
						case CimType.Real64:
						{
							value = Convert.ToDouble(val, (IFormatProvider)invariantCulture.GetFormat(typeof(double)));
							break;
						}
						case CimType.SInt16 | CimType.Real32:
						case CimType.SInt16 | CimType.SInt32 | CimType.Real32 | CimType.Real64:
						/*case 9: */
						case CimType.SInt16 | CimType.String:
						case CimType.Real32 | CimType.String:
						case CimType.SInt16 | CimType.Real32 | CimType.String:
						case CimType.SInt16 | CimType.SInt32 | CimType.Real32 | CimType.Real64 | CimType.Boolean | CimType.String | CimType.Object:
						{
							value = val;
							break;
						}
						case CimType.String:
						{
							value = val.ToString();
							break;
						}
						case CimType.Boolean:
						{
							value = Convert.ToBoolean(val, (IFormatProvider)invariantCulture.GetFormat(typeof(bool)));
							break;
						}
						case CimType.Object:
						{
							if (val as ManagementBaseObject == null)
							{
								value = val;
								break;
							}
							else
							{
								value = Marshal.GetObjectForIUnknown(((ManagementBaseObject)val).wbemObject);
								break;
							}
						}
						case CimType.SInt8:
						{
							value = (short)Convert.ToSByte(val, (IFormatProvider)invariantCulture.GetFormat(typeof(short)));
							break;
						}
						case CimType.UInt8:
						{
							value = Convert.ToByte(val, (IFormatProvider)invariantCulture.GetFormat(typeof(byte)));
							break;
						}
						case CimType.UInt16:
						{
							value = (int)Convert.ToUInt16(val, (IFormatProvider)invariantCulture.GetFormat(typeof(ushort)));
							break;
						}
						case CimType.UInt32:
						{
							value = (int)Convert.ToUInt32(val, (IFormatProvider)invariantCulture.GetFormat(typeof(uint)));
							break;
						}
						case CimType.SInt64:
						{
							long num = Convert.ToInt64(val, (IFormatProvider)invariantCulture.GetFormat(typeof(long)));
							value = num.ToString((IFormatProvider)invariantCulture.GetFormat(typeof(long)));
							break;
						}
						case CimType.UInt64:
						{
							ulong num1 = Convert.ToUInt64(val, (IFormatProvider)invariantCulture.GetFormat(typeof(ulong)));
							value = num1.ToString((IFormatProvider)invariantCulture.GetFormat(typeof(ulong)));
							break;
						}
						default:
						{
							if (cimType == CimType.DateTime || cimType == CimType.Reference)
							{
								value = val.ToString();
								break;
							}
							else if (cimType == CimType.Char16)
							{
								value = (short)Convert.ToChar(val, (IFormatProvider)invariantCulture.GetFormat(typeof(char)));
								break;
							}
							value = val;
							break;
						}
					}
				}
				else
				{
					Array arrays = (Array)val;
					int length = arrays.Length;
					CimType cimType1 = type;
					switch (cimType1)
					{
						case CimType.SInt16:
						{
							if (val as short[] == null)
							{
								value = new short[length];
								for (int i = 0; i < length; i++)
								{
									((short[])value)[i] = Convert.ToInt16(arrays.GetValue(i), (IFormatProvider)invariantCulture.GetFormat(typeof(short)));
								}
								break;
							}
							else
							{
								value = val;
								break;
							}
						}
						case CimType.SInt32:
						{
							if (val as int[] == null)
							{
								value = new int[length];
								for (int j = 0; j < length; j++)
								{
									((int[])value)[j] = Convert.ToInt32(arrays.GetValue(j), (IFormatProvider)invariantCulture.GetFormat(typeof(int)));
								}
								break;
							}
							else
							{
								value = val;
								break;
							}
						}
						case CimType.Real32:
						{
							if (val as float[] == null)
							{
								value = new float[length];
								for (int k = 0; k < length; k++)
								{
									((float[])value)[k] = Convert.ToSingle(arrays.GetValue(k), (IFormatProvider)invariantCulture.GetFormat(typeof(float)));
								}
								break;
							}
							else
							{
								value = val;
								break;
							}
						}
						case CimType.Real64:
						{
							if (val as double[] == null)
							{
								value = new double[length];
								for (int l = 0; l < length; l++)
								{
									((double[])value)[l] = Convert.ToDouble(arrays.GetValue(l), (IFormatProvider)invariantCulture.GetFormat(typeof(double)));
								}
								break;
							}
							else
							{
								value = val;
								break;
							}
						}
						case CimType.SInt16 | CimType.Real32:
						case CimType.SInt16 | CimType.SInt32 | CimType.Real32 | CimType.Real64:
						/*case 9: */
						case CimType.SInt16 | CimType.String:
						case CimType.Real32 | CimType.String:
						case CimType.SInt16 | CimType.Real32 | CimType.String:
						case CimType.SInt16 | CimType.SInt32 | CimType.Real32 | CimType.Real64 | CimType.Boolean | CimType.String | CimType.Object:
						{
							value = val;
							break;
						}
						case CimType.String:
						{
							if (val as string[] == null)
							{
								value = new string[length];
								for (int m = 0; m < length; m++)
								{
									((string[])value)[m] = arrays.GetValue(m).ToString();
								}
								break;
							}
							else
							{
								value = val;
								break;
							}
						}
						case CimType.Boolean:
						{
							if (val as bool[] == null)
							{
								value = new bool[length];
								for (int n = 0; n < length; n++)
								{
									((bool[])value)[n] = Convert.ToBoolean(arrays.GetValue(n), (IFormatProvider)invariantCulture.GetFormat(typeof(bool)));
								}
								break;
							}
							else
							{
								value = val;
								break;
							}
						}
						case CimType.Object:
						{
							value = new IWbemClassObject_DoNotMarshal[length];
							for (int o = 0; o < length; o++)
							{
								((IWbemClassObject_DoNotMarshal[])value)[o] = (IWbemClassObject_DoNotMarshal)Marshal.GetObjectForIUnknown(((ManagementBaseObject)arrays.GetValue(o)).wbemObject);
							}
							break;
						}
						case CimType.SInt8:
						{
							value = new short[length];
							for (int p = 0; p < length; p++)
							{
								((short[])value)[p] = Convert.ToSByte(arrays.GetValue(p), (IFormatProvider)invariantCulture.GetFormat(typeof(sbyte)));
							}
							break;
						}
						case CimType.UInt8:
						{
							if (val as byte[] == null)
							{
								value = new byte[length];
								for (int q = 0; q < length; q++)
								{
									((byte[])value)[q] = Convert.ToByte(arrays.GetValue(q), (IFormatProvider)invariantCulture.GetFormat(typeof(byte)));
								}
								break;
							}
							else
							{
								value = val;
								break;
							}
						}
						case CimType.UInt16:
						{
							value = new int[length];
							for (int r = 0; r < length; r++)
							{
								((int[])value)[r] = Convert.ToUInt16(arrays.GetValue(r), (IFormatProvider)invariantCulture.GetFormat(typeof(ushort)));
							}
							break;
						}
						case CimType.UInt32:
						{
							value = new int[length];
							for (int s = 0; s < length; s++)
							{
								((uint[])value)[s] = Convert.ToUInt32(arrays.GetValue(s), (IFormatProvider)invariantCulture.GetFormat(typeof(uint)));
							}
							break;
						}
						case CimType.SInt64:
						{
							value = new string[length];
							for (int t = 0; t < length; t++)
							{
								long num2 = Convert.ToInt64(arrays.GetValue(t), (IFormatProvider)invariantCulture.GetFormat(typeof(long)));
								((string[])value)[t] = num2.ToString((IFormatProvider)invariantCulture.GetFormat(typeof(long)));
							}
							break;
						}
						case CimType.UInt64:
						{
							value = new string[length];
							for (int u = 0; u < length; u++)
							{
								ulong num3 = Convert.ToUInt64(arrays.GetValue(u), (IFormatProvider)invariantCulture.GetFormat(typeof(ulong)));
								((string[])value)[u] = num3.ToString((IFormatProvider)invariantCulture.GetFormat(typeof(ulong)));
							}
							break;
						}
						default:
						{
							if (cimType1 == CimType.DateTime || cimType1 == CimType.Reference)
							{
								if (val as string[] == null)
								{
									value = new string[length];
									for (int m = 0; m < length; m++)
									{
										((string[])value)[m] = arrays.GetValue(m).ToString();
									}
									break;
								}
								else
								{
									value = val;
									break;
								}
							}
							else if (cimType1 == CimType.Char16)
							{
								value = new short[length];
								for (int v = 0; v < length; v++)
								{
									((short[])value)[v] = (short)Convert.ToChar(arrays.GetValue(v), (IFormatProvider)invariantCulture.GetFormat(typeof(char)));
								}
								break;
							}
							value = val;
							break;
						}
					}
				}
			}
			return value;
		}
コード例 #39
0
ファイル: PropertyData.cs プロジェクト: nickchal/pash
		internal static object MapValueToWmiValue(object val, out bool isArray, out CimType type)
		{
			object value = DBNull.Value;
			CultureInfo invariantCulture = CultureInfo.InvariantCulture;
			isArray = false;
			type = CimType.None;
			if (val != null)
			{
				isArray = val.GetType().IsArray;
				Type type1 = val.GetType();
				if (!isArray)
				{
					if (type1 != typeof(ushort))
					{
						if (type1 != typeof(uint))
						{
							if (type1 != typeof(ulong))
							{
								if (type1 != typeof(sbyte))
								{
									if (type1 != typeof(byte))
									{
										if (type1 != typeof(short))
										{
											if (type1 != typeof(int))
											{
												if (type1 != typeof(long))
												{
													if (type1 != typeof(bool))
													{
														if (type1 != typeof(float))
														{
															if (type1 != typeof(double))
															{
																if (type1 != typeof(char))
																{
																	if (type1 != typeof(string))
																	{
																		if (val as ManagementBaseObject != null)
																		{
																			type = CimType.Object;
																			value = Marshal.GetObjectForIUnknown(((ManagementBaseObject)val).wbemObject);
																		}
																	}
																	else
																	{
																		type = CimType.String;
																		value = val;
																	}
																}
																else
																{
																	type = CimType.Char16;
																	value = ((IConvertible)(char)val).ToInt16(null);
																}
															}
															else
															{
																type = CimType.Real64;
																value = val;
															}
														}
														else
														{
															type = CimType.Real32;
															value = val;
														}
													}
													else
													{
														type = CimType.Boolean;
														value = val;
													}
												}
												else
												{
													type = CimType.SInt64;
													value = val.ToString();
												}
											}
											else
											{
												type = CimType.SInt32;
												value = val;
											}
										}
										else
										{
											type = CimType.SInt16;
											value = val;
										}
									}
									else
									{
										type = CimType.UInt8;
										value = val;
									}
								}
								else
								{
									type = CimType.SInt8;
									value = ((IConvertible)(sbyte)val).ToInt16(null);
								}
							}
							else
							{
								type = CimType.UInt64;
								ulong num = (ulong)val;
								value = num.ToString((IFormatProvider)invariantCulture.GetFormat(typeof(ulong)));
							}
						}
						else
						{
							type = CimType.UInt32;
							if (((uint)val & -2147483648) == 0)
							{
								value = Convert.ToInt32(val, (IFormatProvider)invariantCulture.GetFormat(typeof(int)));
							}
							else
							{
								value = Convert.ToString(val, (IFormatProvider)invariantCulture.GetFormat(typeof(uint)));
							}
						}
					}
					else
					{
						type = CimType.UInt16;
						value = ((IConvertible)(ushort)val).ToInt32(null);
					}
				}
				else
				{
					Type elementType = type1.GetElementType();
					if (!elementType.IsPrimitive)
					{
						if (elementType != typeof(string))
						{
							if (val as ManagementBaseObject[] != null)
							{
								Array arrays = (Array)val;
								int length = arrays.Length;
								type = CimType.Object;
								value = new IWbemClassObject_DoNotMarshal[length];
								for (int i = 0; i < length; i++)
								{
									((IWbemClassObject_DoNotMarshal[])value)[i] = (IWbemClassObject_DoNotMarshal)Marshal.GetObjectForIUnknown(((ManagementBaseObject)arrays.GetValue(i)).wbemObject);
								}
							}
						}
						else
						{
							type = CimType.String;
							value = (string[])val;
						}
					}
					else
					{
						if (elementType != typeof(byte))
						{
							if (elementType != typeof(sbyte))
							{
								if (elementType != typeof(bool))
								{
									if (elementType != typeof(ushort))
									{
										if (elementType != typeof(short))
										{
											if (elementType != typeof(int))
											{
												if (elementType != typeof(uint))
												{
													if (elementType != typeof(ulong))
													{
														if (elementType != typeof(long))
														{
															if (elementType != typeof(float))
															{
																if (elementType != typeof(double))
																{
																	if (elementType == typeof(char))
																	{
																		char[] chrArray = (char[])val;
																		int length1 = (int)chrArray.Length;
																		type = CimType.Char16;
																		value = new short[length1];
																		for (int j = 0; j < length1; j++)
																		{
																			((short[])value)[j] = ((IConvertible)chrArray[j]).ToInt16(null);
																		}
																	}
																}
																else
																{
																	type = CimType.Real64;
																	value = (double[])val;
																}
															}
															else
															{
																type = CimType.Real32;
																value = (float[])val;
															}
														}
														else
														{
															long[] numArray = (long[])val;
															int num1 = (int)numArray.Length;
															type = CimType.SInt64;
															value = new string[num1];
															for (int k = 0; k < num1; k++)
															{
																((string[])value)[k] = numArray[k].ToString((IFormatProvider)invariantCulture.GetFormat(typeof(long)));
															}
														}
													}
													else
													{
														ulong[] numArray1 = (ulong[])val;
														int length2 = (int)numArray1.Length;
														type = CimType.UInt64;
														value = new string[length2];
														for (int l = 0; l < length2; l++)
														{
															((string[])value)[l] = numArray1[l].ToString((IFormatProvider)invariantCulture.GetFormat(typeof(ulong)));
														}
													}
												}
												else
												{
													uint[] numArray2 = (uint[])val;
													int num2 = (int)numArray2.Length;
													type = CimType.UInt32;
													value = new string[num2];
													for (int m = 0; m < num2; m++)
													{
														((string[])value)[m] = numArray2[m].ToString((IFormatProvider)invariantCulture.GetFormat(typeof(uint)));
													}
												}
											}
											else
											{
												type = CimType.SInt32;
												value = (int[])val;
											}
										}
										else
										{
											type = CimType.SInt16;
											value = (short[])val;
										}
									}
									else
									{
										ushort[] numArray3 = (ushort[])val;
										int length3 = (int)numArray3.Length;
										type = CimType.UInt16;
										value = new int[length3];
										for (int n = 0; n < length3; n++)
										{
											((int[])value)[n] = ((IConvertible)numArray3[n]).ToInt32(null);
										}
									}
								}
								else
								{
									type = CimType.Boolean;
									value = (bool[])val;
								}
							}
							else
							{
								sbyte[] numArray4 = (sbyte[])val;
								int num3 = (int)numArray4.Length;
								type = CimType.SInt8;
								value = new short[num3];
								for (int o = 0; o < num3; o++)
								{
									((short[])value)[o] = ((IConvertible)numArray4[o]).ToInt16(null);
								}
							}
						}
						else
						{
							byte[] numArray5 = (byte[])val;
							int length4 = (int)numArray5.Length;
							type = CimType.UInt8;
							value = new short[length4];
							for (int p = 0; p < length4; p++)
							{
								((short[])value)[p] = ((IConvertible)numArray5[p]).ToInt16(null);
							}
						}
					}
				}
			}
			return value;
		}
コード例 #40
0
ファイル: CimAsyncOperation.cs プロジェクト: nickchal/pash
		protected object GetReferenceOrReferenceArrayObject(object value, ref CimType referenceType)
		{
			PSReference pSReference = value as PSReference;
			if (pSReference == null)
			{
				object[] objArray = value as object[];
				if (objArray != null)
				{
					if (objArray[0] as PSReference != null)
					{
						CimInstance[] cimInstanceArray = new CimInstance[(int)objArray.Length];
						int num = 0;
						while (num < (int)objArray.Length)
						{
							PSReference pSReference1 = objArray[num] as PSReference;
							if (pSReference1 != null)
							{
								object baseObject = this.GetBaseObject(pSReference1.Value);
								cimInstanceArray[num] = baseObject as CimInstance;
								if (cimInstanceArray[num] != null)
								{
									num++;
								}
								else
								{
									return null;
								}
							}
							else
							{
								return null;
							}
						}
						referenceType = CimType.ReferenceArray;
						return cimInstanceArray;
					}
					else
					{
						return null;
					}
				}
				else
				{
					return null;
				}
			}
			else
			{
				object obj = this.GetBaseObject(pSReference.Value);
				CimInstance cimInstance = obj as CimInstance;
				if (cimInstance != null)
				{
					referenceType = CimType.Reference;
					return cimInstance;
				}
				else
				{
					return null;
				}
			}
		}
        private CodeTypeReference ConvertCIMType(CimType cType, bool isArray)
        {
            string str;
            switch (cType)
            {
                case CimType.SInt16:
                    str = "System.Int16";
                    break;

                case CimType.SInt32:
                    str = "System.Int32";
                    break;

                case CimType.Real32:
                    str = "System.Single";
                    break;

                case CimType.Real64:
                    str = "System.Double";
                    break;

                case CimType.String:
                    str = "System.String";
                    break;

                case CimType.Boolean:
                    str = "System.Boolean";
                    break;

                case CimType.SInt8:
                    str = "System.SByte";
                    break;

                case CimType.UInt8:
                    str = "System.Byte";
                    break;

                case CimType.UInt16:
                    if (this.bUnsignedSupported)
                    {
                        str = "System.UInt16";
                    }
                    else
                    {
                        str = "System.Int16";
                    }
                    break;

                case CimType.UInt32:
                    if (this.bUnsignedSupported)
                    {
                        str = "System.UInt32";
                    }
                    else
                    {
                        str = "System.Int32";
                    }
                    break;

                case CimType.SInt64:
                    str = "System.Int64";
                    break;

                case CimType.UInt64:
                    if (this.bUnsignedSupported)
                    {
                        str = "System.UInt64";
                    }
                    else
                    {
                        str = "System.Int64";
                    }
                    break;

                case CimType.DateTime:
                    str = "System.DateTime";
                    break;

                case CimType.Reference:
                    str = this.PublicNamesUsed["PathClass"].ToString();
                    break;

                case CimType.Char16:
                    str = "System.Char";
                    break;

                default:
                    str = this.PublicNamesUsed["BaseObjClass"].ToString();
                    break;
            }
            if (isArray)
            {
                return new CodeTypeReference(str, 1);
            }
            return new CodeTypeReference(str);
        }
コード例 #42
0
ファイル: CimXmlWriter.cs プロジェクト: billmoling/wbemtools
 public void WriteTypeAttribute(CimType type)
 {
     _body.Add(new CimXmlOperation(TagType.Type, type.ToString()));
     _verifyXTW.WriteAttributeString("TYPE", type.ToString());
 }
コード例 #43
0
		/// <summary>
		/// <para>Adds a new <see cref='System.Management.PropertyData'/> with no assigned value.</para>
		/// </summary>
		/// <param name='propertyName'>The name of the property.</param>
		/// <param name='propertyType'>The CIM type of the property.</param>
		/// <param name='isArray'><see langword='true'/> to specify that the property is an array type; otherwise, <see langword='false'/>.</param>
		/// <remarks>
		///    <para> Properties can only be added to class definitions, not 
		///       to instances. This method is only valid when invoked on a <see cref='System.Management.PropertyDataCollection'/>
		///       in
		///       a <see cref='System.Management.ManagementClass'/>.</para>
		/// </remarks>
		public void Add(string propertyName, CimType propertyType, bool isArray)
		{
			if (null == propertyName)
				throw new ArgumentNullException(propertyName);

			if (parent.GetType() == typeof(ManagementObject)) //can't add properties to instance
				throw new InvalidOperationException();

			int wmiCimType = (int)propertyType;  
			
			if (isArray)
				wmiCimType = (wmiCimType | (int)tag_CIMTYPE_ENUMERATION.CIM_FLAG_ARRAY);

			object dummyObj = System.DBNull.Value;

			int status = parent.wbemObject.Put_(propertyName, 0, ref dummyObj, wmiCimType);

			if (status < 0)
			{
				if ((status & 0xfffff000) == 0x80041000)
					ManagementException.ThrowWithExtendedInfo((ManagementStatus)status);
				else
					Marshal.ThrowExceptionForHR(status);
			}
		}
コード例 #44
0
 /// <summary>
 /// Retrieve the reference object or reference array object.
 /// The returned object has to be either CimInstance or CImInstance[] type,
 /// if not thrown exception.
 /// </summary>
 /// <param name="value"></param>
 /// <param name="referenceType">output the cimtype of the value, either Reference or ReferenceArray</param>
 /// <returns></returns>
 protected object GetReferenceOrReferenceArrayObject(object value, ref CimType referenceType)
 {
     PSReference cimReference = value as PSReference;
     if (cimReference != null)
     {
         object baseObject = GetBaseObject(cimReference.Value);
         CimInstance cimInstance = baseObject as CimInstance;
         if (cimInstance == null)
         {
             return null;
         }
         referenceType = CimType.Reference;
         return cimInstance;
     }
     else
     {
         object[] cimReferenceArray = value as object[];
         if (cimReferenceArray == null)
         {
             return null;
         }
         else if (!(cimReferenceArray[0] is PSReference))
         {
             return null;
         }
         CimInstance[] cimInstanceArray = new CimInstance[cimReferenceArray.Length];
         for (int i = 0; i < cimReferenceArray.Length; i++)
         {
             PSReference tempCimReference = cimReferenceArray[i] as PSReference;
             if (tempCimReference == null)
             {
                 return null;
             }
             object baseObject = GetBaseObject(tempCimReference.Value);
             cimInstanceArray[i] = baseObject as CimInstance;
             if (cimInstanceArray[i] == null)
             {
                 return null;
             }
         }
         referenceType = CimType.ReferenceArray;
         return cimInstanceArray;
     }
 }
コード例 #45
0
ファイル: CimParameter.cs プロジェクト: billmoling/wbemtools
 /// <summary>
 /// Creates a new CIMParameter with the given name and type
 /// </summary>
 /// <param name="type"></param>
 /// <param name="name"></param>
 public CimParameter(CimType type, CimName name)
 {
     _type = type;
     _name = name;
 }
 private static bool isTypeInt(CimType cType)
 {
     switch (cType)
     {
         case CimType.SInt16:
         case CimType.SInt32:
         case CimType.SInt8:
         case CimType.UInt8:
         case CimType.UInt16:
         case CimType.UInt32:
             return true;
     }
     return false;
 }
 private static bool IsPropertyValueType(CimType cType)
 {
     bool flag = true;
     CimType type = cType;
     return ((((type != CimType.String) && (type != CimType.Object)) && (type != CimType.Reference)) && flag);
 }
        private string GetConversionFunction(CimType cimType)
        {
            string str = string.Empty;
            switch (cimType)
            {
                case CimType.SInt16:
                    return "ToInt16";

                case CimType.SInt32:
                    return "ToInt32";

                case CimType.Real32:
                    return "ToSingle";

                case CimType.Real64:
                    return "ToDouble";

                case (CimType.Real32 | CimType.SInt16):
                case (CimType.Real64 | CimType.SInt16):
                case ((CimType) 9):
                case (CimType.String | CimType.SInt16):
                case (CimType.String | CimType.Real32):
                case CimType.Object:
                case (CimType.String | CimType.Real32 | CimType.SInt16):
                case (CimType.Object | CimType.SInt16):
                    return str;

                case CimType.String:
                    return "ToString";

                case CimType.Boolean:
                    return "ToBoolean";

                case CimType.SInt8:
                    return "ToSByte";

                case CimType.UInt8:
                    return "ToByte";

                case CimType.UInt16:
                    if (this.bUnsignedSupported)
                    {
                        return "ToUInt16";
                    }
                    return "ToInt16";

                case CimType.UInt32:
                    if (this.bUnsignedSupported)
                    {
                        return "ToUInt32";
                    }
                    return "ToInt32";

                case CimType.SInt64:
                    return "ToInt64";

                case CimType.UInt64:
                    if (this.bUnsignedSupported)
                    {
                        return "ToUInt64";
                    }
                    return "ToInt64";

                case CimType.Char16:
                    return "ToChar";
            }
            return str;
        }
コード例 #49
0
		public void Add (string propertyName, object propertyValue, CimType propertyType)
		{
			throw new NotImplementedException ();
		}
コード例 #50
0
		/// <summary>
		/// <para>Adds a new <see cref='System.Management.PropertyData'/> with the specified value and CIM type.</para>
		/// </summary>
		/// <param name='propertyName'>The name of the property.</param>
		/// <param name='propertyValue'>The value of the property (which can be null).</param>
		/// <param name='propertyType'>The CIM type of the property.</param>
		/// <remarks>
		///    <para> Properties can only be added to class definitions, not 
		///       to instances. This method is only valid when invoked on a <see cref='System.Management.PropertyDataCollection'/>
		///       in
		///       a <see cref='System.Management.ManagementClass'/>.</para>
		/// </remarks>
		public void Add(string propertyName, Object propertyValue, CimType propertyType)
		{
			if (null == propertyName)
				throw new ArgumentNullException("propertyName");

			if (parent.GetType() == typeof(ManagementObject)) //can't add properties to instance
				throw new InvalidOperationException();

			int wmiCimType = (int)propertyType;
			bool isArray = false;

			if ((null != propertyValue) && propertyValue.GetType().IsArray)
			{
				isArray = true;
				wmiCimType = (wmiCimType | (int)tag_CIMTYPE_ENUMERATION.CIM_FLAG_ARRAY);
			}

			object wmiValue = PropertyData.MapValueToWmiValue(propertyValue, propertyType, isArray);

			int status = parent.wbemObject.Put_(propertyName, 0, ref wmiValue, wmiCimType);

			if (status < 0)
			{
				if ((status & 0xfffff000) == 0x80041000)
					ManagementException.ThrowWithExtendedInfo((ManagementStatus)status);
				else
					Marshal.ThrowExceptionForHR(status);
			}
		}
コード例 #51
0
 /// <summary>
 /// Creates a new CimPropertyArray with the given name and type
 /// </summary>
 /// <param name="name"></param>
 /// <param name="type"></param>
 public CimPropertyArray(CimName name, CimType type)
     : base(name, type)
 {
 }
コード例 #52
0
        /// <summary>
        /// Converts a numberic value to appropriate type and adds it to array
        /// </summary>
        private static string ConvertToNumericValueAndAddToArray(CimType cimType, string numericValue,ArrayList arrayToAdd,out string enumType)
        {
            string retFunctionName = String.Empty;
            enumType = String.Empty;

            switch(cimType)
            {
                case CimType.UInt8:              
                case CimType.SInt8:
                case CimType.SInt16:
                case CimType.UInt16:
                case CimType.SInt32:            
                    arrayToAdd.Add(System.Convert.ToInt32(numericValue,(IFormatProvider)CultureInfo.InvariantCulture.GetFormat(typeof(System.Int32))));
                    retFunctionName = "ToInt32";
                    enumType = "System.Int32";
                    break;

                case CimType.UInt32:
                    arrayToAdd.Add(System.Convert.ToInt32(numericValue,(IFormatProvider)CultureInfo.InvariantCulture.GetFormat(typeof(System.Int32))));
                    retFunctionName = "ToInt32";
                    enumType = "System.Int32";
                    break;
            }
            return retFunctionName;
        }
コード例 #53
0
        /// <summary>
        /// This function will convert the given CIMTYPE to an acceptable .NET type.
        /// Since CLS doen't support lotz of the basic types, we are using .NET helper 
        /// classes here. We safely assume that there won't be any problem using them
        /// since .NET has to be there for the System.Management.Dll to work.
        /// </summary>
        /// <param name="cType"> </param>
        /// <param name="isArray"> </param>
        private CodeTypeReference ConvertCIMType(CimType cType,bool isArray)
        {
            string strType;
            switch(cType)
            {
                case CimType.SInt8:
                {
                    strType = "System.SByte";
                    break;
                }
                case CimType.UInt8: //TODO : is this fine???
                {
                    strType = "System.Byte";
                    break;
                }
                case CimType.SInt16:
                {
                    strType = "System.Int16";
                    break;
                }
                case CimType.UInt16:
                {
                    if (bUnsignedSupported == false)
                    {
                        strType = "System.Int16";
                    }
                    else
                    {
                        strType = "System.UInt16";
                    }
                    break;
                }
                case CimType.SInt32:
                {
                    strType = "System.Int32";
                    break;
                }
                case CimType.UInt32:
                {
                    if (bUnsignedSupported == false)
                    {
                        strType = "System.Int32";
                    }
                    else
                    {
                        strType = "System.UInt32";
                    }
                    break;
                }
                case CimType.SInt64:
                {
                    strType = "System.Int64";
                    break;
                }
                case CimType.UInt64:
                {
                    if (bUnsignedSupported == false)
                    {
                        strType = "System.Int64";
                    }
                    else
                    {
                        strType = "System.UInt64";
                    }
                    break;
                }
                case CimType.Real32:
                {
                    strType = "System.Single";
                    break;
                }
                case CimType.Real64:
                {
                    strType = "System.Double";
                    break;
                }
                case CimType.Boolean:
                {
                    strType = "System.Boolean";
                    break;
                }
                case CimType.String:
                {
                    strType = "System.String";
                    break;
                }
                case CimType.DateTime:
                {
                    strType = "System.DateTime";
                    break;
                }
                case CimType.Reference:
                {
                    strType = PublicNamesUsed["PathClass"].ToString();
                    break;
                }
                case CimType.Char16:
                {
                    strType = "System.Char";
                    break;
                }
                case CimType.Object:
                default:
                    strType = PublicNamesUsed["BaseObjClass"].ToString();
                    break;
            }

            if (isArray )
            {
                return new CodeTypeReference(strType,1);
            }
            else
            {
                return new CodeTypeReference(strType);
            }
        }
コード例 #54
0
ファイル: Services.cs プロジェクト: RSchwoerer/Terminals
        private Type ConvertCimType(CimType ctValue)
        {
            Type tReturnVal = null;

            switch (ctValue)
            {
                case CimType.Boolean:
                    tReturnVal = typeof (Boolean);
                    break;
                case CimType.Char16:
                    tReturnVal = typeof (String);
                    break;
                case CimType.DateTime:
                    tReturnVal = typeof (DateTime);
                    break;
                case CimType.Object:
                    tReturnVal = typeof (Object);
                    break;
                case CimType.Real32:
                    tReturnVal = typeof (Decimal);
                    break;
                case CimType.Real64:
                    tReturnVal = typeof (Decimal);
                    break;
                case CimType.Reference:
                    tReturnVal = typeof (Object);
                    break;
                case CimType.SInt16:
                    tReturnVal = typeof (Int16);
                    break;
                case CimType.SInt32:
                    tReturnVal = typeof (Int32);
                    break;
                case CimType.SInt8:
                    tReturnVal = typeof (Int16);
                    break;
                case CimType.String:
                    tReturnVal = typeof (String);
                    break;
                case CimType.UInt16:
                    tReturnVal = typeof (UInt16);
                    break;
                case CimType.UInt32:
                    tReturnVal = typeof (UInt32);
                    break;
                case CimType.UInt64:
                    tReturnVal = typeof (UInt64);
                    break;
                case CimType.UInt8:
                    tReturnVal = typeof (UInt16);
                    break;
            }
            return tReturnVal;
        }
コード例 #55
0
ファイル: CimInstance.cs プロジェクト: nickchal/pash
		internal static object ConvertToNativeLayer(object value, CimType cimType)
		{
			CimInstance cimInstance = value as CimInstance;
			if (cimInstance == null)
			{
				CimInstance[] cimInstanceArray = value as CimInstance[];
				if (cimInstanceArray == null)
				{
					if (cimType != CimType.Unknown)
					{
						return CimProperty.ConvertToNativeLayer(value, cimType);
					}
					else
					{
						return value;
					}
				}
				else
				{
					InstanceHandle[] instanceHandle = new InstanceHandle[(int)cimInstanceArray.Length];
					for (int i = 0; i < (int)cimInstanceArray.Length; i++)
					{
						CimInstance cimInstance1 = cimInstanceArray[i];
						if (cimInstance1 != null)
						{
							instanceHandle[i] = cimInstance1.InstanceHandle;
						}
						else
						{
							instanceHandle[i] = null;
						}
					}
					return instanceHandle;
				}
			}
			else
			{
				return cimInstance.InstanceHandle;
			}
		}
コード例 #56
0
        /// <summary>
        /// This function is used to determine whether the given CIMTYPE can be represented as an integer.
        /// This helper function is mainly used to determine whether this type will be support by enums.
        /// </summary>
        /// <param name="cType"> </param>
        private static bool isTypeInt(CimType cType)
        {
            bool retVal;
            switch(cType)
            {
                case CimType.UInt8: //TODO : is this fine???
                case CimType.UInt16:
                case CimType.UInt32:        // FIXX VB code generator cannot have Long enumerators
                case CimType.SInt8:
                case CimType.SInt16:
                case CimType.SInt32:
                {
                    retVal = true;
                    break;
                }
                case CimType.SInt64:
                case CimType.UInt64:
                case CimType.Real32:
                case CimType.Real64:
                case CimType.Boolean:
                case CimType.String:
                case CimType.DateTime:
                case CimType.Reference:
                case CimType.Char16:
                case CimType.Object:
                default:
                    retVal = false;
                    break;
            }

            return retVal;

        }
コード例 #57
0
ファイル: CimConverter.cs プロジェクト: nickchal/pash
		public static Type GetDotNetType(CimType cimType)
		{
			CimType cimType1 = cimType;
			switch (cimType1)
			{
				case CimType.Unknown:
				{
					return null;
				}
				case CimType.Boolean:
				{
					return typeof(bool);
				}
				case CimType.UInt8:
				{
					return typeof(byte);
				}
				case CimType.SInt8:
				{
					return typeof(sbyte);
				}
				case CimType.UInt16:
				{
					return typeof(ushort);
				}
				case CimType.SInt16:
				{
					return typeof(short);
				}
				case CimType.UInt32:
				{
					return typeof(uint);
				}
				case CimType.SInt32:
				{
					return typeof(int);
				}
				case CimType.UInt64:
				{
					return typeof(ulong);
				}
				case CimType.SInt64:
				{
					return typeof(long);
				}
				case CimType.Real32:
				{
					return typeof(float);
				}
				case CimType.Real64:
				{
					return typeof(double);
				}
				case CimType.Char16:
				{
					return typeof(char);
				}
				case CimType.DateTime:
				{
					return null;
				}
				case CimType.String:
				{
					return typeof(string);
				}
				case CimType.Reference:
				{
					return typeof(CimInstance);
				}
				case CimType.Instance:
				{
					return typeof(CimInstance);
				}
				case CimType.BooleanArray:
				{
					return typeof(bool[]);
				}
				case CimType.UInt8Array:
				{
					return typeof(byte[]);
				}
				case CimType.SInt8Array:
				{
					return typeof(sbyte[]);
				}
				case CimType.UInt16Array:
				{
					return typeof(ushort[]);
				}
				case CimType.SInt16Array:
				{
					return typeof(long[]);
				}
				case CimType.UInt32Array:
				{
					return typeof(uint[]);
				}
				case CimType.SInt32Array:
				{
					return typeof(int[]);
				}
				case CimType.UInt64Array:
				{
					return typeof(ulong[]);
				}
				case CimType.SInt64Array:
				{
					return typeof(long[]);
				}
				case CimType.Real32Array:
				{
					return typeof(float[]);
				}
				case CimType.Real64Array:
				{
					return typeof(double[]);
				}
				case CimType.Char16Array:
				{
					return typeof(char[]);
				}
				case CimType.DateTimeArray:
				{
					return null;
				}
				case CimType.StringArray:
				{
					return typeof(string[]);
				}
				case CimType.ReferenceArray:
				{
					return typeof(CimInstance[]);
				}
				case CimType.InstanceArray:
				{
					return typeof(CimInstance[]);
				}
			}
			return null;
		}
コード例 #58
0
        /// <summary>
        /// Function to get the Converstion function to be used for Numeric datatypes
        /// </summary>
        String GetConversionFunction(CimType cimType)
        {
            String retFunctionName = String.Empty;

            switch(cimType)
            {
                case CimType.UInt8:  
                    retFunctionName = "ToByte";
                    break;
            
                case CimType.SInt8:
                    retFunctionName = "ToSByte";
                    break;

                case CimType.SInt16:
                    retFunctionName = "ToInt16";
                    break;

                case CimType.UInt16:
                    if (bUnsignedSupported == false)
                    {
                        retFunctionName = "ToInt16";
                    }
                    else
                    {
                        retFunctionName = "ToUInt16";
                    }
                    break;
            
                case CimType.SInt32:
            
                    retFunctionName = "ToInt32";
                    break;
            
                case CimType.UInt32:
                {
                    if (bUnsignedSupported == false)
                    {
                        retFunctionName = "ToInt32";
                    }
                    else
                    {
                        retFunctionName = "ToUInt32";
                    }
                    break;
                }
                case CimType.SInt64:
                {
                    retFunctionName = "ToInt64";
                    break;
                }
                case CimType.UInt64:
                {
                    if (bUnsignedSupported == false)
                    {
                        retFunctionName = "ToInt64";
                    }
                    else
                    {
                        retFunctionName = "ToUInt64";
                    }
                    break;
                }
                case CimType.Real32:
                {
                    retFunctionName = "ToSingle";
                    break;
                }
                case CimType.Real64:
                {
                    retFunctionName = "ToDouble";
                    break;
                }
                case CimType.Boolean:
                {
                    retFunctionName = "ToBoolean";
                    break;
                }

                case CimType.Char16:
                {
                    retFunctionName = "ToChar";
                    break;
                }
                
                case CimType.String:
                {
                    retFunctionName = "ToString";
                    break;
                }

            }
            return retFunctionName;
        }
コード例 #59
0
        /// <summary>
        /// Checks if the given property type is represented as ValueType
        /// </summary>
        private static bool IsPropertyValueType(CimType cType)
        {
            bool ret = true;
            switch(cType)
            {
                case CimType.String:
                case CimType.Reference:
                case CimType.Object:
                    ret = false;
                    break;

            }
            return ret;
        }
コード例 #60
0
		internal CimPropertyStandalone(string name, object value, CimType cimType, CimFlags flags)
		{
			this._name = name;
			this._cimType = cimType;
			this._flags = flags;
			this.Value = value;
		}