Пример #1
0
        /// <summary>
        /// Gets the integer value of the child leaf with the specified tag.
        /// Throws an exception if this EmberNode is not derived from EmberContainer.
        /// </summary>
        /// <param name="tag">The tag of the leaf whose value to return.</param>
        /// <param name="value">Received the value of the child node with the specified tag
        /// if a child leaf of type int or long exists.</param>
        /// <returns>True if a fitting child leaf exists and <paramref name="value"/>
        /// has received its value.</returns>
        public static bool GetInteger(this EmberNode node, BerTag tag, out long value)
        {
            var child = node[tag];

            if (child != null &&
                child.BerTypeNumber == BerType.Integer)
            {
                var integerLeaf = child as EmberLeaf <int>;

                if (integerLeaf != null)
                {
                    value = integerLeaf.Value;
                    return(true);
                }

                var longLeaf = child as EmberLeaf <long>;

                if (longLeaf != null)
                {
                    value = longLeaf.Value;
                    return(true);
                }
            }

            value = 0;
            return(false);
        }
 GlowStreamDescription ConvertStreamDescription(BerTag tag, XElement xml)
 {
     return(new GlowStreamDescription(
                tag,
                XmlConvert.ToInt32(xml.Element("format").Value),
                XmlConvert.ToInt32(xml.Element("offset").Value)));
 }
Пример #3
0
 /// <summary>
 /// Asserts that no node with the specified tag is already present in this container.
 /// </summary>
 protected void AssertNotPresent(BerTag tag)
 {
     if (this[tag] != null)
     {
         throw new InvalidOperationException("Node with specified tag is already present");
     }
 }
Пример #4
0
        internal override int Update()
        {
            var output      = new BerMemoryOutput();
            var implicitTag = new BerTag(BerClass.Universal, BerTypeNumber, true);

            var childrenLength = 0;

            foreach (var child in this)
            {
                childrenLength += child.IsDirty
                              ? child.Update()
                              : child.EncodedLength;
            }

            BerEncoding.EncodeTag(output, Tag.ToContainer());
            BerEncoding.EncodeLength(output, BerDefinitions.IndefiniteLength);

            BerEncoding.EncodeTag(output, implicitTag);
            BerEncoding.EncodeLength(output, BerDefinitions.IndefiniteLength);

            _encodedFrameHeader = output.ToArray();
            EncodedLength       = childrenLength + _encodedFrameHeader.Length + BerEncoding.IndefiniteLengthTerminator.Length;

            return(EncodedLength);
        }
 public AsyncContainer(BerTag tag, uint type, int length)
 {
     Tag       = tag;
     Type      = type;
     Length    = length;
     BytesRead = 0;
 }
Пример #6
0
        public override EmberNode CreateNodeFromXml(uint type, BerTag tag, XmlReader reader)
        {
            switch(type)
             {
            case GlowType.Parameter:               return new GlowParameter(tag);
            case GlowType.Command:                 return new GlowCommand(tag);
            case GlowType.Node:                    return new GlowNode(tag);
            case GlowType.ElementCollection:       return new GlowElementCollection(tag);
            case GlowType.StreamEntry:             return new GlowStreamEntry(tag);
            case GlowType.StreamCollection:        return new GlowStreamCollection(tag);
            case GlowType.StringIntegerPair:       return new GlowStringIntegerPair(tag);
            case GlowType.StringIntegerCollection: return new GlowStringIntegerCollection(tag);
            case GlowType.QualifiedNode:           return new GlowQualifiedNode(tag);
            case GlowType.QualifiedParameter:      return new GlowQualifiedParameter(tag);
            case GlowType.RootElementCollection:   return new GlowRootElementCollection(tag);
            case GlowType.StreamDescription:       return new GlowStreamDescription(tag);
            case GlowType.Matrix:                  return new GlowMatrix(tag);
            case GlowType.Target:                  return new GlowTarget(tag);
            case GlowType.Source:                  return new GlowSource(tag);
            case GlowType.Connection:              return new GlowConnection(tag);
            case GlowType.QualifiedMatrix:         return new GlowQualifiedMatrix(tag);
            case GlowType.Label:                   return new GlowLabel(tag);
            case GlowType.Function:                return new GlowFunction(tag);
            case GlowType.QualifiedFunction:       return new GlowQualifiedFunction(tag);
            case GlowType.TupleItemDescription:    return new GlowTupleItemDescription(tag);
            case GlowType.Invocation:              return new GlowInvocation(tag);
            case GlowType.InvocationResult:        return new GlowInvocationResult(tag);
            case GlowType.Template:                return new GlowTemplate(tag);
             }

             return base.CreateNodeFromXml(type, tag, reader);
        }
