コード例 #1
0
        public override void Invoke()
        {
            if (string.IsNullOrEmpty(Address) && !Value.HasValue)
            {
                WriteLine("Missing Task reference address or state value..." + Environment.NewLine);
                return;
            }

            ulong stateFlag = Value.GetValueOrDefault();

            // access the Task state field if the flag is not given as a parameter
            if (!Value.HasValue)
            {
                // skip 0x or leading 0000 if needed
                if (Address.StartsWith("0x"))
                {
                    Address = Address.Substring(2);
                }
                Address = Address.TrimStart('0');

                if (!ulong.TryParse(Address, System.Globalization.NumberStyles.HexNumber, System.Globalization.CultureInfo.InvariantCulture, out var address))
                {
                    WriteLine("Numeric value expected: either a task address or -v <state value>..." + Environment.NewLine);
                    return;
                }

                // check if it is a task address
                stateFlag = Helper.GetTaskStateFromAddress(address);
                if (stateFlag == 0)
                {
                    WriteLine("Either a valid task address or -v <state value> is expected..." + Environment.NewLine);
                    return;
                }
            }

            string state = ClrMDHelper.GetTaskState(stateFlag);

            if (state != null)
            {
                WriteLine(state);
            }
            else
            {
                WriteLine("Either a task address or a valid state is expected..." + Environment.NewLine);
            }

            WriteLine("");
        }
コード例 #2
0
        public override void Invoke()
        {
            if (string.IsNullOrEmpty(Address) && !Value.HasValue)
            {
                WriteLine("Missing Task reference address or state value..." + Environment.NewLine);
                return;
            }

            ulong stateFlag = Value.GetValueOrDefault();

            // access the Task state field if the flag is not given as a parameter
            if (!Value.HasValue)
            {
                if (!TryParseAddress(Address, out var address))
                {
                    WriteLine("Numeric value expected: either a task address or -v <state value>..." + Environment.NewLine);
                    return;
                }

                // check if it is a task address
                stateFlag = Helper.GetTaskStateFromAddress(address);
                if (stateFlag == 0)
                {
                    WriteLine("Either a valid task address or -v <state value> is expected..." + Environment.NewLine);
                    return;
                }
            }

            string state = ClrMDHelper.GetTaskState(stateFlag);

            if (state != null)
            {
                WriteLine(state);
            }
            else
            {
                WriteLine("Either a task address or a valid state is expected..." + Environment.NewLine);
            }

            WriteLine("");
        }