Inheritance: RelNode
示例#1
0
        private Dictionary <uint, Node> ReadNodes(OsiReader reader)
        {
            var nodes = new Dictionary <uint, Node>();
            var count = reader.ReadUInt32();

            while (count-- > 0)
            {
                Node node   = null;
                var  type   = reader.ReadByte();
                var  nodeId = reader.ReadUInt32();
                switch ((Node.Type)type)
                {
                case Node.Type.Database:
                    node = new DatabaseNode();
                    break;

                case Node.Type.Proc:
                    node = new ProcNode();
                    break;

                case Node.Type.DivQuery:
                    node = new DivQueryNode();
                    break;

                case Node.Type.InternalQuery:
                    node = new InternalQueryNode();
                    break;

                case Node.Type.And:
                    node = new AndNode();
                    break;

                case Node.Type.NotAnd:
                    node = new NotAndNode();
                    break;

                case Node.Type.RelOp:
                    node = new RelOpNode();
                    break;

                case Node.Type.Rule:
                    node = new RuleNode();
                    break;

                case Node.Type.UserQuery:
                    node = new UserQueryNode();
                    break;

                default:
                    throw new NotImplementedException("No serializer found for this node type");
                }

                node.Read(reader);
                nodes.Add(nodeId, node);
            }

            return(nodes);
        }
示例#2
0
        public void Visit(RuleNode node)
        {
            Visit(node as RelNode);
            writer.WritePropertyName("calls");
            writer.WriteStartArray();
            foreach (var call in node.Calls)
            {
                Visit(call);
            }
            writer.WriteEndArray();

            writer.WritePropertyName("variables");
            writer.WriteStartArray();
            foreach (var v in node.Variables)
            {
                VisitVar(v);
            }
            writer.WriteEndArray();

            writer.WritePropertyName("line");
            writer.WriteValue(node.Line);
            writer.WritePropertyName("query");
            writer.WriteValue(node.IsQuery);
        }
示例#3
0
文件: Story.cs 项目: Norbyte/lslib
        private Dictionary<uint, Node> ReadNodes(OsiReader reader)
        {
            var nodes = new Dictionary<uint, Node>();
            var count = reader.ReadUInt32();
            while (count-- > 0)
            {
                Node node = null;
                var type = reader.ReadByte();
                var nodeId = reader.ReadUInt32();
                switch ((Node.Type)type)
                {
                    case Node.Type.Database:
                        node = new DatabaseNode();
                        break;

                    case Node.Type.Proc:
                        node = new ProcNode();
                        break;

                    case Node.Type.DivQuery:
                        node = new DivQueryNode();
                        break;

                    case Node.Type.InternalQuery:
                        node = new InternalQueryNode();
                        break;

                    case Node.Type.And:
                        node = new AndNode();
                        break;

                    case Node.Type.NotAnd:
                        node = new NotAndNode();
                        break;

                    case Node.Type.RelOp:
                        node = new RelOpNode();
                        break;

                    case Node.Type.Rule:
                        node = new RuleNode();
                        break;

                    case Node.Type.UserQuery:
                        node = new UserQueryNode();
                        break;

                    default:
                        throw new NotImplementedException("No serializer found for this node type");
                }

                node.Read(reader);
                nodes.Add(nodeId, node);
            }

            return nodes;
        }