本文整理汇总了C#中System.Management.ManagementOperationObserver.GetNewPutSink方法的典型用法代码示例。如果您正苦于以下问题:C# ManagementOperationObserver.GetNewPutSink方法的具体用法?C# ManagementOperationObserver.GetNewPutSink怎么用?C# ManagementOperationObserver.GetNewPutSink使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Management.ManagementOperationObserver
的用法示例。
在下文中一共展示了ManagementOperationObserver.GetNewPutSink方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CopyTo
/// <summary>
/// <para>Copies the object to a different location, asynchronously.</para>
/// </summary>
/// <param name='watcher'>The object that will receive the results of the operation.</param>
/// <param name='path'>The path to which the object should be copied.</param>
/// <param name='options'>The options for how the object should be put.</param>
public void CopyTo(ManagementOperationObserver watcher, ManagementPath path, PutOptions options)
{
if (null == watcher)
throw new ArgumentNullException("watcher");
else
{
Initialize ( false ) ;
ManagementScope destinationScope = null;
destinationScope = new ManagementScope(path, scope);
destinationScope.Initialize();
PutOptions o = (null != options) ? (PutOptions) options.Clone() : new PutOptions();
// If someone has registered for progress, make sure we flag it
if (watcher.HaveListenersForProgress)
o.SendStatus = true;
WmiEventSink sink = watcher.GetNewPutSink(destinationScope, o.Context,
path.GetNamespacePath((int)tag_WBEM_GET_TEXT_FLAGS.WBEMPATH_GET_SERVER_AND_NAMESPACE_ONLY), ClassName);
IWbemServices destWbemServices = destinationScope.GetIWbemServices();
SecurityHandler securityHandler = null;
int status = (int)ManagementStatus.NoError;
securityHandler = destinationScope.GetSecurityHandler();
if (IsClass)
{
status = destinationScope.GetSecuredIWbemServicesHandler( destWbemServices ).PutClassAsync_(
wbemObject,
o.Flags,
o.GetContext(),
sink.Stub);
}
else
{
status = destinationScope.GetSecuredIWbemServicesHandler( destWbemServices ).PutInstanceAsync_(
wbemObject,
o.Flags,
o.GetContext(),
sink.Stub);
}
if (securityHandler != null)
securityHandler.Reset();
if (status < 0)
{
watcher.RemoveSink(sink);
if ((status & 0xfffff000) == 0x80041000)
ManagementException.ThrowWithExtendedInfo((ManagementStatus)status);
else
Marshal.ThrowExceptionForHR(status);
}
}
}
示例2: CopyTo
public void CopyTo(ManagementOperationObserver watcher, ManagementPath path, PutOptions options)
{
int num;
PutOptions putOption;
if (watcher != null)
{
this.Initialize(false);
ManagementScope managementScope = new ManagementScope(path, this.scope);
managementScope.Initialize();
if (options != null)
{
putOption = (PutOptions)options.Clone();
}
else
{
putOption = new PutOptions();
}
PutOptions putOption1 = putOption;
if (watcher.HaveListenersForProgress)
{
putOption1.SendStatus = true;
}
WmiEventSink newPutSink = watcher.GetNewPutSink(managementScope, putOption1.Context, path.GetNamespacePath(8), base.ClassName);
IWbemServices wbemServices = managementScope.GetIWbemServices();
SecurityHandler securityHandler = managementScope.GetSecurityHandler();
if (!base.IsClass)
{
num = managementScope.GetSecuredIWbemServicesHandler(wbemServices).PutInstanceAsync_(base.wbemObject, putOption1.Flags, putOption1.GetContext(), newPutSink.Stub);
}
else
{
num = managementScope.GetSecuredIWbemServicesHandler(wbemServices).PutClassAsync_(base.wbemObject, putOption1.Flags, putOption1.GetContext(), newPutSink.Stub);
}
if (securityHandler != null)
{
securityHandler.Reset();
}
if (num < 0)
{
watcher.RemoveSink(newPutSink);
if (((long)num & (long)-4096) != (long)-2147217408)
{
Marshal.ThrowExceptionForHR(num);
}
else
{
ManagementException.ThrowWithExtendedInfo((ManagementStatus)num);
return;
}
}
return;
}
else
{
throw new ArgumentNullException("watcher");
}
}
示例3: Put
/// <summary>
/// <para>Commits the changes to the object asynchronously and
/// using the specified options.</para>
/// </summary>
/// <param name='watcher'>A <see cref='System.Management.ManagementOperationObserver'/> used to handle the progress and results of the asynchronous operation.</param>
/// <param name=' options'>A <see cref='System.Management.PutOptions'/> used to specify additional options for the commit operation.</param>
public void Put(ManagementOperationObserver watcher, PutOptions options)
{
if (null == watcher)
throw new ArgumentNullException("watcher");
else
{
Initialize ( false ) ;
PutOptions o = (null == options) ?
new PutOptions() : (PutOptions)options.Clone();
// If someone has registered for progress, make sure we flag it
if (watcher.HaveListenersForProgress)
o.SendStatus = true;
IWbemServices wbemServices = scope.GetIWbemServices();
WmiEventSink sink = watcher.GetNewPutSink(scope,
o.Context, scope.Path.GetNamespacePath((int)tag_WBEM_GET_TEXT_FLAGS.WBEMPATH_GET_SERVER_AND_NAMESPACE_ONLY), ClassName);
// Add ourselves to the watcher so we can update our state
sink.InternalObjectPut +=
new InternalObjectPutEventHandler(this.HandleObjectPut);
SecurityHandler securityHandler = null;
// Assign to error initially to insure internal event handler cleanup
// on non-management exception.
int status = (int)ManagementStatus.Failed;
securityHandler = scope.GetSecurityHandler();
if (IsClass)
{
status = scope.GetSecuredIWbemServicesHandler( wbemServices ).PutClassAsync_(
wbemObject,
o.Flags,
o.GetContext(),
sink.Stub);
}
else
{
status = scope.GetSecuredIWbemServicesHandler( wbemServices ).PutInstanceAsync_(
wbemObject,
o.Flags,
o.GetContext(),
sink.Stub);
}
if (securityHandler != null)
securityHandler.Reset();
if (status < 0)
{
sink.InternalObjectPut -= new InternalObjectPutEventHandler(this.HandleObjectPut);
watcher.RemoveSink(sink);
if ((status & 0xfffff000) == 0x80041000)
ManagementException.ThrowWithExtendedInfo((ManagementStatus)status);
else
Marshal.ThrowExceptionForHR(status);
}
}
}