예제 #1
0
        public static AppSettings FromAppConfig()
        {
            var settings = new AppSettings();

            var path = ConfigurationManager.AppSettings["RepositoriesDirectory"];

            if (string.IsNullOrEmpty(path)) {
                throw new InvalidOperationException("The 'Repositories' AppSetting has not been initialised.");
            }
            if(path.StartsWith("~")) {
                path = HostingEnvironment.MapPath(path);
                if(path==null) {
                    throw new ArgumentException("Virtual path '{0}' could not be mapped".With(path));
                }
            }
            if (!Directory.Exists(path)) {
                throw new DirectoryNotFoundException(
                    string.Format("Could not find the directory '{0}' which is configured as the directory of repositories.", path));
            }

            settings.RepositoriesDirectory = new DirectoryInfo(path);

            var uploadPackRaw = ConfigurationManager.AppSettings["UploadPack"];
            var receivePackRaw = ConfigurationManager.AppSettings["ReceivePack"];

            bool uploadpack;
            bool receivePack;

            if (!string.IsNullOrEmpty(uploadPackRaw) && bool.TryParse(uploadPackRaw, out uploadpack)) {
                settings.UploadPack = uploadpack;
            }

            if (!string.IsNullOrEmpty(receivePackRaw) && bool.TryParse(receivePackRaw, out receivePack)) {
                settings.ReceivePack = receivePack;
            }

            var runHooksSilentlyRaw = ConfigurationManager.AppSettings["runHooksSilently"];
            var hookTimeoutRaw = ConfigurationManager.AppSettings["hookTimeout"];

            bool runHooksSilently;
            TimeSpan hookTimeout;

            if(!string.IsNullOrEmpty(runHooksSilentlyRaw) && bool.TryParse(runHooksSilentlyRaw, out runHooksSilently)) {
                settings.RunHooksSilently = runHooksSilently;
            }
            if(!string.IsNullOrEmpty(hookTimeoutRaw) && TimeSpan.TryParse(hookTimeoutRaw, out hookTimeout)) {
                settings.HookTimeout = hookTimeout;
            } else {
                settings.HookTimeout = TimeSpan.FromMinutes(10);
            }

            return settings;
        }
예제 #2
0
        public static AppSettings FromAppConfig()
        {
            var settings = new AppSettings();

            var path = ConfigurationManager.AppSettings["RepositoriesDirectory"];

            if (string.IsNullOrEmpty(path)) {
                throw new InvalidOperationException("The 'Repositories' AppSetting has not been initialised.");
            }

            if (!Directory.Exists(path)) {
                throw new DirectoryNotFoundException(
                    string.Format("Could not find the directory '{0}' which is configured as the directory of repositories.", path));
            }

            settings.RepositoriesDirectory = new DirectoryInfo(path);

            var uploadPackRaw = ConfigurationManager.AppSettings["UploadPack"];
            var receivePackRaw = ConfigurationManager.AppSettings["ReceivePack"];
            var postRecieveHookRaw = ConfigurationManager.AppSettings["PostReceiveHook"];

            settings.FogBugzApi = ConfigurationManager.AppSettings["FogbugzUri"];

            bool uploadpack;
            bool receivePack;
            bool postRecieveHook;

            if (!string.IsNullOrEmpty(uploadPackRaw) && bool.TryParse(uploadPackRaw, out uploadpack)) {
                settings.UploadPack = uploadpack;
            }

            if (!string.IsNullOrEmpty(receivePackRaw) && bool.TryParse(receivePackRaw, out receivePack)) {
                settings.ReceivePack = receivePack;
            }

            if (!string.IsNullOrEmpty(postRecieveHookRaw) && bool.TryParse(postRecieveHookRaw, out postRecieveHook))
            {
                settings.PostRecieveHook = postRecieveHook;
            }

            return settings;
        }
예제 #3
0
        public static AppSettings FromAppConfig()
        {
            var settings = new AppSettings();

            var path = ConfigurationManager.AppSettings["RepositoriesDirectory"];

            if (string.IsNullOrEmpty(path)) {
                throw new InvalidOperationException("The 'Repositories' AppSetting has not been initialised.");
            }

            if (path.StartsWith("~/")){
                path = System.Web.HttpContext.Current.Server.MapPath(path);
            }

            if (!Directory.Exists(path)) {
                throw new DirectoryNotFoundException(
                    string.Format("Could not find the directory '{0}' which is configured as the directory of repositories.", path));
            }

            settings.RepositoriesDirectory = new DirectoryInfo(path);

            var uploadPackRaw = ConfigurationManager.AppSettings["UploadPack"];
            var receivePackRaw = ConfigurationManager.AppSettings["ReceivePack"];

            bool uploadpack;
            bool receivePack;

            if (!string.IsNullOrEmpty(uploadPackRaw) && bool.TryParse(uploadPackRaw, out uploadpack)) {
                settings.UploadPack = uploadpack;
            }

            if (!string.IsNullOrEmpty(receivePackRaw) && bool.TryParse(receivePackRaw, out receivePack)) {
                settings.ReceivePack = receivePack;
            }

            return settings;
        }
예제 #4
0
 public RepositoryService(AppSettings appSettings)
 {
     this.appSettings = appSettings;
 }
예제 #5
0
 public RepositoryService()
 {
     appSettings = AppSettings.FromAppConfig();
 }