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


C# Hosting.VirtualPathProvider类代码示例

本文整理汇总了C#中System.Web.Hosting.VirtualPathProvider的典型用法代码示例。如果您正苦于以下问题:C# VirtualPathProvider类的具体用法?C# VirtualPathProvider怎么用?C# VirtualPathProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


VirtualPathProvider类属于System.Web.Hosting命名空间,在下文中一共展示了VirtualPathProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BuildManagerViewEngine

        internal BuildManagerViewEngine(IViewPageActivator viewPageActivator, IResolver<IViewPageActivator> activatorResolver,
            IDependencyResolver dependencyResolver, VirtualPathProvider pathProvider)
        {
            if (viewPageActivator != null)
            {
                _viewPageActivator = viewPageActivator;
            }
            else
            {
                _activatorResolver = activatorResolver ?? new SingleServiceResolver<IViewPageActivator>(
                                                              () => null,
                                                              new DefaultViewPageActivator(dependencyResolver),
                                                              "BuildManagerViewEngine constructor");
            }

            if (pathProvider != null)
            {
                Func<VirtualPathProvider> providerFunc = () => pathProvider;
                _fileExistsCache = new FileExistenceCache(providerFunc);
                VirtualPathProviderFunc = providerFunc;
            }
            else
            {
                if (_sharedFileExistsCache == null)
                {
                    // Startup initialization race is OK providing service remains read-only
                    _sharedFileExistsCache = new FileExistenceCache(() => HostingEnvironment.VirtualPathProvider);
                }

                _fileExistsCache = _sharedFileExistsCache;
            }
        }
开发者ID:tlycken,项目名称:aspnetwebstack,代码行数:32,代码来源:BuildManagerViewEngine.cs

示例2: LoadContent

    /// <summary>
    /// 利用指定 VirtualPathProvider 将虚拟路径所指向文件当作静态文件加载。
    /// </summary>
    /// <param name="provider">指定的 VirtualPathProvider</param>
    /// <param name="virtualPath">虚拟路径</param>
    /// <returns>加载结果</returns>
    public HtmlContentResult LoadContent( VirtualPathProvider provider, string virtualPath )
    {

      if ( !VirtualPathUtility.IsAppRelative( virtualPath ) )
        return null;

      if ( !provider.FileExists( virtualPath ) )
        return null;

      var file = provider.GetFile( virtualPath );

      if ( file == null )
        return null;



      var key = provider.GetCacheKey( virtualPath ) ?? "StaticFile_" + virtualPath;

      var content = HttpRuntime.Cache.Get( key ) as string;


      if ( content == null )
      {
        var dependency = HtmlServices.CreateCacheDependency( provider, virtualPath );
        content = LoadContent( file );

        HttpRuntime.Cache.Insert( key, content, dependency );
      }


      return new HtmlContentResult( content, key );
    }
开发者ID:ajayumi,项目名称:Jumony,代码行数:38,代码来源:StaticFileContentProvider.cs

示例3: RegisterVirtualPathProvider

 public void RegisterVirtualPathProvider(VirtualPathProvider virtualPathProvider)
 {
     // Sets up the provider chain
     var previousField = typeof(VirtualPathProvider).GetField("_previous", BindingFlags.NonPublic | BindingFlags.Instance);
     previousField.SetValue(virtualPathProvider, VirtualPathProvider);
     VirtualPathProvider = virtualPathProvider;
 }
开发者ID:Ralphvanderneut,项目名称:EPiCommerce.Integration.Sample,代码行数:7,代码来源:TestHostingEnvironment.cs

示例4: EPiServerHostingEnvironment

 public EPiServerHostingEnvironment()
 {
     //We need the first provider to be one that doesn't delegates to its parent.
     //The default hosting environment uses a MapPathBasedVirtualPathProvider but that's internal
     //so we use our custom dummy provider.
     _provider = new DummyVirtualPathProvider();
 }
开发者ID:stefanforsberg,项目名称:EPiTest,代码行数:7,代码来源:EPiServerHostingEnviroment.cs

