Exemplo n.º 1
3
        public string Build(BundleType type, IEnumerable<string> files)
        {
            if (files == null || !files.Any())
                return string.Empty;

            string bundleVirtualPath = this.GetBundleVirtualPath(type, files);
            var bundleFor = BundleTable.Bundles.GetBundleFor(bundleVirtualPath);
            if (bundleFor == null)
            {
                lock (s_lock)
                {
                    bundleFor = BundleTable.Bundles.GetBundleFor(bundleVirtualPath);
                    if (bundleFor == null)
                    {
                        var nullOrderer = new NullOrderer();

                        Bundle bundle = (type == BundleType.Script) ?
                            new CustomScriptBundle(bundleVirtualPath) as Bundle :
                            new SmartStyleBundle(bundleVirtualPath) as Bundle;
                        bundle.Orderer = nullOrderer;

                        bundle.Include(files.ToArray());

                        BundleTable.Bundles.Add(bundle);
                    }
                }
            }

            if (type == BundleType.Script)
                return Scripts.Render(bundleVirtualPath).ToString();

            return Styles.Render(bundleVirtualPath).ToString();
        }
Exemplo n.º 2
0
        public static UnityEngine.Object Load(string prefabName, BundleType bundleType = BundleType.Resources)
        {
            if (bundleType == BundleType.Resources || ForceResourcesLoad)
            {
                return(ResourcesLoad(prefabName));
            }

            UnityEngine.Object obj = null;

            {
                string ABPrefabName = prefabName.Remove(0, prefabName.LastIndexOf('/') + 1);

                if (bundleType == BundleType.Main)
                {
                    if (MainBundle == null)
                    {
                        return(ResourcesLoad(prefabName));
                    }
                    obj = MainBundle.LoadAsset(ABPrefabName);
                }
                else
                {
                    if (bundleType == BundleType.Art)
                    {
                        return(ResourcesLoad(prefabName));
                    }
                    obj = ArtBundle.LoadAsset(ABPrefabName);
                }
            }
            return(obj);
        }
Exemplo n.º 3
0
        public static bool ValidateAndSaveAssetBundle(BundleType bundleType, AssetBundleDownloadTask task)
        {
            string localFilePath = task.AssetBundleInfo.LocalFilePath;

            try
            {
                CreateParentDirectory(localFilePath);
                DeleteFile(localFilePath);
                byte[]          downloadedBytes = task.DownloadedBytes;
                AssetBundleInfo assetBundleInfo = task.AssetBundleInfo;
                if (GlobalVars.DataUseAssetBundle)
                {
                    string str2 = CalculateFileCrc(localFilePath, downloadedBytes);
                    if (str2 != assetBundleInfo.FileCrc)
                    {
                        throw new Exception(string.Format("CRC Mismatch. Local:{0}, Remote:{1}. Retry downloading.", str2, assetBundleInfo.FileCrc));
                    }
                }
                File.WriteAllBytes(localFilePath, downloadedBytes);
                return(true);
            }
            catch (Exception)
            {
                if (File.Exists(localFilePath))
                {
                    File.Delete(localFilePath);
                }
                return(false);
            }
        }
Exemplo n.º 4
0
    void newDefBundleTo(string parent, BundleType bundleType)
    {
        // Find a new bundle name
        string defBundleName     = "EmptyBundle";
        string currentBundleName = defBundleName;
        int    index             = 0;

        while (BundleManager.GetBundleData(currentBundleName) != null)
        {
            currentBundleName = defBundleName + (++index);
        }

        bool created = BundleManager.CreateNewBundle(currentBundleName, parent, bundleType);

        if (created)
        {
            if (IsFold(parent))
            {
                SetFold(parent, false);
            }

            m_Selections.Clear();
            m_Selections.Add(currentBundleName);
        }

        StartEditBundleName(currentBundleName);
    }
