本文整理汇总了C#中IRootPathProvider.GetRootPath方法的典型用法代码示例。如果您正苦于以下问题:C# IRootPathProvider.GetRootPath方法的具体用法?C# IRootPathProvider.GetRootPath怎么用?C# IRootPathProvider.GetRootPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRootPathProvider
的用法示例。
在下文中一共展示了IRootPathProvider.GetRootPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetStitchResponse
private static Func<NancyContext, Response> GetStitchResponse(IEnumerable<ICompile> compilers, IRootPathProvider rootPathProvider, IStitchConfiguration configuration)
{
return ctx =>
{
if (ctx.Request == null) return null;
if (compilers == null) return null;
if (rootPathProvider == null) return null;
if (ctx.Request.Uri.ToLowerInvariant().EndsWith(".stitch"))
{
Package package = null;
if (configuration.Files != null)
{
var file = configuration.Files.Where(f => f.Name.Equals(ctx.Request.Uri, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();
if (file != null)
{
package = new Package(
rootPathProvider.GetRootPath(),
file.Paths,
file.Dependencies,
file.Identifier ?? configuration.Identifier ?? "require",
compilers);
}
}
if (package == null)
{
package = new Package(
rootPathProvider.GetRootPath(),
configuration.Paths,
configuration.Dependencies,
configuration.Identifier ?? "require",
compilers);
}
var response = new Response
{
StatusCode = HttpStatusCode.OK,
ContentType = "application/x-javascript",
Contents = s =>
{
using (var writer = new StreamWriter(s))
{
writer.Write(package.Compile());
writer.Flush();
}
}
};
return response;
}
return null;
};
}
示例2: EnvironmentPathProvider
public EnvironmentPathProvider(IRootPathProvider rootPathProvider)
{
_rootPath = rootPathProvider.GetRootPath();
_rootUrl = "http://localhost:39465/"; // todo:
var dataPath = WebConfigurationManager.AppSettings["DataPath"];
if (String.IsNullOrEmpty(dataPath)) dataPath = _rootPath;
_applicationAppDataPath = Path.Combine(dataPath, @"Data");
_applicationContentDataPath = Path.Combine(rootPathProvider.GetRootPath(), @"Content");
}
示例3: ScriptModule
public ScriptModule(IRootPathProvider root, ScriptBuilder scriptBuilder)
{
Get["/js/debug"] = _ =>
{
return Response.AsText(scriptBuilder.GetScripts(root.GetRootPath(), false), "application/javascript");
};
Get["/js/min"] = _ =>
{
//Maybe some server side caching could be great
//In the future, when retrieving scripts becomes relative to the user role, the cache could map roles and relevant scripts together
return Response.AsText(scriptBuilder.GetScripts(root.GetRootPath(), true), "application/javascript");
};
}
示例4: LessModule
public LessModule(IRootPathProvider root)
{
var urlPrefix = System.Configuration.ConfigurationManager.AppSettings["app:UrlPrefix"] ?? string.Empty;
Get[urlPrefix + "/less/desktop"] = _ =>
{
var manifest = System.Configuration.ConfigurationManager.AppSettings["app:LessManifest"];
if (manifest.StartsWith("/"))
{
manifest = manifest.Substring(1);
}
manifest = manifest.Replace("/", "\\");
var lessFile = Path.Combine(root.GetRootPath(), manifest);
if (!File.Exists(lessFile))
{
throw new FileNotFoundException("Less manifest was not found");
}
var less = File.ReadAllText(lessFile);
var config = dotless.Core.configuration.DotlessConfiguration.GetDefaultWeb();
config.Logger = typeof(dotless.Core.Loggers.AspResponseLogger);
config.CacheEnabled = false;
config.MinifyOutput = true;
var css = dotless.Core.LessWeb.Parse(less, config);
return Response.AsText(css, "text/css");
};
}
示例5: RenderExternalJavascript
public static void RenderExternalJavascript(Stream responseStream, IRootPathProvider rootPath)
{
using (var js = new FileStream(Path.Combine(rootPath.GetRootPath(), "content/external.js"), FileMode.Open))
{
js.CopyTo(responseStream);
}
}
示例6: ConnectionManager
public ConnectionManager(IRootPathProvider rootPathProvider)
{
this.factory = DbProviderFactories.GetFactory("System.Data.SQLite");
this.databaseName = Path.Combine(rootPathProvider.GetRootPath(), "data.db");
CreateDatabase();
}
示例7: InfoModule
public InfoModule(IRootPathProvider rootPathProvider, NancyInternalConfiguration configuration)
: base("/info")
{
Get["/"] = _ => View["Info"];
Get["/data"] = _ =>
{
dynamic data = new ExpandoObject();
data.Nancy = new ExpandoObject();
data.Nancy.Version = string.Format("v{0}", this.GetType().Assembly.GetName().Version.ToString());
data.Nancy.CachesDisabled = StaticConfiguration.DisableCaches;
data.Nancy.TracesDisabled = StaticConfiguration.DisableErrorTraces;
data.Nancy.CaseSensitivity = StaticConfiguration.CaseSensitive ? "Sensitive" : "Insensitive";
data.Nancy.RootPath = rootPathProvider.GetRootPath();
data.Nancy.Hosting = this.GetHosting();
data.Nancy.BootstrapperContainer = this.GetBootstrapperContainer();
data.Nancy.LocatedBootstrapper = NancyBootstrapperLocator.Bootstrapper.GetType().ToString();
data.Nancy.LoadedViewEngines = GetViewEngines();
data.Configuration = new Dictionary<string, object>();
foreach (var propertyInfo in configuration.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public))
{
var value =
propertyInfo.GetValue(configuration, null);
data.Configuration[propertyInfo.Name] = (!typeof(IEnumerable).IsAssignableFrom(value.GetType())) ?
new[] { value.ToString() } :
((IEnumerable<object>) value).Select(x => x.ToString());
}
return Response.AsJson((object)data);
};
}
示例8: BuildFileDownloadResponse
private static dynamic BuildFileDownloadResponse(IRootPathProvider pathProvider, string fileName)
{
var mimeType = MimeTypes.GetMimeType(fileName);
var path = Path.Combine(pathProvider.GetRootPath(), fileName);
Func<Stream> file = () => new FileStream(path, FileMode.Open);
var response = new StreamResponse(file, mimeType);
var fileInfo = new FileInfo(path);
return response.AsAttachment(fileInfo.Name);
}
示例9: CassetteStartup
public CassetteStartup(IRootPathProvider rootPathProvider)
{
this.rootPathProvider = rootPathProvider;
// This will trigger creation of the Cassette infrastructure at the time of the first request.
// The virtual directory is not known until that point, and the virtual directory is required for creation.
this.getApplication = InitializeApplication;
CassetteApplicationContainer.SetApplicationAccessor(() => getApplication());
routeGenerator = new CassetteRouteGenerator(rootPathProvider.GetRootPath(), GetCurrentContext);
}
示例10: HelpApi
public HelpApi(IRootPathProvider pathProvider):base("/help")
{
var xmlDocPath = Path.Combine(pathProvider.GetRootPath(), ConfigurationManager.AppSettings["xmlDocumentationFile"]);
_apiExplorer = new DefaultApiExplorer(ModulePath, xmlDocPath);
Get["/"] = q => View["RouteCatelog.cshtml", _apiExplorer.ModuleRouteCatelog];
Get["/{api*}"] = context =>
{
var model = _apiExplorer.GetRouteDetail(Request.Path);
return View["RouteDetail.cshtml", model];
};
Get["/resourceModel/{modelName}"] = context => View["ResourceModel.cshtml", _apiExplorer.GetResourceDetail(Request.Path)];
}
示例11: SaveFile
protected string SaveFile(HttpFile file, IRootPathProvider pathProvider)
{
var uploadDirectory = Path.Combine(pathProvider.GetRootPath(), "Content", "uploads");
if (!Directory.Exists(uploadDirectory))
{
Directory.CreateDirectory(uploadDirectory);
}
var filename = Path.Combine(uploadDirectory, System.Guid.NewGuid().ToString() + file.Name); //HACK creates a unique file name by prepending a Guid
using (FileStream fileStream = new FileStream(filename, FileMode.Create))
{
file.Value.CopyTo(fileStream);
}
return filename;
}
示例12: TransformJSX
public static IEnumerable<string> TransformJSX(IRootPathProvider pathProvider)
{
var outputFiles = new List<string>();
bool useHarmony = false;
bool stripTypes = false;
var config = React.AssemblyRegistration.Container.Resolve<IReactSiteConfiguration>();
config
.SetReuseJavaScriptEngines(false)
.SetUseHarmony(useHarmony)
.SetStripTypes(stripTypes);
var environment = React.AssemblyRegistration.Container.Resolve<IReactEnvironment>();
string root = pathProvider.GetRootPath();
var files = Directory.EnumerateFiles(root + "Scripts", "*.jsx", SearchOption.AllDirectories);
foreach (var path in files)
{
outputFiles.Add(environment.JsxTransformer.TransformAndSaveJsxFile("~/" + path.Replace(root, string.Empty)));
}
return outputFiles;
}
示例13: HomeModule
public HomeModule(
IMarkdownRepository markdownRepository,
IMembershipOrganisationRepository membershipOrganisationRepository,
IPaymentMethodRepository paymentMethodRepository,
RegistrationViewModel registrationViewModel,
IRootPathProvider rootPathProvider
)
{
// todo: do I really need / and /{page}?
Get["/"] = parameters =>
{
return PageView(markdownRepository.GetMarkdown("home"));
};
Get["/registration"] = parameters =>
{
var isDeveloperMachine = rootPathProvider.GetRootPath().StartsWith(@"C:\Users\Tim\Code\");
return View["registration", new { isDeveloperMachine }];
};
Post["/registration"] = parameters =>
{
this.BindTo(registrationViewModel);
var validation = this.Validate(registrationViewModel);
if (!validation.IsValid)
{
return View["registration", registrationViewModel];
}
throw new System.NotImplementedException("post valid viewmodel");
};
Get["/{page}", ctx => markdownRepository.MarkdownExists(ctx.Request.Path)] = parameters =>
{
return PageView(markdownRepository.GetMarkdown(parameters.page));
};
}
示例14: RootPathStartup
/// <summary>
/// Initializes a new instance of the <see cref="RootPathStartup"/> class.
/// </summary>
/// <param name="rootPathProvider">An <see cref="IRootPathProvider"/> instance.</param>
public RootPathStartup(IRootPathProvider rootPathProvider)
{
GenericFileResponse.RootPath = rootPathProvider.GetRootPath();
}
示例15: ConfigureTimesheetModules
private void ConfigureTimesheetModules(IRootPathProvider pathProvider)
{
var configPath = Path.Combine(pathProvider.GetRootPath(), "timesheet.config");
config = new TimesheetConfig();
using (var timesheetStream = new StreamReader(configPath))
{
var configXml = new XmlSerializer(typeof(TimesheetConfig));
config = (TimesheetConfig)configXml.Deserialize(timesheetStream);
timesheetStream.Close();
}
timesheetLog = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Timesheet.log");
timesheetPythonModulesPath = Path.Combine(pathProvider.GetRootPath(), config.Module.Relativepath);
estimatedHoursScript = Path.Combine(timesheetPythonModulesPath, config.WeeksFeed.Filename);
spreadsheetGeneratorScript = Path.Combine(timesheetPythonModulesPath, config.SpreadsheetGenerator.Filename);
timesheetWriterType = config.WriterType.Type ?? string.Empty;
}