protected virtual string GetNitroNetBasePath() { var rootPath = HostingEnvironment.MapPath("~/"); var basePath = PathInfo.Combine(PathInfo.Create(rootPath), PathInfo.Create(Settings.GetAppSetting("NitroNet.BasePath"))); return(basePath.ToString()); }
public static INitroNetConfig LoadNitroConfiguration(string basePath, string fileName) { if (basePath == null) { throw new ArgumentNullException("basePath"); } var basePathInfo = PathInfo.Create(basePath); var configFile = PathInfo.Combine(basePathInfo, PathInfo.Create(fileName)); if (!File.Exists(configFile.ToString())) { throw new ConfigurationException(string.Format("Could not find configuration in path '{0}' in {1}.", configFile, basePathInfo)); } NitroNetJsonConfig jsonConfig; using (var reader = new JsonTextReader(new StreamReader(new FileStream(configFile.ToString(), FileMode.Open, FileAccess.Read)))) { jsonConfig = new JsonSerializer().Deserialize <NitroNetJsonConfig>(reader); } return(new NitroNetConfig { ViewPaths = jsonConfig.ViewPaths.Select(path => GetDefaultValueIfNotSet(path, PathInfo.Create("views"))), PartialPaths = jsonConfig.PartialPaths.Select(path => GetDefaultValueIfNotSet(path, PathInfo.Create("partials"))), ComponentPaths = jsonConfig.ComponentPaths.Select(path => GetDefaultValueIfNotSet(path, PathInfo.Create("components"), PathInfo.Create("modules"))) }); }
protected virtual string GetNitroNetBasePath() { var rootPath = HostingEnvironment.MapPath("~/"); var basePath = PathInfo.Combine(PathInfo.Create(rootPath), PathInfo.Create(ConfigurationManager.AppSettings["NitroNet.BasePath"])); return(basePath.ToString()); }
public Task <string> VerifyGitRepository(string path = null) { var basePath = WorkingDirectory; var searchPath = path == null ? basePath : PathInfo.GetUnresolvedProviderPathFromPSPath(path); var dirPath = PathInfo.Combine(searchPath, ".git"); return(Task.FromResult(Directory.Exists(dirPath) ? dirPath : null)); }
private static PathInfo GetDefaultValueIfNotSet(string value, params PathInfo[] defaultLocation) { if (string.IsNullOrEmpty(value)) { return(PathInfo.Combine(defaultLocation)); } return(PathInfo.Create(value)); }
/// <summary>Registers the type mappings with the Unity container.</summary> /// <param name="container">The unity container to configure.</param> /// <remarks>There is no need to register concrete types such as controllers or API controllers (unless you want to /// change the defaults), as Unity allows resolving a concrete type even if it was not previously registered.</remarks> public static void RegisterTypes(IUnityContainer container) { // NOTE: To load from web.config uncomment the line below. Make sure to add a Microsoft.Practices.Unity.Configuration to the using statements. // container.LoadConfiguration(); // TODO: Register your types here // container.RegisterType<IProductRepository, ProductRepository>(); var rootPath = HostingEnvironment.MapPath("~/"); var basePath = PathInfo.Combine(PathInfo.Create(rootPath), PathInfo.Create(ConfigurationManager.AppSettings["NitroNet.BasePath"])).ToString(); new DefaultUnityModule(basePath).Configure(container); }