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


C# VirtualPathProvider.GetDirectory方法代码示例

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


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

示例1: AnalyzeViews

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

				virtualDirList.AddRange(
					from virtualDirectory in vpp.GetDirectory("~/Areas/").Directories.Cast<VirtualDirectory>()
					let virtualPath = String.Format("~/Areas/{0}/Views/{1}", virtualDirectory.Name, source.ControllerName)
					select virtualPath);

				foreach (var virtualDir in virtualDirList.Where(vpp.DirectoryExists))
				{
					logger.Debug(String.Format("Analyzing directory {0}", virtualDir));
					foreach (var file in vpp.GetDirectory(virtualDir).Files.OfType<VirtualFile>())
					{
						Debug.Assert(file.Name != null, "file.Name != null");
						if (!file.Name.EndsWith(source.ViewFileExtension) || file.Name.StartsWith("_"))
						{
							logger.Info(String.Format("Skipping file {0}", file.VirtualPath));
							continue;
						}
						logger.Debug(String.Format("Analyzing file {0}", file.VirtualPath));

						ContentRegistration registration = null;
						if (httpContext.IsDebuggingEnabled)
						{
							registration = AnalyzeView(httpContext, file, source.ControllerName, source.ModelType);
						}
						else
						{
							try
							{
								registration = AnalyzeView(httpContext, file, source.ControllerName, source.ModelType);
							}
							catch (Exception ex)
							{
								logger.Error(ex);
							}
						}

						if (registration != null)
							registrations.Add(registration);
					}
				}
			}
			return registrations;
		}
开发者ID:kodeo,项目名称:n2cms,代码行数:53,代码来源:ViewTemplateAnalyzer.cs

示例2: 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

示例3: 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

示例4: 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)
                    yield return description;
            }
        }
开发者ID:amarwadi,项目名称:n2cms,代码行数:20,代码来源:ViewTemplateAnalyzer.cs

示例5: FindMatchingFile

        /// <summary>
        /// Try and find a file in the specified folder that matches name.
        /// </summary>
        /// <returns>The full path to the file that matches the requested file
        /// or null if no matching file is found</returns>
        internal static string FindMatchingFile(VirtualPathProvider vpp, string folder, string name) {
            Debug.Assert(vpp != null);
            Debug.Assert(!String.IsNullOrEmpty(folder));
            Debug.Assert(!String.IsNullOrEmpty(name));

            // Get the virtual path information
            VirtualDirectory directory = vpp.GetDirectory(folder);

            // If the folder specified doesn't exist
            // or it doesn't contain any files
            if (directory == null || directory.Files == null) {
                return null;
            }

            // Go through every file in the directory
            foreach (VirtualFile file in directory.Files) {
                string path = file.VirtualPath;

                // Compare the filename to the filename that we passed
                if (Path.GetFileName(path).Equals(name, StringComparison.OrdinalIgnoreCase)) {
                    return path;
                }
            }

            // If no matching files, return null
            return null;
        }
开发者ID:jesshaw,项目名称:ASP.NET-Mvc-3,代码行数:32,代码来源:Themes.cs

示例6: GetAvailableThemes

        internal static ReadOnlyCollection<string> GetAvailableThemes(VirtualPathProvider vpp, string themeDirectory) {
            VirtualDirectory directory = vpp.GetDirectory(themeDirectory);

            var themes = new List<string>();

            // Go through every file in the directory
            foreach (VirtualDirectory dir in directory.Directories) {
                themes.Add(dir.Name);
            }
            return themes.AsReadOnly();
        }
开发者ID:jesshaw,项目名称:ASP.NET-Mvc-3,代码行数:11,代码来源:Themes.cs


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