Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ContentEncoding.cs
1using System.Collections.Generic;
2using System.Threading.Tasks;
7using Waher.Things;
10
12{
17 {
22 : base(null, null)
23 {
24 this.Method = string.Empty;
25 this.Dynamic = true;
26 this.Static = true;
27 }
28
38 : base(Source, Parent)
39 {
40 this.Method = Method;
41 this.Dynamic = Dynamic;
42 this.Static = Static;
43 }
44
48 [Page(7, "Configuration")]
49 [Header(6, "Method:")]
50 [ToolTip(47, "Content-Encoding method to configure.")]
51 [Required]
52 public string Method { get; set; }
53
57 [Page(7, "Configuration")]
58 [Header(55, "Dynamic content.")]
59 [ToolTip(65, "If dynamically generated content can be compressed using this method.")]
60 public bool Dynamic { get; set; }
61
65 [Page(7, "Configuration")]
66 [Header(66, "Static content.")]
67 [ToolTip(67, "If static content can be compressed using this method.")]
68 public bool Static { get; set; }
69
73 public override string NodeId => this.Method;
74
79 public override Task<string> GetTypeNameAsync(Language Language) => Language.GetStringAsync(typeof(GatewayConfigSource), 68, "Content-Encoding");
80
86 public override Task<bool> AcceptsParentAsync(INode Parent)
87 {
88 return Task.FromResult(Parent is WebServer);
89 }
90
97 public override async Task<IEnumerable<Parameter>> GetDisplayableParametersAsync(Language Language, RequestOrigin Caller)
98 {
99 LinkedList<Parameter> Parameters = new LinkedList<Parameter>();
101
102 Parameters.AddLast(new StringParameter("Method", await Namespace.GetStringAsync(69, "Method"), this.Method));
103 Parameters.AddLast(new BooleanParameter("Dynamic", await Namespace.GetStringAsync(70, "Dynamic"), this.Dynamic));
104 Parameters.AddLast(new BooleanParameter("Static", await Namespace.GetStringAsync(71, "Static"), this.Static));
105
106 return Parameters;
107 }
108
112 public override Task UpdateAsync()
113 {
114 IContentEncoding Encoding = Types.FindBest<IContentEncoding, string>(this.Method);
115
116 Encoding?.ConfigureSupport(this.Dynamic, this.Static);
118
119 return base.UpdateAsync();
120 }
121 }
122}
Accept-Encoding HTTP Field header. (RFC 2616, §14.3)
static void ContentEncodingsReconfigured()
If Content-Encodings have been reconfigured.
Static class that dynamically manages types and interfaces available in the runtime environment.
Definition: Types.cs:14
Contains information about a language.
Definition: Language.cs:17
Task< string > GetStringAsync(Type Type, int Id, string Default)
Gets the string value of a string ID. If no such string exists, a string is created with the default ...
Definition: Language.cs:209
async Task< Namespace > GetNamespaceAsync(string Name)
Gets the namespace object, given its name, if available.
Definition: Language.cs:99
Contains information about a namespace in a language.
Definition: Namespace.cs:17
Task< LanguageString > GetStringAsync(int Id)
Gets the string object, given its ID, if available.
Definition: Namespace.cs:65
Abstract base class for gateway configuration nodes.
virtual INode Parent
Parent Node, or null if a root node.
GatewayConfigSource Source
Source hosting the node.
Configures a Content-Encoding in the web server.
override Task UpdateAsync()
Updates the node (in persisted storage).
bool Static
If dynamically generated content can be compressed using this method.
bool Dynamic
If dynamically generated content can be compressed using this method.
override Task< bool > AcceptsParentAsync(INode Parent)
If the node accepts a presumptive parent, i.e. can be added to that parent (if that parent accepts th...
override async Task< IEnumerable< Parameter > > GetDisplayableParametersAsync(Language Language, RequestOrigin Caller)
Gets displayable parameters.
ContentEncoding()
Configures a Content-Encoding in the web server.
override Task< string > GetTypeNameAsync(Language Language)
Gets the type name of the node.
ContentEncoding(GatewayConfigSource Source, WebServer Parent, string Method, bool Dynamic, bool Static)
Configures a Content-Encoding in the web server.
Tokens available in request.
Definition: RequestOrigin.cs:9
Interface for content encodings in HTTP transfers.
void ConfigureSupport(bool Dynamic, bool Static)
Configures support for the algorithm.
Interface for nodes that are published through the concentrator interface.
Definition: INode.cs:49