Ejemplo n.º 1
0
        private string GetInvocationTypeName()
        {
            System.Management.Automation.InvocationInfo invocationInfo = this.InvocationInfo;
            if (invocationInfo == null)
            {
                return("");
            }
            CommandInfo myCommand = invocationInfo.MyCommand;

            if (myCommand == null)
            {
                return("");
            }
            if (myCommand is IScriptCommandInfo)
            {
                return(myCommand.Name);
            }
            CmdletInfo info4 = myCommand as CmdletInfo;

            if (info4 == null)
            {
                return("");
            }
            return(info4.ImplementingType.FullName);
        }
Ejemplo n.º 2
0
 internal InformationalRecord(string message)
 {
     this.message               = message;
     this.invocationInfo        = null;
     this.pipelineIterationInfo = null;
     this.serializeExtendedInfo = false;
 }
Ejemplo n.º 3
0
 internal InformationalRecord(string message)
 {
     this.message = message;
     this.invocationInfo = null;
     this.pipelineIterationInfo = null;
     this.serializeExtendedInfo = false;
 }
Ejemplo n.º 4
0
        internal void SetInvocationInfo(System.Management.Automation.InvocationInfo invocationInfo)
        {
            IScriptExtent displayScriptPosition = null;

            if (this._invocationInfo != null)
            {
                displayScriptPosition = this._invocationInfo.DisplayScriptPosition;
            }
            if (invocationInfo != null)
            {
                this._invocationInfo = new System.Management.Automation.InvocationInfo(invocationInfo.MyCommand, invocationInfo.ScriptPosition);
                this._invocationInfo.InvocationName = invocationInfo.InvocationName;
                if (invocationInfo.MyCommand == null)
                {
                    this._invocationInfo.HistoryId = invocationInfo.HistoryId;
                }
            }
            if (displayScriptPosition != null)
            {
                this._invocationInfo.DisplayScriptPosition = displayScriptPosition;
            }
            this.LockScriptStackTrace();
            if ((invocationInfo != null) && (invocationInfo.PipelineIterationInfo != null))
            {
                int[] list = (int[])invocationInfo.PipelineIterationInfo.Clone();
                this.pipelineIterationInfo = new ReadOnlyCollection <int>(list);
            }
        }
Ejemplo n.º 5
0
 internal void SetInvocationInfo(System.Management.Automation.InvocationInfo invocationInfo)
 {
     this.invocationInfo = invocationInfo;
     if (invocationInfo.PipelineIterationInfo != null)
     {
         int[] list = (int[])invocationInfo.PipelineIterationInfo.Clone();
         this.pipelineIterationInfo = new ReadOnlyCollection <int>(list);
     }
 }
Ejemplo n.º 6
0
 internal ParameterBinderBase(System.Management.Automation.InvocationInfo invocationInfo, System.Management.Automation.ExecutionContext context, InternalCommand command)
 {
     this.RecordBoundParameters = true;
     bindingTracer.ShowHeaders = false;
     this.command = command;
     this.invocationInfo = invocationInfo;
     this.context = context;
     this.engine = context.EngineIntrinsics;
 }
Ejemplo n.º 7
0
 internal void SetInvocationInfo(System.Management.Automation.InvocationInfo invocationInfo)
 {
     this.invocationInfo = invocationInfo;
     if (invocationInfo.PipelineIterationInfo != null)
     {
         int[] list = (int[]) invocationInfo.PipelineIterationInfo.Clone();
         this.pipelineIterationInfo = new ReadOnlyCollection<int>(list);
     }
 }