Пример #7
0
 public void Write(BerTag tag, bool value)
 {
     WriteOuterHeader(tag, 3);
     BerEncoding.EncodeTag(_output, new BerTag(BerType.Boolean));
     BerEncoding.EncodeLength(_output, 1);
     BerEncoding.EncodeBoolean(_output, value);
 }
Пример #8
0
 public void Write(BerTag tag, bool value)
 {
     WriteOuterHeader(tag, 3);
      BerEncoding.EncodeTag(_output, new BerTag(BerType.Boolean));
      BerEncoding.EncodeLength(_output, 1);
      BerEncoding.EncodeBoolean(_output, value);
 }
        EmberSequence ConvertTupleDescription(BerTag tag, XElement xml)
        {
            var ember = new EmberSequence(tag);

            foreach (var itemsXml in xml.Elements("TupleItemDescription"))
            {
                var glowItem = new GlowTupleItemDescription(0, GlowTags.CollectionItem);

                var typeXml = itemsXml.Element("type");
                if (typeXml != null)
                {
                    var type = ConvertParameterType(typeXml.Value);

                    if (type != null)
                    {
                        glowItem.Type = type.Value;
                    }
                }

                itemsXml.Element("name").Do(value => glowItem.Name = value);

                ember.Insert(glowItem);
            }

            return(ember);
        }
Пример #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DataElement"/> struct.
 /// </summary>
 /// <param name="class">The class.</param>
 /// <param name="pc">The PC.</param>
 /// <param name="tag">The tag.</param>
 /// <param name="content">The content.</param>
 public DataElement(BerClass @class, BerPC pc, BerTag tag, byte[] content)
     : this()
 {
     this.Class   = @class;
     this.PC      = pc;
     this.Tag     = tag;
     this.Content = content;
 }
Пример #11
0
        public static GlowValue GetValue(EmberContainer container, BerTag tag)
        {
            var node = container[tag];

            return(node != null
                ? GetValue(node)
                : null);
        }
Пример #12
0
        /// <summary>
        /// Creates a container of an application-defined type with Set semantics
        /// </summary>
        /// <param name="type">Application-defined type. BerType.ApplicationFlag can be omitted.</param>
        public static EmberSet CreateApplicationDefinedSet(BerTag tag, uint type, EmberContainer parent)
        {
            var set = new EmberSet(tag, parent)
             {
            BerTypeNumber = type | BerType.ApplicationFlag
             };

             return set;
        }
Пример #13
0
        /// <summary>
        /// Creates an EmberSequence object with the passed BerType. Convenience method
        /// to be called from an overridden CreateNodeFromXml method.
        /// </summary>
        protected EmberNode CreateSequence(uint type, BerTag tag, XmlReader reader)
        {
            var node = new EmberSequence(tag, null)
            {
                BerTypeNumber = type
            };

            return(node);
        }
Пример #14
0
        /// <summary>
        /// Creates a new instance of EmberSequence with the IsOrdered flag
        /// set to true.
        /// </summary>
        /// <param name="tag">The tag of the new EmberSequence.</param>
        /// <returns>A new instance of EmberSequence with the IsOrdered flag
        /// set to true.</returns>
        public static EmberSequence CreateOrderedSequence(BerTag tag)
        {
            var sequence = new EmberSequence(tag)
            {
                IsOrdered = true,
            };

            return(sequence);
        }
Пример #15
0
        public void Write(BerTag tag, long value)
        {
            var valueLength = BerEncoding.GetLongLength(value);

             WriteOuterHeader(tag, valueLength + 2);
             BerEncoding.EncodeTag(_output, new BerTag(BerType.Integer));
             BerEncoding.EncodeLength(_output, valueLength);
             BerEncoding.EncodeLong(_output, value, (int)valueLength);
        }
