コード例 #1
0
ファイル: Command.cs プロジェクト: MikeBrunoCISSP/x509Crypto
        internal string Usage(bool inCLI = false, bool onlyCommandline = false)
        {
            StringBuilder Expression = new StringBuilder(UsageExpression.Prefix);

            if (!inCLI)
            {
                Expression.Append($"{Constants.AssemblyFile} ");
            }

            Expression.Append(Name);

            if (SupportedModes.Count() > 1)
            {
                Expression.Append($" {SupportedModes.Select(p => p.Name).BarDelimited().InBrackets()}");
            }

            if (onlyCommandline)
            {
                return(Expression.ToString());
            }

            Expression.Append(UsageDetail());
            Expression.AppendLine();
            return(Expression.ToString());
        }
コード例 #2
0
ファイル: Command.cs プロジェクト: MikeBrunoCISSP/x509Crypto
        internal void GetMode(string[] args, ref int index)
        {
            if (HasDefaultMode)
            {
                SelectedMode = SupportedModes.First();
                return;
            }

            SelectedMode = SupportedModes.Find(args[index++]);
        }
コード例 #3
0
ファイル: Command.cs プロジェクト: MikeBrunoCISSP/x509Crypto
        internal string UsageDetail()
        {
            StringBuilder Expression = new StringBuilder($"\r\n{Description}");

            if (HasDefaultMode)
            {
                Expression.Append($"{Samples.Mode}\r\n{UsageExpression.AvailableModes}:");
                SupportedModes.ForEach(p => Expression.Append(p.ShowDescription(SupportedModes.Select(q => q.Name).GetPadding())));
            }

            return(Expression.ToString());
        }
コード例 #4
0
ファイル: Command.cs プロジェクト: MikeBrunoCISSP/x509Crypto
        internal string MarkdownDetail()
        {
            bool          hasDefaultMode = SupportedModes.Count == 1;
            StringBuilder Expression     = new StringBuilder($"\r\n## {Name} Command\r\n");

            if (!hasDefaultMode)
            {
                Expression.AppendLine($"{Description}\r\n\r\n**{Usage(false, true)}**\r\n");
                Expression.AppendLine(MarkdownExpression.SupportedModes);
            }
            SupportedModes.ForEach(p => Expression.AppendLine(p.Markdown(Name, hasDefaultMode)));
            return(Expression.ToString());
        }
コード例 #5
0
ファイル: GZFilter.cs プロジェクト: gabry/GZWebApplication
        public virtual void Validate(IEnumerable <GZFilterMode> allowedModes, GZFilterMode defaultMode)
        {
            if (Mode == GZFilterMode.Undefined)
            {
                if (!SupportedModes.Contains(defaultMode))
                {
                    throw new InvalidOperationException($"Default Mode {defaultMode} is not supported");
                }

                Mode = defaultMode;
            }

            if (!allowedModes.Contains(Mode))
            {
                Mode = GZFilterMode.Undefined;
            }
        }
コード例 #6
0
        /// <inheritdoc />
        public override bool Equals(object obj)
        {
            var other = obj as Mode;

            if (other == null)
            {
                return(false);
            }
            if (!base.Equals(obj))
            {
                return(false);
            }
            if (!SupportedModes.SequenceEqual(other.SupportedModes))
            {
                return(false);
            }
            if (!Modes.SequenceEqual(other.Modes))
            {
                return(false);
            }
            return(true);
        }
コード例 #7
0
        public void TestParseReforgedMapInfo(string mapInfoFilePath, bool expectCustomAbilitySkin, bool expectAccurateProbabilityForCalculations, SupportedModes expectSupportedModes, bool expectGameDataVersionTft)
        {
            using var mapInfoStream = File.OpenRead(mapInfoFilePath);
            var mapInfo = MapInfo.Parse(mapInfoStream);

            if (mapInfo.GameDataVersion == GameDataVersion.Unset)
            {
                Assert.AreEqual(GameDataSet.Unset, mapInfo.GameDataSet);
            }
            else
            {
                Assert.AreEqual(GameDataSet.Default, mapInfo.GameDataSet);
                Assert.AreEqual(expectGameDataVersionTft, mapInfo.GameDataVersion == GameDataVersion.TFT);
            }

            Assert.AreEqual(expectCustomAbilitySkin, mapInfo.MapFlags.HasFlag(MapFlags.CustomAbilitySkin));
            Assert.AreEqual(expectAccurateProbabilityForCalculations, mapInfo.MapFlags.HasFlag(MapFlags.AccurateProbabilityForCalculations));
            Assert.AreEqual(expectSupportedModes, mapInfo.SupportedModes);
        }
コード例 #8
0
        /// <summary>
        /// Checks whether the specified array of operands would provide a match to this
        /// <see cref="X86Instruction"/>.
        /// </summary>
        /// <param name="explicitOperandSize">The explicitly provided operand size of the instruction to be matched,
        /// or <see cref="DataSize.None"/>.</param>
        /// <param name="context">The <see cref="Context"/>/</param>
        /// <param name="operands">The array of <see cref="Operand"/> objects to test.</param>
        /// <returns><see langword="true"/> when the operands match this
        /// <see cref="X86Instruction"/>; otherwise, <see langword="false"/>.</returns>
        public bool Match(DataSize explicitOperandSize, Context context, IList <Operand> operands)
        {
            // Check whether the variant is valid in the current mode.
            if (!SupportedModes.HasFlag(ProcessorModes.Long) && context.AddressingMode == DataSize.Bit64)
            {
                return(false);
            }
            //if (this.operandSize != DataSize.None && this.operandSize != operandSize)
            //    return false;

            //var zipped = descriptors.Zip(operands, (d, o) => new Tuple<OperandDescriptor, Operand>(d, o));

            //// The operand descriptors that were not included in the zipped list must all be None.
            //if (descriptors.Skip(zipped.Count()).Any(d => d.OperandType != OperandType.None))
            //    return false;


            DataSize variantOperandSize = DataSize.None;
            int      j = 0;

            for (int i = 0; i < Descriptors.Count; i++)
            {
                if (Descriptors[i].OperandType == OperandType.None)
                {
                    // A None operand descriptor, which MAY correspond to a null-operand.
                    if (j < operands.Count && operands[j] == null)
                    {
                        j++;
                    }
                }
                else
                {
                    // A not-None operand descriptor, which MUST correspond to a non-null operand.
                    if (j >= operands.Count || operands[j] == null || !operands[j].IsMatch(Descriptors[i]))
                    {
                        return(false);
                    }
                    j++;
                }

                switch (Descriptors[i].OperandType)
                {
                case OperandType.RegisterOperand:
                case OperandType.RegisterOrMemoryOperand:
                    variantOperandSize = Descriptors[i].RegisterType.GetSize();
                    break;

                case OperandType.FixedRegister:
                    variantOperandSize = Descriptors[i].FixedRegister.Size;
                    break;

                default:
                    variantOperandSize = Descriptors[i].Size;
                    break;
                }
            }
            // We have more non-null operands than descriptors.
            for (; j < operands.Count; j++)
            {
                if (operands[j] != null)
                {
                    return(false);
                }
            }

            if (OperandSize != DataSize.None)
            {
                //Contract.Assume(variantOperandSize == DataSize.None || this.operandSize == variantOperandSize);
                variantOperandSize = OperandSize;
            }
            // Has the operand size been specified explicitly,
            // then test wheter it matches the operand size of this variant.
            if (explicitOperandSize != DataSize.None && explicitOperandSize != variantOperandSize)
            {
                return(false);
            }

            // All tests passed. It's a match.
            return(true);
        }