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


C# ClientDependencyType.ToString方法代码示例

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


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

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

示例2: SaveCompositeFile

		/// <summary>
		/// Saves the file's bytes to disk with a hash of the byte array
		/// </summary>
		/// <param name="fileContents"></param>
		/// <param name="type"></param>
		/// <returns>The new file path</returns>
		/// <remarks>
		/// the extension will be: .cdj for JavaScript and .cdc for CSS
		/// </remarks>
		public static string SaveCompositeFile(byte[] fileContents, ClientDependencyType type)
		{
            //don't save the file if composite files are disabled.
            if (!ClientDependencySettings.Instance.EnableCompositeFiles)
                return string.Empty;

			if (!ClientDependencySettings.Instance.CompositeFilePath.Exists)
				ClientDependencySettings.Instance.CompositeFilePath.Create();
			FileInfo fi = new FileInfo(
				Path.Combine(ClientDependencySettings.Instance.CompositeFilePath.FullName,
					fileContents.GetHashCode().ToString() + ".cd" + type.ToString().Substring(0, 1).ToLower()));
			if (fi.Exists)
				fi.Delete();
			FileStream fs = fi.Create();
			fs.Write(fileContents, 0, fileContents.Length);
			fs.Close();
			return fi.FullName;
		}
开发者ID:dufkaf,项目名称:ClientDependency,代码行数:27,代码来源:CompositeFileProcessor.cs

示例3: SaveCompositeFile

	    /// <summary>
	    /// Saves the file's bytes to disk with a hash of the byte array
	    /// </summary>
	    /// <param name="fileContents"></param>
	    /// <param name="type"></param>
	    /// <param name="server"></param>
	    /// <returns>The new file path</returns>
	    /// <remarks>
	    /// the extension will be: .cdj for JavaScript and .cdc for CSS
	    /// </remarks>
	    public override FileInfo SaveCompositeFile(byte[] fileContents, ClientDependencyType type, HttpServerUtilityBase server, int version)
		{
            //don't save the file if composite files are disabled.
            if (!PersistCompositeFiles)
                return null;

            if (!CompositeFilePath.Exists)
                CompositeFilePath.Create();
			
            var fi = new FileInfo(
                Path.Combine(CompositeFilePath.FullName,
					version + "_" + Guid.NewGuid().ToString("N") + ".cd" + type.ToString().Substring(0, 1).ToUpper()));
			
            if (fi.Exists)
				fi.Delete();
			
            var fs = fi.Create();
			fs.Write(fileContents, 0, fileContents.Length);
			fs.Close();
			return fi;
		}
开发者ID:VegasoftTI,项目名称:Dnn.Platform,代码行数:31,代码来源:CompositeFileProcessingProvider.cs

示例4: ProcessCompositeList

        /// <summary>
        /// Returns a URL used to return a compbined/compressed/optimized version of all dependencies.
        /// <remarks>
        /// The full url with the encoded query strings for the handler which will process the composite list
        /// of dependencies. The handler will compbine, compress, minify, and output cache the results
        /// on the base64 encoded string.
        /// </remarks>        
        /// </summary>
        /// <param name="dependencies"></param>
        /// <param name="type"></param>
        /// <param name="http"></param>
        /// <returns>An array containing the list of composite file URLs. This will generally only contain 1 value unless
        /// the number of files registered exceeds the maximum length, then it will return more than one file.</returns>
        public virtual string[] ProcessCompositeList(
            IEnumerable<IClientDependencyFile> dependencies, 
            ClientDependencyType type, 
            HttpContextBase http)
        {
            if (!dependencies.Any())
                return new string[] { };

            switch (UrlType)
            {
                case CompositeUrlType.MappedId:
                    
                    //use the file mapper to create us a file key/id for the file set
                    var fileKey = ClientDependencySettings.Instance.DefaultFileMapProvider.CreateNewMap(http, dependencies, GetVersion());

                    //create the url
                    return new[] { GetCompositeFileUrl(fileKey, type, http, CompositeUrlType.MappedId) };

                default:
                    
                    //build the combined composite list urls          
                    
                    var files = new List<string>();
                    var currBuilder = new StringBuilder();
                    var base64Builder = new StringBuilder();
                    var builderCount = 1;
                    var stringType = type.ToString();
                    foreach (var a in dependencies)
                    {
                        //update the base64 output to get the length
                        base64Builder.Append(a.FilePath.EncodeTo64());

                        //test if the current base64 string exceeds the max length, if so we need to split
                        if ((base64Builder.Length + ClientDependencySettings.Instance.CompositeFileHandlerPath.Length + stringType.Length + 10) 
                            >= (CompositeDependencyHandler.MaxHandlerUrlLength))
                        {
                            //add the current output to the array
                            files.Add(currBuilder.ToString());
                            //create some new output
                            currBuilder = new StringBuilder();
                            base64Builder = new StringBuilder();
                            builderCount++;
                        }

                        //update the normal builder
                        currBuilder.Append(a.FilePath + ";");
                    }

                    if (builderCount > files.Count)
                    {
                        files.Add(currBuilder.ToString());
                    }

                    //now, compress each url
                    for (var i = 0; i < files.Count; i++)
                    {
                        //append our version to the combined url 
                        var encodedFile = files[i].EncodeTo64Url();
                        files[i] = GetCompositeFileUrl(encodedFile, type, http, UrlType);
                    }

                    return files.ToArray();
            }            
        }
开发者ID:biganth,项目名称:Curt,代码行数:77,代码来源:BaseCompositeFileProcessingProvider.cs

