Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ObjectId.cs
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace Waher.Content.Asn1
6{
10 public class ObjectId
11 {
12 private readonly uint[] segments;
13
18 public ObjectId(params uint[] Segments)
19 {
20 this.segments = Segments;
21 }
22
28 public ObjectId(ObjectId Id, params uint[] Segments)
29 {
30 int c = Id.segments.Length;
31 int d = Segments.Length;
32
33 this.segments = new uint[c + d];
34
35 Array.Copy(Id.segments, 0, this.segments, 0, c);
36 Array.Copy(Segments, 0, this.segments, c, d);
37 }
38
42 public uint[] Segments => this.segments;
43
48 public static implicit operator uint[](ObjectId Id) => Id.segments;
49
54 public static implicit operator ObjectId(uint[] Segments) => new ObjectId(Segments);
55
60 public static implicit operator ObjectId(int[] Segments) => new ObjectId(Segments);
61
66 public static implicit operator ObjectId(long[] Segments)
67 {
68 int i, c = Segments.Length;
69 uint[] Segments2 = new uint[c];
70 long l;
71
72 for (i = 0; i < c; i++)
73 {
74 l = Segments[i];
75 if (l >= uint.MinValue && l <= uint.MaxValue)
76 Segments2[i] = (uint)l;
77 else
78 {
79 throw new ArgumentOutOfRangeException(nameof(Segments),
80 "Segments must be within the range of 32-bit integers.");
81 }
82 }
83
84 return new ObjectId(Segments2);
85 }
86 }
87}
Generic array.
Definition: Array.cs:12
ASN.1 Object identifier
Definition: ObjectId.cs:11
uint[] Segments
Segments of Object Identifier
Definition: ObjectId.cs:42
ObjectId(params uint[] Segments)
ASN.1 Object identifier
Definition: ObjectId.cs:18
ObjectId(ObjectId Id, params uint[] Segments)
ASN.1 Object identifier
Definition: ObjectId.cs:28