예제 #1
0
        public bool TryPopulateProperty(string propName, JsonReader j, IProgressMonitor monitor)
        {
            switch (propName.ToLowerInvariant())
            {
            case "displayname":
                displayName = j.ReadAsString();
                break;

            case "name":
                packageName = j.ReadAsString();
                break;

            case "description":
                Description = j.ReadAsString();
                break;

            case "copyright":
                Copyright = j.ReadAsString();
                break;

            case "homepage":
                Homepage = j.ReadAsString();
                break;

            case "authors":
                if (!j.Read() || j.TokenType != JsonToken.StartArray)
                {
                    throw new JsonReaderException("Expected [ when parsing Authors");
                }
                authors.Clear();
                while (j.Read() && j.TokenType != JsonToken.EndArray)
                {
                    if (j.TokenType == JsonToken.String)
                    {
                        authors.Add(j.Value as string);
                    }
                }
                break;

            case "dependencies":
                if (!j.Read() || j.TokenType != JsonToken.StartObject)
                {
                    throw new JsonReaderException("Expected { when parsing Authors");
                }

                DubReferences.DeserializeDubPrjDependencies(j, monitor);
                break;

            case "configurations":
                if (!j.Read() || j.TokenType != JsonToken.StartArray)
                {
                    throw new JsonReaderException("Expected [ when parsing Configurations");
                }

                if (ParentSolution != null && ParentSolution.Configurations.Count == 1 && ParentSolution.Configurations[0].Id == DubProjectConfiguration.DefaultConfigId)
                {
                    ParentSolution.Configurations.Clear();
                }
                if (Configurations.Count == 1 && Configurations[0].Id == DubProjectConfiguration.DefaultConfigId)
                {
                    Configurations.Clear();
                }

                while (j.Read() && j.TokenType != JsonToken.EndArray)
                {
                    AddProjectAndSolutionConfiguration(DubProjectConfiguration.DeserializeFromPackageJson(j));
                }
                break;

            case "subpackages":
                if (!j.Read() || j.TokenType != JsonToken.StartArray)
                {
                    throw new JsonReaderException("Expected [ when parsing subpackages");
                }

                while (j.Read() && j.TokenType != JsonToken.EndArray)
                {
                    DubSubPackage.ReadAndAdd(this, j, monitor);
                }
                break;

            default:
                return(CommonBuildSettings.TryDeserializeBuildSetting(j));
            }

            return(true);
        }
예제 #2
0
        public bool TryPopulateProperty(string propName, JsonReader j)
        {
            switch (propName)
            {
            case "name":
                Name = j.ReadAsString();
                break;

            case "description":
                Description = j.ReadAsString();
                break;

            case "copyright":
                Copyright = j.ReadAsString();
                break;

            case "homepage":
                Homepage = j.ReadAsString();
                break;

            case "authors":
                if (!j.Read() || j.TokenType != JsonToken.StartArray)
                {
                    throw new JsonReaderException("Expected [ when parsing Authors");
                }
                authors.Clear();
                while (j.Read() && j.TokenType != JsonToken.EndArray)
                {
                    if (j.TokenType == JsonToken.String)
                    {
                        authors.Add(j.Value as string);
                    }
                }
                break;

            case "dependencies":
                if (!j.Read() || j.TokenType != JsonToken.StartObject)
                {
                    throw new JsonReaderException("Expected { when parsing Authors");
                }
                dependencies.Clear();
                while (j.Read() && j.TokenType != JsonToken.EndObject)
                {
                    if (j.TokenType == JsonToken.PropertyName)
                    {
                        DeserializeDubPrjDependency(j);
                    }
                }
                break;

            case "configurations":
                if (!j.Read() || j.TokenType != JsonToken.StartArray)
                {
                    throw new JsonReaderException("Expected [ when parsing Configurations");
                }
                if (ParentSolution != null)
                {
                    ParentSolution.Configurations.Clear();
                }
                Configurations.Clear();

                while (j.Read() && j.TokenType != JsonToken.EndArray)
                {
                    AddProjectAndSolutionConfiguration(DubProjectConfiguration.DeserializeFromPackageJson(j));
                }
                break;

            default:
                return(GlobalBuildSettings.TryDeserializeBuildSetting(j));
            }

            return(true);
        }