/// <summary>
        /// Creates an instance of the BreakpointDetails class from a
        /// PowerShell Breakpoint object.
        /// </summary>
        /// <param name="breakpoint">The Breakpoint instance from which details will be taken.</param>
        /// <param name="updateType">The BreakpointUpdateType to determine if the breakpoint is verified.</param>
        /// <returns>A new instance of the BreakpointDetails class.</returns>
        internal static BreakpointDetails Create(
            Breakpoint breakpoint,
            BreakpointUpdateType updateType = BreakpointUpdateType.Set)
        {
            Validate.IsNotNull("breakpoint", breakpoint);

            if (!(breakpoint is LineBreakpoint lineBreakpoint))
            {
                throw new ArgumentException(
                          "Unexpected breakpoint type: " + breakpoint.GetType().Name);
            }

            var breakpointDetails = new BreakpointDetails
            {
                Id           = breakpoint.Id,
                Verified     = updateType != BreakpointUpdateType.Disabled,
                Source       = lineBreakpoint.Script,
                LineNumber   = lineBreakpoint.Line,
                ColumnNumber = lineBreakpoint.Column,
                Condition    = lineBreakpoint.Action?.ToString()
            };

            if (lineBreakpoint.Column > 0)
            {
                breakpointDetails.ColumnNumber = lineBreakpoint.Column;
            }

            return(breakpointDetails);
        }
Exemple #2
0
        /// <summary>
        /// Creates an instance of the BreakpointDetails class from a
        /// PowerShell Breakpoint object.
        /// </summary>
        /// <param name="breakpoint">The Breakpoint instance from which details will be taken.</param>
        /// <returns>A new instance of the BreakpointDetails class.</returns>
        public static BreakpointDetails Create(Breakpoint breakpoint)
        {
            Validate.IsNotNull("breakpoint", breakpoint);

            LineBreakpoint lineBreakpoint = breakpoint as LineBreakpoint;

            if (lineBreakpoint == null)
            {
                throw new ArgumentException(
                          "Unexpected breakpoint type: " + breakpoint.GetType().Name);
            }

            var breakpointDetails = new BreakpointDetails
            {
                Verified   = true,
                Source     = lineBreakpoint.Script,
                LineNumber = lineBreakpoint.Line,
                Condition  = lineBreakpoint.Action?.ToString()
            };

            if (lineBreakpoint.Column > 0)
            {
                breakpointDetails.ColumnNumber = lineBreakpoint.Column;
            }

            return(breakpointDetails);
        }
        /// <summary>
        /// Creates an instance of the <see cref="CommandBreakpointDetails"/> class from a
        /// PowerShell CommandBreakpoint object.
        /// </summary>
        /// <param name="breakpoint">The Breakpoint instance from which details will be taken.</param>
        /// <returns>A new instance of the BreakpointDetails class.</returns>
        internal static CommandBreakpointDetails Create(Breakpoint breakpoint)
        {
            Validate.IsNotNull(nameof(breakpoint), breakpoint);

            if (breakpoint is not CommandBreakpoint commandBreakpoint)
            {
                throw new ArgumentException(
                          "Unexpected breakpoint type: " + breakpoint.GetType().Name);
            }

            return(new()
            {
                Verified = true,
                Name = commandBreakpoint.Command,
                Condition = commandBreakpoint.Action?.ToString()
            });
        }
        /// <summary>
        /// Creates an instance of the <see cref="CommandBreakpointDetails"/> class from a
        /// PowerShell CommandBreakpoint object.
        /// </summary>
        /// <param name="breakpoint">The Breakpoint instance from which details will be taken.</param>
        /// <returns>A new instance of the BreakpointDetails class.</returns>
        public static CommandBreakpointDetails Create(Breakpoint breakpoint)
        {
            Validate.IsNotNull("breakpoint", breakpoint);

            if (!(breakpoint is CommandBreakpoint commandBreakpoint))
            {
                throw new ArgumentException(
                          "Unexpected breakpoint type: " + breakpoint.GetType().Name);
            }

            var breakpointDetails = new CommandBreakpointDetails {
                Verified  = true,
                Name      = commandBreakpoint.Command,
                Condition = commandBreakpoint.Action?.ToString()
            };

            return(breakpointDetails);
        }
Exemple #5
0
        /// <summary>
        /// Creates an instance of the BreakpointDetails class from a
        /// PowerShell Breakpoint object.
        /// </summary>
        /// <param name="breakpoint">The Breakpoint instance from which details will be taken.</param>
        /// <returns>A new instance of the BreakpointDetails class.</returns>
        public static BreakpointDetails Create(Breakpoint breakpoint)
        {
            Validate.IsNotNull("breakpoint", breakpoint);

            LineBreakpoint lineBreakpoint = breakpoint as LineBreakpoint;

            if (lineBreakpoint != null)
            {
                return(new BreakpointDetails
                {
                    LineNumber = lineBreakpoint.Line
                });
            }
            else
            {
                throw new ArgumentException(
                          "Expected breakpoint type:" + breakpoint.GetType().Name);
            }
        }