Exemplo n.º 5
0
        public static bool TryParseSignature(string signatureString, out BundleType type)
        {
            switch (signatureString)
            {
            case nameof(BundleType.UnityWeb):
                type = BundleType.UnityWeb;
                return(true);

            case nameof(BundleType.UnityRaw):
                type = BundleType.UnityRaw;
                return(true);

            case nameof(BundleType.UnityFS):
                type = BundleType.UnityFS;
                return(true);

            case HexFASignature:
                type = BundleType.HexFA;
                return(true);

            default:
                type = default;
                return(false);
            }
        }
Exemplo n.º 6
0
        private static BundleMap CreateBundleMap(BundleType type, DataRow row, string verson)
        {
            var hasVersion = !string.IsNullOrWhiteSpace(verson);
            var versionLen = MARKUP_VERSION.Length;

            var rel = type == BundleType.Script ? REL_SCRIPT_ITEM : REL_STYLE_ITEM;
            var ret = new BundleMap();

            ret.Type          = type;
            ret.ReferenceName = (string)row[COL_REF];
            ret.Paths         = new List <string>();

            var itemRows = row.GetChildRows(rel);

            foreach (var item in itemRows)
            {
                var path = (string)item[COL_PATH];

                if (hasVersion)
                {
                    path = Regex.Replace(path, MARKUP_VERSION, verson, RegexOptions.IgnoreCase);
                }

                ret.Paths.Add(path);
            }

            return(ret);
        }
Exemplo n.º 7
0
    public static string GetViewBundleName(this System.Web.Mvc.HtmlHelper helper, BundleType bundleType)
    {
        var controller = helper.ViewContext.RouteData.Values["controller"].ToString();
        var action     = helper.ViewContext.RouteData.Values["action"].ToString();

        switch (controller.ToLower())
        {
        case "home":
        {
            switch (action.ToLower())
            {
            case "index": return("~/Content/stylesheets-homepage");

            default:
                return("~/Content/stylesheets");
            }
        }

        case "sitemaps":
            return("~/Content/stylesheets-zocial");

        case "blogs":
            return("~/Content/stylesheets-gridmvc");

        case "account":
            return("~/Content/stylesheets-jqueryval");


        default:
            return("~/Content/stylesheets");
        }
    }
 public BundleReader(Stream stream, EndianType endianess, BundleType signature, BundleVersion generation, BundleFlags flags) :
     base(stream, endianess)
 {
     Signature  = signature;
     Generation = generation;
     Flags      = flags;
 }
Exemplo n.º 9
0
 public Bundle(string cdnUrl, string localUrl, BundleType bundleType, bool useMinification = true)
 {
     this.cdnUrl          = cdnUrl;
     this.localUrl        = localUrl;
     this.type            = bundleType;
     this.useMinification = useMinification;
 }
Exemplo n.º 10
0
        public static string AddBundle(this SerializedProperty bundles, string assetPath,
                                       BundleType bundleType = BundleType.Static)
        {
            string abName = AssetDatabase.GetImplicitAssetBundleName(assetPath);

            if (string.IsNullOrEmpty(abName))
            {
                abName = Path.GetFileNameWithoutExtension(assetPath).ToLower();
                if (bundles.FindIndex(abName) >= 0)
                {
                    abName += $"_conflict_{DateTime.Now.ToBinary()}";
                }

                var importer = AssetImporter.GetAtPath(assetPath);
                importer.assetBundleName = abName;
            }
            else
            {
                if (bundles.FindIndex(abName) >= 0)
                {
                    return(string.Empty);
                }
            }

            return(bundles.AddBundleByAbName(abName, bundleType));
        }