示例5: GetCompositeFileUrls

        /// <summary>
        /// When the path type is one of the base64 paths, this will create the composite file urls for all of the dependencies. 
        /// </summary>
        /// <param name="type"></param>
        /// <param name="dependencies"></param>
        /// <param name="compositeFileHandlerPath"></param>
        /// <param name="http"></param>
        /// <param name="maxLength">the max length each url can be</param>
        /// <param name="version">the current cdf version</param>
        /// <returns></returns>
        /// <remarks>
        /// Generally there will only be one path returned but his depends on how many dependencies there are and whether the base64 created path will exceed the max url length parameter.
        /// If the string length exceeds it, then we need to creaet multiple paths all of which must be less length than the maximum provided.
        /// </remarks>
        internal IEnumerable<string> GetCompositeFileUrls(
            ClientDependencyType type,
            IClientDependencyFile[] dependencies,
            string compositeFileHandlerPath,
            HttpContextBase http,
            int maxLength,
            int version)
        {
            var files = new List<string>();
            var currBuilder = new StringBuilder();
            var base64Builder = new StringBuilder();
            var builderCount = 1;
            var stringType = type.ToString();

            var remaining = new Queue<IClientDependencyFile>(dependencies);
            while (remaining.Any())
            {
                var current = remaining.Peek();

                //update the base64 output to get the length
                base64Builder.Append(current.FilePath.EncodeTo64());

                //test if the current base64 string exceeds the max length, if so we need to split
                if ((base64Builder.Length
                     + compositeFileHandlerPath.Length
                     + stringType.Length
                     + version.ToString(CultureInfo.InvariantCulture).Length
                    //this number deals with the ampersands, etc...
                     + 10)
                    >= (maxLength))
                {
                    //we need to do a check here, this is the first one and it's already exceeded the max length we cannot continue
                    if (currBuilder.Length == 0)
                    {
                        throw new InvalidOperationException("The path for the single dependency: '" + current.FilePath + "' exceeds the max length (" + maxLength + "), either reduce the single dependency's path length or increase the CompositeDependencyHandler.MaxHandlerUrlLength value");
                    }

                    //flush the current output to the array
                    files.Add(currBuilder.ToString());
                    //create some new output
                    currBuilder = new StringBuilder();
                    base64Builder = new StringBuilder();
                    builderCount++;
                }
                else
                {
                    //update the normal builder
                    currBuilder.Append(current.FilePath + ";");
                    //remove from the queue
                    remaining.Dequeue();
                }
            }

            //foreach (var a in dependencies)
            //{
            //    //update the base64 output to get the length
            //    base64Builder.Append(a.FilePath.EncodeTo64());

            //    //test if the current base64 string exceeds the max length, if so we need to split
            //    if ((base64Builder.Length
            //        + compositeFileHandlerPath.Length
            //        + stringType.Length
            //        + version.Length
            //        + 10)
            //        >= (maxLength))
            //    {
            //        //add the current output to the array
            //        files.Add(currBuilder.ToString());
            //        //create some new output
            //        currBuilder = new StringBuilder();
            //        base64Builder = new StringBuilder();
            //        builderCount++;
            //    }

            //    //update the normal builder
            //    currBuilder.Append(a.FilePath + ";");
            //}

            if (builderCount > files.Count)
            {
                files.Add(currBuilder.ToString());
            }

            //now, compress each url
            for (var i = 0; i < files.Count; i++)
            {
//.........这里部分代码省略.........
开发者ID:pynej,项目名称:ClientDependency,代码行数:101,代码来源:BaseCompositeFileProcessingProvider.cs

示例6: ProcessCompositeList

        /// <summary>
        /// Returns a URL used to return a compbined/compressed/optimized version of all dependencies.
        /// <remarks>
        /// The full url with the encoded query strings for the handler which will process the composite list
        /// of dependencies. The handler will compbine, compress, minify, and output cache the results
        /// on the base64 encoded string.
        /// </remarks>        
        /// </summary>
        /// <param name="dependencies"></param>
        /// <param name="type"></param>
        /// <param name="http"></param>
        /// <returns>An array containing the list of composite file URLs. This will generally only contain 1 value unless
        /// the number of files registered exceeds the maximum length, then it will return more than one file.</returns>
        public string[] ProcessCompositeList(List<IClientDependencyFile> dependencies, ClientDependencyType type, HttpContextBase http)
        {
            if (dependencies.Count == 0)
                return new string[] { };

            //build the combined composite list urls
            var files = new List<string>();
            var currBuilder = new StringBuilder();
            var builderCount = 1;
            var stringType = type.ToString();
            foreach (var a in dependencies)
            {
                //if the addition of this file is going to exceed 75% of the max length (since we'll be base64 encoding), we'll need to split
                if ((currBuilder.Length +
                    a.FilePath.Length +
                    ClientDependencySettings.Instance.CompositeFileHandlerPath.Length +
                    stringType.Length + 10) >= (CompositeDependencyHandler.MaxHandlerUrlLength * 0.75))
                {
                    //add the current output to the array
                    files.Add(currBuilder.ToString());
                    //create some new output
                    currBuilder = new StringBuilder();
                    builderCount++;
                }

                currBuilder.Append(a.FilePath + ";");
            }

            if (builderCount > files.Count)
            {
                files.Add(currBuilder.ToString());
            }

            //now, compress each url
            for (var i = 0; i < files.Count; i++)
            {
                //append our version to the combined url
                files[i] = AppendVersionQueryString(GetCompositeFileUrl(files[i], type, http));
            }

            return files.ToArray();
        }
开发者ID:aozora,项目名称:arashi,代码行数:55,代码来源:BaseFileRegistrationProvider.cs


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