2using System.Collections.Generic;
3using System.Reflection;
5using System.Threading.Tasks;
25 private string owner =
string.Empty;
26 private bool provisioned =
false;
27 private bool isPublic =
false;
40 [
Page(18,
"Provisioning", 50)]
41 [Header(19,
"Provision node.")]
42 [ToolTip(20,
"If checked, the node will be registered in the Thing Registry (if available), and access rights will be controlled by the corresponding owner (if a Provisioning Server is available).")]
46 get => this.provisioned;
49 if (this.provisioned && !value && !
string.IsNullOrEmpty(this.owner))
50 throw new Exception(
"Device is owned by " + this.owner +
". Device must be disowned first.");
52 this.provisioned = value;
59 [
Page(18,
"Provisioning", 50)]
60 [Header(21,
"Owner:")]
61 [ToolTip(22,
"Communication address of owner.")]
62 [DefaultValueStringEmpty]
69 if (this.provisioned && !
string.IsNullOrEmpty(this.owner) && this.owner != value)
70 throw new Exception(
"Device is owned by " + this.owner +
". Device must be disowned first.");
79 [
Page(18,
"Provisioning", 50)]
80 [Header(23,
"Public node.")]
81 [ToolTip(24,
"If the node is registered as a public node in the Thing Registry.")]
89 if (this.provisioned && !value && this.isPublic && !
string.IsNullOrEmpty(this.owner))
90 throw new Exception(
"Device is owned by " + this.owner +
". Device must be disowned first.");
92 this.isPublic = value;
104 public override string Owner => this.owner;
119 LinkedList<Parameter> Result = await base.GetDisplayableParametersAsync(
Language, Caller) as LinkedList<Parameter>;
123 if (this.provisioned)
145 return Task.CompletedTask;
153 this.owner =
string.Empty;
154 this.isPublic =
false;
159 return Task.CompletedTask;
167 this.isPublic =
false;
172 return Task.CompletedTask;
192 if (!
string.IsNullOrEmpty(s))
201 Type T = Obj.GetType();
202 PropertyInfo PI = T.GetRuntimeProperty(
"BareJID");
203 string BareJid = PI?.GetValue(Obj) as string;
205 if (
string.IsNullOrEmpty(BareJid))
208 StringBuilder sb =
new StringBuilder();
210 sb.Append(
"iotdisco:JID=");
211 sb.Append(Uri.EscapeDataString(BareJid));
213 sb.Append(Uri.EscapeDataString(
this.NodeId));
215 sb.Append(Uri.EscapeDataString(
this.SourceId));
217 if (!
string.IsNullOrEmpty(this.
Partition))
220 sb.Append(Uri.EscapeDataString(
this.Partition));
223 return sb.ToString();
232 if (this.provisioned &&
string.IsNullOrEmpty(this.owner))
235 if (!
string.IsNullOrEmpty(Uri))
242 new string[] { Uri },
null, await
Namespace.
GetStringAsync(95,
"The owner can use this URI to claim ownership of the node."),
243 null,
null,
null,
false,
true,
false)
258 if (!
string.IsNullOrEmpty(e.
Url))
const string ContentTypePng
image/png
Class managing a page in a data form layout.
Static class that dynamically manages types and interfaces available in the runtime environment.
static bool TryGetModuleParameter(string Name, out object Value)
Tries to get a module parameter value.
Contains information about a language.
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 ...
async Task< Namespace > GetNamespaceAsync(string Name)
Gets the namespace object, given its name, if available.
Contains information about a namespace in a language.
Task< LanguageString > GetStringAsync(int Id)
Gets the string object, given its ID, if available.
Basic access point for runtime language localization.
static async Task< Language > GetLanguageAsync(string Code)
Gets the languge object, given its language code, if available.
Static class managing persistent settings.
static async Task< string > GetAsync(string Key, string DefaultValue)
Gets a string-valued setting.
Boolean-valued parameter.
Event arguments for events that request an URL to a QR code.
virtual async Task NodeUpdated()
Persists changes to the node, and generates a node updated event.
Guid ObjectId
Object ID in persistence layer.
string SourceId
Optional ID of source containing node.
string Partition
Optional partition in which the Node ID is unique.
Defines the Metering Topology data source. This data source contains a tree structure of persistent r...
Base class for all provisioned metering nodes.
bool Public
If the node is public in the regitry or not.
bool Provisioned
If the node is provisioned is not. Property is editable.
ProvisionedMeteringNode()
Base class for all provisioned metering nodes.
override Task Disowned()
Called when node has been disowned by its owner.
virtual async Task AnnotatePropertyForm(FormState Form)
Annotates the property form.
override Task Removed()
Called when node has been removed from the registry.
override Task Claimed(string Owner, bool IsPublic)
Called when node has been claimed by an owner.
override async Task< IEnumerable< Parameter > > GetDisplayableParametersAsync(Language Language, RequestOrigin Caller)
Gets displayable parameters.
string OwnerAddress
If the node is provisioned is not. Property is editable.
static EventHandlerAsync< GetQrCodeUrlEventArgs > QrCodeUrlRequested
Event raised when a QR code URL is requested.
override string Owner
Who the owner of the node is. The empty string means the node has no owner.
Task< string > GetDiscoUri()
Gets a discovery URI for the thing.
override bool IsProvisioned
If node can be provisioned.
override bool IsPublic
If the node is public.
async Task< string > GetDiscoUri(bool OnlyClaim)
Gets a discovery URI for the thing.
Tokens available in request.