Пример #1
0
        /// <summary>Determines whether the specified property null handling is nullable.</summary>
        /// <param name="nullHandling">The property null handling.</param>
        /// <returns></returns>
        public override bool IsNullable(NullHandling nullHandling)
        {
            if (nullHandling == NullHandling.Swagger)
                return IsRequired == false;

            return base.IsNullable(nullHandling);
        }
Пример #2
0
 internal InstanceProvider(Delegate del, TypeInfo forType, ImmutableArray <InstanceProvider> fallbacks, NullHandling nullability)
 {
     Delegate.Value        = del;
     ConstructsType        = forType;
     ConstructsNullability = nullability;
     _Fallbacks            = fallbacks;
 }
Пример #3
0
 internal InstanceProvider(MethodInfo mtd, TypeInfo forType, ImmutableArray <InstanceProvider> fallbacks, NullHandling nullability, TypeInfo?aheadOfTimeGeneratedType)
 {
     Method.Value          = mtd;
     ConstructsType        = forType;
     ConstructsNullability = nullability;
     _Fallbacks            = fallbacks;
     AheadOfTimeGeneratedType.SetAllowNull(aheadOfTimeGeneratedType);
 }
Пример #4
0
        /// <summary>Gets a value indicating whether the validated data can be null.</summary>
        public virtual bool IsNullable(NullHandling nullHandling)
        {
            if (Type.HasFlag(JsonObjectType.Null) && OneOf.Count == 0)
            {
                return(true);
            }

            return((Type == JsonObjectType.None || Type.HasFlag(JsonObjectType.Null)) && OneOf.Any(o => o.IsNullable(nullHandling)));
        }
Пример #5
0
        internal InstanceProvider(ConstructorInfo cons, ImmutableArray <InstanceProvider> fallbacks, NullHandling nullability, TypeInfo?aheadOfTimeGeneratedType)
        {
            Constructor.Value     = cons;
            ConstructsType        = cons.DeclaringTypeNonNull();
            ConstructsNullability = nullability;            // this isn't _always_ CannotBeNull because there might be fallbacks
            _Fallbacks            = fallbacks;

            AheadOfTimeGeneratedType.SetAllowNull(aheadOfTimeGeneratedType);
        }
Пример #6
0
        /// <summary>Determines whether the specified property null handling is nullable.</summary>
        /// <param name="nullHandling">The property null handling.</param>
        /// <returns></returns>
        public override bool IsNullable(NullHandling nullHandling)
        {
            if (nullHandling == NullHandling.Swagger)
            {
                return(IsRequired == false);
            }

            return(base.IsNullable(nullHandling));
        }
Пример #7
0
 public static string WrapInParens(this string str, NullHandling handling)
 {
     if (str == null && handling == NullHandling.EmptyString)
     {
         return(string.Empty);
     }
     else
     {
         return($"({str.NullToNull(handling)})");
     }
 }
Пример #8
0
 public static string WrapInSquareBrackets(this string str, NullHandling handling)
 {
     if (str == null && handling == NullHandling.EmptyString)
     {
         return(string.Empty);
     }
     else
     {
         return($"[{str.NullToNull(handling)}]");
     }
 }
Пример #9
0
 public static string WrapInBraces(this string str, NullHandling handling)
 {
     if (str == null && handling == NullHandling.EmptyString)
     {
         return(string.Empty);
     }
     else
     {
         return($"{{{str.NullToNull(handling)}}}");
     }
 }
Пример #10
0
        /// <summary>Determines whether the specified null handling is nullable.</summary>
        /// <param name="nullHandling">The null handling.</param>
        /// <returns>The result.</returns>
        public bool IsNullable(NullHandling nullHandling)
        {
            if (nullHandling == NullHandling.Swagger)
            {
                if (IsNullableRaw == null)
                    return false;

                return IsNullableRaw.Value;
            }

            return Schema?.ActualSchema.IsNullable(nullHandling) ?? false;
        }
Пример #11
0
        /// <summary>Gets a value indicating whether the validated data can be null.</summary>
        /// <param name="nullHandling">The null handling.</param>
        /// <returns>The result.</returns>
        public override bool IsNullable(NullHandling nullHandling)
        {
            if (nullHandling == NullHandling.Swagger)
            {
                if (IsNullableRaw == null)
                    return IsRequired == false;

                return IsNullableRaw.Value;
            }

            return base.IsNullable(nullHandling);
        }
Пример #12
0
        /// <summary>Determines whether the specified null handling is nullable.</summary>
        /// <param name="nullHandling">The null handling.</param>
        /// <param name="fallbackValue">The fallback value when 'x-nullable' is not defined.</param>
        /// <returns>The result.</returns>
        public bool IsNullable(NullHandling nullHandling, bool fallbackValue)
        {
            if (nullHandling == NullHandling.Swagger)
            {
                if (IsNullableRaw == null)
                {
                    return(fallbackValue);
                }

                return(IsNullableRaw.Value);
            }

            return(Schema?.ActualSchema.IsNullable(nullHandling) ?? false);
        }