Exemplo n.º 11
0
        public static string RemoteAssetBundleDirctory(BundleType bundleType, string serverAddr, string remoteDir)
        {
            string     str2;
            string     str  = string.Empty;
            BundleType type = bundleType;

            if (type != BundleType.DATA_FILE)
            {
                if (type != BundleType.RESOURCE_FILE)
                {
                    throw new Exception("Invalid Type or State!");
                }
            }
            else
            {
                str = "data";
                goto Label_003B;
            }
            str = "resource";
Label_003B:
            str2 = !string.IsNullOrEmpty(remoteDir) ? remoteDir : str;
            if (LOCAL_TEST)
            {
                string[] textArray1 = new string[] { "file://", DATA_PATH, "/../Packages/", str2, "/editor_compressed/" };
                return(string.Concat(textArray1));
            }
            string str3 = "android_compressed";

            string[] textArray2 = new string[] { serverAddr, "/", str2, "/", str3, "/" };
            return(string.Concat(textArray2));
        }
Exemplo n.º 12
0
        private static bool FilterObject(UnityEngine.Object asset, BundleType bundleType)
        {
            if (asset == null)
            {
                return(false);
            }

            switch (bundleType)
            {
            case BundleType.FBX:
                return(!(asset.GetType() == typeof(AnimationClip) && asset.name == EditorConst.EDITOR_ANICLIP_NAME));

            case BundleType.Controller:
                string typeName = asset.GetType().ToString();
                for (int i = 0; i < EditorConst.EDITOR_CONTROL_NAMES.Length; ++i)
                {
                    if (typeName.Contains(EditorConst.EDITOR_CONTROL_NAMES[i]))
                    {
                        return(false);
                    }
                }
                return(true);

            default:
                return(true);
            }
        }
Exemplo n.º 13
0
 public BundleModel(string path, uint ver, BundleType kind)
 {
     address = path;
     version = ver;
     type    = kind;
     name    = path;
     UID     = address + "_" + ver;
 }
Exemplo n.º 14
0
 public string GetFileNameByAssetName(BundleType bundleType, string assetName)
 {
     if (this._assetName2FileNameDict[bundleType].ContainsKey(assetName))
     {
         return(this._assetName2FileNameDict[bundleType][assetName]);
     }
     return(null);
 }
Exemplo n.º 15
0
 public string GetAssetNameByResPath(BundleType bundleType, string resPath)
 {
     if (this._resPath2AssetNameDict[bundleType].ContainsKey(resPath))
     {
         return(this._resPath2AssetNameDict[bundleType][resPath]);
     }
     return(null);
 }
Exemplo n.º 16
0
 public AssetBundleInfo GetAssetBundleInfoByFileName(BundleType bundleType, string fileName)
 {
     if (this._fileName2AssetBundleDict[bundleType].ContainsKey(fileName))
     {
         return(this._fileName2AssetBundleDict[bundleType][fileName]);
     }
     return(null);
 }
Exemplo n.º 17
0
 public static AssetBundleInfo[] GetVersionAssetBundleInfo(BundleType bundleType)
 {
     if (bundleType == BundleType.DATA_FILE)
     {
         return(new AssetBundleInfo[] { new AssetBundleInfo("DataVersion", 100L, string.Empty, null, null, UnloadMode.MANUAL_UNLOAD, DownloadMode.IMMEDIATELY, bundleType, false, string.Empty) });
     }
     return(new AssetBundleInfo[] { new AssetBundleInfo("ResourceVersion", 100L, string.Empty, null, null, UnloadMode.MANUAL_UNLOAD, DownloadMode.IMMEDIATELY, bundleType, false, "event"), new AssetBundleInfo("ResourceVersion", 100L, string.Empty, null, null, UnloadMode.MANUAL_UNLOAD, DownloadMode.IMMEDIATELY, bundleType, false, string.Empty) });
 }
Exemplo n.º 18
0
        public static void RemoveAllAssetBundle(BundleType bundleType)
        {
            string path = AssetBundleUtility.LocalAssetBundleDirectory(bundleType);

            if (Directory.Exists(path))
            {
                Directory.Delete(path, true);
            }
        }
Exemplo n.º 19
0
 internal Bundle(BundleType _type, bool _debug, bool _useCompression, bool _removeComments, int _lineBreakPosition)
 {
     //Only used for CSS
     Type              = _type;
     Debug             = _debug;
     UseCompression    = _useCompression;
     RemoveComments    = _removeComments;
     LineBreakPosition = _lineBreakPosition;
 }