Пример #16
0
        public override EmberNode CreateNodeFromXml(uint type, BerTag tag, XmlReader reader)
        {
            switch (type)
            {
            case GlowType.Parameter:               return(new GlowParameter(tag));

            case GlowType.Command:                 return(new GlowCommand(tag));

            case GlowType.Node:                    return(new GlowNode(tag));

            case GlowType.ElementCollection:       return(new GlowElementCollection(tag));

            case GlowType.StreamEntry:             return(new GlowStreamEntry(tag));

            case GlowType.StreamCollection:        return(new GlowStreamCollection(tag));

            case GlowType.StringIntegerPair:       return(new GlowStringIntegerPair(tag));

            case GlowType.StringIntegerCollection: return(new GlowStringIntegerCollection(tag));

            case GlowType.QualifiedNode:           return(new GlowQualifiedNode(tag));

            case GlowType.QualifiedParameter:      return(new GlowQualifiedParameter(tag));

            case GlowType.RootElementCollection:   return(new GlowRootElementCollection(tag));

            case GlowType.StreamDescription:       return(new GlowStreamDescription(tag));

            case GlowType.Matrix:                  return(new GlowMatrix(tag));

            case GlowType.Target:                  return(new GlowTarget(tag));

            case GlowType.Source:                  return(new GlowSource(tag));

            case GlowType.Connection:              return(new GlowConnection(tag));

            case GlowType.QualifiedMatrix:         return(new GlowQualifiedMatrix(tag));

            case GlowType.Label:                   return(new GlowLabel(tag));

            case GlowType.Function:                return(new GlowFunction(tag));

            case GlowType.QualifiedFunction:       return(new GlowQualifiedFunction(tag));

            case GlowType.TupleItemDescription:    return(new GlowTupleItemDescription(tag));

            case GlowType.Invocation:              return(new GlowInvocation(tag));

            case GlowType.InvocationResult:        return(new GlowInvocationResult(tag));

            case GlowType.Template:                return(new GlowTemplate(tag));

            case GlowType.QualifiedTemplate:       return(new GlowQualifiedTemplate(tag));
            }

            return(base.CreateNodeFromXml(type, tag, reader));
        }
Пример #17
0
        /// <summary>
        /// Creates a new instance containing the passed <paramref name="value"/>
        /// </summary>
        /// <param name="tag">The tag of the newly created node.</param>
        /// <param name="value">The primitive value to hold.</param>
        public ObjectIdentifierEmberLeaf(BerTag tag, int[] value)
            : base(tag)
        {
            Value = (value != null && value.Length > 1)
                 ? value
                 : new int[] { 0, 0 };

            BerTypeNumber = BerType.ObjectIdentifier;
        }
Пример #18
0
        public void Write(BerTag tag, long value)
        {
            var valueLength = BerEncoding.GetLongLength(value);

            WriteOuterHeader(tag, valueLength + 2);
            BerEncoding.EncodeTag(_output, new BerTag(BerType.Integer));
            BerEncoding.EncodeLength(_output, valueLength);
            BerEncoding.EncodeLong(_output, value, (int)valueLength);
        }
Пример #19
0
        /// <summary>
        /// Creates a container of an application-defined type with Set semantics
        /// </summary>
        /// <param name="type">Application-defined type. BerType.ApplicationFlag can be omitted.</param>
        public static EmberSet CreateApplicationDefinedSet(BerTag tag, uint type, EmberContainer parent)
        {
            var set = new EmberSet(tag, parent)
            {
                BerTypeNumber = type | BerType.ApplicationFlag
            };

            return(set);
        }
Пример #20
0
        public void Write(BerTag tag, double value)
        {
            var valueOutput = new BerMemoryOutput();
            var valueLength = BerEncoding.EncodeReal(valueOutput, value);

            WriteOuterHeader(tag, valueLength + 2);
            BerEncoding.EncodeTag(_output, new BerTag(BerType.Real));
            BerEncoding.EncodeLength(_output, valueLength);
            _output.WriteBytes(valueOutput.Memory);
        }
