Example #1
0
        public static DubSubPackage ReadAndAdd(DubProject superProject, JsonReader r, IProgressMonitor monitor)
        {
            if (r.TokenType != JsonToken.StartObject)
            {
                throw new JsonReaderException("Illegal token on subpackage definition beginning");
            }

            var sub = new DubSubPackage();

            sub.FileName = superProject.FileName;

            sub.OriginalBasePath = superProject is DubSubPackage ? (superProject as DubSubPackage).OriginalBasePath :
                                   superProject.BaseDirectory;
            sub.VirtualBasePath = sub.OriginalBasePath;

            sub.BeginLoad();

            sub.AddProjectAndSolutionConfiguration(new DubProjectConfiguration {
                Name = GettextCatalog.GetString("Default"), Id = DubProjectConfiguration.DefaultConfigId
            });

            superProject.packagesToAdd.Add(sub);

            while (r.Read())
            {
                if (r.TokenType == JsonToken.PropertyName)
                {
                    sub.TryPopulateProperty(r.Value as string, r, monitor);
                }
                else if (r.TokenType == JsonToken.EndObject)
                {
                    break;
                }
            }

            sub.packageName = superProject.packageName + ":" + (sub.packageName ?? string.Empty);

            var sourcePaths = sub.GetSourcePaths().ToArray();

            if (sourcePaths.Length > 0 && !string.IsNullOrWhiteSpace(sourcePaths[0]))
            {
                sub.VirtualBasePath = new FilePath(sourcePaths [0]);
            }

            PackageJsonParser.LoadDubProjectReferences(sub, monitor);

            // TODO: What to do with new configurations that were declared in this sub package? Add them to all other packages as well?
            sub.EndLoad();

            if (r.TokenType != JsonToken.EndObject)
            {
                throw new JsonReaderException("Illegal token on subpackage definition end");
            }
            return(sub);
        }
Example #2
0
 public object ReadFile(FilePath file, Type expectedType, IProgressMonitor monitor)
 {
     return(PackageJsonParser.ReadFile_(file, expectedType, monitor));
 }