Exemplo n.º 20
0
 /// <summary>
 /// 制定包含byte[]构造的对象类型
 /// </summary>
 /// <param name="type"></param>
 /// <param name="entry"></param>
 /// <returns></returns>
 public bool RegisterDataEntry(BundleType type, Type entry)
 {
     if (!reflMap.ContainsKey(type))
     {
         reflMap.Add(type, entry);
         return(true);
     }
     return(false);
 }
Exemplo n.º 21
0
 public BundleDownloadTask(string _name, string _keyName, int _version, BundleType _bundleType)
 {
     name                = _name;
     keyName             = _keyName;
     version             = _version;
     bundleType          = _bundleType;
     isDownloaded        = false;
     reDownloadTimesLeft = 10;
 }
Exemplo n.º 22
0
 public void UnloadUnusedAssetBundle(BundleType bundleType)
 {
     foreach (AssetBundleInfo info in this._fileName2AssetBundleDict[bundleType].Values)
     {
         if (((info != null) && info.IsLoaded()) && (info.FileUnloadMode == UnloadMode.MANUAL_UNLOAD))
         {
             info.Unload(false);
         }
     }
 }
Exemplo n.º 23
0
        public AssetBundleInfo GetAssetBundleInfoByAssetName(BundleType bundleType, string assetName)
        {
            string fileNameByAssetName = this.GetFileNameByAssetName(bundleType, assetName);

            if (fileNameByAssetName != null)
            {
                return(this.GetAssetBundleInfoByFileName(bundleType, fileNameByAssetName));
            }
            return(null);
        }
Exemplo n.º 24
0
 public override void Read(PackFileDeserializer des, BinaryReaderEx br)
 {
     base.Read(des, br);
     m_assets = des.ReadClassPointerArray <hkReferencedObject>(br);
     m_name   = des.ReadStringPointer(br);
     m_type   = (BundleType)br.ReadSByte();
     br.ReadUInt32();
     br.ReadUInt16();
     br.ReadByte();
 }
Exemplo n.º 25
0
    //获取指定资源的ab名称
    public static string GetResABName(string assetPath)
    {
        Init();
        BundleType type         = BundleType.Default;//默认打包策略
        string     validatePath = null;

        //自定义中,最后一个出现的一定是最终的ab名称
        for (int i = ruleList.Count - 1; i >= 0; i--)
        {
            AssetBundlePath abPath = ruleList[i];
            if (assetPath.StartsWith(abPath.path + "/"))
            {
                type         = abPath.type;
                validatePath = abPath.path;
                break;
            }
        }
        //没有定制该资源的ab策略
        if (validatePath == null)
        {
            Debug.LogError("<AssetBundleNameAuto> 该资源所在的位置不正确,无法获取ab包名称,路径 = " + assetPath);
            return("");
        }
        switch (type)
        {
        case BundleType.FolderAll:
            //就直接到定制的文件夹
            return(validatePath.Replace("Assets/", "").Replace("/", "_").ToLower());

        case BundleType.Default:
            string leftPath = assetPath.Replace(validatePath + "/", "");
            int    index    = leftPath.IndexOf("/", StringComparison.Ordinal);
            if (index > 0)
            {    //还有文件夹,就命名到该文件夹
                return((validatePath.Replace("Assets/", "").Replace("/", "_") + "_" + leftPath.Substring(0, index)).ToLower());
            }
            else
            {    //没有文件夹,就需要加上文件名称
                return((validatePath.Replace("Assets/", "").Replace("/", "_") + "_" + leftPath.Split('.')[0]).ToLower());
            }

        case BundleType.Folder:
            leftPath = assetPath.Replace(validatePath + "/", "");
            index    = leftPath.IndexOf("/", StringComparison.Ordinal);
            if (index > 0)
            {    //还有文件夹,就命名到该文件夹
                return((validatePath.Replace("Assets/", "").Replace("/", "_") + "_" + leftPath.Substring(0, index)).ToLower());
            }
            else
            {    //没有文件夹,就直接到定制的文件夹
                return(validatePath.Replace("Assets/", "").Replace("/", "_").ToLower());
            }
        }
        return("");
    }
