コード例 #1
0
        private void AddAssembly(string path)
        {
            var name     = Path.GetFileNameWithoutExtension(path);
            var settings = AssembliesSettingsFile.GetOrAdd(name);

            settings.Name         = name;
            settings.OriginalPath = path;
            settings.ModifiedTime = File.GetLastWriteTimeUtc(path);
            settings.SubPath      = Path.Combine(name, Path.GetFileName(path));
        }
コード例 #2
0
        public void Uninstall(string name)
        {
            TryClean();

            var toFolder = GetAssemblyFolder(name);

            Directory.Delete(toFolder, true);

            AssembliesSettingsFile.Delete(name);

            Load();
        }
コード例 #3
0
        public void Update(string name)
        {
            if (!UpdatingIsNeed(name))
            {
                return;
            }

            var settings = AssembliesSettingsFile.Get(name);
            var path     = settings.OriginalPath;

            Uninstall(name);
            Install(path);
        }
コード例 #4
0
        public virtual void Load()
        {
            TryClean();

            AssembliesSettingsFile.Load();

            ActiveFolder = CreateActiveFolder();
            DirectoryUtilities.Copy(AssembliesFolder, ActiveFolder, true);

            ActiveAssemblies = AssembliesSettings
                               .Select(item => Path.Combine(ActiveFolder, item.Value.SubPath))
                               .Where(i => !string.IsNullOrWhiteSpace(i))
                               .Where(File.Exists)
                               .Select(LoadAssembly)
                               .ToDictionary(i => i.GetSimpleName(), i => i);
        }
コード例 #5
0
        public bool UpdatingIsNeed(string name)
        {
            var settings = AssembliesSettingsFile.Get(name);
            var path     = settings.OriginalPath;

            if (string.IsNullOrWhiteSpace(path) ||
                !File.Exists(path))
            {
                return(false);
            }

            var time      = settings.ModifiedTime;
            var checkTime = File.GetLastWriteTimeUtc(path);

            if (time == checkTime)
            {
                return(false);
            }

            return(true);
        }
コード例 #6
0
        public virtual void Save()
        {
            TryClean();

            AssembliesSettingsFile.Save();
        }