Пример #1
0
        /// <summary>
        /// Gets the <see cref="Example"/> with the given flags.
        /// </summary>
        /// <param name="flags">The flags for the example.</param>
        /// <returns>The <see cref="Example"/>.</returns>
        /// <remarks>Ignores unsupported flags.</remarks>
        private Example GetExample(ExampleFlags flags)
        {
            this.EnsureInitialized();

            // ignore flags we don't support
            flags = FilterFlags(flags);

            if (!examples.TryGetValue(flags, out var example))
            {
                example = GetDefaultExample();

                if (flags.HasFlag(ExampleFlags.Transpose))
                {
                    example.Model.Transpose();
                }

                if (flags.HasFlag(ExampleFlags.Reverse))
                {
                    example.Model.ReverseAllAxes();
                }

                examples[flags] = example;
            }

            return(example);
        }
Пример #2
0
        public void FlagTest(ExampleFlags flags)
        {
            string c = flags.C?.Name;

            Console.WriteLine($"A: {flags.A}");
            Console.WriteLine($"B: {flags.B}");
            Console.WriteLine($"C: {(c == null ? "null" : c)}");
            Console.WriteLine($"D: {flags.D}");
        }
Пример #3
0
        /// <summary>
        /// Initializes this instance if it is not already initialized.
        /// </summary>
        private void EnsureInitialized()
        {
            if (this.initialized)
            {
                return;
            }

            this.initialized = true;
            this.examples    = new Dictionary <ExampleFlags, Example>();

            this.Example = GetDefaultExample();

            this.exampleSupport = PrepareFlags(this.Example.Model?.IsTransposable() == true, this.Example.Model?.IsReversible() == true);

            // remember the 'default' model: loads the transposed/reversed ones as we need them
            this.examples.Add(PrepareFlags(false, false), this.Example);
        }
Пример #4
0
 /// <summary>
 /// Filters unsupported flags from the given flags.
 /// </summary>
 /// <param name="flags">The original set of flags.</param>
 /// <returns>The filtered flags.</returns>
 private ExampleFlags FilterFlags(ExampleFlags flags)
 {
     return(flags & exampleSupport);
 }
Пример #5
0
 /// <summary>
 /// Gets the <see cref="IPlotController"/> for the example with the given flags.
 /// </summary>
 /// <param name="flags">The flags for the example.</param>
 /// <returns>The <see cref="IPlotController"/>.</returns>
 /// <remarks>Ignores unsupported flags.</remarks>
 public IPlotController GetController(ExampleFlags flags)
 {
     return(this.GetExample(flags).Controller);
 }
Пример #6
0
 /// <summary>
 /// Gets the <see cref="PlotModel"/> for the example with the given flags.
 /// </summary>
 /// <param name="flags">The flags for the example.</param>
 /// <returns>The <see cref="PlotModel"/>.</returns>
 /// <remarks>Ignores unsupported flags.</remarks>
 public PlotModel GetModel(ExampleFlags flags)
 {
     return(this.GetExample(flags).Model);
 }
Пример #7
0
 /// <summary>
 /// Gets the code for the example with the given flags.
 /// </summary>
 /// <param name="flags">The flags for the example.</param>
 /// <returns>Code that produces the example.</returns>
 /// <remarks>Ignores unsupported flags.</remarks>
 public string GetCode(ExampleFlags flags)
 {
     return(this.GetModel(flags)?.ToCode());
 }
Пример #8
0
 public void Test(ExampleFlags flags, ExampleFlags flags2)
 {
     Console.WriteLine(flags.A);
 }
Пример #9
0
 public void Test([AllowSpaces] string test, ExampleFlags flags)
 {
     Console.WriteLine(flags.A);
 }
Пример #10
0
 public void Test(ExampleFlags flags, int optional = 0)
 {
     Console.WriteLine(flags.A);
 }