Exemplo n.º 26
0
        public static void SetBundleType(this Bundle bundle, BundleType type)
        {
            List<Tag> result = new List<Tag>(bundle.Tags.Exclude(new Tag[] { MESSAGE_TAG, DOCUMENT_TAG }));

            if (type == BundleType.Document)
                result.Add(DOCUMENT_TAG);
            else if (type == BundleType.Message)
                result.Add(MESSAGE_TAG);

            bundle.Tags = result;
        }
Exemplo n.º 27
0
 public static string GenBundleNameByType(BundleType type)
 {
     if (!m_typeCount.ContainsKey(type))
     {
         m_typeCount.Add(type, 1);
     }
     else
     {
         ++m_typeCount[type];
     }
     return(BundleTypeTool.GetBundleID(type, m_typeCount[type] - 1).ToString());
 }
Exemplo n.º 28
0
    // Get scene or plain assets from include paths
    internal static string[] GetAssetsFromPaths(string[] includeList, BundleType bundleType)
    {
        // Get all the includes file's paths
        List <string> files = new List <string>();

        foreach (string includPath in includeList)
        {
            files.AddRange(GetAssetsFromPath(includPath, bundleType));
        }

        return(files.ToArray());
    }
Exemplo n.º 29
0
 public static string GenBundleNameByType(BundleType type)
 {
     if (!m_typeCount.ContainsKey(type))
     {
         m_typeCount.Add(type, 1);
     }
     else
     {
         ++m_typeCount[type];
     }
     return(string.Format("{0}_{1}", type, m_typeCount[type] - 1));
 }
Exemplo n.º 30
0
 internal Bundle(BundleType _type, bool _debug, bool _useCompression, bool _obfuscate, bool _preserveSemicolons, bool _disableOptimizations, bool _ignoreEval, int _lineBreakPosition)
 {
     //Only used for JS
     Type                 = _type;
     Debug                = _debug;
     UseCompression       = _useCompression;
     Obfuscate            = _obfuscate;
     PreserveSemicolons   = _preserveSemicolons;
     DisableOptimizations = _disableOptimizations;
     IgnoreEval           = _ignoreEval;
     LineBreakPosition    = _lineBreakPosition;
 }
Exemplo n.º 31
0
 public void CopyData(BundleImportData data)
 {
     RootPath      = data.RootPath;
     FileNameMatch = data.FileNameMatch;
     Index         = data.Index;
     Type          = data.Type;
     LoadState     = data.LoadState;
     Publish       = data.Publish;
     LimitCount    = data.LimitCount;
     LimitKBSize   = data.LimitKBSize;
     PushDependice = data.PushDependice;
 }
