コード例 #1
0
        public string GetKnownFolder(string knownFolder, Object requestImpl)
        {
            if (requestImpl == null)
            {
                throw new ArgumentNullException("requestImpl");
            }

            using (var request = requestImpl.As <Request>()) {
                request.Debug("Calling 'ProviderService::GetKnownFolder'");
                if (!string.IsNullOrEmpty(knownFolder))
                {
                    if (knownFolder.Equals("tmp", StringComparison.OrdinalIgnoreCase) || knownFolder.Equals("temp", StringComparison.OrdinalIgnoreCase))
                    {
                        return(FilesystemExtensions.TempPath);
                    }
                    KnownFolder folder;
                    if (Enum.TryParse(knownFolder, true, out folder))
                    {
                        return(KnownFolders.GetFolderPath(folder));
                    }
                }

                request.Error(ErrorCategory.InvalidArgument, knownFolder, Constants.Messages.UnknownFolderId, knownFolder);
            }
            return(null);
        }
コード例 #2
0
        public string GetKnownFolder(string knownFolder, IRequestObject requestObject)
        {
            Activity();

            if (requestObject == null)
            {
                throw new ArgumentNullException("requestObject");
            }

            using (var request = requestObject.As <Request>()) {
                request.Debug("Calling 'ProviderService::GetKnownFolder'");
                if (!string.IsNullOrEmpty(knownFolder))
                {
                    if (knownFolder.Equals("tmp", StringComparison.OrdinalIgnoreCase) || knownFolder.Equals("temp", StringComparison.OrdinalIgnoreCase))
                    {
                        return(FilesystemExtensions.TempPath);
                    }

                    if (knownFolder.Equals("SystemAssemblyLocation", StringComparison.OrdinalIgnoreCase))
                    {
                        return(PackageManager._instance.SystemAssemblyLocation);
                    }

                    if (knownFolder.Equals("UserAssemblyLocation", StringComparison.OrdinalIgnoreCase))
                    {
                        return(PackageManager._instance.UserAssemblyLocation);
                    }

                    if (knownFolder.Equals("ProviderAssemblyLocation", StringComparison.OrdinalIgnoreCase))
                    {
                        return(AdminPrivilege.IsElevated ? PackageManager._instance.SystemAssemblyLocation : PackageManager._instance.UserAssemblyLocation);
                    }

                    KnownFolder folder;
                    if (Enum.TryParse(knownFolder, true, out folder))
                    {
                        return(KnownFolders.GetFolderPath(folder));
                    }
                }

                request.Error(ErrorCategory.InvalidArgument, knownFolder, Constants.Messages.UnknownFolderId, knownFolder);
            }
            return(null);
        }
コード例 #3
0
        private void DeleteNuGet()
        {
            var systemBase = KnownFolders.GetFolderPath(KnownFolder.CommonApplicationData);

            Assert.False(string.IsNullOrEmpty(systemBase));

            var nugets = NugetsInPath(Path.Combine(systemBase, "oneget", "ProviderAssemblies"));

            foreach (var nuget in nugets)
            {
                nuget.TryHardToDelete();
            }

            var userBase = KnownFolders.GetFolderPath(KnownFolder.LocalApplicationData);

            Assert.False(string.IsNullOrEmpty(userBase));

            nugets = NugetsInPath(Path.Combine(userBase, "oneget", "ProviderAssemblies"));
            foreach (var nuget in nugets)
            {
                nuget.TryHardToDelete();
            }
        }