Ejemplo n.º 8
0
 /// <summary>Creates an instance of the HttpPipeline for each call.</summary>
 /// <param name="invocationInfo">The <see cref="System.Management.Automation.InvocationInfo" /> from the cmdlet</param>
 /// <param name="correlationId">the cmdlet's correlation id.</param>
 /// <param name="processRecordId">the cmdlet's process record correlation id.</param>
 /// <returns>An instance of Microsoft.Azure.AzConfig.Runtime.HttpPipeline for the remote call.</returns>
 public Microsoft.Azure.AzConfig.Runtime.HttpPipeline CreatePipeline(System.Management.Automation.InvocationInfo invocationInfo, string correlationId, string processRecordId)
 {
     Microsoft.Azure.AzConfig.Runtime.HttpPipeline pipeline = null;
     BeforeCreatePipeline(invocationInfo, ref pipeline);
     pipeline = (pipeline ?? (_handler.UseProxy ? _pipelineWithProxy : _pipeline)).Clone();
     AfterCreatePipeline(invocationInfo, ref pipeline);
     OnNewRequest?.Invoke(invocationInfo, correlationId, processRecordId, (step) => { pipeline.Prepend(step); }, (step) => { pipeline.Append(step); });
     return(pipeline);
 }
Ejemplo n.º 9
0
 internal ParameterBinderBase(System.Management.Automation.InvocationInfo invocationInfo, System.Management.Automation.ExecutionContext context, InternalCommand command)
 {
     this.RecordBoundParameters = true;
     bindingTracer.ShowHeaders  = false;
     this.command        = command;
     this.invocationInfo = invocationInfo;
     this.context        = context;
     this.engine         = context.EngineIntrinsics;
 }
Ejemplo n.º 10
0
        private void ConstructFromPSObjectForRemoting(PSObject serializedErrorRecord)
        {
            if (serializedErrorRecord == null)
            {
                throw PSTraceSource.NewArgumentNullException("serializedErrorRecord");
            }
            PSObject propertyValue = RemotingDecoder.GetPropertyValue <PSObject>(serializedErrorRecord, "Exception");
            object   targetObject  = RemotingDecoder.GetPropertyValue <object>(serializedErrorRecord, "TargetObject");
            PSObject serializedRemoteInvocationInfo = RemotingDecoder.GetPropertyValue <PSObject>(serializedErrorRecord, "InvocationInfo");
            string   str = null;

            if (propertyValue != null)
            {
                PSPropertyInfo info = propertyValue.Properties["Message"];
                if (info != null)
                {
                    str = info.Value as string;
                }
            }
            string fullyQualifiedErrorId = RemotingDecoder.GetPropertyValue <string>(serializedErrorRecord, "FullyQualifiedErrorId");

            if (fullyQualifiedErrorId == null)
            {
                fullyQualifiedErrorId = "fullyQualifiedErrorId";
            }
            ErrorCategory   errorCategory = RemotingDecoder.GetPropertyValue <ErrorCategory>(serializedErrorRecord, "errorCategory_Category");
            string          str3          = RemotingDecoder.GetPropertyValue <string>(serializedErrorRecord, "ErrorCategory_Activity");
            string          str4          = RemotingDecoder.GetPropertyValue <string>(serializedErrorRecord, "ErrorCategory_Reason");
            string          str5          = RemotingDecoder.GetPropertyValue <string>(serializedErrorRecord, "ErrorCategory_TargetName");
            string          str6          = RemotingDecoder.GetPropertyValue <string>(serializedErrorRecord, "ErrorCategory_TargetType");
            string          str7          = RemotingDecoder.GetPropertyValue <string>(serializedErrorRecord, "ErrorCategory_Message");
            string          noteValue     = GetNoteValue(serializedErrorRecord, "ErrorDetails_Message") as string;
            string          str9          = GetNoteValue(serializedErrorRecord, "ErrorDetails_RecommendedAction") as string;
            RemoteException exception     = new RemoteException((str != null) ? str : str7, propertyValue, serializedRemoteInvocationInfo);

            this.PopulateProperties(exception, targetObject, fullyQualifiedErrorId, errorCategory, str3, str4, str5, str6, str7, noteValue, str9);
            exception.SetRemoteErrorRecord(this);
            this.serializeExtendedInfo = RemotingDecoder.GetPropertyValue <bool>(serializedErrorRecord, "SerializeExtendedInfo");
            if (this.serializeExtendedInfo)
            {
                this._invocationInfo = new System.Management.Automation.InvocationInfo(serializedErrorRecord);
                ArrayList list = RemotingDecoder.GetPropertyValue <ArrayList>(serializedErrorRecord, "PipelineIterationInfo");
                if (list != null)
                {
                    this.pipelineIterationInfo = new ReadOnlyCollection <int>((int[])list.ToArray(typeof(int)));
                }
            }
            else
            {
                this._invocationInfo = null;
            }
        }
