Пример #1
0
		internal SharedInstanceHandle(InstanceHandle handle, SharedInstanceHandle parent) : this(handle)
		{
			this._parent = parent;
			if (this._parent != null)
			{
				this._parent.AddRef();
			}
		}
Пример #2
0
 internal SharedInstanceHandle(InstanceHandle handle, SharedInstanceHandle parent) : this(handle)
 {
     this._parent = parent;
     if (this._parent != null)
     {
         this._parent.AddRef();
     }
 }
Пример #3
0
 internal void AddRef()
 {
     lock (this._numberOfReferencesLock)
     {
         if (this._numberOfReferences != 0)
         {
             SharedInstanceHandle sharedInstanceHandle = this;
             sharedInstanceHandle._numberOfReferences = sharedInstanceHandle._numberOfReferences + 1;
         }
         else
         {
             throw new ObjectDisposedException(this.ToString());
         }
     }
 }
Пример #4
0
 internal void Release()
 {
     lock (this._numberOfReferencesLock)
     {
         SharedInstanceHandle sharedInstanceHandle = this;
         sharedInstanceHandle._numberOfReferences = sharedInstanceHandle._numberOfReferences - 1;
         if (this._numberOfReferences == 0)
         {
             this._handle.Dispose();
             if (this._parent != null)
             {
                 this._parent.Release();
             }
         }
     }
 }
Пример #5
0
		internal static object ConvertFromNativeLayer(object value, SharedInstanceHandle sharedParentHandle = null, CimInstance parent = null, bool clone = false)
		{
			InstanceHandle instanceHandle;
			InstanceHandle instanceHandle1;
			InstanceHandle instanceHandle2 = value as InstanceHandle;
			if (instanceHandle2 == null)
			{
				InstanceHandle[] instanceHandleArray = value as InstanceHandle[];
				if (instanceHandleArray == null)
				{
					return value;
				}
				else
				{
					CimInstance[] cimInstanceArray = new CimInstance[(int)instanceHandleArray.Length];
					for (int i = 0; i < (int)instanceHandleArray.Length; i++)
					{
						InstanceHandle instanceHandle3 = instanceHandleArray[i];
						if (instanceHandle3 != null)
						{
							CimInstance[] cimInstance = cimInstanceArray;
							int num = i;
							if (clone)
							{
								instanceHandle = instanceHandle3.Clone();
							}
							else
							{
								instanceHandle = instanceHandle3;
							}
							cimInstance[num] = new CimInstance(instanceHandle, sharedParentHandle);
							if (parent != null)
							{
								cimInstanceArray[i].SetCimSessionComputerName(parent.GetCimSessionComputerName());
								cimInstanceArray[i].SetCimSessionInstanceId(parent.GetCimSessionInstanceId());
							}
						}
						else
						{
							cimInstanceArray[i] = null;
						}
					}
					return cimInstanceArray;
				}
			}
			else
			{
				if (clone)
				{
					instanceHandle1 = instanceHandle2.Clone();
				}
				else
				{
					instanceHandle1 = instanceHandle2;
				}
				CimInstance cimInstance1 = new CimInstance(instanceHandle1, sharedParentHandle);
				if (parent != null)
				{
					cimInstance1.SetCimSessionComputerName(parent.GetCimSessionComputerName());
					cimInstance1.SetCimSessionInstanceId(parent.GetCimSessionInstanceId());
				}
				return cimInstance1;
			}
		}
Пример #6
0
		private CimInstance(SerializationInfo info, StreamingContext context)
		{
			this._CimSessionInstanceID = Guid.Empty;
			if (info != null)
			{
				string str = info.GetString("MI_XML");
				byte[] bytes = Encoding.Unicode.GetBytes(str);
				CimDeserializer cimDeserializer = CimDeserializer.Create();
				using (cimDeserializer)
				{
					int num = 0;
					InstanceHandle instanceHandle = cimDeserializer.DeserializeInstanceHandle(bytes, ref num, null);
					this._myHandle = new SharedInstanceHandle(instanceHandle);
				}
				this.SetCimSessionComputerName(info.GetString("CSCN"));
				return;
			}
			else
			{
				throw new ArgumentNullException("info");
			}
		}
Пример #7
0
		public CimInstance(CimClass cimClass)
		{
			InstanceHandle instanceHandle = null;
			this._CimSessionInstanceID = Guid.Empty;
			if (cimClass != null)
			{
				MiResult miResult = ApplicationMethods.NewInstance(CimApplication.Handle, cimClass.CimSystemProperties.ClassName, cimClass.ClassHandle, out instanceHandle);
				if (miResult != MiResult.INVALID_PARAMETER)
				{
					CimException.ThrowIfMiResultFailure(miResult);
					this._myHandle = new SharedInstanceHandle(instanceHandle);
					miResult = InstanceMethods.SetNamespace(this._myHandle.Handle, cimClass.CimSystemProperties.Namespace);
					CimException.ThrowIfMiResultFailure(miResult);
					miResult = InstanceMethods.SetServerName(this._myHandle.Handle, cimClass.CimSystemProperties.ServerName);
					CimException.ThrowIfMiResultFailure(miResult);
					return;
				}
				else
				{
					throw new ArgumentOutOfRangeException("cimClass");
				}
			}
			else
			{
				throw new ArgumentNullException("cimClass");
			}
		}
Пример #8
0
		public CimInstance(string className, string namespaceName)
		{
			InstanceHandle instanceHandle = null;
			this._CimSessionInstanceID = Guid.Empty;
			if (className != null)
			{
				MiResult miResult = ApplicationMethods.NewInstance(CimApplication.Handle, className, null, out instanceHandle);
				MiResult miResult1 = miResult;
				if (miResult1 != MiResult.INVALID_PARAMETER)
				{
					CimException.ThrowIfMiResultFailure(miResult);
					this._myHandle = new SharedInstanceHandle(instanceHandle);
					if (namespaceName != null)
					{
						miResult = InstanceMethods.SetNamespace(this._myHandle.Handle, namespaceName);
						CimException.ThrowIfMiResultFailure(miResult);
					}
					return;
				}
				else
				{
					throw new ArgumentOutOfRangeException("className");
				}
			}
			else
			{
				throw new ArgumentNullException("className");
			}
		}
Пример #9
0
		public CimInstance(CimInstance cimInstanceToClone)
		{
			this._CimSessionInstanceID = Guid.Empty;
			if (cimInstanceToClone != null)
			{
				InstanceHandle instanceHandle = cimInstanceToClone.InstanceHandle.Clone();
				this._myHandle = new SharedInstanceHandle(instanceHandle);
				return;
			}
			else
			{
				throw new ArgumentNullException("cimInstanceToClone");
			}
		}
Пример #10
0
		internal CimInstance(InstanceHandle handle, SharedInstanceHandle parentHandle)
		{
			this._CimSessionInstanceID = Guid.Empty;
			this._myHandle = new SharedInstanceHandle(handle, parentHandle);
		}
Пример #11
0
		internal CimPropertyOfInstance (SharedInstanceHandle instanceHandle, CimInstance instance, int index)
		{
			this._instanceHandle = instanceHandle;
			this._instance = instance;
			this._index = index;
		}