public virtual T CreateBundle(string path, IEnumerable <IFile> allFiles, BundleDescriptor bundleDescriptor) { var bundle = CreateBundleCore(path, bundleDescriptor); var filesArray = allFiles.ToArray(); AddAssets(bundle, filesArray, bundleDescriptor.AssetFilenames); AddReferences(bundle, bundleDescriptor.References); SetIsSortedIfExplicitFilenames(bundle, bundleDescriptor.AssetFilenames); return(bundle); }
T CreateSingleFileBundle <T>( string applicationRelativePath, IFile file, IBundleFactory <T> bundleFactory, BundleDescriptor descriptor = null) where T : Bundle { descriptor = descriptor ?? new BundleDescriptor { AssetFilenames = { applicationRelativePath } }; return(bundleFactory.CreateBundle(applicationRelativePath, new[] { file }, descriptor)); }
public void AddUrlWithLocalAssets <T>(string url, LocalAssetSettings localAssetSettings, Action <Bundle> customizeBundle = null) where T : Bundle { var existingBundle = bundles.FirstOrDefault( b => b.ContainsPath(PathUtilities.AppRelative(localAssetSettings.Path)) ); if (existingBundle != null) { Remove(existingBundle); } var bundleFactory = bundleFactoryProvider.GetBundleFactory <T>(); var sourceDirectory = settings.SourceDirectory; IEnumerable <IFile> files; BundleDescriptor bundleDescriptor; if (sourceDirectory.DirectoryExists(localAssetSettings.Path)) { var fileSearch = localAssetSettings.FileSearch ?? fileSearchProvider.GetFileSearch(typeof(T)); var directory = sourceDirectory.GetDirectory(localAssetSettings.Path); files = fileSearch.FindFiles(directory); var descriptorFile = TryGetDescriptorFile <T>(directory); bundleDescriptor = ReadOrCreateBundleDescriptor(descriptorFile); } else { var singleFile = sourceDirectory.GetFile(localAssetSettings.Path); if (singleFile.Exists) { files = new[] { singleFile }; bundleDescriptor = new BundleDescriptor { AssetFilenames = { "*" } }; } else { throw new DirectoryNotFoundException(string.Format("File or directory not found: \"{0}\"", localAssetSettings.Path)); } } bundleDescriptor.FallbackCondition = localAssetSettings.FallbackCondition; bundleDescriptor.ExternalUrl = url; var bundle = bundleFactory.CreateBundle(localAssetSettings.Path, files, bundleDescriptor); if (customizeBundle != null) { customizeBundle(bundle); } Add(bundle); }
T CreateDirectoryBundle <T>( string applicationRelativePath, IBundleFactory <T> bundleFactory, IEnumerable <IFile> allFiles, IDirectory directory, BundleDescriptor descriptor = null) where T : Bundle { if (descriptor == null) { var descriptorFile = TryGetDescriptorFile <T>(directory); descriptor = ReadOrCreateBundleDescriptor(descriptorFile); } return(bundleFactory.CreateBundle(applicationRelativePath, allFiles, descriptor)); }
public BundleDescriptor Read() { using (var stream = sourceFile.OpenRead()) using (var reader = new StreamReader(stream)) { string line; while ((line = reader.ReadLine()) != null) { ProcessLine(line); } } var descriptor = new BundleDescriptor(); descriptor.AssetFilenames.AddRange(assetFilenames); descriptor.References.AddRange(references); descriptor.ExternalUrl = externalUrl; descriptor.FallbackCondition = fallbackCondition; return descriptor; }
public BundleDescriptor Read() { using (var stream = sourceFile.OpenRead()) using (var reader = new StreamReader(stream)) { string line; while ((line = reader.ReadLine()) != null) { ProcessLine(line); } } var descriptor = new BundleDescriptor(); descriptor.AssetFilenames.AddRange(assetFilenames); descriptor.References.AddRange(references); descriptor.ExternalUrl = externalUrl; descriptor.FallbackCondition = fallbackCondition; return(descriptor); }
protected abstract T CreateBundleCore(string path, BundleDescriptor bundleDescriptor);