示例5: Write

        private void Write(HttpContext context, VirtualPathProvider vpp, string cssPath)
        {
            var mappedPath = context.Server.MapPath(cssPath);
            if(File.Exists(mappedPath))
                context.Response.AddFileDependency(mappedPath);

            var file = vpp.GetFile(cssPath);
            using (var s = file.Open())
            using (var tr = new StreamReader(s))
            {
                while (tr.Peek() >= 0)
                {
                    var line = tr.ReadLine();
                    string importPath = GetImportedPath(context, vpp, cssPath, line);

                    if (string.IsNullOrEmpty(importPath))
                        // process all lines except imports
                        context.Response.Write(Process(line, VirtualPathUtility.GetDirectory(cssPath)));
                    else if (vpp.FileExists(importPath))
                        // recurse into imports and output
                        Write(context, vpp, importPath);
                    else
                        // fallback just write the line
                        context.Response.Write(line);

                    context.Response.Write(Environment.NewLine);
            
                }
            }
        }
开发者ID:JohnsonYuan,项目名称:n2cms,代码行数:30,代码来源:CssCompilerHandler.cs

示例6: ContentPathProvider

        public ContentPathProvider(VirtualPathProvider baseProvider, Configuration.Configuration services)
        {
            _baseProvider = baseProvider;
            _config = services;
            _internalResources = new Dictionary<string, string>();

            switch (_config.ViewEngineOptions.Type)
            {
                case Configuration.ViewEngineType.Razor:
                    _extension = ".cshtml";
                    break;
                case Configuration.ViewEngineType.ASPX:
                    _extension = ".aspx";
                    break;
                default:
                    throw new ArgumentException("Invalid ViewEngine Specified.");
            }

            Action<string> addResource = (file) =>
                _internalResources.Add(file + _extension, string.Format("Meek.Content.{0}.{1}{2}", _config.ViewEngineOptions.Type.ToString(), file, _extension));

            addResource("Manage");
            addResource("CreatePartial");
            addResource("List");
            addResource("BrowseFiles");
            addResource("UploadFileSuccess");
        }
开发者ID:GStore,项目名称:Meek,代码行数:27,代码来源:ContentPathProvider.cs

示例7: FindRegistrations

        public virtual IEnumerable<ViewTemplateDescription> FindRegistrations(VirtualPathProvider vpp, HttpContextBase httpContext, IEnumerable<ViewTemplateSource> sources)
        {
            foreach (var source in sources)
            {
                string virtualDir = "~/Views/" + source.ControllerName;
                if (!vpp.DirectoryExists(virtualDir))
                    continue;

                List<ViewTemplateDescription> descriptions = new List<ViewTemplateDescription>();
                foreach (var file in vpp.GetDirectory(virtualDir).Files.OfType<VirtualFile>().Where(f => f.Name.EndsWith(source.ViewFileExtension)))
                {
                    var description = AnalyzeView(httpContext, file, source.ControllerName, source.ModelType);
                    if (description != null)
                        descriptions.Add(description);
                }

                foreach (var description in descriptions)
                {
                    description.Definition.Add(new TemplateSelectorAttribute
                    {
                        Name = "TemplateName",
                        Title = "Template",
                        AllTemplates = descriptions.Select(d => new TemplateSelectorAttribute.Info { Name = d.Registration.Template, Title = d.Registration.Title }).ToArray(),
                        ContainerName = source.TemplateSelectorContainerName,
                        Required = true,
                        HelpTitle = "The page must be saved for another template's fields to appear",
                        RequiredPermission = Security.Permission.Administer
                    });
                }

                foreach (var description in descriptions)
                    yield return description;
            }
        }
开发者ID:AnonymousRetard,项目名称:n2cms,代码行数:34,代码来源:ViewTemplateAnalyzer.cs

示例8: Register

		public void Register(VirtualPathProvider provider)
		{
			if (provider == null)
				throw new ArgumentNullException("provider");

			_providers.Add(provider);
		}
开发者ID:damirarh,项目名称:griffin.mvccontrib,代码行数:7,代码来源:CompositeVirtualPathProvider.cs

示例9: AnalyzeViews

		public virtual IEnumerable<ContentRegistration> AnalyzeViews(VirtualPathProvider vpp, HttpContextBase httpContext, IEnumerable<ViewTemplateSource> sources)
		{
			var registrations = new List<ContentRegistration>();
			foreach (var source in sources)
			{
				string virtualDir = Url.ResolveTokens(Url.ThemesUrlToken) + "Default/Views/" + source.ControllerName;

				logger.DebugFormat("Analyzing directory {0}", virtualDir);

				if (!vpp.DirectoryExists(virtualDir))
				{
					virtualDir = "~/Views/" + source.ControllerName;
					if (!vpp.DirectoryExists(virtualDir))
						continue;
				}

				foreach (var file in vpp.GetDirectory(virtualDir).Files.OfType<VirtualFile>().Where(f => f.Name.EndsWith(source.ViewFileExtension)))
				{
					logger.DebugFormat("Analyzing file {0}", file.VirtualPath);

					var registration = AnalyzeView(httpContext, file, source.ControllerName, source.ModelType);
					if (registration != null)
						registrations.Add(registration);
				}
			}
			return registrations;
		}