Ejemplo n.º 11
0
 internal InformationalRecord(PSObject serializedObject)
 {
     this.message = (string) SerializationUtilities.GetPropertyValue(serializedObject, "InformationalRecord_Message");
     this.serializeExtendedInfo = (bool) SerializationUtilities.GetPropertyValue(serializedObject, "InformationalRecord_SerializeInvocationInfo");
     if (this.serializeExtendedInfo)
     {
         this.invocationInfo = new System.Management.Automation.InvocationInfo(serializedObject);
         ArrayList psObjectPropertyBaseObject = (ArrayList) SerializationUtilities.GetPsObjectPropertyBaseObject(serializedObject, "InformationalRecord_PipelineIterationInfo");
         this.pipelineIterationInfo = new ReadOnlyCollection<int>((int[]) psObjectPropertyBaseObject.ToArray(Type.GetType("System.Int32")));
     }
     else
     {
         this.invocationInfo = null;
     }
 }
Ejemplo n.º 12
0
 internal InformationalRecord(PSObject serializedObject)
 {
     this.message = (string)SerializationUtilities.GetPropertyValue(serializedObject, "InformationalRecord_Message");
     this.serializeExtendedInfo = (bool)SerializationUtilities.GetPropertyValue(serializedObject, "InformationalRecord_SerializeInvocationInfo");
     if (this.serializeExtendedInfo)
     {
         this.invocationInfo = new System.Management.Automation.InvocationInfo(serializedObject);
         ArrayList psObjectPropertyBaseObject = (ArrayList)SerializationUtilities.GetPsObjectPropertyBaseObject(serializedObject, "InformationalRecord_PipelineIterationInfo");
         this.pipelineIterationInfo = new ReadOnlyCollection <int>((int[])psObjectPropertyBaseObject.ToArray(Type.GetType("System.Int32")));
     }
     else
     {
         this.invocationInfo = null;
     }
 }
        static IAzureContext GetDefaultContext(IProfileProvider provider, System.Management.Automation.InvocationInfo invocationInfo)
        {
            IAzureContextContainer context;
            var contextConverter = new AzureContextConverter();

            if (invocationInfo.BoundParameters.ContainsKey("DefaultContext") &&
                contextConverter.CanConvertFrom(invocationInfo.BoundParameters["DefaultContext"], typeof(IAzureContextContainer)))
            {
                context = contextConverter.ConvertFrom(invocationInfo.BoundParameters["DefaultContext"], typeof(IAzureContextContainer), CultureInfo.InvariantCulture, true) as IAzureContextContainer;
            }
            else
            {
                context = provider.Profile;
            }

            return(context?.DefaultContext);
        }
        /// <summary>
        /// The cmdlet will call this when it is trying to fill in a parameter value that it needs
        /// </summary>
        /// <param name="resourceId"><c>string</c>containing the expected resource id (ie, ARM).</param>
        /// <param name="moduleName"><c>string</c>containing the name of the module being loaded.</param>
        /// <param name="invocationInfo">The <see cref="System.Management.Automation.InvocationInfo" /> from the cmdlet</param>
        /// <param name="correlationId">The <see cref="string" /> containing the correlation id for the cmdlet</param>
        /// <param name="name">The <see cref="string" /> parameter name being asked for</param>
        public object GetParameterValue(string resourceId, string moduleName, System.Management.Automation.InvocationInfo invocationInfo, string correlationId, string name)
        {
            var defaultContext = GetDefaultContext(_provider, invocationInfo);
            var endpoint       = GetDefaultEndpoint(defaultContext, AzureEnvironment.Endpoint.ResourceManager);

            switch (name)
            {
            case "subscriptionId":
                return(defaultContext?.Subscription?.Id);

            case "host":
                return(endpoint?.Host);

            case "port":
                return(endpoint?.Port);
            }

            return(string.Empty);
        }
