本文整理汇总了C#中PathDefinition类的典型用法代码示例。如果您正苦于以下问题:C# PathDefinition类的具体用法?C# PathDefinition怎么用?C# PathDefinition使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PathDefinition类属于命名空间,在下文中一共展示了PathDefinition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetCacheDependency
/// <summary>
/// Creates a cache dependency based on the specified virtual paths.
/// </summary>
/// <param name="definition">The definition.</param>
/// <param name="virtualPath">The path to the primary virtual resource.</param>
/// <returns>
/// A <see cref="T:System.Web.Caching.CacheDependency"/> object for the specified virtual resources.
/// </returns>
public virtual CacheDependency GetCacheDependency(PathDefinition definition, string virtualPath, IEnumerable virtualPathDependencies, DateTime utcStart)
{
CacheDependency result = this.GetCurrentCacheDependency(definition, virtualPath, virtualPathDependencies, utcStart);
//If the requested file does not exist in the current resolver then keep these dependencies and add dependencies of the next resolver.
//This will allow the resolvers higher in the chain to be pinged again when the file might be available to them.
if (this.Next != null && !this.CurrentExists(definition, virtualPath))
{
var nextDependencies = this.Next.GetCacheDependency(definition, virtualPath, virtualPathDependencies, utcStart);
if (nextDependencies != null)
{
if (result != null)
{
var aggr = new AggregateCacheDependency();
aggr.Add(result, nextDependencies);
result = aggr;
}
else
{
result = nextDependencies;
}
}
}
return result;
}
示例2: Exists
/// <summary>
/// Determines whether a file with the specified virtual path exists.
/// </summary>
/// <param name="virtualPath">The virtual path to check.</param>
public virtual bool Exists(PathDefinition definition, string virtualPath)
{
virtualPath = this.RemoveParams(virtualPath);
var resolverStrategy = ObjectFactory.Resolve<IResourceResolverStrategy>();
return resolverStrategy.Exists(definition, virtualPath);
}
示例3: GetCacheDependency
/// <summary>
/// Creates a cache dependency based on the specified virtual paths.
/// </summary>
/// <param name="definition">The definition.</param>
/// <param name="virtualPath">The path to the primary virtual resource.</param>
/// <returns>
/// A <see cref="T:System.Web.Caching.CacheDependency"/> object for the specified virtual resources.
/// </returns>
public virtual CacheDependency GetCacheDependency(PathDefinition definition, string virtualPath, IEnumerable virtualPathDependencies, DateTime utcStart)
{
virtualPath = this.virtualPathBuilder.RemoveParams(virtualPath);
var resolverStrategy = ObjectFactory.Resolve<IResourceResolverStrategy>();
return resolverStrategy.GetCacheDependency(definition, virtualPath, virtualPathDependencies, utcStart);
}
示例4: Open
/// <summary>
/// Opens the the file with the specified virtual path.
/// </summary>
/// <param name="virtualPath">The virtual path of the file to open.</param>
public virtual Stream Open(PathDefinition definition, string virtualPath)
{
virtualPath = this.virtualPathBuilder.RemoveParams(virtualPath);
var resolverStrategy = ObjectFactory.Resolve<IResourceResolverStrategy>();
return resolverStrategy.Open(definition, virtualPath);
}
示例5: GetControlPresentation
/// <summary>
/// Gets the control presentation that contains the requested resource from the database.
/// </summary>
/// <param name="virtualPathDefinition">The definition.</param>
/// <param name="virtualPath">The virtual path.</param>
/// <returns></returns>
protected override ControlPresentation GetControlPresentation(PathDefinition virtualPathDefinition, string virtualPath)
{
if (this.ControlPresentationResult.ContainsKey(virtualPath))
return this.ControlPresentationResult[virtualPath];
else
return null;
}
示例6: Open
/// <summary>
/// Opens the the file with the specified virtual path.
/// </summary>
/// <param name="definition">The definition.</param>
/// <param name="virtualPath">The virtual path of the file to open.</param>
/// <returns></returns>
public virtual Stream Open(PathDefinition definition, string virtualPath)
{
if (this.Next != null && !this.CurrentExists(definition, virtualPath))
return this.Next.Open(definition, virtualPath);
return this.CurrentOpen(definition, virtualPath);
}
示例7: CurrentOpen
/// <inheritdoc />
protected override Stream CurrentOpen(PathDefinition definition, string virtualPath)
{
Assembly assembly = this.GetAssembly(definition);
var resourceName = this.GetResourceName(definition, virtualPath);
var resources = assembly.GetManifestResourceNames();
var caseSensitiveName = resources.First(r => string.Equals(resourceName, r, StringComparison.OrdinalIgnoreCase));
var stream = assembly.GetManifestResourceStream(caseSensitiveName);
return stream;
}
示例8: Exists
/// <inheritdoc />
public override bool Exists(PathDefinition definition, string virtualPath)
{
if (this.ExistsMock != null)
{
return this.ExistsMock(definition, virtualPath);
}
else
{
return base.Exists(definition, virtualPath);
}
}
示例9: CurrentExists
/// <inheritdoc />
protected override bool CurrentExists(PathDefinition definition, string virtualPath)
{
if (definition.ResourceLocation.IsNullOrEmpty())
return false;
Assembly assembly = this.GetAssembly(definition);
var resourceName = this.GetResourceName(definition, virtualPath);
var resources = assembly.GetManifestResourceNames();
return resources.Contains(resourceName, StringComparer.OrdinalIgnoreCase);
}
示例10: GetCurrentFiles
/// <inheritdoc />
protected override IEnumerable<string> GetCurrentFiles(PathDefinition definition, string path)
{
var mappedPath = this.GetFileName(definition, path);
if (mappedPath != null && Directory.Exists(mappedPath))
{
return Directory.GetFiles(mappedPath)
.Select(f => f.Replace(mappedPath, path));
}
return null;
}
示例11: CurrentOpen
/// <inheritdoc />
protected override Stream CurrentOpen(PathDefinition definition, string virtualPath)
{
var controlPresentation = this.GetControlPresentation(definition, virtualPath);
if (controlPresentation != null && !controlPresentation.Data.IsNullOrEmpty())
{
var bytes = RouteHelper.GetContentWithPreamble(controlPresentation.Data);
return new MemoryStream(bytes);
}
throw new ArgumentException("Could not find resource at " + virtualPath + " in the database.");
}
示例12: GetControlPresentation
/// <summary>
/// Gets the control presentation that contains the requested resource from the database.
/// </summary>
/// <param name="definition">The definition.</param>
/// <param name="virtualPath">The virtual path.</param>
protected virtual ControlPresentation GetControlPresentation(PathDefinition definition, string virtualPath)
{
var resourceName = VirtualPathUtility.ToAppRelative(virtualPath);
var areaName = VirtualPathUtility.AppendTrailingSlash(VirtualPathUtility.ToAppRelative(definition.VirtualPath));
var extension = VirtualPathUtility.GetExtension(virtualPath).ToLower();
var controlPresentation = PageManager.GetManager().GetPresentationItems<ControlPresentation>()
.FirstOrDefault(cp => cp.AreaName == areaName && cp.NameForDevelopers == resourceName
&& cp.DataType == extension);
return controlPresentation;
}
示例13: GetCurrentCacheDependency
/// <inheritdoc />
protected override CacheDependency GetCurrentCacheDependency(PathDefinition definition, string virtualPath, IEnumerable virtualPathDependencies, DateTime utcStart)
{
var controlPresentation = this.GetControlPresentation(definition, virtualPath);
if (controlPresentation != null)
{
return new ControlPresentationCacheDependency(controlPresentation.Id.ToString());
}
// Change to any ControlPresentation record will invalidate the cache for this virtual path.
return new ControlPresentationCacheDependency(typeof(ControlPresentation));
}
示例14: GetCacheDependency
/// <inheritdoc />
public override CacheDependency GetCacheDependency(PathDefinition definition, string virtualPath, IEnumerable virtualPathDependencies, DateTime utcStart)
{
if (this.GetCacheDependencyMock != null)
{
return this.GetCacheDependencyMock(definition, virtualPath, virtualPathDependencies, utcStart);
}
else
{
return base.GetCacheDependency(definition, virtualPath, virtualPathDependencies, utcStart);
}
}
示例15: GetCacheDependency
public System.Web.Caching.CacheDependency GetCacheDependency(PathDefinition definition, string virtualPath, IEnumerable virtualPathDependencies, DateTime utcStart)
{
var id = this.ResolveFormDescriptionId(virtualPath);
if (id != null && this.DescriptionExists(id.Value))
{
return new DataItemSystemCacheDependency(typeof(FormDescription), itemId: id.Value.ToString("D"));
}
else
{
return new DataItemSystemCacheDependency(typeof(FormDescription));
}
}