Пример #21
0
        public void Write(BerTag tag, double value)
        {
            var valueOutput = new BerMemoryOutput();
             var valueLength = BerEncoding.EncodeReal(valueOutput, value);

             WriteOuterHeader(tag, valueLength + 2);
             BerEncoding.EncodeTag(_output, new BerTag(BerType.Real));
             BerEncoding.EncodeLength(_output, valueLength);
             _output.WriteBytes(valueOutput.Memory);
        }
Пример #22
0
        public void WriteRelativeOid(BerTag tag, int[] value)
        {
            var innerTag    = new BerTag(BerType.RelativeOid);
            var valueLength = BerEncoding.GetRelativeOidLength(value);

            WriteOuterHeader(tag, valueLength + BerEncoding.GetHeaderLength(innerTag, valueLength));
            BerEncoding.EncodeTag(_output, innerTag);
            BerEncoding.EncodeLength(_output, valueLength);
            BerEncoding.EncodeRelativeOid(_output, value);
        }
Пример #23
0
        public void Write(BerTag tag, byte[] value)
        {
            var valueLength = value.Length;
            var innerTag    = new BerTag(BerType.OctetString);

            WriteOuterHeader(tag, valueLength + BerEncoding.GetHeaderLength(innerTag, valueLength));
            BerEncoding.EncodeTag(_output, innerTag);
            BerEncoding.EncodeLength(_output, valueLength);
            _output.WriteBytes(value);
        }
Пример #24
0
        /// <summary>
        /// Creates a new instance of EmberContainer.
        /// </summary>
        /// <param name="tag">The tag of the new node.</param>
        /// <param name="parent">The parent to insert the new node into.</param>
        /// <param name="type">The BerType of the new node.</param>
        public EmberContainer(BerTag tag, EmberContainer parent, uint type)
            : base(tag)
        {
            BerTypeNumber = type;

            if (parent != null)
            {
                parent.InsertChildNode(this);
            }
        }
Пример #25
0
        /// <summary>
        /// Creates a container of an application-defined type with Sequence semantics
        /// </summary>
        /// <param name="type">Application-defined type. BerType.ApplicationFlag can be omitted.</param>
        public static EmberSequence CreateApplicationDefinedSequence(BerTag tag, uint type, EmberContainer parent, bool isOrdered = false)
        {
            var sequence = new EmberSequence(tag, parent)
            {
                BerTypeNumber = type | BerType.ApplicationFlag,
                IsOrdered     = isOrdered,
            };

            return(sequence);
        }
Пример #26
0
        /// <summary>
        /// Creates a container of an application-defined type with Sequence semantics
        /// </summary>
        /// <param name="type">Application-defined type. BerType.ApplicationFlag can be omitted.</param>
        public static EmberSequence CreateApplicationDefinedSequence(BerTag tag, uint type, EmberContainer parent, bool isOrdered = false)
        {
            var sequence = new EmberSequence(tag, parent)
             {
            BerTypeNumber = type | BerType.ApplicationFlag,
            IsOrdered = isOrdered,
             };

             return sequence;
        }
Пример #27
0
        /// <summary>
        /// Gets the value of the child leaf with the specified tag.
        /// Throws an exception if this EmberNode is not derived from EmberContainer or
        /// if no child node of type EmberLeaf&lt;TValue&gt; with the specified tag exists.
        /// It is strongly recommended to use type specific methods such as GetInteger(),
        /// GetDateTime() etc. Only use this method if there is no specialized
        /// method for the type you want to get.
        /// </summary>
        /// <typeparam name="TValue">The type of the leaf value to get.</typeparam>
        /// <param name="tag">The tag of the leaf whose value to return.</param>
        /// <returns>The value of the child node with the specified tag.</returns>
        public static TValue Get <TValue>(this EmberNode node, BerTag tag)
        {
            var leaf = node[tag] as EmberLeaf <TValue>;

            if (leaf != null)
            {
                return(leaf.Value);
            }

            throw new BerException(5, "Leaf not found or type mismatch");
        }
