A dub package container.
Наследование: Solution
Пример #1
0
        public static object ReadFile_(string file, Type expectedType, IProgressMonitor monitor)
        {
            bool clearLoadedPrjList = AlreadyLoadedPackages == null;
            if (clearLoadedPrjList)
                AlreadyLoadedPackages = new List<string> ();

            if (AlreadyLoadedPackages.Contains (file))
                return null;
            AlreadyLoadedPackages.Add (file);

            DubProject defaultPackage;
            try{
                using (var s = File.OpenText (file))
                using (var r = new JsonTextReader (s))
                    defaultPackage = ReadPackageInformation(file, r, monitor);
            }catch(Exception ex){
                if (clearLoadedPrjList)
                    AlreadyLoadedPackages = null;
                monitor.ReportError ("Couldn't load dub package \"" + file + "\"", ex);
                return null;
            }

            if (expectedType.IsInstanceOfType (defaultPackage)) {
                LoadDubProjectReferences (defaultPackage, monitor);

                if (clearLoadedPrjList)
                    AlreadyLoadedPackages = null;

                return defaultPackage;
            }

            var sln = new DubSolution();

            if (!expectedType.IsInstanceOfType (sln)) {
                if (clearLoadedPrjList)
                    AlreadyLoadedPackages = null;
                return null;
            }

            sln.RootFolder.AddItem(defaultPackage, false);
            sln.StartupItem = defaultPackage;

            // Introduce solution configurations
            foreach (var cfg in defaultPackage.Configurations)
                sln.AddConfiguration(cfg.Name, false).Platform = cfg.Platform;

            LoadDubProjectReferences (defaultPackage, monitor, sln);

            sln.LoadUserProperties();

            if (clearLoadedPrjList) {
                AlreadyLoadedPackages = null;

                // Clear 'dub list' outputs
                DubReferencesCollection.DubListOutputs.Clear ();
            }

            return sln;
        }
Пример #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 object ReadFile_(string file, Type expectedType, IProgressMonitor monitor)
        {
            DubProject defaultPackage;
            bool clearLoadedPrjList = AlreadyLoadedPackages == null;
            if (clearLoadedPrjList)
                AlreadyLoadedPackages = new Dictionary<string, DubProject> ();

            if (AlreadyLoadedPackages.TryGetValue (file, out defaultPackage))
                return defaultPackage;

            try{
                defaultPackage = ReadPackageInformation(file, monitor);
            }catch(Exception ex){
                if (clearLoadedPrjList)
                    AlreadyLoadedPackages = null;
                monitor.ReportError ("Couldn't load dub package \"" + file + "\"", ex);
                return null;
            }

            if (expectedType.IsInstanceOfType (defaultPackage)) {
                LoadDubProjectReferences (defaultPackage, monitor);

                if (clearLoadedPrjList)
                    AlreadyLoadedPackages = null;

                return defaultPackage;
            }

            var sln = new DubSolution();

            if (!expectedType.IsInstanceOfType (sln)) {
                if (clearLoadedPrjList)
                    AlreadyLoadedPackages = null;
                return null;
            }

            sln.RootFolder.AddItem(defaultPackage, false);
            sln.StartupItem = defaultPackage;

            // Introduce solution configurations
            foreach (var cfg in defaultPackage.Configurations)
                sln.AddConfiguration(cfg.Name, false).Platform = cfg.Platform;

            LoadDubProjectReferences (defaultPackage, monitor, sln);

            // Apply subConfigurations
            var subConfigurations = new Dictionary<string, string>(defaultPackage.CommonBuildSettings.subConfigurations);

            foreach (var item in sln.Items)
            {
                var prj = item as SolutionEntityItem;
                if (prj == null)
                    continue;

                foreach (var cfg in sln.Configurations)
                {
                    var prjItem = cfg.GetEntryForItem(prj);
                    string cfgId;
                    if (subConfigurations.TryGetValue(prj.ItemId, out cfgId))
                        prjItem.ItemConfiguration = cfgId;

                    var prjCfg = defaultPackage.GetConfiguration(cfg.Selector) as DubProjectConfiguration;
                    if (prjCfg != null && prjCfg.BuildSettings.subConfigurations.TryGetValue(prj.ItemId, out cfgId))
                        prjItem.ItemConfiguration = cfgId;
                }
            }

            sln.LoadUserProperties();

            if (clearLoadedPrjList) {
                AlreadyLoadedPackages = null;

                // Clear 'dub list' outputs
                DubReferencesCollection.DubListOutputs.Clear ();
            }

            return sln;
        }
Пример #5
0
        public static object ReadFile_(string file, Type expectedType, IProgressMonitor monitor)
        {
            bool clearLoadedPrjList = AlreadyLoadedPackages == null;

            if (clearLoadedPrjList)
            {
                AlreadyLoadedPackages = new List <string> ();
            }

            if (AlreadyLoadedPackages.Contains(file))
            {
                return(null);
            }
            AlreadyLoadedPackages.Add(file);

            DubProject defaultPackage;

            try{
                using (var s = File.OpenText(file))
                    using (var r = new JsonTextReader(s))
                        defaultPackage = ReadPackageInformation(file, r, monitor);
            }catch (Exception ex) {
                if (clearLoadedPrjList)
                {
                    AlreadyLoadedPackages = null;
                }
                monitor.ReportError("Couldn't load dub package \"" + file + "\"", ex);
                return(null);
            }

            if (expectedType.IsInstanceOfType(defaultPackage))
            {
                LoadDubProjectReferences(defaultPackage, monitor);

                if (clearLoadedPrjList)
                {
                    AlreadyLoadedPackages = null;
                }

                return(defaultPackage);
            }

            var sln = new DubSolution();

            if (!expectedType.IsInstanceOfType(sln))
            {
                if (clearLoadedPrjList)
                {
                    AlreadyLoadedPackages = null;
                }
                return(null);
            }

            sln.RootFolder.AddItem(defaultPackage, false);
            sln.StartupItem = defaultPackage;

            // Introduce solution configurations
            foreach (var cfg in defaultPackage.Configurations)
            {
                sln.AddConfiguration(cfg.Name, false).Platform = cfg.Platform;
            }

            LoadDubProjectReferences(defaultPackage, monitor, sln);

            sln.LoadUserProperties();

            if (clearLoadedPrjList)
            {
                AlreadyLoadedPackages = null;

                // Clear 'dub list' outputs
                DubReferencesCollection.DubListOutputs.Clear();
            }

            return(sln);
        }