/// <summary>
        /// Serializes the Value of the current instance
        /// </summary>
        /// <param name="writer">The writer to which to serialize</param>
        private void SerializeChildren(BinaryWriter writer)
        {
            if (Children == null)
            {
                writer.Write((byte)0);
            }
            else
            {
                writer.Write((byte)1);
                writer.Write(Children.Count);

                foreach (string name in Children.Keys)
                {
                    if (name == null)
                    {
                        writer.Write((byte)0);
                    }
                    else
                    {
                        writer.Write((byte)1);
                        writer.Write(name);
                    }
                    RecognizedSemanticValue child = Children[name];
                    if (child == null)
                    {
                        writer.Write((byte)0);
                    }
                    else
                    {
                        writer.Write((byte)1);
                        child.Serialize(writer);
                    }
                }
            }
        }
        /// <summary>
        /// Deserializes the Children of the current instance
        /// </summary>
        /// <param name="reader">the reader from which to deserialize</param>
        private void DeserializeChildren(BinaryReader reader)
        {
            if (reader.ReadByte() != 0)
            {
                Children = new DssDictionary <string, RecognizedSemanticValue>();
                int count = reader.ReadInt32();

                for (int i = 0; i < count; i++)
                {
                    string name = null;
                    RecognizedSemanticValue child = null;
                    if (reader.ReadByte() != 0)
                    {
                        name = reader.ReadString();
                    }
                    if (reader.ReadByte() != 0)
                    {
                        child = new RecognizedSemanticValue();
                        child.Deserialize(reader);
                    }
                    Children[name] = child;
                }
            }
            else
            {
                Children = null;
            }
        }
        /// <summary>
        /// Creates a clone of the current instance
        /// </summary>
        /// <returns>clone of the current instance (deeply cloned)</returns>
        public object Clone()
        {
            RecognizedSemanticValue clone = new RecognizedSemanticValue();

            CopyTo(clone);
            return(clone);
        }
        /// <summary>
        /// Copys the values of the current instance to the target instance
        /// </summary>
        /// <param name="target">target instance</param>
        public void CopyTo(IDssSerializable target)
        {
            RecognizedSemanticValue clone = (RecognizedSemanticValue)target;

            clone.TypeOfValue = TypeOfValue;
            clone.Value       = Value;

            clone.KeyName    = KeyName;
            clone.Confidence = Confidence;

            if (Children != null)
            {
                clone.Children = new DssDictionary <string, RecognizedSemanticValue>();
                foreach (var child in Children)
                {
                    clone.Children[child.Key] = child.Value == null ? null : (RecognizedSemanticValue)child.Value.Clone();
                }
            }
            else
            {
                clone.Children = null;
            }
        }