示例#1
0
            public IEnumerable <GlowContainer> Visit(GlowQualifiedNode glow, object state)
            {
                EndPointNumber = glow.Path[0];

                if (glow.Path.Length == 1) // translate to root level
                {
                    var children = glow.Children;

                    if (children != null)
                    {
                        foreach (var child in children.Elements)
                        {
                            yield return(child);
                        }
                    }
                }
                else
                {
                    var newPath      = glow.Path.Skip(1).ToArray();
                    var newQualified = new GlowQualifiedNode(newPath);

                    foreach (var ember in glow)
                    {
                        if (ember.Tag != GlowTags.QualifiedNode.Path)
                        {
                            newQualified.Insert(ember);
                        }
                    }

                    yield return(newQualified);
                }
            }
示例#2
0
文件: Model.cs 项目: scy/ember-plus
        bool IGlowVisitor <object, bool> .Visit(GlowQualifiedNode glow, object state)
        {
            Element parent;
            var     local      = GetElementAt(glow.Path, out parent);
            var     isComplete = glow.Identifier != null;

            if (parent != null)
            {
                var xml = isComplete
                      ? BuildXml(glow)
                      : null;

                if (local == null)
                {
                    local = new Element(parent, glow.Path.Last(), glow.Identifier, ElementType.Node, xml);

                    parent._children.Add(local);
                }
                else
                {
                    local.Update(glow.Identifier, ElementType.Node, xml);
                }

                var children = glow.Children;

                if (children != null)
                {
                    isComplete |= children.Accept(local, null);
                }
            }

            return(isComplete);
        }
        GlowQualifiedNode ConvertQualifiedNode(XElement xml)
        {
            var glow = new GlowQualifiedNode(ConvertPath(xml.Attribute("path").Value));

            FillNode(glow, xml);
            return(glow);
        }
        object IGlowVisitor <XmlWriter, object> .Visit(GlowQualifiedNode glow, XmlWriter state)
        {
            state.WriteStartElement("QualifiedNode");
            state.WriteAttributeString("path", ConvertPath(glow.Path));

            ConvertNode(glow, state);

            state.WriteEndElement();
            return(null);
        }
示例#5
0
        bool IGlowVisitor <object, bool> .Visit(GlowQualifiedNode glow, object state)
        {
            if (_onNode != null)
            {
                _onNode(glow);
                return(true);
            }

            return(false);
        }
示例#6
0
            public GlowContainer Visit(GlowQualifiedNode glow, object state)
            {
                var newPath      = PrependPathWithEndPointNumber(glow.Path);
                var newQualified = new GlowQualifiedNode(newPath);

                foreach (var ember in glow)
                {
                    if (ember.Tag != GlowTags.QualifiedNode.Path)
                    {
                        newQualified.Insert(ember);
                    }
                }

                return(newQualified);
            }
示例#7
0
            void CreateGlowNode(Item item, int[] path, int?number, int fields, GlowElementCollectionBase parent)
            {
                if (number != null)
                {
                    path = path.Concat(new[] { number.Value }).ToArray();
                }

                var glow = new GlowQualifiedNode(path);

                if ((fields & GlowFieldFlags.Identifier) != 0)
                {
                    glow.Identifier = item.Identifier;
                }

                if ((fields & GlowFieldFlags.Description) != 0 &&
                    String.IsNullOrEmpty(item.Name) == false)
                {
                    glow.Description = item.Name;
                }

                parent.Insert(glow);
            }
示例#8
0
文件: Model.cs 项目: scy/ember-plus
        static GlowRootElementCollection BuildQualified(Element local, GlowElement glow)
        {
            var qualified = null as GlowElement;

            if (local.Type != ElementType.Root)
            {
                var path = local.BuildPath();

                if (local.Type == ElementType.Parameter)
                {
                    var qparam = new GlowQualifiedParameter(path);
                    qparam.Children = new GlowElementCollection(GlowTags.QualifiedParameter.Children);
                    qparam.Children.Insert(glow);
                    qualified = qparam;
                }
                else if (local.Type == ElementType.Node)
                {
                    var qnode = new GlowQualifiedNode(path);
                    qnode.Children = new GlowElementCollection(GlowTags.QualifiedNode.Children);
                    qnode.Children.Insert(glow);
                    qualified = qnode;
                }
            }
            else
            {
                qualified = glow;
            }

            if (qualified != null)
            {
                var root = GlowRootElementCollection.CreateRoot();
                root.Insert(qualified);
                return(root);
            }

            return(null);
        }
        GlowContainer IElementVisitor <ElementToGlowOptions, GlowContainer> .Visit(Node element, ElementToGlowOptions state)
        {
            var glow         = new GlowQualifiedNode(element.Path);
            var dirFieldMask = state.DirFieldMask;

            if (dirFieldMask.HasBits(GlowFieldFlags.Identifier))
            {
                glow.Identifier = element.Identifier;
            }

            if ((dirFieldMask.HasBits(GlowFieldFlags.Description)) &&
                String.IsNullOrEmpty(element.Description) == false)
            {
                glow.Description = element.Description;
            }

            if ((dirFieldMask == GlowFieldFlags.All) &&
                String.IsNullOrEmpty(element.SchemaIdentifier) == false)
            {
                glow.SchemaIdentifiers = element.SchemaIdentifier;
            }

            return(glow);
        }
示例#10
0
 GlowQualifiedNode ConvertQualifiedNode(XElement xml)
 {
     var glow = new GlowQualifiedNode(ConvertPath(xml.Attribute("path").Value));
      FillNode(glow, xml);
      return glow;
 }
示例#11
0
            void CreateGlowNode(Item item, int[] path, int? number, int fields, GlowElementCollectionBase parent)
            {
                if(number != null)
                   path = path.Concat(new[] { number.Value }).ToArray();

                var glow = new GlowQualifiedNode(path);

                if((fields & GlowFieldFlags.Identifier) != 0)
                   glow.Identifier = item.Identifier;

                if((fields & GlowFieldFlags.Description) != 0
                && String.IsNullOrEmpty(item.Name) == false)
                   glow.Description = item.Name;

                parent.Insert(glow);
            }