Ejemplo n.º 15
0
 /// <summary>FIXME: Method BeforeCreatePipeline is MISSING DESCRIPTION</summary>
 /// <param name="invocationInfo">The <see cref="System.Management.Automation.InvocationInfo" /> from the cmdlet</param>
 /// <param name="pipeline">The HttpPipeline for the request</param>
 partial void BeforeCreatePipeline(System.Management.Automation.InvocationInfo invocationInfo, ref Microsoft.Azure.PowerShell.Cmdlets.AppConfiguration.Runtime.HttpPipeline pipeline);
Ejemplo n.º 16
0
 internal DebuggerStopEventArgs(System.Management.Automation.InvocationInfo invocationInfo, List <Breakpoint> breakpoints)
 {
     this.InvocationInfo = invocationInfo;
     this.Breakpoints    = new ReadOnlyCollection <Breakpoint>(breakpoints);
     this.ResumeAction   = DebuggerResumeAction.Continue;
 }
Ejemplo n.º 17
0
 /// <summary>Called to dispatch events to the common module listener</summary>
 /// <param name="id">The ID of the event </param>
 /// <param name="token">The cancellation token for the event </param>
 /// <param name="getEventData">A delegate to get the detailed event data</param>
 /// <param name="signal">The callback for the event dispatcher </param>
 /// <param name="invocationInfo">The <see cref="System.Management.Automation.InvocationInfo" /> from the cmdlet</param>
 /// <param name="parameterSetName">the cmdlet's parameterset name.</param>
 /// <param name="correlationId">the cmdlet's correlation id.</param>
 /// <param name="processRecordId">the cmdlet's process record correlation id.</param>
 /// <param name="exception">the exception that is being thrown (if available)</param>
 /// <returns>
 /// A <see cref="System.Threading.Tasks.Task" /> that will be complete when handling of the event is completed.
 /// </returns>
 public async System.Threading.Tasks.Task Signal(string id, System.Threading.CancellationToken token, System.Func <System.EventArgs> getEventData, SignalDelegate signal, System.Management.Automation.InvocationInfo invocationInfo, string parameterSetName, string correlationId, string processRecordId, System.Exception exception)
 {
     using ( NoSynchronizationContext )
     {
         await EventListener?.Invoke(id, token, getEventData, signal, invocationInfo, parameterSetName, correlationId, processRecordId, exception);
     }
 }
Ejemplo n.º 18
0
 private void ConstructFromPSObjectForRemoting(PSObject serializedErrorRecord)
 {
     if (serializedErrorRecord == null)
     {
         throw PSTraceSource.NewArgumentNullException("serializedErrorRecord");
     }
     PSObject propertyValue = RemotingDecoder.GetPropertyValue<PSObject>(serializedErrorRecord, "Exception");
     object targetObject = RemotingDecoder.GetPropertyValue<object>(serializedErrorRecord, "TargetObject");
     PSObject serializedRemoteInvocationInfo = RemotingDecoder.GetPropertyValue<PSObject>(serializedErrorRecord, "InvocationInfo");
     string str = null;
     if (propertyValue != null)
     {
         PSPropertyInfo info = propertyValue.Properties["Message"];
         if (info != null)
         {
             str = info.Value as string;
         }
     }
     string fullyQualifiedErrorId = RemotingDecoder.GetPropertyValue<string>(serializedErrorRecord, "FullyQualifiedErrorId");
     if (fullyQualifiedErrorId == null)
     {
         fullyQualifiedErrorId = "fullyQualifiedErrorId";
     }
     ErrorCategory errorCategory = RemotingDecoder.GetPropertyValue<ErrorCategory>(serializedErrorRecord, "errorCategory_Category");
     string str3 = RemotingDecoder.GetPropertyValue<string>(serializedErrorRecord, "ErrorCategory_Activity");
     string str4 = RemotingDecoder.GetPropertyValue<string>(serializedErrorRecord, "ErrorCategory_Reason");
     string str5 = RemotingDecoder.GetPropertyValue<string>(serializedErrorRecord, "ErrorCategory_TargetName");
     string str6 = RemotingDecoder.GetPropertyValue<string>(serializedErrorRecord, "ErrorCategory_TargetType");
     string str7 = RemotingDecoder.GetPropertyValue<string>(serializedErrorRecord, "ErrorCategory_Message");
     string noteValue = GetNoteValue(serializedErrorRecord, "ErrorDetails_Message") as string;
     string str9 = GetNoteValue(serializedErrorRecord, "ErrorDetails_RecommendedAction") as string;
     RemoteException exception = new RemoteException((str != null) ? str : str7, propertyValue, serializedRemoteInvocationInfo);
     this.PopulateProperties(exception, targetObject, fullyQualifiedErrorId, errorCategory, str3, str4, str5, str6, str7, noteValue, str9);
     exception.SetRemoteErrorRecord(this);
     this.serializeExtendedInfo = RemotingDecoder.GetPropertyValue<bool>(serializedErrorRecord, "SerializeExtendedInfo");
     if (this.serializeExtendedInfo)
     {
         this._invocationInfo = new System.Management.Automation.InvocationInfo(serializedErrorRecord);
         ArrayList list = RemotingDecoder.GetPropertyValue<ArrayList>(serializedErrorRecord, "PipelineIterationInfo");
         if (list != null)
         {
             this.pipelineIterationInfo = new ReadOnlyCollection<int>((int[]) list.ToArray(typeof(int)));
         }
     }
     else
     {
         this._invocationInfo = null;
     }
 }
