public GivenConfigurationClassInAssembly_WhenExecute() { originalDirectory = Environment.CurrentDirectory; path = new TempDirectory(); var assemblyPath = Path.Combine(path, "Test.dll"); BundleConfiguration.GenerateAssembly(assemblyPath); File.WriteAllText(Path.Combine(path, "test.css"), "p { background-image: url(test.png); }"); File.WriteAllText(Path.Combine(path, "test.coffee"), "x = 1\nlog(x)"); File.WriteAllText(Path.Combine(path, "test.png"), ""); Environment.CurrentDirectory = path; cachePath = Path.Combine(path, "cache"); var buildEngine = new BuildEngineStub(); var task = new CreateBundles { Source = path, Bin = path, Output = cachePath, BuildEngine = buildEngine }; try { task.Execute(); } catch (Exception exception) { var t = exception.ToString(); } }
public GivenConfigurationClassInAssembly_WhenExecute() { originalDirectory = Environment.CurrentDirectory; path = new TempDirectory(); var assemblyPath = Path.Combine(path, "Test.dll"); BundleConfiguration.GenerateAssembly(assemblyPath); File.WriteAllText(Path.Combine(path, "test.css"), "p { background-image: url(test.png); }"); File.WriteAllText(Path.Combine(path, "test.coffee"), "x = 1"); File.WriteAllText(Path.Combine(path, "test.png"), ""); Environment.CurrentDirectory = path; cachePath = Path.Combine(path, "cache"); var task = new CreateBundles { Source = path, Bin = path, Output = cachePath, BuildEngine = Mock.Of <IBuildEngine>() }; task.Execute(); }
public static BundleConfiguration AddBaseBundles(this BundleConfiguration bundleConfiguration, params string[] bundleNames) { Check.NotNull(bundleNames, nameof(bundleNames)); bundleConfiguration.BaseBundles.AddRange(bundleNames); return(bundleConfiguration); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configure(WebAPIConfiguration.Register); FilterConfiguration.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfiguration.RegisterRoutes(RouteTable.Routes); BundleConfiguration.RegisterBundles(BundleTable.Bundles); }
static void GenerateConfigurationFile() { BundleConfiguration bundleConfiguration = (BundleConfiguration)Resources.Load("BundleConfig"); if (!bundleConfiguration) { Debug.LogError("Failed to find 'BundleConfig' file in Assets/Resources/"); return; } CharacterConfiguration configuration = (CharacterConfiguration)Resources.Load("CharacterConfig"); if (!configuration) { Debug.LogError("Failed to find 'CharacterConfig' file in Assets/Resources/"); return; } StringBuilder sb = new StringBuilder(); JsonWriter writer = new JsonWriter(sb); writer.PrettyPrint = true; writer.WriteObjectStart(); writer.WritePropertyName("Prefab"); writer.Write(configuration.prefab.name); writer.WritePropertyName("Animations"); writer.WriteArrayStart(); foreach (AnimationInfos info in configuration.animationsInfos) { JsonAnimInfos animInfo = new JsonAnimInfos(); animInfo.name = info.name; if (info.sprite) { animInfo.image = info.sprite.name; } if (info.audioClip) { animInfo.audio = info.audioClip.name; } writer.Write(JsonMapper.ToJson(animInfo)); } writer.WriteArrayEnd(); writer.WriteObjectEnd(); string path = "Assets/Characters/" + bundleConfiguration.targetModelFolder + "/" + bundleConfiguration.bundleName + "_config.json"; StreamWriter fileWriter = new StreamWriter(path); fileWriter.WriteLine(sb.ToString()); fileWriter.Close(); }
public void Configuration(IAppBuilder app) { BundleConfiguration.Configure(BundleTable.Bundles); // BundleTable.EnableOptimizations = false; new WindsorContainer() .Configure() .Configure(new HubConfiguration(), app) .Configure(GlobalConfiguration.Configuration); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RegisterGlobalFilters(GlobalFilters.Filters); RegisterRoutes(RouteTable.Routes); BundleConfiguration.RegisterBundles(BundleTable.Bundles); Bootstrapper.With.Autofac().Start(); }
static void CheckBundle() { BundleConfiguration configuration = (BundleConfiguration)Resources.Load("BundleConfig"); if (configuration.bundleName.Contains(".unity3d")) { configuration.bundleName = configuration.bundleName.Substring(0, configuration.bundleName.IndexOf(".unity3d")); } string file = configuration.bundlePlatform == TargetPlatform.Android ? configuration.bundleName + "_android.unity3d" : configuration.bundleName + "_ios.unity3d"; string filePath = Path.Combine(characterOutputPath, configuration.bundleName + "/" + file); if (!File.Exists(filePath)) { Debug.LogError("Failed to find bundle: " + filePath); return; } AssetBundle assetBundle = AssetBundle.LoadFromFile(filePath); if (assetBundle == null) { Debug.Log("Failed to load AssetBundle!"); return; } string[] assetNameList = assetBundle.GetAllAssetNames(); foreach (string name in assetNameList) { Debug.Log(name); } TextAsset[] configurationFiles = assetBundle.LoadAllAssets <TextAsset>(); if (configurationFiles.Length == 1) { Debug.Log("YOUR BUNDLE IS VALID !"); } else { if (configurationFiles.Length == 0) { Debug.LogError("Configuration file not found. Please create a configuration file name_config.json"); } else { Debug.LogError("Too much configuration files found... Just one supported actually"); foreach (TextAsset txt in configurationFiles) { Debug.Log("File: " + txt.name); } } } assetBundle.Unload(false); }
public static void CreateMyAsset() { BundleConfiguration asset = ScriptableObject.CreateInstance <BundleConfiguration>(); AssetDatabase.CreateAsset(asset, "Assets/BundleGeneratorConfig.asset"); AssetDatabase.SaveAssets(); EditorUtility.FocusProjectWindow(); Selection.activeObject = asset; }
public static BundleConfiguration AddContributors(this BundleConfiguration bundleConfiguration, params Type[] contributorTypes) { Check.NotNull(contributorTypes, nameof(contributorTypes)); foreach (var contributorType in contributorTypes) { bundleConfiguration.Contributors.Add(contributorType); } return(bundleConfiguration); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FiltersConfiguration.RegisterGlobalFilters(GlobalFilters.Filters); RouteTable.Routes.RegisterRobotsTxt(); RouteConfiguration.RegisterRoutes(RouteTable.Routes); BundleConfiguration.RegisterBundles(BundleTable.Bundles); }
private async Task <AssetBundle> BuildBundle(BuildContext context, BundleConfiguration bundle) { var bundleAssets = new List <IAsset>(); foreach (var batch in bundle.Assets.Batch(Environment.ProcessorCount)) { var tasks = batch.Select(source => Task.Run(() => BuildAsset(context, source))); var assets = await Task.WhenAll(tasks); bundleAssets.AddRange(assets.SelectMany(a => a)); } return(new AssetBundle(bundle.Name, bundleAssets)); }
private BundleConfiguration CreateBundle(string bundleName, Action <BundleConfiguration> configureAction) { var bundle = new BundleConfiguration(bundleName); configureAction?.Invoke(bundle); if (_lazyBundleConfigurationActions.TryGetValue(bundleName, out var configurationActions)) { lock (configurationActions) { configurationActions.ForEach(c => c.Invoke(bundle)); } } lock (_lazyAllBundleConfigurationActions) { _lazyAllBundleConfigurationActions.ForEach(c => c.Invoke(bundle)); } return(bundle); }
public override void AddToConfiguration(BundleConfiguration configuration) { configuration.AddFiles(File); }
public abstract void AddToConfiguration(BundleConfiguration configuration);
static void GenerateBundle() { BundleConfiguration configuration = (BundleConfiguration)Resources.Load("BundleConfig"); if (!configuration) { Debug.LogError("Failed to find 'BundleConfig' file in Assets/Resources/"); return; } if (configuration) { Debug.Log("Configuration file found."); Debug.Log("Bundle name: " + configuration.bundleName); Debug.Log("Target model folder: " + configuration.targetModelFolder); Debug.Log("Bundle platform: " + configuration.bundlePlatform); if (!Directory.Exists(characterRootFolder + "/" + configuration.targetModelFolder)) { Debug.LogError(characterRootFolder + "/" + configuration.targetModelFolder + " doesn't exist..."); return; } AssetBundleBuild[] buildMap = new AssetBundleBuild[1]; buildMap[0].assetBundleName = configuration.bundleName + ".unity3d"; List <string> fileList = new List <string>(); string[] allfiles = Directory.GetFiles(characterRootFolder + "/" + configuration.targetModelFolder, "*.*", SearchOption.AllDirectories); foreach (string file in allfiles) { string filename = Path.GetFileName(file); if (!filename.Contains(".meta")) { int startIndex = file.IndexOf("Assets/"); int endIndex = file.Length - startIndex; string relativePath = file.Substring(startIndex, endIndex).Replace("\\", "/"); fileList.Add(relativePath); } } buildMap[0].assetNames = fileList.ToArray(); if (configuration.bundleName.Contains(".unity3d")) { configuration.bundleName = configuration.bundleName.Substring(0, configuration.bundleName.IndexOf(".unity3d")); } buildMap[0].assetBundleName = configuration.bundlePlatform == TargetPlatform.Android ? configuration.bundleName + "_android.unity3d" : configuration.bundleName + "_ios.unity3d"; if (!Directory.Exists(characterOutputPath)) { Debug.Log("Creating folder: " + characterOutputPath); Directory.CreateDirectory(characterOutputPath); } if (!Directory.Exists(characterOutputPath + "/" + configuration.bundleName)) { Debug.Log("Creating folder: " + characterOutputPath + "/" + configuration.bundleName); Directory.CreateDirectory(characterOutputPath + "/" + configuration.bundleName); } switch (configuration.bundlePlatform) { case TargetPlatform.Android: Debug.Log("Building bundle for Android"); BuildPipeline.BuildAssetBundles(characterOutputPath + "/" + configuration.bundleName, buildMap, BuildAssetBundleOptions.None, BuildTarget.Android); break; case TargetPlatform.iOS: Debug.Log("Building bundle for iOS"); BuildPipeline.BuildAssetBundles(characterOutputPath + "/" + configuration.bundleName, buildMap, BuildAssetBundleOptions.None, BuildTarget.iOS); break; } } else { Debug.LogError("Configuration file not found."); } }
private IEnumerator LoadingBundle() { BundleConfiguration configuration = (BundleConfiguration)Resources.Load("BundleConfig"); if (string.IsNullOrEmpty(configuration.bundleName)) { Debug.LogError("Please provide a bundle name in configuration file."); yield break; } BundleInfo bundleInfo = new BundleInfo(); if (configuration.bundleName.Contains(".unity3d")) { configuration.bundleName = configuration.bundleName.Substring(0, configuration.bundleName.IndexOf(".unity3d")); } string file = configuration.bundlePlatform == TargetPlatform.Android ? configuration.bundleName + "_android.unity3d" : configuration.bundleName + "_ios.unity3d"; string filePath = Path.Combine(characterOutputPath, configuration.bundleName + "/" + file); if (!File.Exists(filePath)) { Debug.LogError("Failed to find bundle: " + filePath); yield break; } AssetBundle assetBundle = AssetBundle.LoadFromFile(filePath); if (assetBundle == null) { Debug.Log("Failed to load AssetBundle!"); yield break; } TextAsset[] characterConfigurations = assetBundle.LoadAllAssets <TextAsset>(); if (characterConfigurations.Length != 1) { if (characterConfigurations.Length == 0) { Debug.LogError("Configuration file not found. Please create a configuration file name_config.json"); yield break; } else { Debug.LogError("Too much configuration files found... Just one supported actually"); foreach (TextAsset txt in characterConfigurations) { Debug.Log("File: " + txt.name); } yield break; } } TextAsset configFile = characterConfigurations[0]; JsonData data = JsonMapper.ToObject(configFile.text); try { bundleInfo.prefab = (string)data["Prefab"]; Debug.Log("Prefab: " + bundleInfo.prefab); Debug.Log("Animations : " + data["Animations"].Count); for (int i = 0; i < data["Animations"].Count; i++) { BundleAnimationInfo info = new BundleAnimationInfo(); info.name = (string)data["Animations"][i][0]; info.image = (string)data["Animations"][i][1]; info.audio = (string)data["Animations"][i][2]; bundleInfo.animationInfoList.Add(info); } } catch (Exception e) { Debug.LogError("Exception message: " + e.Message); } InstantiateBundle(bundleInfo, assetBundle); assetBundle.Unload(false); yield return(null); }
public BundleHandlerTests() { _router = Substitute.For <IRouter>(); _fhirRequestContext = new DefaultFhirRequestContext { BaseUri = new Uri("https://localhost/"), CorrelationId = Guid.NewGuid().ToString(), ResponseHeaders = new HeaderDictionary(), }; var fhirRequestContextAccessor = Substitute.For <RequestContextAccessor <IFhirRequestContext> >(); fhirRequestContextAccessor.RequestContext.Returns(_fhirRequestContext); IHttpContextAccessor httpContextAccessor = Substitute.For <IHttpContextAccessor>(); var fhirJsonSerializer = new FhirJsonSerializer(); var fhirJsonParser = new FhirJsonParser(); ISearchService searchService = Substitute.For <ISearchService>(); var resourceReferenceResolver = new ResourceReferenceResolver(searchService, new QueryStringParser()); var transactionBundleValidator = new TransactionBundleValidator(resourceReferenceResolver); var bundleHttpContextAccessor = new BundleHttpContextAccessor(); IFeatureCollection featureCollection = CreateFeatureCollection(); var httpContext = new DefaultHttpContext(featureCollection) { Request = { Scheme = "https", Host = new HostString("localhost"), PathBase = new PathString("/"), }, }; httpContextAccessor.HttpContext.Returns(httpContext); var transactionHandler = Substitute.For <ITransactionHandler>(); var resourceIdProvider = new ResourceIdProvider(); IAuditEventTypeMapping auditEventTypeMapping = Substitute.For <IAuditEventTypeMapping>(); _bundleConfiguration = new BundleConfiguration(); var bundleOptions = Substitute.For <IOptions <BundleConfiguration> >(); bundleOptions.Value.Returns(_bundleConfiguration); _mediator = Substitute.For <IMediator>(); _bundleHandler = new BundleHandler( httpContextAccessor, fhirRequestContextAccessor, fhirJsonSerializer, fhirJsonParser, transactionHandler, bundleHttpContextAccessor, resourceIdProvider, transactionBundleValidator, resourceReferenceResolver, auditEventTypeMapping, bundleOptions, DisabledFhirAuthorizationService.Instance, _mediator, NullLogger <BundleHandler> .Instance); }
public static BundleConfiguration AddFiles(this BundleConfiguration bundleConfiguration, params string[] files) { bundleConfiguration.Contributors.AddFiles(files); return(bundleConfiguration); }
public override void AddToConfiguration(BundleConfiguration configuration) { configuration.AddContributors(Type); }
public BundleHandlerTests() { _router = Substitute.For <IRouter>(); var fhirRequestContext = new DefaultFhirRequestContext { BaseUri = new Uri("https://localhost/"), CorrelationId = Guid.NewGuid().ToString(), }; _fhirRequestContextAccessor = Substitute.For <IFhirRequestContextAccessor>(); _fhirRequestContextAccessor.FhirRequestContext.Returns(fhirRequestContext); _httpContextAccessor = Substitute.For <IHttpContextAccessor>(); _fhirJsonSerializer = new FhirJsonSerializer(); _fhirJsonParser = new FhirJsonParser(); _searchService = Substitute.For <ISearchService>(); var fhirDataStore = Substitute.For <IFhirDataStore>(); var conformanceProvider = Substitute.For <Lazy <IConformanceProvider> >(); var resourceWrapperFactory = Substitute.For <IResourceWrapperFactory>(); var resourceIdProvider = Substitute.For <ResourceIdProvider>(); var transactionBundleValidator = new TransactionBundleValidator(fhirDataStore, conformanceProvider, resourceWrapperFactory, _searchService, resourceIdProvider); _bundleHttpContextAccessor = new BundleHttpContextAccessor(); IFeatureCollection featureCollection = CreateFeatureCollection(); var httpContext = new DefaultHttpContext(featureCollection) { Request = { Scheme = "https", Host = new HostString("localhost"), PathBase = new PathString("/"), }, }; _httpContextAccessor.HttpContext.Returns(httpContext); var transactionHandler = Substitute.For <ITransactionHandler>(); _resourceIdProvider = new ResourceIdProvider(); _auditEventTypeMapping = Substitute.For <IAuditEventTypeMapping>(); _bundleConfiguration = new BundleConfiguration(); var bundleOptions = Substitute.For <IOptions <BundleConfiguration> >(); bundleOptions.Value.Returns(_bundleConfiguration); _bundleHandler = new BundleHandler( _httpContextAccessor, _fhirRequestContextAccessor, _fhirJsonSerializer, _fhirJsonParser, transactionHandler, _bundleHttpContextAccessor, _resourceIdProvider, transactionBundleValidator, _auditEventTypeMapping, bundleOptions, NullLogger <BundleHandler> .Instance); }