示例#1
0
        /// <summary>
        /// Creates a <see cref="System.Management.Automation.Job"/> object that invokes a static method
        /// (of the class named by <see cref="Microsoft.PowerShell.Cmdletization.CmdletAdapter&lt;TObjectInstance&gt;.ClassName"/>)
        /// in the wrapped object model.
        /// </summary>
        /// <param name="session">Remote session to invoke the method in.</param>
        /// <param name="methodInvocationInfo">Method invocation details.</param>
        internal override StartableJob CreateStaticMethodInvocationJob(CimSession session, MethodInvocationInfo methodInvocationInfo)
        {
            TerminatingErrorTracker tracker = TerminatingErrorTracker.GetTracker(this.CmdletInvocationInfo, isStaticCmdlet: true);

            if (tracker.IsSessionTerminated(session))
            {
                return(null);
            }

            if (!IsSupportedSession(session, tracker))
            {
                return(null);
            }

            CimJobContext jobContext = this.CreateJobContext(session, targetObject: null);

            StartableJob result;

            if (methodInvocationInfo.MethodName.Equals(CimCmdletAdapter.CreateInstance_MethodName, StringComparison.OrdinalIgnoreCase))
            {
                result = new CreateInstanceJob(
                    jobContext,
                    methodInvocationInfo);
            }
            else
            {
                result = new StaticMethodInvocationJob(
                    jobContext,
                    methodInvocationInfo);
            }

            return(result);
        }
示例#2
0
        internal override StartableJob CreateStaticMethodInvocationJob(CimSession session, MethodInvocationInfo methodInvocationInfo)
        {
            StartableJob            staticMethodInvocationJob;
            TerminatingErrorTracker tracker = TerminatingErrorTracker.GetTracker(this.CmdletInvocationInfo, true);

            if (!tracker.IsSessionTerminated(session))
            {
                if (this.IsSupportedSession(session, tracker))
                {
                    CimJobContext cimJobContext = this.CreateJobContext(session, null);
                    if (!methodInvocationInfo.MethodName.Equals("cim:CreateInstance", StringComparison.OrdinalIgnoreCase))
                    {
                        staticMethodInvocationJob = new StaticMethodInvocationJob(cimJobContext, methodInvocationInfo);
                    }
                    else
                    {
                        staticMethodInvocationJob = new CreateInstanceJob(cimJobContext, methodInvocationInfo);
                    }
                    return(staticMethodInvocationJob);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }