/// <summary> /// Disable the Channel for this particualr value. /// </summary> /// <param name="channelNumber"></param> public void DisableChannel(UInt32 channelNumber) { this.AssertNotDisposed(); MI_Result result = this._operationOptionsHandle.Value.SetNumber("__MI_OPERATIONOPTIONS_CHANNEL", channelNumber, (MI_OperationOptionsFlags)1); CimException.ThrowIfMiResultFailure(result); }
/// <summary> /// Sets regular prompt user /// </summary> /// <param name="callbackMode"></param> /// <param name="automaticConfirmation"></param> public void SetPromptUserRegularMode(CimCallbackMode callbackMode, bool automaticConfirmation) { this.AssertNotDisposed(); MI_Result result = this.OperationOptionsHandleOnDemand.SetNumber("__MI_OPERATIONOPTIONS_PROMPTUSERMODE", (UInt32)callbackMode, MI_OperationOptionsFlags.Unused); CimException.ThrowIfMiResultFailure(result); }
/// <summary> /// Sets a string /// </summary> /// <param name="optionName"></param> /// <param name="optionValue"></param> /// <param name="flags"></param> /// <exception cref="ArgumentNullException">Thrown when <paramref name="optionName"/> is <c>null</c></exception> public void SetString(string optionName, string optionValue, UInt32 flags) { if (string.IsNullOrWhiteSpace(optionName)) { throw new ArgumentNullException("optionName"); } this.AssertNotDisposed(); MI_Result result = this._subscriptionDeliveryOptionsHandle.SetString(optionName, optionValue, flags); CimException.ThrowIfMiResultFailure(result); }
static private MI_Application GetApplicationHandle() { MI_Application applicationHandle; MI_Instance errorDetailsHandle; MI_Result result = MI_Application.Initialize(ApplicationID, out errorDetailsHandle, out applicationHandle); CimException.ThrowIfMiResultFailure(result, errorDetailsHandle); return(applicationHandle); }
/// <summary> /// Instantiates a deep copy of <paramref name="optionsToClone"/> /// </summary> /// <param name="optionsToClone">options to clone</param> /// <exception cref="ArgumentNullException">Thrown when <paramref name="optionsToClone"/> is <c>null</c></exception> public CimSubscriptionDeliveryOptions(CimSubscriptionDeliveryOptions optionsToClone) { if (optionsToClone == null) { throw new ArgumentNullException("optionsToClone"); } MI_SubscriptionDeliveryOptions tmp; MI_Result result = optionsToClone.SubscriptionDeliveryOptionsHandle.Clone(out tmp); CimException.ThrowIfMiResultFailure(result); this._subscriptionDeliveryOptionsHandle = tmp; }
public override void Add(CimProperty newProperty) { if (newProperty != null) { MiResult miResult = InstanceMethods.AddElement(this._instanceHandle.Handle, newProperty.Name, CimInstance.ConvertToNativeLayer(newProperty.Value), newProperty.CimType.ToMiType(), newProperty.Flags.ToMiFlags()); CimException.ThrowIfMiResultFailure(miResult); return; } else { throw new ArgumentNullException("newProperty"); } }
public static MI_Instance Clone(this MI_Instance handleToClone) { if (handleToClone == null || handleToClone.IsNull) { throw new ArgumentNullException(); } MI_Instance clonedHandle; MI_Result result = handleToClone.Clone(out clonedHandle); CimException.ThrowIfMiResultFailure(result); return(clonedHandle); }
public override CimQualifier this[string qualifierName] { get { if (string.IsNullOrWhiteSpace(qualifierName)) { throw new ArgumentNullException("qualifierName"); } string name; MI_QualifierSet qualifierSet; MI_ParameterSet parameterSet; MI_Result result = this.classHandle.GetMethodAt((uint)methodIndex, out name, out qualifierSet, out parameterSet); CimException.ThrowIfMiResultFailure(result); MI_Type parameterType; string referenceClass; MI_QualifierSet methodQualifierSet; result = parameterSet.GetParameterAt((uint)parameterName, out name, out parameterType, out referenceClass, out methodQualifierSet); CimException.ThrowIfMiResultFailure(result); MI_Type qualifierType; MI_Flags qualifierFlags; MI_Value qualifierValue; UInt32 index; result = methodQualifierSet.GetQualifier(qualifierName, out qualifierType, out qualifierFlags, out qualifierValue, out index); switch (result) { case MI_Result.MI_RESULT_NO_SUCH_PROPERTY: case MI_Result.MI_RESULT_NOT_FOUND: return(null); default: CimException.ThrowIfMiResultFailure(result); return(new CimQualifierOfMethodParameter(this.classHandle, methodIndex, parameterName, (int)index)); } } }
public static MI_Class Clone(this MI_Class handleToClone) { if (handleToClone == null) { return(null); } // TODO: handleToClone.AssertValidInternalState(); MI_Class clonedHandle; MI_Result result = handleToClone.Clone(out clonedHandle); CimException.ThrowIfMiResultFailure(result); return(clonedHandle); }
/// <summary> /// Sets a custom transport option /// </summary> /// <param name="optionName"></param> /// <param name="optionValue"></param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="optionName"/> is <c>null</c></exception> public void SetOption(string optionName, UInt32 optionValue) { if (string.IsNullOrWhiteSpace(optionName)) { throw new ArgumentNullException("optionName"); } this.AssertNotDisposed(); MI_Result result = this.OperationOptionsHandleOnDemand.SetNumber(optionName, optionValue, MI_OperationOptionsFlags.Unused); CimException.ThrowIfMiResultFailure(result); }
public override void AddDestinationCredentials(CimCredential credential) { if (credential != null) { base.AssertNotDisposed(); MiResult miResult = DestinationOptionsMethods.AddDestinationCredentials(base.DestinationOptionsHandleOnDemand, credential.GetCredential()); CimException.ThrowIfMiResultFailure(miResult); return; } else { throw new ArgumentNullException("credential"); } }
public void SetString(string optionName, string optionValue, uint flags) { if (!string.IsNullOrWhiteSpace(optionName)) { this.AssertNotDisposed(); MiResult miResult = MiResult.OK; //TODO: SubscriptionDeliveryOptionsMethods.SetString(this._subscriptionDeliveryOptionsHandle, optionName, optionValue, flags); CimException.ThrowIfMiResultFailure(miResult); return; } else { throw new ArgumentNullException("optionName"); } }
public override void Add(CimProperty newProperty) { if (newProperty == null) { throw new ArgumentNullException("newProperty"); } MI_Result result = this._instance.InstanceHandle.AddElement( newProperty.Name, ValueHelpers.ConvertToNativeLayer(newProperty.Value, newProperty.CimType), newProperty.CimType.FromCimType(), newProperty.Flags.FromCimFlags()); CimException.ThrowIfMiResultFailure(result); }
private CimDeserializer(string format, uint flags) { Debug.Assert(!string.IsNullOrEmpty(format), "Caller should verify that format != null"); MI_Deserializer tmpHandle; // TODO: Fix MI_SerializerFlags in next line to come from "flags" MI_Result result = CimApplication.Handle.NewDeserializer(MI_SerializerFlags.None, format, out tmpHandle); if (result == MI_Result.MI_RESULT_INVALID_PARAMETER) { throw new ArgumentOutOfRangeException("format"); } CimException.ThrowIfMiResultFailure(result); this._myHandle = tmpHandle; }
/// <summary> /// Sets a custom option /// </summary> /// <param name="optionName"></param> /// <param name="optionValue"></param> /// <param name="flags"></param> /// <exception cref="ArgumentNullException">Thrown when <paramref name="optionName"/> is <c>null</c></exception> public void SetInterval(string optionName, TimeSpan optionValue, UInt32 flags) { if (string.IsNullOrWhiteSpace(optionName)) { throw new ArgumentNullException("optionName"); } this.AssertNotDisposed(); // TODO: convert optionValue to MI_Interval MI_Interval interval; interval.days = interval.hours = interval.minutes = interval.seconds = interval.microseconds = interval.__padding1 = interval.__padding2 = interval.__padding3 = 0; MI_Result result = this._subscriptionDeliveryOptionsHandle.SetInterval(optionName, interval, flags); CimException.ThrowIfMiResultFailure(result); }
public CimSubscriptionDeliveryOptions(CimSubscriptionDeliveryOptions optionsToClone) { SubscriptionDeliveryOptionsHandle subscriptionDeliveryOptionsHandle = null; if (optionsToClone != null) { MiResult miResult = MiResult.OK; //TODO: SubscriptionDeliveryOptionsMethods.Clone(optionsToClone.SubscriptionDeliveryOptionsHandle, out subscriptionDeliveryOptionsHandle); CimException.ThrowIfMiResultFailure(miResult); this._subscriptionDeliveryOptionsHandle = subscriptionDeliveryOptionsHandle; return; } else { throw new ArgumentNullException("optionsToClone"); } }
public override CimQualifier this[string qualifierName] { get { if (string.IsNullOrWhiteSpace(qualifierName)) { throw new ArgumentNullException("qualifierName"); } UInt32 index; MI_Value value; bool valueExists; MI_Type type; string referenceClass; MI_QualifierSet qualifierSet; MI_Flags flags; MI_Result result = this.classHandle.GetElement(name, out value, out valueExists, out type, out referenceClass, out qualifierSet, out flags, out index); CimException.ThrowIfMiResultFailure(result); MI_Type qualifierType; MI_Flags qualifierFlags; MI_Value qualifierValue; result = qualifierSet.GetQualifier(qualifierName, out qualifierType, out qualifierFlags, out qualifierValue, out index); switch (result) { case MI_Result.MI_RESULT_NO_SUCH_PROPERTY: case MI_Result.MI_RESULT_NOT_FOUND: return(null); default: CimException.ThrowIfMiResultFailure(result); return(new CimQualifierOfProperty(this.classHandle, name, (int)index)); } } }
private CimPropertyStandalone GetProperty() { string name; MI_Value value; MI_Type type; MI_Flags flags; MI_Result result = this._instance.InstanceHandle.GetElementAt((uint)this._index, out name, out value, out type, out flags); CimException.ThrowIfMiResultFailure(result); var convertedValue = ValueHelpers.ConvertFromNativeLayer(value, type, flags); return(new CimPropertyStandalone(name, convertedValue, type.ToCimType(), flags.ToCimFlags())); }
private static ApplicationHandle GetApplicationHandle() { ApplicationHandle applicationHandle = null; InstanceHandle instanceHandle = null; MiResult miResult = ApplicationMethods.Initialize(0, AppDomain.CurrentDomain.FriendlyName, out instanceHandle, out applicationHandle); CimException.ThrowIfMiResultFailure(miResult, instanceHandle); AppDomain currentDomain = AppDomain.CurrentDomain; currentDomain.DomainUnload += (object sender, EventArgs eventArgs) => CimApplication.Shutdown(); AppDomain appDomain = AppDomain.CurrentDomain; appDomain.ProcessExit += (object param0, EventArgs param1) => { ApplicationMethods.SupressFurtherCallbacks(); CimApplication.Shutdown(); }; return(applicationHandle); }
internal void Cancel(CancellationMode cancellationMode) { Debug.Assert(cancellationMode != CancellationMode.NoCancellationOccured, "Caller should verify the right cancellation mode is used"); Debug.Assert(cancellationMode != CancellationMode.IgnoreCancellationRequests, "Caller should verify the right cancellation mode is used"); lock (this._cancellationModeLock) { if (this._cancellationMode == CancellationMode.IgnoreCancellationRequests) { return; } this._cancellationMode = cancellationMode; } MI_Result result = this._handle.Cancel(MI_CancellationReason.MI_REASON_NONE); CimException.ThrowIfMiResultFailure(result); this.Cancelled.SafeInvoke(this, EventArgs.Empty); }
/// <summary> /// Creates a new <see cref="CimOperationOptions"/> instance. /// </summary> /// <param name="mustUnderstand">Indicates whether the server has to understand all the options.</param> public CimOperationOptions(bool mustUnderstand) { var operationCallbacks = new MI_OperationCallbacks(); this._operationCallback = operationCallbacks; _writeMessageCallback = null; _writeProgressCallback = null; _writeErrorCallback = null; _promptUserCallback = null; this._operationOptionsHandle = new Lazy <MI_OperationOptions>( delegate { MI_OperationOptions operationOptionsHandle; MI_Result result = CimApplication.Handle.NewOperationOptions( mustUnderstand, out operationOptionsHandle); CimException.ThrowIfMiResultFailure(result); return(operationOptionsHandle); }); }
/// <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); }
public void AddCredentials(string optionName, CimCredential optionValue, uint flags) { if (string.IsNullOrWhiteSpace(optionName) || optionValue == null) { throw new ArgumentNullException("optionName"); } else { if (optionValue != null) { this.AssertNotDisposed(); MiResult miResult = MiResult.OK; //TODO: SubscriptionDeliveryOptionsMethods.AddCredentials(this._subscriptionDeliveryOptionsHandle, optionName, optionValue.GetCredential(), flags); CimException.ThrowIfMiResultFailure(miResult); return; } else { throw new ArgumentNullException("optionValue"); } } }
/// <summary> /// Instantiates a deep copy of <paramref name="optionsToClone"/> /// </summary> /// <param name="optionsToClone">options to clone</param> /// <exception cref="ArgumentNullException">Thrown when <paramref name="optionsToClone"/> is <c>null</c></exception> public CimOperationOptions(CimOperationOptions optionsToClone) { if (optionsToClone == null) { throw new ArgumentNullException("optionsToClone"); } this._operationCallback = optionsToClone.GetOperationCallbacks(); _writeMessageCallback = optionsToClone._writeMessageCallback; _writeProgressCallback = optionsToClone._writeProgressCallback; _writeErrorCallback = optionsToClone._writeErrorCallback; _promptUserCallback = optionsToClone._promptUserCallback; this._operationOptionsHandle = new Lazy <MI_OperationOptions>( delegate { MI_OperationOptions tmp; MI_Result result = optionsToClone.OperationOptionsHandle.Clone(out tmp); CimException.ThrowIfMiResultFailure(result); return(tmp); }); }
private CimSessionOptions(string protocol, bool validateProtocol) { if (validateProtocol) { if (string.IsNullOrWhiteSpace(protocol)) { throw new ArgumentNullException("protocol"); } } this.Protocol = protocol; this._destinationOptionsHandle = new Lazy <MI_DestinationOptions>( delegate { MI_DestinationOptions tmp; MI_Result result = CimApplication.Handle.NewDestinationOptions(out tmp); CimException.ThrowIfMiResultFailure(result); return(tmp); }); }
public override CimMethodParameterDeclaration this[string parameterName] { get { if (string.IsNullOrWhiteSpace(parameterName)) { throw new ArgumentNullException("parameterName"); } UInt32 index; string name; MI_QualifierSet qualifierSet; MI_ParameterSet parameterSet; MI_Result result = this.classHandle.GetMethodAt((uint)methodIndex, out name, out qualifierSet, out parameterSet); CimException.ThrowIfMiResultFailure(result); MI_Type parameterType; string referenceClass; result = parameterSet.GetParameter(parameterName, out parameterType, out referenceClass, out qualifierSet, out index); switch (result) { case MI_Result.MI_RESULT_NOT_FOUND: return(null); default: CimException.ThrowIfMiResultFailure(result); return(new CimMethodParameterDeclarationOfMethod(this.classHandle, methodIndex, (int)index)); } } }
public override CimQualifier this[string methodName] { get { if (string.IsNullOrWhiteSpace(methodName)) { throw new ArgumentNullException("methodName"); } string name; MI_QualifierSet qualifierSet; MI_ParameterSet parameterSet; MI_Result result = this.classHandle.GetMethodAt((uint)methodIndex, out name, out qualifierSet, out parameterSet); CimException.ThrowIfMiResultFailure(result); MI_Type qualifierType; MI_Flags qualifierFlags; MI_Value qualifierValue; UInt32 index; result = qualifierSet.GetQualifier(name, out qualifierType, out qualifierFlags, out qualifierValue, out index); switch (result) { case MI_Result.MI_RESULT_NOT_FOUND: return(null); default: CimException.ThrowIfMiResultFailure(result); return(new CimMethodQualifierDeclarationOfMethod(this.classHandle, methodIndex, (int)index)); } } }
internal void Cancel(CancellationMode cancellationMode) { lock (this._cancellationModeLock) { if (this._cancellationMode != CancellationMode.IgnoreCancellationRequests) { this._cancellationMode = cancellationMode; } else { return; } } lock (this._cancelVsCloseLock) { if (this._handle != null) { MiResult miResult = OperationMethods.Cancel(this._handle, MiCancellationReason.None); CimException.ThrowIfMiResultFailure(miResult); } } this.Cancelled.SafeInvoke <EventArgs>(this, EventArgs.Empty); }
public override CimPropertyDeclaration this[string propertyName] { get { if (string.IsNullOrWhiteSpace(propertyName)) { throw new ArgumentNullException("propertyName"); } MI_Value value; bool valueExists; MI_Type type; string referenceClass; MI_QualifierSet qualifierSet; MI_Flags flags; UInt32 index; MI_Result result = this.classHandle.GetElement(propertyName, out value, out valueExists, out type, out referenceClass, out qualifierSet, out flags, out index); switch (result) { case MI_Result.MI_RESULT_NO_SUCH_PROPERTY: return(null); default: CimException.ThrowIfMiResultFailure(result); return(new CimClassPropertyOfClass(this.classHandle, (int)index)); } } }
public override CimQualifier this[string qualifierName] { get { if (string.IsNullOrWhiteSpace(qualifierName)) { throw new ArgumentNullException("qualifierName"); } MI_QualifierSet qualifierSet; MI_Result result = this.classHandle.GetClassQualifierSet(out qualifierSet); CimException.ThrowIfMiResultFailure(result); // TODO: there aren't many comments for the above pattern throughout the MMI sources, but if the above fails we shouldn't throw exception, just return MI_RESULT_NOT_FOUND like below. Make sure all of these cases are accounted for in MMI MI_Type qualifierType; MI_Flags qualifierFlags; MI_Value qualifierValue; UInt32 index; result = qualifierSet.GetQualifier(qualifierName, out qualifierType, out qualifierFlags, out qualifierValue, out index); switch (result) { case MI_Result.MI_RESULT_NOT_FOUND: return(null); default: CimException.ThrowIfMiResultFailure(result); return(new CimQualifierOfClass(this.classHandle, (int)index)); } } }