开发者ID:grbbod,项目名称:drconnect-jungo,代码行数:27,代码来源:ViewTemplateAnalyzer.cs

示例10: FileExistenceCache

 public FileExistenceCache(VirtualPathProvider virtualPathProvider, int milliSecondsBeforeReset = 1000)
 {
     Contract.Assert(virtualPathProvider != null);
     _virtualPathProvider = virtualPathProvider;
     _virtualPathFileExists = virtualPathProvider.FileExists;
     _ticksBeforeReset = milliSecondsBeforeReset * TicksPerMillisecond;
     Reset();
 }
开发者ID:brianly,项目名称:aspnetwebstack,代码行数:8,代码来源:FileExistenceCache.cs

示例11: BuildManagerDirectoryBuilder

		public BuildManagerDirectoryBuilder (VirtualPath virtualPath)
		{
			if (virtualPath == null)
				throw new ArgumentNullException ("virtualPath");

			this.vpp = HostingEnvironment.VirtualPathProvider;
			this.virtualPath = virtualPath;
			this.virtualPathDirectory = VirtualPathUtility.GetDirectory (virtualPath.Absolute);
		}
开发者ID:tgiphil,项目名称:mono,代码行数:9,代码来源:BuildManagerDirectoryBuilder.cs

示例12: SetUp

 public override void SetUp()
 {
     base.SetUp();
     var routeData = new RouteData();
     routeData.Values["controller"] = "MyController";
     virtualPathProvider = new XsltTestVirtualPathProvider();
     _context = new ControllerContext(HttpContext, routeData, MockRepository.GenerateStub<ControllerBase>());
     mockRepository.ReplayAll();
 }
开发者ID:JonKruger,项目名称:MvcContrib,代码行数:9,代码来源:XsltViewTest.cs

示例13: MustacheView

 /// <summary>
 /// Initialise a new Pattern Lab view
 /// </summary>
 /// <param name="engine">The current view engine</param>
 /// <param name="controllerContext">The current controller context</param>
 /// <param name="virtualPathProvider">The current virtual path provider</param>
 /// <param name="viewPath">The path to the view</param>
 /// <param name="masterPath">The optional path to the master view</param>
 /// <param name="parameters">Any pattern parameters</param>
 public MustacheView(MustacheViewEngine engine, ControllerContext controllerContext,
     VirtualPathProvider virtualPathProvider, string viewPath, string masterPath, Dictionary<string, object> parameters)
 {
     _engine = engine;
     _controllerContext = controllerContext;
     _masterPath = masterPath;
     _parameters = parameters;
     _viewPath = viewPath;
     _virtualPathProvider = virtualPathProvider;
 }
开发者ID:fhchina,项目名称:patternlab-net,代码行数:19,代码来源:MustacheView.cs

示例14: ResourcePathProvider

 public ResourcePathProvider(IEnumerable<Assembly> assemblies, VirtualPathProvider previous)
 {
     this.previous = previous;
     resources = new Dictionary<string, EmbeddedFile>();
     foreach (var embeddedFile in assemblies.SelectMany(a => a.GetManifestResourceNames().Select(n => new EmbeddedFile(a, n))))
     {
         if (!resources.ContainsKey(embeddedFile.Key))
         {
             resources.Add(embeddedFile.Key, embeddedFile);
         }
     }
 }
开发者ID:chrisfoster78,项目名称:Cms4,代码行数:12,代码来源:ResourcePathProvider.cs

示例15: ResolveThemedContent

        private static string ResolveThemedContent(HttpContextBase httpContext, VirtualPathProvider vpp, string contentPath)
        {
            string theme = httpContext.GetTheme();
            if (string.IsNullOrEmpty(theme))
                return Url.ToAbsolute(contentPath);

            string themeContentPath = "~/Themes/" + theme + contentPath.TrimStart('~');
            if (!vpp.FileExists(themeContentPath))
                return Url.ToAbsolute(contentPath);

            return Url.ToAbsolute(themeContentPath);
        }
开发者ID:AnonymousRetard,项目名称:n2cms,代码行数:12,代码来源:ThemeExtensions.cs


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