Esempio n. 1
0
        public void ReadPips(JsonFilter reader)
        {
            Dictionary <string, PipType> pipTypeLookup = new Dictionary <string, PipType>();

            foreach (PipType pt in Enum.GetValues(typeof(PipType)))
            {
                pipTypeLookup[pt.ToString()] = pt;
            }

            AssertPostRead(reader, JsonToken.StartArray);
            while (reader.Read() && reader.TokenType == JsonToken.StartObject)
            {
                AssertPostRead(reader, JsonToken.PropertyName);
                var id = (uint)reader.ReadAsInt32();

                while (reader.Read() && reader.TokenType == JsonToken.PropertyName)
                {
                    string propertyName = (string)reader.Value;
                    switch (propertyName)
                    {
                    case "type":
                        PipTypes[id] = pipTypeLookup[reader.ReadAsString()];
                        break;

                    case "stableId":
                        SemiStableHashes[id] = ulong.Parse(reader.ReadAsString(), NumberStyles.HexNumber);
                        break;

                    default:
                        reader.Skip();
                        break;
                    }
                }

                AssertToken(reader, JsonToken.EndObject);
            }

            AssertToken(reader, JsonToken.EndArray);
        }
Esempio n. 2
0
        public void ReadGraph(JsonFilter reader)
        {
            Dictionary <string, PipType> pipTypeLookup = new Dictionary <string, PipType>();

            foreach (PipType pt in Enum.GetValues(typeof(PipType)))
            {
                pipTypeLookup[pt.ToString()] = pt;
            }

            AssertPostRead(reader, JsonToken.StartArray);
            while (reader.Read() && reader.TokenType == JsonToken.StartObject)
            {
                AssertPostRead(reader, JsonToken.PropertyName);
                var    id   = (int)reader.ReadAsInt32();
                NodeId node = GetNodeForId(id);


                while (reader.Read() && reader.TokenType == JsonToken.PropertyName)
                {
                    int    value        = 0;
                    string propertyName = (string)reader.Value;
                    switch (propertyName)
                    {
                    case "type":
                        PipTypes[node] = pipTypeLookup[reader.ReadAsString()];
                        break;

                    case "stableId":
                        SemiStableHashes[node] = ulong.Parse(reader.ReadAsString(), NumberStyles.HexNumber);
                        break;

                    case "dependsOn":
                        AssertPostRead(reader, JsonToken.StartArray);
                        while (reader.TryReadInt32(out value))
                        {
                            MutableDataflowGraph.AddEdge(GetNodeForId(value), node);
                        }

                        AssertToken(reader, JsonToken.EndArray);
                        break;

                    case "consumes":
                        AssertPostRead(reader, JsonToken.StartArray);
                        while (reader.TryReadInt32(out value))
                        {
                            var list = GetOrAddDependenciesList(node);
                            list.Add(value);
                        }

                        AssertToken(reader, JsonToken.EndArray);
                        break;

                    case "produces":
                        AssertPostRead(reader, JsonToken.StartArray);
                        while (reader.TryReadInt32(out value))
                        {
                            m_pipProducers[value] = node;
                        }

                        AssertToken(reader, JsonToken.EndArray);
                        break;

                    case "provenance":
                        AssertPostRead(reader, JsonToken.StartObject);
                        while (reader.Read() && reader.TokenType == JsonToken.PropertyName)
                        {
                            if (reader.Value.Equals("value"))
                            {
                                var outputValue = FullSymbol.Create(SymbolTable, reader.ReadAsString());
                                OutputValues[node] = outputValue;
                                continue;
                            }

                            reader.Skip();
                        }

                        AssertToken(reader, JsonToken.EndObject);
                        break;

                    default:
                        reader.Skip();
                        break;
                    }
                }

                AssertToken(reader, JsonToken.EndObject);
            }

            AssertToken(reader, JsonToken.EndArray);
        }