Пример #28
0
        public static void InsertValue(EmberContainer container, BerTag tag, GlowValue value)
        {
            var leaf = ValueToLeaf(tag, value);

            if (leaf == null)
            {
                throw new ArgumentException("Type not supported");
            }

            container.Insert(leaf);
        }
Пример #29
0
        /// <summary>
        /// Creates a new instance containing the passed <paramref name="value"/>
        /// </summary>
        /// <param name="tag">The tag of the newly created node.</param>
        /// <param name="value">The primitive value to hold.</param>
        public OctetStringEmberLeaf(BerTag tag, byte[] value)
            : base(tag)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            Value         = value;
            BerTypeNumber = BerType.OctetString;
        }
Пример #30
0
        protected EmberSet EnsureContentsAndRemove(BerTag tag)
        {
            var contents = EnsureContents();

            if (contents != null)
            {
                contents.Remove(tag);
            }

            return(contents);
        }
Пример #31
0
        /// <summary>
        /// Gets the RELATIVE OBJECT value of the child leaf with the specified tag.
        /// Throws an exception if this EmberNode is not derived from EmberContainer or
        /// if no child node of type EmberLeaf&lt;int[]&gt; with the specified tag exists.
        /// </summary>
        /// <param name="tag">The tag of the leaf whose value to return.</param>
        /// <returns>The value of the child node with the specified tag.</returns>
        public static int[] GetRelativeOid(this EmberNode node, BerTag tag)
        {
            int[] value;

            if (GetRelativeOid(node, tag, out value))
            {
                return(value);
            }

            throw new BerException(5, "leaf not found or leaf type mismatch");
        }
Пример #32
0
        GlowValue GetValue(BerTag tag)
        {
            var contents = EnsureContents();

            if (contents != null)
            {
                return(InternalTools.GetValue(contents, tag));
            }

            return(null);
        }
Пример #33
0
        GlowMinMax GetMinMax(BerTag tag)
        {
            var contents = EnsureContents();

            if (contents != null)
            {
                return(InternalTools.GetMinMax(contents, tag));
            }

            return(null);
        }
Пример #34
0
        public void Write(BerTag tag, string value)
        {
            var valueOutput = new BerMemoryOutput();
            var valueLength = BerEncoding.EncodeUtf8String(valueOutput, value);
            var innerTag    = new BerTag(BerType.UTF8String);

            WriteOuterHeader(tag, valueLength + BerEncoding.GetHeaderLength(innerTag, valueLength));
            BerEncoding.EncodeTag(_output, innerTag);
            BerEncoding.EncodeLength(_output, valueLength);
            _output.WriteBytes(valueOutput.Memory);
        }
Пример #35
0
        /// <summary>
        /// Removes the child node with the specified tag.
        /// </summary>
        /// <param name="tag">The tag of the child node to remove.</param>
        /// <returns>True if the child node was found and removed, otherwise false.</returns>
        public override sealed bool Remove(BerTag tag)
        {
            var result = base.Remove(tag);

            if (IsMapUsed)
            {
                _nodesMap.Remove(tag);
            }

            return(result);
        }
Пример #36
0
        /// <summary>
        /// Gets the integer value of the child leaf with the specified tag.
        /// Throws an exception if this EmberNode is not derived from EmberContainer or
        /// if no child node of type EmberLeaf&lt;int&gt; or EmberLeaf&lt;long&gt; with the specified tag exists.
        /// </summary>
        /// <param name="tag">The tag of the leaf whose value to return.</param>
        /// <returns>The value of the child node with the specified tag.</returns>
        public static long GetInteger(this EmberNode node, BerTag tag)
        {
            long value;

            if (GetInteger(node, tag, out value))
            {
                return(value);
            }

            throw new BerException(5, "Leaf not found or type mismatch");
        }
Пример #37
0
        public override EmberNode CreateNodeFromXml(uint type, BerTag tag, XmlReader reader)
        {
            switch(type & ~BerType.ApplicationFlag)
             {
            case 1:
               return CreateSet(type, tag, reader);

            case 2:
               return CreateSequence(type, tag, reader);
             }

             return null;
        }
