private SettingsStorageMountPoint CreateSolutionMountPoint()
        {
            var name = "Solution (Unity)";
            // Set at a priority less than the .sln.dotSettings layer, so we can be overridden
            var priority    = ProjectModelSettingsStorageMountPointPriorityClasses.SolutionShared * 0.9;
            var isAvailable = new IsAvailableByDataConstant <ISolution>(myLifetime, ProjectModelDataConstants.SOLUTION,
                                                                        mySolution, myLocks);

            return(CreateMountPoint(myLifetime, name, priority, isAvailable, mySettingsStorageProviders));
        }
        private SettingsStorageMountPoint CreateProjectMountPoint(Lifetime lifetime, IProject project)
        {
            var name = $"Project {project.Name} (Unity)";
            // Set at a priority less than the .csproj.dotSettings layer, so we can be overridden
            var priority    = ProjectModelSettingsStorageMountPointPriorityClasses.ProjectShared * 0.9;
            var isAvailable =
                new IsAvailableByDataConstant <IProject>(lifetime, ProjectModelDataConstants.PROJECT, project,
                                                         myLocks);

            return(CreateMountPoint(lifetime, name, priority, isAvailable, mySettingsStorageProviders));
        }
Ejemplo n.º 3
0
        public FindAndLoadSettings(Lifetime lifetimeComponent, SettingsStorageProvidersCollection publisher, SolutionFileLocationLive solfile, IThreading threading, IFileSystemTracker filetracker, FileSettingsStorageBehavior behavior, ISolution solution, IShellLocks locks)
        {
            // In case the solution path changes, watch each value anew
            solfile.SolutionFileLocation.ForEachValue_NotNull(lifetimeComponent, (lifetimeLocation, location) =>
            {
                double priority = ProjectModelSettingsStorageMountPointPriorityClasses.SolutionShared;
                for (FileSystemPath dir = location.Directory; !dir.IsNullOrEmpty(); dir = dir.Directory)
                {
                    try
                    {
                        priority *= .9; // The upper folder, the lower priority (regular solution-shared file takes over all of them)

                        // Walk up folders
                        // TODO: add file-system-watcher here
                        foreach (FileSystemPath settingsfile in dir.GetChildFiles("*." + AutoLoadExtension, PathSearchFlags.ExcludeDirectories | PathSearchFlags.ExcludeHidden))
                        {
                            var relativePath = settingsfile.MakeRelativeTo(location.Directory).FullPath;
                            var name         = relativePath.Replace("." + AutoLoadExtension, "");

                            // Physical storage
                            IProperty <FileSystemPath> livepath = new Property <FileSystemPath>(lifetimeLocation, "StoragePath", settingsfile);
                            var storage = new XmlFileSettingsStorage(lifetimeLocation, name, livepath, SettingsStoreSerializationToXmlDiskFile.SavingEmptyContent.KeepFile, threading, filetracker, behavior, null);

                            // Mount as a layer
                            IIsAvailable availability        = new IsAvailableByDataConstant <ISolution>(lifetimeLocation, ProjectModelDataConstants.SOLUTION, solution, locks); // Only when querying in solution context (includes Application-Wide)
                            ISettingsStorageMountPoint mount = new SettingsStorageMountPoint(storage.Storage, SettingsStorageMountPoint.MountPath.Default, 0, priority, availability, name);

                            // Metadata
                            livepath.FlowInto(lifetimeLocation, mount.Metadata.GetOrCreateProperty(UserFriendlySettingsLayers.DiskFilePath, null, true));
                            mount.Metadata.Set(UserFriendlySettingsLayers.Origin, string.Format("Automatically loaded from solution parent folder, \"{0}\"", relativePath));
                            mount.Metadata.Set(UserInjectedSettingsLayers.IsHostingUserInjections, true);

                            // Publish
                            publisher.Storages.Add(lifetimeLocation, storage.Storage);
                            publisher.MountPoints.Add(lifetimeLocation, mount);
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.LogException(ex);
                    }
                }
            });
        }
Ejemplo n.º 4
0
        private static SettingsStorageMountPoint CreateMountPoint(Lifetime projectLifetime,
                                                                  IProject project, SettingsStorageProvidersCollection settingsStorageProviders,
                                                                  IShellLocks locks, ILogger logger,
                                                                  InternKeyPathComponent interned)
        {
            var storageName = $"Project {project.Name} (Unity)";
            var storage     = SettingsStorageFactory.CreateStorage(projectLifetime, storageName, logger, interned);
            var isAvailable = new IsAvailableByDataConstant <IProject>(projectLifetime,
                                                                       ProjectModelDataConstants.Project, project, locks);

            // Set at a priority less than the .csproj.dotSettings layer, so we can be overridden
            var priority   = ProjectModelSettingsStorageMountPointPriorityClasses.ProjectShared * 0.9;
            var mountPoint = new SettingsStorageMountPoint(storage, SettingsStorageMountPoint.MountPath.Default,
                                                           MountPointFlags.IsDefaultValues, priority, isAvailable, storageName);

            settingsStorageProviders.MountPoints.Add(projectLifetime, mountPoint);
            settingsStorageProviders.Storages.Add(projectLifetime, storage);

            return(mountPoint);
        }