本文整理汇总了C#中ClientDependencyType类的典型用法代码示例。如果您正苦于以下问题:C# ClientDependencyType类的具体用法?C# ClientDependencyType怎么用?C# ClientDependencyType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ClientDependencyType类属于命名空间,在下文中一共展示了ClientDependencyType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: AddResourceToClientDependency
/// <summary>
/// Adds an embedded resource to the ClientDependency output by name
/// </summary>
/// <param name="ctl">The CTL.</param>
/// <param name="resourceName">Name of the resource.</param>
/// <param name="type">The type.</param>
public static void AddResourceToClientDependency(this Control ctl, string resourceName, ClientDependencyType type)
{
//get the urls for the embedded resources
//var resourceUrl = ctl.Page.ClientScript.GetWebResourceUrl(ctl.GetType(), resourceName);
var resourceUrl = ctl.Page.ClientScript.GetWebResourceUrl(typeof(AbstractPrevalueEditor), resourceName);
//This only works in v4 currently or until i release CD version 1.2, so in the meantime, we'll use the below method
//add the resources to client dependency
//ClientDependencyLoader.Instance.RegisterDependency(resourceUrl, type);
switch (type)
{
case ClientDependencyType.Css:
ctl.Page.Header.Controls.Add(
new LiteralControl("<link type='text/css' rel='stylesheet' href='" + resourceUrl + "' />"));
break;
case ClientDependencyType.Javascript:
ctl.Page.ClientScript.RegisterClientScriptResource(typeof(ResourceExtensions), resourceName);
break;
default:
break;
}
}
开发者ID:Jeavon,项目名称:Cloud-Proivders-for-Universal-Media-Picker,代码行数:31,代码来源:ResourceExtensions.cs
示例2: BasicFile
public BasicFile(ClientDependencyType type)
{
DependencyType = type;
HtmlAttributes = new Dictionary<string, string>();
Priority = Constants.DefaultPriority;
Group = Constants.DefaultGroup;
}
开发者ID:dufkaf,项目名称:ClientDependency,代码行数:7,代码来源:BasicFile.cs
示例3: CreatePath
/// <summary>
/// Creates a path based on the format, fileKey, type and version specified.
/// </summary>
/// <param name="pathBasedUrlFormat"></param>
/// <param name="fileKey"></param>
/// <param name="type"></param>
/// <param name="version"></param>
/// <returns></returns>
public static string CreatePath(string pathBasedUrlFormat, string fileKey, ClientDependencyType type, int version)
{
var pathUrl = pathBasedUrlFormat;
var dependencyId = new StringBuilder();
int pos = 0;
//split paths at a max of 240 chars to not exceed the max path length of a URL
while (fileKey.Length > pos)
{
if (dependencyId.Length > 0)
{
dependencyId.Append('/');
}
var len = Math.Min(fileKey.Length - pos, 240);
dependencyId.Append(fileKey.Substring(pos, len));
pos += 240;
}
pathUrl = pathUrl.Replace("{dependencyId}", dependencyId.ToString());
pathUrl = pathUrl.Replace("{version}", version.ToString());
switch (type)
{
case ClientDependencyType.Css:
pathUrl = pathUrl.Replace("{type}", "css");
break;
case ClientDependencyType.Javascript:
pathUrl = pathUrl.Replace("{type}", "js");
break;
}
return pathUrl;
}
开发者ID:dufkaf,项目名称:ClientDependency,代码行数:37,代码来源:PathBasedUrlFormatter.cs
示例4: RegisterIncludes
private void RegisterIncludes(IEnumerable<BasicFile> files, ClientDependencyLoader loader, ClientDependencyType dependencyType)
{
foreach (var file in files)
{
loader.RegisterDependency(file.Group, file.Priority, file.FilePath, "", dependencyType, file.HtmlAttributes, file.ForceProvider);
}
}
开发者ID:dufkaf,项目名称:ClientDependency,代码行数:7,代码来源:HtmlInclude.cs
示例5: WriteContentToStream
/// <summary>
/// Writes the actual contents of a file or request result to the stream and ensures the contents are minified if necessary
/// </summary>
/// <param name="provider"></param>
/// <param name="sw"></param>
/// <param name="content"></param>
/// <param name="type"></param>
/// <param name="context"></param>
/// <param name="originalUrl">The original Url that the content is related to</param>
internal static void WriteContentToStream(BaseCompositeFileProcessingProvider provider, StreamWriter sw, string content, ClientDependencyType type, HttpContextBase context, string originalUrl)
{
if (type == ClientDependencyType.Css)
{
IEnumerable<string> importedPaths;
var removedImports = CssHelper.ParseImportStatements(content, out importedPaths);
//need to write the imported sheets first since these theoretically should *always* be at the top for browser to support them
foreach (var importPath in importedPaths)
{
var uri = new Uri(originalUrl, UriKind.RelativeOrAbsolute)
.MakeAbsoluteUri(context);
var absolute = uri.ToAbsolutePath(importPath);
provider.WritePathToStream(ClientDependencyType.Css, absolute, context, sw);
}
//ensure the Urls in the css are changed to absolute
var parsedUrls = CssHelper.ReplaceUrlsWithAbsolutePaths(removedImports, originalUrl, context);
//then we write the css with the removed import statements
sw.WriteLine(provider.MinifyFile(parsedUrls, ClientDependencyType.Css));
}
else
{
sw.WriteLine(provider.MinifyFile(content, type));
}
}
开发者ID:belmer,项目名称:ClientDependency,代码行数:36,代码来源:DefaultFileWriter.cs
示例6: RegisterEmbeddedClientResource
/// <summary>
/// Registers the embedded client resource.
/// </summary>
/// <param name="page">The page.</param>
/// <param name="resourceContainer">The type containing the embedded resource</param>
/// <param name="resourceName">Name of the resource.</param>
/// <param name="type">The type.</param>
public static void RegisterEmbeddedClientResource(this Page page, Type resourceContainer, string resourceName, ClientDependencyType type)
{
var target = page.Header;
// if there's no <head runat="server" /> don't throw an exception.
if (target != null)
{
switch (type)
{
case ClientDependencyType.Css:
// get the urls for the embedded resources
var resourceUrl = page.ClientScript.GetWebResourceUrl(resourceContainer, resourceName);
var link = new HtmlLink();
link.Attributes.Add("href", resourceUrl);
link.Attributes.Add("type", "text/css");
link.Attributes.Add("rel", "stylesheet");
target.Controls.Add(link);
break;
case ClientDependencyType.Javascript:
page.ClientScript.RegisterClientScriptResource(resourceContainer, resourceName);
break;
default:
break;
}
}
}
开发者ID:phaniarveti,项目名称:Experiments,代码行数:35,代码来源:ResourceExtensions.cs
示例7: GetCompositeFileUrl
/// <summary>
/// Returns the url for the composite file handler for the filePath specified.
/// </summary>
/// <param name="filePaths"></param>
/// <param name="type"></param>
/// <param name="http"></param>
/// <returns></returns>
public static string GetCompositeFileUrl(string filePaths, ClientDependencyType type, HttpContextBase http)
{
//build the combined composite list url
string handler = "{0}?s={1}&t={2}";
string combinedurl = string.Format(handler, ClientDependencySettings.Instance.CompositeFileHandlerPath, http.Server.UrlEncode(EncodeTo64(filePaths)), type.ToString());
return combinedurl;
}
开发者ID:aozora,项目名称:arashi,代码行数:14,代码来源:BaseFileRegistrationProvider.cs
示例8: WriteToStream
public bool WriteToStream(BaseCompositeFileProcessingProvider provider, StreamWriter sw, FileInfo fi, ClientDependencyType type, string origUrl, HttpContextBase http)
{
try
{
//if it is a file based dependency then read it
var fileContents = File.ReadAllText(fi.FullName, Encoding.UTF8); //read as utf 8
//for our custom file reader to work we just need to put the origUrl into the httpcontext items so
//we can retreive it in the reader to then figure out the 'real' requested path.
http.Items["Cdf_LessWriter_origUrl"] = origUrl;
//get the default less config
var config = DotlessConfiguration.GetDefaultWeb();
//set the file reader to our custom file reader
config.LessSource = typeof(CdfFileReader);
//disable cache for this engine since we are already caching our own, plus enabling this will cause errors because
// the import paths aren't resolved properly.
config.CacheEnabled = false;
//get the engine based on the custom config with our custom file reader
var lessEngine = LessWeb.GetEngine(config);
var output = lessEngine.TransformToCss(fileContents, origUrl);
DefaultFileWriter.WriteContentToStream(provider, sw, output, type, http, origUrl);
return true;
}
catch (Exception ex)
{
ClientDependencySettings.Instance.Logger.Error(string.Format("Could not write file {0} contents to stream. EXCEPTION: {1}", fi.FullName, ex.Message), ex);
return false;
}
}
开发者ID:ElijahGlover,项目名称:ClientDependency,代码行数:32,代码来源:LessWriter.cs
示例9: ScanPropertyEditors
/// <summary>
/// Get all dependencies declared on property editors
/// </summary>
/// <param name="cdfType"></param>
/// <param name="httpContext"></param>
/// <returns></returns>
protected JArray ScanPropertyEditors(ClientDependencyType cdfType, HttpContextBase httpContext)
{
if (httpContext == null) throw new ArgumentNullException("httpContext");
var cdfAttributes =
PropertyEditorResolver.Current.PropertyEditors
.SelectMany(x => x.GetType().GetCustomAttributes<PropertyEditorAssetAttribute>(false))
.Where(x => x.AssetType == cdfType)
.Select(x => x.DependencyFile)
.ToList();
string jsOut;
string cssOut;
var renderer = ClientDependencySettings.Instance.MvcRendererCollection["Umbraco.DependencyPathRenderer"];
renderer.RegisterDependencies(cdfAttributes, new HashSet<IClientDependencyPath>(), out jsOut, out cssOut, httpContext);
var toParse = cdfType == ClientDependencyType.Javascript ? jsOut : cssOut;
var result = new JArray();
//split the result by the delimiter and add to the array
foreach (var u in toParse.Split(new[] { DependencyPathRenderer.Delimiter }, StringSplitOptions.RemoveEmptyEntries))
{
result.Add(u);
}
return result;
}
开发者ID:phaniarveti,项目名称:Experiments,代码行数:31,代码来源:AssetInitialization.cs
示例10: BundleDefinition
public BundleDefinition(
ClientDependencyType type,
string name)
{
if (name == null) throw new ArgumentNullException("name");
Type = type;
Name = name;
}
开发者ID:pynej,项目名称:ClientDependency,代码行数:8,代码来源:BundleDefinition.cs
示例11: PlaceholderReplacementEventArgs
public PlaceholderReplacementEventArgs(
HttpContextBase httpContext,
ClientDependencyType type,
string replacedText,
Match regexMatch)
: base(httpContext, replacedText)
{
Type = type;
RegexMatch = regexMatch;
}
开发者ID:dufkaf,项目名称:ClientDependency,代码行数:10,代码来源:PlaceholderReplacementEventArgs.cs
示例12: BundleDefinition
public BundleDefinition(
ClientDependencyType type,
string name,
int priority = Constants.DefaultPriority, int group = Constants.DefaultGroup)
{
if (name == null) throw new ArgumentNullException("name");
Type = type;
Name = name;
Group = group;
Priority = priority;
}
开发者ID:dufkaf,项目名称:ClientDependency,代码行数:11,代码来源:BundleDefinition.cs
示例13: ClientDependencyAttribute
/// <summary>
/// Initializes a new instance of the <see cref="ClientDependencyAttribute"/> class.
/// </summary>
/// <param name="priority">The priority.</param>
/// <param name="dependencyType">Type of the dependency.</param>
/// <param name="filePath">The file path to the dependency.</param>
/// <param name="appendUmbracoPath">if set to <c>true</c> the current umbraco path will be prefixed to the filePath.</param>
/// <param name="invokeJavascriptMethodOnLoad">The name of the Javascript method to invoke when the dependency is loaded.</param>
public ClientDependencyAttribute(int priority, ClientDependencyType dependencyType, string filePath, bool appendUmbracoPath, string invokeJavascriptMethodOnLoad)
{
if (String.IsNullOrEmpty(filePath))
throw new ArgumentException("filePath");
Priority = priority;
FilePath = appendUmbracoPath ? GlobalSettings.Path + "/" + filePath : filePath;
DependencyType = dependencyType;
InvokeJavascriptMethodOnLoad = invokeJavascriptMethodOnLoad ?? String.Empty;
ClientDependencyLoader.Instance.RegisterDependency(FilePath, DependencyType == ClientDependencyType.Css ? ClientDependency.Core.ClientDependencyType.Css : ClientDependency.Core.ClientDependencyType.Javascript);
}
开发者ID:CarlSargunar,项目名称:Umbraco-CMS,代码行数:20,代码来源:ClientDependencyAttribute.cs
示例14: MinifyFile
protected override string MinifyFile(string fileContents, ClientDependencyType type)
{
switch (type)
{
case ClientDependencyType.Css:
return MinifyCss ? CssMin.CompressCSS(fileContents) : fileContents;
case ClientDependencyType.Javascript:
return MinifyJs ? JSMin.CompressJS(fileContents) : fileContents;
default:
return fileContents;
}
}
开发者ID:VegasoftTI,项目名称:Dnn.Platform,代码行数:12,代码来源:DnnCompositeFileProcessingProvider.cs
示例15: CombineFiles
/// <summary>
/// combines all files to a byte array
/// </summary>
/// <param name="filePaths"></param>
/// <param name="context"></param>
/// <param name="type"></param>
/// <param name="fileDefs"></param>
/// <returns></returns>
public override byte[] CombineFiles(string[] filePaths, HttpContextBase context, ClientDependencyType type, out List<CompositeFileDefinition> fileDefs)
{
var ms = new MemoryStream(5000);
var sw = new StreamWriter(ms, Encoding.UTF8);
var fDefs = filePaths.Select(s => WritePathToStream(type, s, context, sw)).Where(def => def != null).ToList();
sw.Flush();
byte[] outputBytes = ms.ToArray();
sw.Close();
ms.Close();
fileDefs = fDefs;
return outputBytes;
}
开发者ID:dufkaf,项目名称:ClientDependency,代码行数:22,代码来源:CompositeFileProcessingProvider.cs
示例16: WriteToStream
public bool WriteToStream(BaseCompositeFileProcessingProvider provider, StreamWriter sw, FileInfo fi, ClientDependencyType type, string origUrl, HttpContextBase http)
{
try
{
//if it is a file based dependency then read it
var fileContents = File.ReadAllText(fi.FullName, Encoding.UTF8); //read as utf 8
WriteContentToStream(provider, sw, fileContents, type, http, origUrl);
return true;
}
catch (Exception ex)
{
ClientDependencySettings.Instance.Logger.Error(string.Format("Could not write file {0} contents to stream. EXCEPTION: {1}", fi.FullName, ex.Message), ex);
return false;
}
}
开发者ID:belmer,项目名称:ClientDependency,代码行数:15,代码来源:DefaultFileWriter.cs
示例17: Parse
public static bool Parse(string pathBasedUrlFormat, string path, out string fileKey, out ClientDependencyType type, out int version)
{
try
{
//start parsing from the end
var typeIndex = pathBasedUrlFormat.IndexOf("{type}");
var versionIndex = pathBasedUrlFormat.IndexOf("{version}");
var typeDelimiter = pathBasedUrlFormat.Substring(versionIndex + "{version}".Length, typeIndex - (versionIndex + "{version}".Length));
var typeAsString = "";
for (var i = path.Length - 1; i > path.LastIndexOf(typeDelimiter) + (typeDelimiter.Length - 1); i--)
{
typeAsString += path[i];
}
typeAsString = typeAsString.ReverseString().ToUpper();
var versionDelimiter = pathBasedUrlFormat.Substring("{dependencyId}".Length, versionIndex - ("{dependencyId}".Length));
var versionAsString = "";
for (var i = path.LastIndexOf(typeDelimiter) - 1;
i > path.Substring(0, path.LastIndexOf(typeDelimiter)).LastIndexOf(versionDelimiter) + (typeDelimiter.Length - 1); i--)
{
versionAsString += path[i];
}
versionAsString = versionAsString.ReverseString();
//var p = path.IndexOf(versionDelimiter);
//fileKey = p > 0 ? path.Substring(0, p) : "";
fileKey = path.Substring(0, path.Substring(0, path.LastIndexOf(typeDelimiter)).LastIndexOf(versionDelimiter));
//there may be '/' in the fileKey since we add additional paths when the max path length is exceeded
fileKey = fileKey.Replace("/", "");
type = typeAsString == "js".ToUpper() ? ClientDependencyType.Javascript : ClientDependencyType.Css;
if (!int.TryParse(versionAsString, out version))
{
return false;
}
return true;
}
catch (ArgumentOutOfRangeException)
{
fileKey = "";
version = -1;
type = ClientDependencyType.Javascript;
return false;
}
}
开发者ID:dufkaf,项目名称:ClientDependency,代码行数:48,代码来源:PathBasedUrlFormatter.cs
示例18: ClientDependencyAttribute
/// <summary>
/// Initializes a new instance of the <see cref="ClientDependencyAttribute"/> class.
/// </summary>
/// <param name="group"></param>
/// <param name="priority">The priority.</param>
/// <param name="dependencyType">Type of the dependency.</param>
/// <param name="fileName"></param>
/// <param name="pathNameAlias"></param>
public ClientDependencyAttribute(int group, int priority, ClientDependencyType dependencyType, string fileName, string pathNameAlias, bool forceBundle)
{
if (String.IsNullOrEmpty(fileName))
throw new ArgumentNullException("fileName");
Priority = priority;
Group = group;
FilePath = fileName;
PathNameAlias = pathNameAlias;
DependencyType = dependencyType;
ForceBundle = forceBundle;
HtmlAttributes = new Dictionary<string, string>();
}
开发者ID:dufkaf,项目名称:ClientDependency,代码行数:25,代码来源:ClientDependencyAttribute.cs
示例19: WriteToStream
public bool WriteToStream(BaseCompositeFileProcessingProvider provider, StreamWriter sw, FileInfo fi, ClientDependencyType type, string origUrl, HttpContextBase http)
{
try
{
//NOTE: We don't want this compressed since CDF will do that ourselves
var output = Compiler.Compile(fi.FullName, false, new List<string>());
DefaultFileWriter.WriteContentToStream(provider, sw, output, type, http, origUrl);
return true;
}
catch (Exception ex)
{
ClientDependencySettings.Instance.Logger.Error(string.Format("Could not write file {0} contents to stream. EXCEPTION: {1}", fi.FullName, ex.Message), ex);
return false;
}
}
开发者ID:belmer,项目名称:ClientDependency,代码行数:17,代码来源:SassWriter.cs
示例20: WriteToStream
public bool WriteToStream(BaseCompositeFileProcessingProvider provider, StreamWriter sw, FileInfo fi, ClientDependencyType type, string origUrl, HttpContextBase http)
{
try
{
//if it is a file based dependency then read it
using (var fileStream = fi.OpenRead())
{
WriteContentToStream(provider, sw, fileStream, type, http, origUrl);
}
return true;
}
catch (Exception ex)
{
ClientDependencySettings.Instance.Logger.Error($"Could not write file {fi.FullName} contents to stream. EXCEPTION: {ex.Message}", ex);
return false;
}
}
开发者ID:dufkaf,项目名称:ClientDependency,代码行数:17,代码来源:DefaultFileWriter.cs
注:本文中的ClientDependencyType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论