Пример #38
0
 /// <summary>
 /// Creates a new instance of GlowStringIntegerPair.
 /// </summary>
 protected internal GlowStringIntegerPair(BerTag tag)
     : base(tag, GlowType.StringIntegerPair)
 {
 }
Пример #39
0
 /// <summary>
 /// Creates a new instance of GlowFunctionBase.
 /// </summary>
 protected GlowFunctionBase(BerTag? tag, uint type)
     : base(tag, type)
 {
 }
Пример #40
0
        public static int GetHeaderLength(BerTag tag, int length)
        {
            int result = GetTagLength(tag);

             if(length <= 0x7F || length == BerDefinitions.IndefiniteLength)
            return result + 1;

             return result + 1 + GetIntegerLength(length);
        }
Пример #41
0
        public static int GetTagLength(BerTag tag)
        {
            var number = tag.Number;

             if(number < 0x1F)
            return 1;

             return 1 + GetMultiByteLongLength(number);
        }
Пример #42
0
 void InsertMinMax(BerTag tag, GlowMinMax value)
 {
     InternalTools.InsertMinMax(EnsureContentsAndRemove(tag), tag, value);
 }
Пример #43
0
        EmberSequence ConvertTupleDescription(BerTag tag, XElement xml)
        {
            var ember = new EmberSequence(tag);

             foreach(var itemsXml in xml.Elements("TupleItemDescription"))
             {
            var glowItem = new GlowTupleItemDescription(0, GlowTags.CollectionItem);

            var typeXml = itemsXml.Element("type");
            if(typeXml != null)
            {
               var type = ConvertParameterType(typeXml.Value);

               if(type != null)
                  glowItem.Type = type.Value;
            }

            itemsXml.Element("name").Do(value => glowItem.Name = value);

            ember.Insert(glowItem);
             }

             return ember;
        }
Пример #44
0
 /// <summary>
 /// Creates a new instance of GlowParameterBase.
 /// </summary>
 protected GlowParameterBase(BerTag? tag, uint type)
     : base(tag, type)
 {
 }
Пример #45
0
 void InsertValue(BerTag tag, GlowValue value)
 {
     InternalTools.InsertValue(EnsureContentsAndRemove(tag), tag, value);
 }
Пример #46
0
 /// <summary>
 /// Creates a new instance of GlowTarget.
 /// </summary>
 /// <param name="tag">Either a specific tag or null when the node
 /// is to be inserted into a matrix signal collection. The tag will be
 /// set to GlowTags.CollectionItem if the passed tag is null.</param>
 protected internal GlowTarget(BerTag? tag)
     : base(tag, GlowType.Target)
 {
 }
Пример #47
0
 /// <summary>
 /// Creates a new instance of GlowTarget.
 /// </summary>
 /// <param name="number">Value of the "number" field.</param>
 /// <param name="tag">Either a specific tag or null when the node
 /// is to be inserted into a matrix signal collection. The tag will be
 /// set to GlowTags.CollectionItem if the passed tag is null.</param>
 public GlowTarget(int number, BerTag? tag = null)
     : base(number, tag, GlowType.Target)
 {
 }
Пример #48
0
 /// <summary>
 /// Creates a new instance of GlowStreamEntry.
 /// <param name="tag">Tag of the new GlowStreamEntry or
 /// GlowTags.StreamCollection.StreamEntry if null.</param>
 /// </summary>
 public GlowStreamEntry(BerTag? tag = null)
     : base(tag ?? GlowTags.StreamCollection.StreamEntry, GlowType.StreamEntry)
 {
 }
Пример #49
0
 GlowStreamDescription ConvertStreamDescription(BerTag tag, XElement xml)
 {
     return new GlowStreamDescription(
     tag,
     XmlConvert.ToInt32(xml.Element("format").Value),
     XmlConvert.ToInt32(xml.Element("offset").Value));
 }
Пример #50
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GlowTemplateBase"/> class.
 /// </summary>
 /// <param name="tag"></param>
 /// <param name="type"></param>
 protected GlowTemplateBase(BerTag tag, uint type)
     : base(tag, type)
 {
 }
