Exemplo n.º 1
0
        /// <summary>
        /// <para>
        /// Set <see cref="CimInstance"/> with properties specified in cmdlet
        /// </para>
        /// </summary>
        /// <param name="cimInstance"></param>
        public void SetCimInstance(CimInstance cimInstance, CimSetCimInstanceContext context, CmdletOperationBase cmdlet)
        {
            DebugHelper.WriteLog("CimSetCimInstance::SetCimInstance", 4);

            if (!cmdlet.ShouldProcess(cimInstance.ToString(), action))
            {
                return;
            }

            Exception exception = null;

            if (!SetProperty(context.Property, ref cimInstance, ref exception))
            {
                cmdlet.ThrowTerminatingError(exception, action);
                return;
            }

            CimSessionProxy proxy = CreateCimSessionProxy(context.Proxy, context.PassThru);

            proxy.ModifyInstanceAsync(cimInstance.CimSystemProperties.Namespace, cimInstance);
        }
Exemplo n.º 2
0
        /// <summary>
        /// <para>
        /// Set <see cref="CimInstance"/> with properties specified in cmdlet
        /// </para>
        /// </summary>
        /// <param name="cimInstance"></param>
        public void SetCimInstance(CimInstance cimInstance, CimSetCimInstanceContext context, CmdletOperationBase cmdlet)
        {
            DebugHelper.WriteLog("CimSetCimInstance::SetCimInstance", 4);

            if (!cmdlet.ShouldProcess(cimInstance.ToString(), action))
            {
                return;
            }

            Exception exception = null;
            if (!SetProperty(context.Property, ref cimInstance, ref exception))
            {
                cmdlet.ThrowTerminatingError(exception, action);
                return;
            }
            CimSessionProxy proxy = CreateCimSessionProxy(context.Proxy, context.PassThru);
            proxy.ModifyInstanceAsync(cimInstance.CimSystemProperties.Namespace, cimInstance);
        }
Exemplo n.º 3
0
 /// <summary>
 /// <para>
 /// Set <see cref="CimSessionProxy"/> properties
 /// </para>
 /// </summary>
 /// <param name="proxy"></param>
 /// <param name="cmdlet"></param>
 private void SetSessionProxyProperties(
     ref CimSessionProxy proxy,
     CimBaseCommand cmdlet)
 {
     if (cmdlet is GetCimInstanceCommand)
     {
         GetCimInstanceCommand getCimInstance = cmdlet as GetCimInstanceCommand;
         proxy.KeyOnly = getCimInstance.KeyOnly;
         proxy.Shallow = getCimInstance.Shallow;
         proxy.OperationTimeout = getCimInstance.OperationTimeoutSec;
         if(getCimInstance.ResourceUri != null )
         {
             proxy.ResourceUri = getCimInstance.ResourceUri;
         }
     }
     else if (cmdlet is RemoveCimInstanceCommand)
     {
         RemoveCimInstanceCommand removeCimInstance = cmdlet as RemoveCimInstanceCommand;
         proxy.OperationTimeout = removeCimInstance.OperationTimeoutSec;
         if(removeCimInstance.ResourceUri != null )
         {
             proxy.ResourceUri = removeCimInstance.ResourceUri;                
         }
         CimRemoveCimInstanceContext context = new CimRemoveCimInstanceContext(
             ConstValue.GetNamespace(removeCimInstance.Namespace),
             proxy);
         proxy.ContextObject = context;
     }
     else if (cmdlet is SetCimInstanceCommand)
     {
         SetCimInstanceCommand setCimInstance = cmdlet as SetCimInstanceCommand;
         proxy.OperationTimeout = setCimInstance.OperationTimeoutSec;
         if(setCimInstance.ResourceUri != null )
         {
             proxy.ResourceUri = setCimInstance.ResourceUri;                
         }
         CimSetCimInstanceContext context = new CimSetCimInstanceContext(
             ConstValue.GetNamespace(setCimInstance.Namespace),
             setCimInstance.Property,
             proxy,
             cmdlet.ParameterSetName,
             setCimInstance.PassThru);
         proxy.ContextObject = context;
     }
 }