当前位置: 首页>>代码示例>>C#>>正文


C# IRootPathProvider.GetRootPath方法代码示例

本文整理汇总了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;
                };
        }
开发者ID:nathanpalmer,项目名称:Nancy.Stitch,代码行数:55,代码来源:Stitch.cs

示例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");
        }
开发者ID:khellang,项目名称:Solvberget,代码行数:12,代码来源:EnvironmentPathProvider.cs

示例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");
            };
        }
开发者ID:joakimjm,项目名称:eziou,代码行数:15,代码来源:ScriptModule.cs

示例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");
            };
        }
开发者ID:joakimjm,项目名称:eziou,代码行数:32,代码来源:LessModule.cs

示例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);
     }
 }
开发者ID:jdaigle,项目名称:CommentR,代码行数:7,代码来源:ResourcesModule.cs

示例6: ConnectionManager

        public ConnectionManager(IRootPathProvider rootPathProvider)
        {
            this.factory = DbProviderFactories.GetFactory("System.Data.SQLite");
            this.databaseName = Path.Combine(rootPathProvider.GetRootPath(), "data.db");

            CreateDatabase();
        }
开发者ID:jchannon,项目名称:Glimpse.Nancy,代码行数:7,代码来源:ConnectionManager.cs

示例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);
            };
        }
开发者ID:RobertTheGrey,项目名称:Nancy,代码行数:34,代码来源:InfoModule.cs

示例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);
        }
开发者ID:charlesarmitage,项目名称:Timesheet-Moose,代码行数:10,代码来源:TimesheetModule.cs

示例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);
    }
开发者ID:thefringeninja,项目名称:Cassette.Nancy,代码行数:11,代码来源:CassetteStartup.cs

示例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)];
        }
开发者ID:MingLu8,项目名称:Nancy.WebApi.HelpPages,代码行数:15,代码来源:HelpApi.cs

示例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;
        }
开发者ID:TIMBS,项目名称:OutlookParser,代码行数:17,代码来源:FileUploadModule.cs

示例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;
        }
开发者ID:nfink,项目名称:Haven,代码行数:21,代码来源:Bootstrapper.cs

示例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));
                };
        }
开发者ID:NicoleMurphy,项目名称:ConfluxWritersDay,代码行数:39,代码来源:HomeModule.cs

示例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();
 }
开发者ID:rspacjer,项目名称:Nancy,代码行数:8,代码来源:RootPathStartup.cs

示例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;
        }
开发者ID:charlesarmitage,项目名称:Timesheet-Moose,代码行数:18,代码来源:TimesheetModule.cs


注:本文中的IRootPathProvider.GetRootPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。