Ejemplo n.º 19
0
 internal ParameterBinderController(System.Management.Automation.InvocationInfo invocationInfo, ExecutionContext context, ParameterBinderBase parameterBinder)
 {
     this.DefaultParameterBinder = parameterBinder;
     this._context        = context;
     this._invocationInfo = invocationInfo;
 }
Ejemplo n.º 20
0
 /// <summary>FIXME: Method BeforeCreatePipeline is MISSING DESCRIPTION</summary>
 /// <param name="invocationInfo">The <see cref="System.Management.Automation.InvocationInfo" /> from the cmdlet</param>
 /// <param name="pipeline">The HttpPipeline for the request</param>
 partial void BeforeCreatePipeline(System.Management.Automation.InvocationInfo invocationInfo, ref Microsoft.Azure.AzConfig.Runtime.HttpPipeline pipeline);
Ejemplo n.º 21
0
 internal void SetInvocationInfo(System.Management.Automation.InvocationInfo invocationInfo)
 {
     IScriptExtent displayScriptPosition = null;
     if (this._invocationInfo != null)
     {
         displayScriptPosition = this._invocationInfo.DisplayScriptPosition;
     }
     if (invocationInfo != null)
     {
         this._invocationInfo = new System.Management.Automation.InvocationInfo(invocationInfo.MyCommand, invocationInfo.ScriptPosition);
         this._invocationInfo.InvocationName = invocationInfo.InvocationName;
         if (invocationInfo.MyCommand == null)
         {
             this._invocationInfo.HistoryId = invocationInfo.HistoryId;
         }
     }
     if (displayScriptPosition != null)
     {
         this._invocationInfo.DisplayScriptPosition = displayScriptPosition;
     }
     this.LockScriptStackTrace();
     if ((invocationInfo != null) && (invocationInfo.PipelineIterationInfo != null))
     {
         int[] list = (int[]) invocationInfo.PipelineIterationInfo.Clone();
         this.pipelineIterationInfo = new ReadOnlyCollection<int>(list);
     }
 }
