Exemplo n.º 1
0
        /// <summary>
        /// Node constructor
        /// </summary>
        /// <param name="name">Name of Node</param>
        /// <param name="parent">Parent of Node</param>
        /// <param name="link">DSLink container of Node</param>
        /// <param name="className">Node class name</param>
        public Node(string name, Node parent, DSLinkContainer link, string className = "node")
        {
            if (name == null)
            {
                throw new ArgumentException("Name must not be null.");
            }
            ClassName = className;
            Parent    = parent;
            _children = new Dictionary <string, Node>();

            Configs        = new MetadataMap("$");
            Attributes     = new MetadataMap("@");
            PrivateConfigs = new MetadataMap("");

            Configs.OnSet    += UpdateSubscribers;
            Attributes.OnSet += UpdateSubscribers;

            _removedChildren = new List <Node>();
            _subscribers     = new List <int>();
            _streams         = new List <int>();
            _link            = link;

            _createInitialData();

            Value        = new Value();
            Value.OnSet += ValueSet;

            if (parent != null)
            {
                if (name.Equals(""))
                {
                    throw new ArgumentException("name");
                }
                Name = name;
                Path = (parent.Path.Equals("/") ? "" : parent.Path) + "/" + name;
            }
            else
            {
                Name = name;
                Path = "/" + name;
            }

            link?.Responder?.StreamManager?.OnActivateNode(this);
        }