Пример #51
0
 /// <summary>
 /// Creates an encodable instance of GlowEnumEntry with
 /// the specified name/value pair.
 /// </summary>
 /// <param name="tag">The field tag of the enum entry.</param>
 /// <param name="name">The name of the enum entry.</param>
 /// <param name="value">The value of the enum entry.</param>
 public GlowStringIntegerPair(BerTag tag, string name, int value)
     : this(tag)
 {
     EntryName = name;
      EntryInteger = value;
 }
Пример #52
0
 public EmberDynamicContainer(BerTag tag, EmberContainer parent)
     : base(tag, parent, true)
 {
 }
Пример #53
0
 /// <summary>
 /// Creates a new instance of GlowElementCollectionBase.
 /// </summary>
 protected GlowElementCollectionBase(BerTag tag, uint type)
     : base(tag, type, isOrdered: false)
 {
 }
Пример #54
0
        // ====================================================================
        //
        // Decode functions
        //
        // ====================================================================
        public static BerTag DecodeTag(IBerInput input)
        {
            var tagByte = input.ReadByte();
             var tag = new BerTag((byte)(tagByte & 0xE0), (uint)(tagByte & 0x1F));

             if(tag.Number == 0x1F)
            tag.Number = DecodeMultiByteInteger(input);

             return tag;
        }
Пример #55
0
 /// <summary>
 /// Creates a new instance of GlowMatrix.
 /// </summary>
 /// <param name="tag">Either a specific tag or null when the node
 /// is to be inserted into a GlowElementCollection. The tag will be
 /// set to GlowTags.CollectionItem if the passed tag is null.</param>
 /// <param name="type">ber type of the represented glow type</param>
 protected GlowMatrixBase(BerTag? tag, uint type)
     : base(tag, type)
 {
 }
Пример #56
0
        // ====================================================================
        //
        // Encode functions
        // all return the number of bytes in the
        // encoded result.
        //
        // ====================================================================
        public static int EncodeTag(IBerOutput output, BerTag tag)
        {
            var number = tag.Number;
             var size = 1;
             tag.Preamble &= 0xE0;

             if(number < 0x1F)
             {
            output.WriteByte((byte)(tag.Preamble | (number & 0x1F)));
             }
             else
             {
            output.WriteByte((byte)(tag.Preamble | 0x1F));

            size += EncodeMultiByteInteger(output, number);
             }

             return size;
        }
Пример #57
0
 /// <summary>
 /// Creates a new instance of GlowSource.
 /// </summary>
 /// <param name="number">Value of the "number" field.</param>
 /// <param name="tag">Either a specific tag or null when the node
 /// is to be inserted into a matrix signal collection. The tag will be
 /// set to GlowTags.CollectionItem if the passed tag is null.</param>
 public GlowSource(int number, BerTag? tag = null)
     : base(number, tag, GlowType.Source)
 {
 }
Пример #58
0
        GlowStringIntegerCollection ConvertStringIntegerCollection(BerTag tag, XElement xml)
        {
            var glow = new GlowStringIntegerCollection(tag);
             var glowEntries = from xmlChild in xml.Elements("StringIntegerPair")
                           let name = xmlChild.Attribute("entryString").Value
                           let value = XmlConvert.ToInt32(xmlChild.Attribute("entryInteger").Value)
                           select new GlowStringIntegerPair(GlowTags.StringIntegerCollection.StringIntegerPair, name, value);

             foreach(var glowEntry in glowEntries)
            glow.Insert(glowEntry);

             return glow;
        }
Пример #59
0
 /// <summary>
 /// Creates a new instance of GlowStringIntegerCollection.
 /// </summary>
 public GlowStringIntegerCollection(BerTag tag)
     : base(tag, GlowType.StringIntegerCollection, isOrdered: false)
 {
 }
Пример #60
0
 /// <summary>
 /// Creates a new instance of GlowSource.
 /// </summary>
 /// <param name="tag">Either a specific tag or null when the node
 /// is to be inserted into a matrix signal collection. The tag will be
 /// set to GlowTags.CollectionItem if the passed tag is null.</param>
 protected internal GlowSource(BerTag? tag)
     : base(tag, GlowType.Source)
 {
 }