Ejemplo n.º 22
0
 internal ParameterBinderController(System.Management.Automation.InvocationInfo invocationInfo, ExecutionContext context, ParameterBinderBase parameterBinder)
 {
     this.DefaultParameterBinder = parameterBinder;
     this._context = context;
     this._invocationInfo = invocationInfo;
 }
 /// <summary>
 /// Implementation of the OnNewRequest Event
 ///
 /// The cmdlet will call this when a new request is being created.
 /// </summary>
 /// <param name="invocationInfo">The <see cref="System.Management.Automation.InvocationInfo" /> from the cmdlet</param>
 /// <param name="correlationId">The <see cref="string" /> containing the correlation id for the cmdlet (if available)</param>
 /// <param name="processRecordId">The <see cref="string" /> containing the correlation id for the individual process record. (if available)</param>
 /// <param name="prependStep">a delegate which allows the module to prepend a step in the HTTP Pipeline</param>
 /// <param name="appendStep">a delegate which allows the module to append a step in the HTTP Pipeline</param>
 public void OnNewRequest(System.Management.Automation.InvocationInfo invocationInfo, string correlationId, string processRecordId, PipelineChangeDelegate prependStep, PipelineChangeDelegate appendStep)
 {
     appendStep(this.SendHandler(GetDefaultContext(_provider, invocationInfo), AzureEnvironment.Endpoint.ResourceManager));
 }
 /// <summary>
 ///  Called for well-known parameters that require argument completers
 ///  </summary>
 /// <param name="completerName">string - the type of completer requested (Resource, Location)</param>
 /// <param name="invocationInfo">The <see cref="System.Management.Automation.InvocationInfo" /> from the cmdlet</param>
 /// <param name="correlationId">The <see cref="string" /> containing the correlation id for the cmdlet (if available)</param>
 /// <param name="resourceTypes">An <see cref="System.String[]"/> containing resource (or resource types) being completed  </param >
 /// <param name="parentResourceParameterNames"> An <see cref="System.String[]"/> containing list of parent resource parameter names (if applicable)</param >
 /// <returns>A <see cref="System.String[]"/> containing the valid options for the completer.</returns>
 public string[] CompleteArgument(string completerName, System.Management.Automation.InvocationInfo invocationInfo, string correlationId, string[] resourceTypes, string[] parentResourceParameterNames)
 {
     return(new string[] { "" });
 }
Ejemplo n.º 25
0
 /// <summary>Gets parameters from a common module.</summary>
 /// <param name="invocationInfo">The <see cref="System.Management.Automation.InvocationInfo" /> from the cmdlet</param>
 /// <param name="correlationId">the cmdlet's correlation id.</param>
 /// <param name="parameterName">The name of the parameter to get the value for.</param>
 /// <returns>
 /// The parameter value from the common module. (Note: this should be type converted on the way back)
 /// </returns>
 public object GetParameter(System.Management.Automation.InvocationInfo invocationInfo, string correlationId, string parameterName) => GetParameterValue?.Invoke(ResourceId, Name, invocationInfo, correlationId, parameterName);
Ejemplo n.º 26
0
 internal PSDebugContext(System.Management.Automation.InvocationInfo invocationInfo, List <Breakpoint> breakpoints)
 {
     this.InvocationInfo = invocationInfo;
     this.Breakpoints    = breakpoints.ToArray();
 }
Ejemplo n.º 27
0
 internal CallStackFrame(System.Management.Automation.Language.FunctionContext functionContext, System.Management.Automation.InvocationInfo invocationInfo)
 {
     this.InvocationInfo   = invocationInfo;
     this._functionContext = functionContext;
     this.Position         = functionContext.CurrentPosition;
 }
Ejemplo n.º 28
0
 internal ScriptBlockInvocationEventArgs(System.Management.Automation.ScriptBlock scriptBlock, bool useLocalScope, System.Management.Automation.ScriptBlock.ErrorHandlingBehavior errorHandlingBehavior, object dollarUnder, object input, object scriptThis, Pipe outputPipe, System.Management.Automation.InvocationInfo invocationInfo, params object[] args)
 {
     if (scriptBlock == null)
     {
         throw PSTraceSource.NewArgumentNullException("scriptBlock");
     }
     this.ScriptBlock           = scriptBlock;
     this.OutputPipe            = outputPipe;
     this.UseLocalScope         = useLocalScope;
     this.ErrorHandlingBehavior = errorHandlingBehavior;
     this.DollarUnder           = dollarUnder;
     this.Input          = input;
     this.ScriptThis     = scriptThis;
     this.InvocationInfo = invocationInfo;
     this.Args           = args;
 }