Exemplo n.º 32
0
        private static void Init()
        {
            BMDataAccessor.Refresh();
            Clear();

            foreach (BundleState bundleState in BMDataAccessor.States)
            {
                if (!m_stateDict.ContainsKey(bundleState.bundleID))
                {
                    m_stateDict.Add(bundleState.bundleID, bundleState);
                }
                else
                {
                    Debug.LogError("[BundleDataManager] Bundle State Conflict " + bundleState.bundleID);
                }
            }

            foreach (BundleData bundleData in BMDataAccessor.Datas)
            {
                if (!m_dataDict.ContainsKey(bundleData.name))
                {
                    m_dataDict.Add(bundleData.name, bundleData);
                }
                else
                {
                    Debug.LogError("[BundleDataManager] Bundle Data Conflict " + bundleData.name);
                }

                BundleType type = bundleData.type;
                if (!m_typeCount.ContainsKey(type))
                {
                    m_typeCount.Add(type, 1);
                }
                else
                {
                    ++m_typeCount[type];
                }

                for (int i = 0; i < bundleData.includs.Count; ++i)
                {
                    string guid = AssetDatabase.AssetPathToGUID(bundleData.includs[i]);
                    if (!m_guidToBundle.ContainsKey(guid))
                    {
                        m_guidToBundle.Add(guid, bundleData.name);
                    }
                    else
                    {
                        Debug.LogError("[BundleDataManager] Include Path Conflict " + bundleData.includs[i]);
                    }
                }
            }
        }
        protected virtual string GetBundleVirtualPath(BundleType type, IEnumerable<string> files)
        {
            if (files == null || !files.Any())
                throw new ArgumentException("parts");

            string prefix = "~/bundles/js/";
            string postfix = ".js";
            if (type == BundleType.Stylesheet)
            {
                prefix = "~/bundles/css/";
                postfix = ".css";
            }

			// TBD: routing fix
			postfix = "";

            // compute hash
            var hash = "";
            using (SHA256 sha = new SHA256Managed())
            {
                var hashInput = "";
                foreach (var file in files.OrderBy(x => x))
                {
                    hashInput += file;
                    hashInput += ",";
                }

                byte[] input = sha.ComputeHash(Encoding.Unicode.GetBytes(hashInput));
                hash = HttpServerUtility.UrlTokenEncode(input);

                // append StoreId & ThemeName to hash in order to vary cache by store/theme combination
                if (type == BundleType.Stylesheet && !_workContext.IsAdmin && files.Any(x => x.EndsWith(".less", StringComparison.OrdinalIgnoreCase)))
                {
                    hash += "-s" + _storeContext.CurrentStore.Id;
					hash += "-t" + _themeContext.CurrentTheme.ThemeName;
                }
            }

            // ensure only valid chars
            hash = SeoExtensions.GetSeName(hash);

            var sb = new StringBuilder(prefix);
            sb.Append(hash);
			sb.Append(postfix); 
            return sb.ToString();
        }
Exemplo n.º 34
0
        /// <summary>
        /// Tries to load default data from item db, and saves reference
        /// to data in DataInfo.
        /// </summary>
        public void LoadDefault()
        {
            this.DataInfo = MabiData.ItemDb.Find(this.Info.Class);
            if (this.DataInfo != null)
            {
                this.Info.KnockCount = this.DataInfo.KnockCount;
                this.OptionInfo.KnockCount = this.DataInfo.KnockCount;

                this.OptionInfo.Durability = this.DataInfo.Durability;
                this.OptionInfo.DurabilityMax = this.DataInfo.Durability;
                this.OptionInfo.DurabilityOriginal = this.DataInfo.Durability;
                this.OptionInfo.AttackMin = this.DataInfo.AttackMin;
                this.OptionInfo.AttackMax = this.DataInfo.AttackMax;
                this.OptionInfo.Balance = this.DataInfo.Balance;
                this.OptionInfo.Critical = this.DataInfo.Critical;
                this.OptionInfo.Defense = this.DataInfo.Defense;
                this.OptionInfo.Protection = this.DataInfo.Protection;
                this.OptionInfo.Price = this.DataInfo.Price;
                this.OptionInfo.SellingPrice = this.DataInfo.SellingPrice;
                this.OptionInfo.WeaponType = this.DataInfo.WeaponType;
                this.OptionInfo.AttackSpeed = this.DataInfo.AttackSpeed;
                this.OptionInfo.EffectiveRange = this.DataInfo.Range;

                this.OptionInfo.Flag = 1;

                this.Type = (ItemType)this.DataInfo.Type;
                this.StackType = (BundleType)this.DataInfo.StackType;
                this.StackMax = this.DataInfo.StackMax;
                this.StackItem = this.DataInfo.StackItem;
                this.Width = this.DataInfo.Width;
                this.Height = this.DataInfo.Height;

                var rand = RandomProvider.Get();
                this.Info.ColorA = MabiData.ColorMapDb.GetRandom(this.DataInfo.ColorMap1, rand);
                this.Info.ColorB = MabiData.ColorMapDb.GetRandom(this.DataInfo.ColorMap2, rand);
                this.Info.ColorC = MabiData.ColorMapDb.GetRandom(this.DataInfo.ColorMap3, rand);
            }
            else
            {
                Logger.Warning("Item '{0}' couldn't be found in the database.", this.Info.Class);
            }

            if (this.StackType != BundleType.Sac && this.Info.Amount < 1)
                this.Info.Amount = 1;
            if (this.StackMax < 1)
                this.StackMax = 1;
        }
