Inheritance: JSONThing
Esempio n. 1
0
        void DeserializeDubPrjDependencies(JSONObject j, DubBuildSettings settings)
        {
            foreach (var kv in j.Properties) {
                var depName = kv.Key;
                var depVersion = string.Empty;
                var depPath = string.Empty;

                if (kv.Value is JSONValueLeaf)
                    depVersion = (kv.Value as JSONValueLeaf).Value;
                else if (kv.Value is JSONObject) {
                    foreach (var kvv in (kv.Value as JSONObject).Properties) {
                        switch (kvv.Key) {
                            case "version":
                                depVersion = ExpectJsonStringValue (kvv.Value, "version");
                                break;
                            case "path":
                                depPath = ExpectJsonStringValue (kvv.Value, "path");
                                break;
                        }
                    }
                } else
                    throw new InvalidDataException ("Error while deserializing dub project dependency");

                settings.dependencies[depName] =  new DubProjectDependency { Name = depName, Version = depVersion, Path = depPath };
            }
        }
Esempio n. 2
0
        DubProjectConfiguration DeserializeFromPackageJson(JSONObject j)
        {
            var c = new DubProjectConfiguration { Name = "<Undefined>" };

            if (j.Properties.ContainsKey ("name"))
                c.Name = ExpectJsonStringValue(j.Properties ["name"], "name");

            foreach (var kv in j.Properties) {
                TryDeserializeBuildSetting (c.BuildSettings, kv.Key, kv.Value);
            }

            return c;
        }
Esempio n. 3
0
        JSONObject ReadObject(JsonReader r)
        {
            if (r.TokenType != JsonToken.StartObject)
                throw new InvalidDataException ("Object begin expected");
            r.Read ();

            var o = new JSONObject();
            while (r.TokenType == JsonToken.PropertyName) {
                var name = (r.Value as string).ToLowerInvariant();
                r.Read ();
                var thing = ReadThing (r);

                o.Properties.Add (name, thing);
            }

            if (r.TokenType != JsonToken.EndObject)
                throw new InvalidDataException ("Object end expected");
            r.Read ();

            return o;
        }