Пример #13
0
        /// <summary>Determines whether the specified property null handling is nullable.</summary>
        /// <param name="nullHandling">The property null handling.</param>
        /// <returns></returns>
        public override bool IsNullable(NullHandling nullHandling)
        {
            if (IsEnumeration && Enumeration.Contains(null))
            {
                return(true);
            }

            if (nullHandling == NullHandling.Swagger)
            {
                return(IsRequired == false);
            }

            return(base.IsNullable(nullHandling));
        }
Пример #14
0
        /// <summary>If the input is null, returns "null". Otherwise, returns the input.</summary>
        public static string NullToNull(this string str, NullHandling handling)
        {
            if (str == null)
            {
                switch (handling)
                {
                case NullHandling.EmptyContent:
                case NullHandling.EmptyString:
                    return(string.Empty);

                case NullHandling.LiteralNull:
                    return("null");

                case NullHandling.None:
                default:
                    return(null);
                }
            }
            return(str);
        }
Пример #15
0
        /// <summary>Resolves the type of the dictionary value of the given schema (must be a dictionary schema).</summary>
        /// <param name="schema">The schema.</param>
        /// <param name="fallbackType">The fallback type (e.g. 'object').</param>
        /// <param name="nullHandling">The null handling.</param>
        /// <returns>The type.</returns>
        protected string ResolveDictionaryValueType(JsonSchema4 schema, string fallbackType, NullHandling nullHandling)
        {
            if (schema.AdditionalPropertiesSchema != null)
            {
                return(Resolve(schema.AdditionalPropertiesSchema, schema.AdditionalPropertiesSchema.ActualSchema.IsNullable(nullHandling), null));
            }

            if (schema.AllowAdditionalProperties == false && schema.PatternProperties.Any())
            {
                var valueTypes = schema.PatternProperties
                                 .Select(p => Resolve(p.Value, p.Value.IsNullable(nullHandling), null))
                                 .Distinct()
                                 .ToList();

                if (valueTypes.Count == 1)
                {
                    return(valueTypes.First());
                }
            }

            return(fallbackType);
        }
Пример #16
0
 /// <summary>Determines whether the specified null handling is nullable (fallback value: false).</summary>
 /// <param name="nullHandling">The null handling.</param>
 /// <returns>The result.</returns>
 public bool IsNullable(NullHandling nullHandling)
 {
     return(IsNullable(nullHandling, false));
 }
Пример #17
0
 public static StringBuilder AppendNullAware(this StringBuilder builder, string appendMe, NullHandling handling)
 => builder.Append(appendMe.NullToNull(handling));
Пример #18
0
 public static StringBuilder AppendInParens(this StringBuilder builder, string appendMe, NullHandling handling)
 => builder.Append(appendMe.WrapInParens(handling));
Пример #19
0
 public static StringBuilder AppendInSquareBrackets(this StringBuilder builder, IStringValue appendMe, NullHandling handling)
 => builder.AppendInSquareBrackets(appendMe?.StringValue, handling);
Пример #20
0
 public static StringBuilder AppendNullAware(this StringBuilder builder, IStringValue appendMe, NullHandling handling)
 => builder.AppendNullAware(appendMe?.StringValue, handling);
    public ChartLayerAppearance AddScatterSeries(string desc_, string[] xAxis_, double[] yAxis_, Color color_, NullHandling nullHandling_ = NullHandling.DontPlot, SymbolIcon icon = SymbolIcon.Circle)
    {
      var d = new DataTable();
      d.Columns.Add("Heading", typeof(string));
      d.Columns.Add(desc_, typeof(double));

      for (int i = 0; i < xAxis_.Length; ++i)
      {
        d.LoadDataRow(!double.IsNaN(yAxis_[i]) ? new object[] {xAxis_[i], yAxis_[i]} : new object[] {xAxis_[i]}, true);
      }

      var series = new NumericSeries
      {
        Key = desc_,
        Label = desc_,
        Data =
        {
          LabelColumn = "Heading",
          ValueColumn = desc_
        }
      };
      series.PEs.Add(new PaintElement(color_));
      ultraChart.CompositeChart.Series.Add(series);

      var chart = new ChartLayerAppearance
      {
        ChartComponent = ultraChart,
        ChartArea = ultraChart.CompositeChart.ChartAreas[0],
        ChartType = ChartType.LineChart,
        Key = string.Format("{0}_chart", desc_),
      };

      chart.Series.Add(series);
      series.Data.DataSource = d;
      series.DataBind();

      chart.AxisX = chart.ChartArea.Axes.FromKey("xAxis_Line");
      chart.AxisY = chart.ChartArea.Axes.FromKey("yAxis_Line");

      var lcApp = (LineChartAppearance)chart.ChartTypeAppearance;
      {
        lcApp.EndStyle = LineCapStyle.Round;
        lcApp.DrawStyle = LineDrawStyle.Dot;
        lcApp.Thickness = 7;
        lcApp.MidPointAnchors = true;
        //lcApp.ConnectWithLines = false;
        //lcApp.Icon = icon;
        //lcApp.IconSize = SymbolIconSize.Medium;
        lcApp.NullHandling = nullHandling_;
      }

      ultraChart.CompositeChart.ChartLayers.Add(chart);

      m_datatables.Add(desc_, d);
      ultraChart.InvalidateLayers();

      return chart;
    }
