Пример #1
0
        protected BlockNode(string blockName)
        {
            Attributes = new AttributeNodeList();
            Children = new List<BlockNode>();
            Parameters = new ParameterNodeList();

            //required bullshit
            if (blockName.Contains("."))
            {
                var values = blockName.Split(".".ToCharArray());
                BlockName = values[0];
                foreach (var value in values.Skip(1))
                {
                    Attributes.Add(new AttributeNode("class", value));
                }
            }
            else
            {
                BlockName = blockName;
            }
        }
Пример #2
0
        private AttributeNodeList MergeAttributeNodes(AttributeNodeList destinationNodes, AttributeNodeList sourceNodes)
        {
            if (sourceNodes != null && destinationNodes != null)
            {
                foreach (var source in sourceNodes)
                {
                    bool found = false;
                    foreach (var destination in destinationNodes)
                    {
                        if (destination.Key == source.Key)
                        {
                            found = true;
                            //override or append?
                            destination.Key = source.Key;
                            destination.ValueType = source.ValueType;
                            destination.Value = source.Value;
                        }
                    }

                    if (!found)
                    {
                        destinationNodes.Add(source);
                    }
                }
            }

            return destinationNodes ?? sourceNodes;
        }