예제 #1
0
        public static DubProject ReadPackageInformation(FilePath packageJsonPath, JsonReader r, IProgressMonitor monitor)
        {
            var defaultPackage = new DubProject();

            defaultPackage.FileName      = packageJsonPath;
            defaultPackage.BaseDirectory = packageJsonPath.ParentDirectory;

            defaultPackage.BeginLoad();

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

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

            defaultPackage.Items.Add(new ProjectFile(packageJsonPath, BuildAction.None));

            defaultPackage.EndLoad();
            return(defaultPackage);
        }
예제 #2
0
        public object ReadFile(FilePath file, Type expectedType, IProgressMonitor monitor)
        {
            object ret;
            var    serializer = new JsonSerializer();

            DubSolution sln;
            var         dp = new DubProject {
                FileName = file, BaseDirectory = file.ParentDirectory
            };

            if (expectedType.Equals(typeof(SolutionEntityItem)))
            {
                ret = dp;
                sln = null;
            }
            else if (expectedType.Equals(typeof(WorkspaceItem)))
            {
                ret = sln = new DubSolution(file);
                sln.RootFolder.AddItem(dp, false);
                sln.StartupItem = dp;
                dp.AddProjectAndSolutionConfiguration(new DubProjectConfiguration {
                    Name = "Default", Id = "Default"
                });
            }
            else
            {
                return(null);
            }

            using (var s = File.OpenText(file))
                using (var rdr = new JsonTextReader(s))
                {
                    while (rdr.Read())
                    {
                        if (rdr.TokenType == JsonToken.PropertyName)
                        {
                            dp.TryPopulateProperty(rdr.Value as string, rdr);
                        }
                        else if (rdr.TokenType == JsonToken.EndObject)
                        {
                            break;
                        }
                    }
                }

            dp.UpdateFilelist();
            if (sln != null)
            {
                sln.LoadUserProperties();
            }

            return(ret);
        }
예제 #3
0
        public object ReadFile(FilePath file, Type expectedType, IProgressMonitor monitor)
        {
            object ret;
            var serializer = new JsonSerializer();

            DubSolution sln;
            var dp = new DubProject { FileName = file, BaseDirectory = file.ParentDirectory };
            if (expectedType.Equals(typeof(SolutionEntityItem))){
                ret = dp;
                sln = null;
            }
            else if(expectedType.Equals(typeof(WorkspaceItem)))
            {
                ret = sln = new DubSolution(file);
                sln.RootFolder.AddItem(dp, false);
                sln.StartupItem = dp;
                dp.AddProjectAndSolutionConfiguration(new DubProjectConfiguration { Name = "Default", Id = "Default" });
            }
            else
                return null;

            using (var s = File.OpenText(file))
            using(var rdr = new JsonTextReader(s))
            {
                while (rdr.Read())
                {
                    if (rdr.TokenType == JsonToken.PropertyName)
                        dp.TryPopulateProperty(rdr.Value as string, rdr);
                    else if (rdr.TokenType == JsonToken.EndObject)
                        break;
                }
            }

            dp.UpdateFilelist();
            if (sln != null)
                sln.LoadUserProperties();

            return ret;
        }
예제 #4
0
        public static DubProject ReadPackageInformation(FilePath packageJsonPath,JsonReader r, IProgressMonitor monitor)
        {
            var defaultPackage = new DubProject();
            defaultPackage.FileName = packageJsonPath;
            defaultPackage.BaseDirectory = packageJsonPath.ParentDirectory;

            defaultPackage.BeginLoad ();

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

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

            defaultPackage.Items.Add(new ProjectFile(packageJsonPath, BuildAction.None));

            defaultPackage.EndLoad ();
            return defaultPackage;
        }