Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
McpRangeParameterAttribute.cs
2using System.Text;
3using Waher.Script;
4
6{
11 {
18 : base(Title, Description)
19 {
20 this.MinValue = null;
21 this.MaxValue = null;
22 }
23
32 object? MinValue, object? MaxValue)
33 : base(Title, Description)
34 {
35 this.MinValue = MinValue;
36 this.MaxValue = MaxValue;
37 }
38
42 public object? MinValue { get; }
43
47 public object? MaxValue { get; }
48
53 public override void Annotate(Dictionary<string, object?> Schema)
54 {
55 base.Annotate(Schema);
56
57 if (!(this.MinValue is null))
58 Schema["minimum"] = this.MinValue;
59
60 if (!(this.MaxValue is null))
61 Schema["maximum"] = this.MaxValue;
62 }
63
67 public override string AnnotatedDescription
68 {
69 get
70 {
71 StringBuilder sb = new StringBuilder();
72
73 sb.Append(base.AnnotatedDescription);
74
75 if (this.MinValue is null)
76 sb.Append(" \\(∞");
77 else
78 {
79 sb.Append(" \\[`");
80 sb.Append(Expression.ToExpressionString(this.MinValue));
81 sb.Append('`');
82 }
83
84 sb.Append(',');
85
86 if (this.MaxValue is null)
87 sb.Append("∞\\)");
88 else
89 {
90 sb.Append('`');
91 sb.Append(Expression.ToExpressionString(this.MaxValue));
92 sb.Append("`\\]");
93 }
94
95 return sb.ToString();
96 }
97 }
98
103 public override void GetHtmlInputAttributes(Dictionary<string, string> Attributes)
104 {
105 if (!(this.MinValue is null))
106 Attributes["min"] = this.GetHtmlAttributeValue(this.MinValue);
107
108 if (!(this.MaxValue is null))
109 Attributes["max"] = this.GetHtmlAttributeValue(this.MaxValue);
110 }
111 }
112}
virtual string GetHtmlAttributeValue(object Value)
Gets the HTML attribute value for a parameter, if any.
Abstract base class for MCP-parameters that have a range of valid values.
override void Annotate(Dictionary< string, object?> Schema)
Annotates a schema object with information in the attribute.
McpRangeParameterAttribute(string? Title, string? Description)
Abstract base class for MCP-parameters that have a range of valid values.
override string AnnotatedDescription
Annotated description of parameter.
McpRangeParameterAttribute(string? Title, string? Description, object? MinValue, object? MaxValue)
Abstract base class for MCP-parameters that have a range of valid values.
override void GetHtmlInputAttributes(Dictionary< string, string > Attributes)
Gets HTML input attributes for the parameter, if any.
Class managing a script expression.
Definition: Expression.cs:41
static string ToExpressionString(object Value)
Converts an object to a string, that can be parsed as part of an expression.
Definition: Expression.cs:5052