Esempio n. 1
0
        /// <summary>
        ///     Serializes an attribute set to a string builder in form " [a = b]"
        /// </summary>
        private void AppendAttributeSet(IAttrSet attrSet, StringBuilder sb)
        {
            if (!AttrSet.NotNullOrEmpty(attrSet))
            {
                return;
            }

            sb.Append(" [");
            bool wroteFirst = false;

            foreach (IAttribute attribute in attrSet)
            {
                if (wroteFirst)
                {
                    sb.Append(", ");
                }

                string record = _dotHelper.GetRecordFromAttribute(attribute);
                sb.Append(record);

                wroteFirst = true;
            }

            sb.Append("]");
        }
Esempio n. 2
0
        public IAttrSet Add(IAttribute a)
        {
            bool hasValue      = _set.ContainsKey(a.Key);
            bool newValueGiven = a.StringValue != null;

            if (!hasValue && !newValueGiven)
            {
                // Since no change,
                return(this);
            }

            AttrSet clonedSet = new AttrSet(_set);
            string  key       = a.Key;

            if (newValueGiven)
            {
                clonedSet._set[key] = a;
            }
            else
            {
                clonedSet._set.Remove(key);
            }

            return(clonedSet);
        }
Esempio n. 3
0
        public void SetNodeAttributes(IAttrSet attributesSet)
        {
            if (!AttrSet.NotNullOrEmpty(attributesSet))
            {
                return;
            }

            StringBuilder sb = new StringBuilder();

            sb.Append("node");
            AppendAttributeSet(attributesSet, sb);
            sb.Append(";");
            Line(sb.ToString());
        }
Esempio n. 4
0
        public IAttrSet Add(IAttrSet attrSet)
        {
            bool shouldAdd = attrSet.Any();

            if (!shouldAdd)
            {
                // Since no change
                return(this);
            }

            AttrSet clonedSet = new AttrSet(_set);

            foreach (IAttribute item in attrSet)
            {
                clonedSet._set[item.Key] = item;
            }

            return(clonedSet);
        }