Exemplo n.º 35
0
        public MabiItem(MabiItem itemToCopy)
        {
            this.Info = itemToCopy.Info;
            this.OptionInfo = itemToCopy.OptionInfo;
            this.DataInfo = itemToCopy.DataInfo;

            this.Type = itemToCopy.Type;
            this.StackType = itemToCopy.StackType;
            this.StackMax = itemToCopy.StackMax;
            this.StackItem = itemToCopy.StackItem;
            this.Width = itemToCopy.Width;
            this.Height = itemToCopy.Height;

            this.Id = MabiItem.NewItemId;
        }
Exemplo n.º 36
0
 private string GetBundlePath(string bundle, BundleType type)
 {
     var cache = GetCompressor(type).Cache;
       if (cache.ContainsKey(bundle))
     return cache[bundle];
       else
     throw new Exception("Bundle does not exists");
 }
Exemplo n.º 37
0
 private ICompressor GetCompressor(BundleType type)
 {
     return compressors[type];
 }
Exemplo n.º 38
0
 public Loader(BundleType bundleType, string bundleName)
 {
     _bundleType = bundleType;
     _bundleName = bundleName;
 }
Exemplo n.º 39
0
        private void RegisterBundle(HttpServerUtility server, string bundle,
            BundleType type,
            params string[] files)
        {
            if (string.IsNullOrWhiteSpace(bundle))
            throw new ArgumentNullException("bundle", "Cannot register an empty bundle");
              var compressor = GetCompressor(type);
              if (compressor.Cache.ContainsKey(bundle))
            throw new ArgumentException("Bundle already registered");
              if (files == null || files.Length == 0)
            throw new ArgumentNullException("files", "No files to register");

              var list = files.ToList();
              if (server != null)
            list = list.ConvertAll(file => server.MapPath(file));

              if (RaiseErrorIfFileDoesNotExists)
              {
            var notFound = list.ToList().FindAll(file => !File.Exists(file));
            if (notFound != null && notFound.Count > 0)
              throw new ArgumentException(string.Format("Not able to find following files: {0}{1}", Environment.NewLine, string.Join(Environment.NewLine, notFound)));
              }

              if (IsDevMode)
            compressor.Cache.Add(bundle, string.Join(Environment.NewLine, files.ToList().ConvertAll(path => string.Format(compressor.Tag, ResolvePath(path)))));
              else
              {
            StringBuilder sb = new StringBuilder();
            var yuiCompressor = compressor.GetCompressor();

            list.ToList().ForEach(file =>
            {
              if (RaiseErrorIfFileDoesNotExists || (!RaiseErrorIfFileDoesNotExists && File.Exists(file)))
            sb.Append(yuiCompressor.Compress(File.ReadAllText(file)));
            });

            if (imageCache.Count > 0)
              imageCache.Keys.ToList().ForEach(key => sb.Replace(key, imageCache[key]));

            var content = sb.ToString();
            content = yuiCompressor.Compress(content); // double compression

            var format = AddHash ? "{0}." + CreateHash(content) + ".{1}" : "{0}.{1}";
            var path = Path.Combine(server.MapPath(compressor.Folder), string.Format(format, bundle, compressor.Extension));
            WriteContent(path, content);

            path = ResolvePath(server.RelativePath(path));
            compressor.Cache.Add(bundle, string.Format(compressor.Tag, path));
              }
        }