Пример #22
0
 /// <summary>Initializes a new instance of the <see cref="TypeScriptDefaultValueGenerator"/> class.</summary>
 /// <param name="typeResolver">The type resolver.</param>
 /// <param name="nullHandling">The null handling.</param>
 public CSharpDefaultValueGenerator(ITypeResolver typeResolver, NullHandling nullHandling) : base(typeResolver)
 {
     _nullHandling = nullHandling;
 }
Пример #23
0
 public static string WrapInParens(this string str, NullHandling handling) =>
 str == null && handling == NullHandling.EmptyString ? string.Empty : $"({str.NullToNull(handling)})";
Пример #24
0
 public static string WrapInSquareBrackets(this string str, NullHandling handling) =>
 str == null && handling == NullHandling.EmptyString ? string.Empty : $"[{str.NullToNull(handling)}]";
Пример #25
0
 private static StringBuilder AppendIn(this StringBuilder b, char l, string?s, char r, NullHandling h) =>
 h switch
 {
Пример #26
0
    public ChartLayerAppearance AddScatterSeries(int areaIndex_, DateTime[] dates_, double[] values_, string desc_, Color color_, object nanREplaceValue_ = null, NullHandling nullHandling_ = NullHandling.Zero)
    {
      DataTable d = new DataTable();
      d.Columns.Add("Date", typeof(DateTime));
      d.Columns.Add(desc_, typeof(double));

      for (int i = 0; i < dates_.Length; ++i)
        if (double.IsNaN(values_[i]))
          d.LoadDataRow(new object[] { dates_[i], nanREplaceValue_ }, true);
        else
          d.LoadDataRow(new object[] { dates_[i], values_[i] }, true);

      ChartLayerAppearance chart;
      NumericTimeSeries series;
      ScatterChartAppearance lcApp;

      series = new NumericTimeSeries();
      series.Data.TimeValueColumn = "Date";
      series.Data.ValueColumn = desc_;
      series.Key = string.Format("{0}_{1}_sc", areaIndex_, desc_); ;
      series.Label = desc_;
      series.PEs.Add(new PaintElement(color_));
      ultraChart.CompositeChart.Series.Add(series);

      chart = new ChartLayerAppearance();
      chart.ChartComponent = ultraChart;
      chart.ChartArea = ultraChart.CompositeChart.ChartAreas[areaIndex_];
      chart.AxisX = chart.ChartArea.Axes[0];
      chart.AxisY = chart.ChartArea.Axes[1];
      chart.ChartType = ChartType.ScatterChart;
      lcApp = (ScatterChartAppearance)chart.ChartTypeAppearance;
      lcApp.ConnectWithLines = false;
      lcApp.Icon = SymbolIcon.Circle;
      lcApp.IconSize = SymbolIconSize.Medium;
      lcApp.NullHandling = nullHandling_;

      chart.Key = string.Format("{0}_{1}_sc_chart", areaIndex_, desc_);
      ultraChart.CompositeChart.ChartLayers.Add(chart);

      chart.Series.Add(series);
      series.Data.DataSource = d;
      chart.Series.Add(series);
      series.DataBind();

      dts.Add(d);
      //m_yAxisDescriptionToFormat[desc_] = yLabelFormat_;

      return chart;
    }
Пример #27
0
    public ChartLayerAppearance AddSeries(int areaIndex_, DateTime[] dates_, double[] values_, string desc_, object nanReplaceValue = null, NullHandling nullHandling_ = NullHandling.Zero, int yAxisExtent_=15, string yAxisFormat_=null)
    {
      DataTable d = new DataTable();
      d.Columns.Add("Date", typeof(DateTime));
      d.Columns.Add(desc_, typeof(double));

      for (int i = 0; i < dates_.Length; ++i)
      {
        if (double.IsNaN(values_[i]))
          d.LoadDataRow(new object[] { dates_[i], nanReplaceValue }, true);
        else
          d.LoadDataRow(new object[] { dates_[i], values_[i] }, true);
      }

      ChartLayerAppearance chart;
      NumericTimeSeries series;
      LineChartAppearance lcApp;

      series = new NumericTimeSeries();
      series.Data.TimeValueColumn = "Date";
      series.Data.ValueColumn = desc_;
      series.Key = desc_;
      series.Label = desc_;
      series.PEs.Add(new PaintElement(ColorAttribute.GetColor(ultraChart.CompositeChart.Series.Count)));
      ultraChart.CompositeChart.Series.Add(series);

      chart = new ChartLayerAppearance();
      chart.ChartComponent = ultraChart;
      chart.ChartArea = ultraChart.CompositeChart.ChartAreas[areaIndex_];
      chart.AxisX = chart.ChartArea.Axes[0];
      chart.AxisY = findYAxis(areaIndex_, yAxisExtent_, yAxisFormat_ == null ? m_yAxisLabelFormatString : yAxisFormat_);
      chart.ChartType = ChartType.LineChart;
      lcApp = (LineChartAppearance)chart.ChartTypeAppearance;
      lcApp.Thickness = 2;
      lcApp.MidPointAnchors = false;
      lcApp.NullHandling = nullHandling_;

      chart.Key = string.Format("{0}_{1}_chart_l",areaIndex_, desc_);
      ultraChart.CompositeChart.ChartLayers.Add(chart);

      chart.Series.Add(series);
      series.Data.DataSource = d;
      chart.Series.Add(series);
      series.DataBind();


      return chart;
    }
Пример #28
0
 public StringFormatExtractionFunction(string format, NullHandling nullHandling = NullHandling.nullString)
 {
     Format       = format;
     NullHandling = nullHandling;
 }
    public ChartLayerAppearance AddBottomSeries(DateTime[] dates_, double[] values_, string desc_, Color lineColor_, object nanReplaceValue = null, NullHandling nullHandling_ = NullHandling.Zero)
    {
      if (dates_ == null || dates_.Length == 0) return null;
      DataTable d = new DataTable();
      d.Columns.Add("Date", typeof(DateTime));
      d.Columns.Add(desc_, typeof(double));

      for (int i = 0; i < dates_.Length; ++i)
      {
        if (double.IsNaN(values_[i]))
          d.LoadDataRow(new object[] { dates_[i], nanReplaceValue }, true);
        else
          d.LoadDataRow(new object[] { dates_[i], values_[i] }, true);
      }

      var series = new NumericTimeSeries();
      series.Data.TimeValueColumn = "Date";
      series.Data.ValueColumn = desc_;
      series.Key = desc_;
      series.Label = desc_;
      series.PEs.Add(new PaintElement(lineColor_));
      ultraChart1.CompositeChart.Series.Add(series);

      var chart = new ChartLayerAppearance();
      chart.ChartComponent = ultraChart1;
      chart.ChartArea = ultraChart1.CompositeChart.ChartAreas.FromKey("areaBottom");
      chart.AxisX = chart.ChartArea.Axes[0];
      chart.AxisY = chart.ChartArea.Axes[1];
      chart.ChartType = ChartType.LineChart;
      var lcApp = (LineChartAppearance)chart.ChartTypeAppearance;
      lcApp.Thickness = 2;
      lcApp.MidPointAnchors = false;
      lcApp.NullHandling = nullHandling_;

      chart.Key = string.Format("{0}_chart", desc_);
      ultraChart1.CompositeChart.ChartLayers.Add(chart);

      chart.Series.Add(series);
      series.Data.DataSource = d;
      series.DataBind();

      m_datatables.Add(desc_, d);

      return chart;
    }
Пример #30
0
        private ChartLayerAppearance AddScatterSeries(DateTime[] dates_, double[] values_, string desc_, Color color_,
            int yAxisExtent_, string yLabelFormat_, object nanREplaceValue_ = null,
            NullHandling nullHandling_ = NullHandling.Zero, string[] pointLabels_ = null,
            SymbolIcon icon = SymbolIcon.Circle)
        {
            if (lineChartDataDisplay1.DataTableKeys.Contains(desc_))
                desc_ = desc_ + "(2)";

            if(ViewModel.HasTechnicals)
                return lineChartDataDisplay1.AddScatterSeries(dates_.Select(d => d.ToString("dd MMM yy")).ToArray(), values_, desc_, color_, yAxisExtent_, yLabelFormat_, nanREplaceValue_, nullHandling_, icon: icon);
            else
                return lineChartDataDisplay1.AddScatterSeries(dates_, values_, desc_, color_, yAxisExtent_, yLabelFormat_, nanREplaceValue_, nullHandling_, icon: icon);

        }
Пример #31
0
 public static string WrapInBraces(this string str, NullHandling handling) =>
 str == null && handling == NullHandling.EmptyString ? string.Empty : $"{{{str.NullToNull(handling)}}}";