Ejemplo n.º 1
0
        public static MiResult GetElementCount(InstanceHandle handle, out int num)
        {
            NativeCimInstance instance = CimNativeApi.MarshalledObject.FromPointer <NativeCimInstance> (handle.DangerousGetHandle());
            var properties             = NativeCimPropertiesHelper.Deserialize(PropertiesOrSystem(instance));

            num = properties.Count;
            return(MiResult.OK);
        }
Ejemplo n.º 2
0
        public static MiResult ClearElementAt(InstanceHandle handle, int _index)
        {
            NativeCimInstance instance = CimNativeApi.MarshalledObject.FromPointer <NativeCimInstance> (handle.DangerousGetHandle());
            var properties             = NativeCimPropertiesHelper.Deserialize(PropertiesOrSystem(instance));

            properties.ElementAt(_index).Value = null;
            instance.Properties = NativeCimPropertiesHelper.Serialize(properties);
            handle.DangerousSetHandle((IntPtr)CimNativeApi.MarshalledObject.Create <NativeCimInstance>(instance));
            return(MiResult.OK);
        }
Ejemplo n.º 3
0
        public static MiResult GetElementAt_GetValue(InstanceHandle handle, int _index, out object obj)
        {
            NativeCimInstance instance = CimNativeApi.MarshalledObject.FromPointer <NativeCimInstance> (handle.DangerousGetHandle());

            obj = null;
            if (_index != -1)
            {
                var properties = NativeCimPropertiesHelper.Deserialize(PropertiesOrSystem(instance));
                var element    = properties.ElementAtOrDefault(_index);
                obj = element.Value;
            }
            return(MiResult.OK);
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
        internal static MiResult NewInstance(ApplicationHandle applicationHandle, string p1, object p2, out InstanceHandle instanceHandle)
        {
            NativeCimInstance instance = new NativeCimInstance();

            instance.CimClassName     = p1;
            instance.ClassName        = p1;
            instance.Properties       = NativeCimPropertiesHelper.Serialize(new NativeCimProperties());
            instance.SystemProperties = NativeCimPropertiesHelper.Serialize(new NativeCimProperties());
            instance.Namespace        = "root/cimv2";
            instance.ServerName       = "localhost";
            instance.Qualifiers       = NativeCimQualifiersHelper.Serialize(new NativeCimQualifiers());
            IntPtr instancePtr = CimNativeApi.MarshalledObject.Create <NativeCimInstance>(instance);

            instanceHandle = new InstanceHandle(instancePtr, false);
            return(MiResult.OK);
        }
Ejemplo n.º 6
0
        public static MiResult GetElementAt_GetName(InstanceHandle handle, int _index, out string str)
        {
            NativeCimInstance instance = CimNativeApi.MarshalledObject.FromPointer <NativeCimInstance> (handle.DangerousGetHandle());
            var properties             = NativeCimPropertiesHelper.Deserialize(PropertiesOrSystem(instance));
            int i = 0;

            str = null;
            foreach (var element in properties)
            {
                if (i == _index)
                {
                    str = element.Name;
                    break;
                }
                i++;
            }
            return(MiResult.OK);
        }
Ejemplo n.º 7
0
        public static MiResult GetElementAt_GetType(InstanceHandle handle, int _index, out MiType miType)
        {
            NativeCimInstance instance = CimNativeApi.MarshalledObject.FromPointer <NativeCimInstance> (handle.DangerousGetHandle());
            var properties             = NativeCimPropertiesHelper.Deserialize(PropertiesOrSystem(instance));
            int i = 0;

            miType = MiType.Boolean;
            foreach (var element in properties)
            {
                if (i == _index)
                {
                    Type type = element.Value.GetType();
                    miType = CimConverter.GetCimType(type).ToMiType();
                    break;
                }
                i++;
            }
            return(MiResult.OK);
        }
Ejemplo n.º 8
0
        public static MiResult GetElement_GetIndex(InstanceHandle handle, string propertyName, out int num)
        {
            NativeCimInstance instance = CimNativeApi.MarshalledObject.FromPointer <NativeCimInstance> (handle.DangerousGetHandle());
            var properties             = NativeCimPropertiesHelper.Deserialize(PropertiesOrSystem(instance));

            num = -1;
            int i = 0;

            foreach (var element in properties)
            {
                if (element.Name == propertyName)
                {
                    num = i;
                    break;
                }
                i++;
            }
            return(MiResult.OK);
        }