Esempio n. 1
0
        public static void RemoveRoomResources()
        {
            //string roomName = Config.RoomObject.GameObjectName;
            string roomName = RoomManager.SyncRoomName();

            BundleHandler.RemoveRoomResources(roomName);
        }
Esempio n. 2
0
        /// <summary>
        /// Преобразование файлов .bundle в набор файлов и обратно
        /// </summary>
        /// <param name="bundleFile"> Секция bundleconfig.json </param>
        /// <param name="template"> Шаблон тега(ов) в формате String.Format </param>
        /// <param name="singleFile">Режим одного файла или многих файлов </param>
        public static void BundleFiles(string bundleFile, string template, bool singleFile)
        {
            var server           = HttpContext.Current.Server;
            var response         = HttpContext.Current.Response;
            var bundleConfigFile = server.MapPath("/bundleconfig.json");

            // IE9 не переваривает стили с >4000 селекторов, поэтому отказываемся от бандла
            if (singleFile && template.ToUpper().Contains(StylesheetTemplatePart))
            {
                singleFile = HttpContext.Current.Request.Browser.Browser != IeBrowserName || !SplitCssBrowserType.IsMatch(HttpContext.Current.Request.Browser.Type);
            }

            if (singleFile)
            {
                response.Write(CreateHashedLink(bundleFile, template));
            }
            else
            {
                var boundles = BundleHandler.GetBundles(bundleConfigFile);
                boundles.FirstOrDefault(b => b.OutputFileName == bundleFile)?.InputFiles.ForEach(fileUrl =>
                {
                    var debugFile = fileUrl;

                    var unMinified = fileUrl.Replace(".min.", ".");
                    if (File.Exists(server.MapPath("/" + unMinified)))
                    {
                        debugFile = unMinified;
                    }

                    response.Write(CreateHashedLink(debugFile, template));
                });
            }
        }
Esempio n. 3
0
        internal static IEnumerable <Bundle> IsOutputConfigered(string configFile, string sourceFile)
        {
            List <Bundle> list = new List <Bundle>();

            if (string.IsNullOrEmpty(configFile))
            {
                return(list);
            }

            try
            {
                var bundles = BundleHandler.GetBundles(configFile);

                foreach (Bundle bundle in bundles)
                {
                    if (bundle.GetAbsoluteOutputFile().Equals(sourceFile, StringComparison.OrdinalIgnoreCase))
                    {
                        list.Add(bundle);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
            }

            return(list);
        }
Esempio n. 4
0
        private ITaskRunnerNode GetFileType(string configPath, string extension)
        {
            var configs = BundleHandler.GetBundles(configPath);
            var types   = configs?.Where(c => Path.GetExtension(c.OutputFileName).Equals(extension, StringComparison.OrdinalIgnoreCase));

            if (types == null || !types.Any())
            {
                return(null);
            }

            string cwd          = Path.GetDirectoryName(configPath);
            string friendlyName = GetFriendlyName(extension);

            TaskRunnerNode type = new TaskRunnerNode(friendlyName, true)
            {
                Command = GetCommand(cwd, $"*{extension} \"{configPath}\"")
            };

            foreach (var config in types)
            {
                TaskRunnerNode child = new TaskRunnerNode(config.OutputFileName, true)
                {
                    Command = GetCommand(cwd, $"\"{config.OutputFileName}\" \"{configPath}\"")
                };

                type.Children.Add(child);
            }

            return(type);
        }
        private void LoadBundles()
        {
            if (_bundles == null)
            {
                lock (_lock)
                {
                    if (_bundles == null)
                    {
                        if (!BundleHandler.TryGetBundles(_configurationPath, out var bundles))
                        {
                            throw new Exception("Unable to load bundles.");
                        }

                        var result = new List <Bundle>();
                        foreach (var bundle in bundles)
                        {
                            var b = new Bundle();
                            b.Name          = bundle.OutputFileName;
                            b.OutputFileUrl = bundle.GetAbsoluteOutputFile();
                            b.InputFileUrls = bundle.GetAbsoluteInputFiles().ToList();
                            result.Add(b);
                        }

                        _bundles = result;
                    }
                }
            }
        }
        /// <summary>
        /// 包含Bundle是否需要加载判断,添加资源引用计数,并在尚未加载Bundle时,设置加载完成时回调
        /// </summary>
        /// <param name="bundleIndex"></param>
        /// <param name="assetIndex"></param>
        private void LoadBundleForLoadAsset(int bundleIndex, int assetIndex)
        {
            BundleHandler bundleHandler = m_BundleHandlers[bundleIndex];

            if (bundleHandler == null)
            {
                bundleHandler = m_BundleHandlerPool.Alloc();
                bundleHandler.SetBundleIndex(bundleIndex);
                m_BundleHandlers[bundleIndex] = bundleHandler;
            }

            BundleAction bundleAction = bundleHandler.AddReference();

            if (bundleAction == BundleAction.Load)
            {
                m_BundleActionRequests.Enqueue(new BundleActionRequest(bundleIndex, bundleAction));

                MDebug.LogVerbose(LOG_TAG, $"Add load bundle action. Bundle:({m_BundleInfos[bundleIndex].BundleName}) Asset:({(AssetKey)assetIndex})");
            }
            else if (bundleAction == BundleAction.Null)
            {
                // Dont need handle
            }
            else
            {
                MDebug.Assert(false, "AsestBundle", "Not support BundleAction: " + bundleAction);
            }

            bundleHandler.TryAddDependencyAsset(m_AssetHandlers[assetIndex]);
        }
Esempio n. 7
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            // Add framework services.
            services.AddMvc(options =>
            {
                options.Filters.Add <ExceptionFilter>();
                //options.Filters.Add<ModelValidationFilter>();
            }).AddJsonOptions(options =>
            {
                options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
            }).AddControllersAsServices();

            services.AddScoped <ExceptionFilter>()
            .AddScoped <ModelValidationFilter>();

            services.AddSingleton <IConfiguration>(Configuration);

            services.AddOptions();

            services.Configure <Parent>(Configuration.GetSection("Parent"));

            services.AddEntityFrameworkSqlServer();

            var builder = new ContainerBuilder();

            // Register services here

            builder.RegisterTypes(Assembly.GetEntryAssembly().GetTypes())
            .Where(type => type.IsAssignableTo <BaseBusiness>())
            .AsImplementedInterfaces()
            .InstancePerLifetimeScope();

            builder.RegisterTypes(Assembly.GetEntryAssembly().GetTypes())
            .AsClosedTypesOf(typeof(BaseRepository <>))
            .AsImplementedInterfaces()
            .InstancePerLifetimeScope();

            builder.RegisterTypes(Assembly.GetEntryAssembly().GetTypes())
            .Where(type => type.IsAssignableTo <BaseContext>())
            .AsImplementedInterfaces()
            //.OnActivating(x =>
            //{
            //	var context = x.Instance as IContext;

            //	context.SetConnection(Configuration);
            //})
            .InstancePerLifetimeScope();

            //builder.RegisterType<Logging.ILogger>()
            //	.As<Logger>()
            //	.OnPreparing(x => x.Parameters.);

            builder.Populate(services);

            this.ApplicationContainer = builder.Build();

            BundleHandler.TryGetBundles("bundleconfig.json", out IEnumerable <Bundle> bundles);

            return(new AutofacServiceProvider(this.ApplicationContainer));
        }
Esempio n. 8
0
        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>();

            _bundleHandler = new BundleHandler(
                _httpContextAccessor,
                _fhirRequestContextAccessor,
                _fhirJsonSerializer,
                _fhirJsonParser,
                transactionHandler,
                _bundleHttpContextAccessor,
                _resourceIdProvider,
                transactionBundleValidator,
                _auditEventTypeMapping,
                NullLogger <BundleHandler> .Instance);
        }
Esempio n. 9
0
 public string GetRemark()
 {
     if (this._table.GetTableType() != 1)
     {
         return(this._table.GetName().Comment);
     }
     return(BundleHandler.GetString(this._hndTableRemarks, this.GetName()));
 }
Esempio n. 10
0
        public static void UnpackRoomBundle()
        {
            //string roomName = Config.RoomObject.GameObjectName;
            string roomName       = RoomManager.SyncRoomName();
            string roomBundlePath = Config.AssetBundle.RoomPackage.CompileAbsoluteAssetPath(Config.AssetBundle.RoomPackage.CompileFilename(), roomName);

            BundleHandler.UnpackFinalRoomTextureBundle(roomBundlePath);
        }
Esempio n. 11
0
 public void SetLocale(CultureInfo l)
 {
     lock (BundleHandler.SetGlobalLock)
     {
         BundleHandler.SetLocale(l);
         this._hndColumnRemarks = BundleHandler.GetBundleHandle("column-remarks", null);
         this._hndTableRemarks  = BundleHandler.GetBundleHandle("table-remarks", null);
         BundleHandler.SetLocale(BundleHandler.GetLocale());
     }
 }
Esempio n. 12
0
        private void OnApplicationPostResolveRequestCache(object sender, EventArgs e)
        {
            HttpApplication app = (HttpApplication)sender;

            // If there are any bundles, see if its a bundle request first and don't do routing if so
            if (BundleTable.Bundles.Count > 0)
            {
                BundleHandler.RemapHandlerForBundleRequests(app);
            }
        }
Esempio n. 13
0
        public string GetColRemarks(int i)
        {
            if (this._table.GetTableType() != 1)
            {
                return(null);
            }
            string key = this.GetName() + "_" + this.GetColName(i);

            return(BundleHandler.GetString(this._hndColumnRemarks, key));
        }
Esempio n. 14
0
        private void AddBundle(object sender, EventArgs e)
        {
            var item = ProjectHelpers.GetSelectedItems().FirstOrDefault();

            if (item == null || item.ContainingProject == null)
            {
                return;
            }

            string folder              = item.ContainingProject.GetRootFolder();
            string configFile          = Path.Combine(folder, Constants.CONFIG_FILENAME);
            IEnumerable <string> files = ProjectHelpers.GetSelectedItemPaths().Select(f => BundlerMinifier.FileHelpers.MakeRelative(configFile, f));
            string inputFile           = item.Properties.Item("FullPath").Value.ToString();
            string outputFile          = inputFile;

            if (files.Count() > 1)
            {
                outputFile = GetOutputFileName(inputFile, Path.GetExtension(files.First()));
            }
            else
            {
                // Reminify file
                var bundles = BundleFileProcessor.IsFileConfigured(configFile, inputFile);

                if (bundles.Any())
                {
                    BundleService.SourceFileChanged(configFile, inputFile);
                    Telemetry.TrackEvent("VS recompile config");
                    return;
                }
            }

            if (string.IsNullOrEmpty(outputFile))
            {
                return;
            }

            BundlerMinifierPackage._dte.StatusBar.Progress(true, "Creating bundle", 0, 2);

            string relativeOutputFile = BundlerMinifier.FileHelpers.MakeRelative(configFile, outputFile);
            Bundle bundle             = CreateBundleFile(files, relativeOutputFile);

            BundleHandler.AddBundle(configFile, bundle);

            BundlerMinifierPackage._dte.StatusBar.Progress(true, "Creating bundle", 1, 2);

            item.ContainingProject.AddFileToProject(configFile, "None");
            BundlerMinifierPackage._dte.StatusBar.Progress(true, "Creating bundle", 2, 2);

            BundleService.Process(configFile);
            BundlerMinifierPackage._dte.StatusBar.Progress(false, "Creating bundle");
            BundlerMinifierPackage._dte.StatusBar.Text = "Bundle created";

            Telemetry.TrackEvent("VS create bundle");
        }
Esempio n. 15
0
        public static void InstantiateRoom()
        {
            string roomName = RoomManager.SyncRoomName();
            //string roomName = Config.RoomObject.GameObjectName;
            string rawResourceBundlePath = Config.AssetBundle.RawPackage.CompileAbsoluteAssetPath(Config.AssetBundle.RawPackage.CompileFilename(), roomName);

            Debug.Log("Room name = " + roomName);
            Debug.Log("rawResource bundle path = " + rawResourceBundlePath);

            BundleHandler.InstantiateRoom(rawResourceBundlePath);
        }
Esempio n. 16
0
 private void visitBundle(WWW www, BundleHandler cb)
 {
     if (string.IsNullOrEmpty(www.error))
     {
         cb(www.assetBundle);
     }
     else
     {
         Debug.LogError(www.error);
     }
 }
Esempio n. 17
0
        private void CreateAdornments(ITextDocument document, IWpfTextView textView)
        {
            string fileName = document.FilePath;

            if (Path.GetFileName(fileName) == Constants.CONFIG_FILENAME)
            {
                LogoAdornment highlighter = new LogoAdornment(textView, _isVisible, _initOpacity);
            }
            else if (Path.IsPathRooted(fileName)) // Check that it's not a dynamic generated file
            {
                var item = BundlerMinifierPackage._dte.Solution.FindProjectItem(fileName);

                if (item == null || item.ContainingProject == null)
                {
                    return;
                }

                string configFile = item.ContainingProject.GetConfigFile();

                if (string.IsNullOrEmpty(configFile))
                {
                    return;
                }

                string extension          = Path.GetExtension(fileName.Replace(".map", ""));
                string normalizedFilePath = fileName.Replace(".map", "").Replace(".min" + extension, extension);

                try
                {
                    var bundles = BundleHandler.GetBundles(configFile);

                    foreach (Bundle bundle in bundles)
                    {
                        if (bundle.InputFiles.Count == 1 && bundle.InputFiles.First() == bundle.OutputFileName && !fileName.Contains(".min.") && !fileName.Contains(".map"))
                        {
                            continue;
                        }

                        if (bundle.GetAbsoluteOutputFile().Equals(normalizedFilePath, StringComparison.OrdinalIgnoreCase))
                        {
                            GeneratedAdornment generated = new GeneratedAdornment(textView, _isVisible, _initOpacity);
                            textView.Properties.AddProperty("generated", true);
                            break;
                        }
                    }
                }
                catch (Exception ex)
                {
                    Logger.Log(ex);
                }
            }
        }
Esempio n. 18
0
        public static void CreateRoomPrefab(GameObject obj)
        {
#if UNITY_EDITOR
            if (obj != null)
            {
                //AssetDatabase.CreateAsset(obj, "Assets/Room Texture/Resources/Test.obj");
                //AssetDatabase.SaveAssets();
                //AssetDatabase.Refresh();

                //string roomName = Config.RoomObject.GameObjectName;
                string roomName = obj.name ?? Config.RoomObject.GameObjectName;

                if (!Directory.Exists(Config.Prefab.CompileAbsoluteAssetDirectory(roomName)))
                {
                    //Directory.CreateDirectory(Config.Prefab.CompileAbsoluteAssetDirectory());
                    AbnormalDirectoryHandler.CreateDirectory(Config.Prefab.CompileAbsoluteAssetDirectory(roomName));
                    Debug.Log("Prefab folder created: " + Config.Prefab.CompileAbsoluteAssetDirectory(roomName));
                }
                //var emptyPrefab = PrefabUtility.CreateEmptyPrefab(CrossPlatformNames.Prefab.CompileCompatibleOutputFolder() + '/' + CrossPlatformNames.Prefab.Filename);
                //PrefabUtility.ReplacePrefab()
                //PrefabUtility.CreatePrefab(CrossPlatformNames.Prefab.CompileCompatibleOutputFolder() + '/' + CrossPlatformNames.Prefab.Filename, AssetDatabase.Find)

                //PrefabUtility.CreatePrefab(Config.Prefab.CompileUnityAssetDirectory(roomName) + '/' + Config.Prefab.CompileFilename(), obj); // CompileCompatibleOutputFolder
                PrefabUtility.CreatePrefab(Config.Prefab.CompileUnityAssetPath(Config.Prefab.CompileFilename(), roomName), obj);
                //PrefabUtility.CreatePrefab(CrossPlatformNames.Prefab.OutputFilepath, obj);

                Debug.Log("Room prefab generated at " + Config.Prefab.CompileUnityAssetDirectory(roomName));
                //Debug.Log("Room path = " + CrossPlatformNames.Prefab.OutputFilepath);
                //Debug.Log("Room path = " + Config.Prefab.CompileUnityAssetDirectory(roomName) + '/' + Config.Prefab.CompileFilename()); // CompileCompatibleOutputFolder
                Debug.Log("Room path = " + Config.Prefab.CompileUnityAssetPath(Config.Prefab.CompileFilename(), roomName));
            }
            else
            {
                //UnityEngine.Debug.Log(Messages.GameObjectDoesNotExist);

                //string originalRoomName = Config.RoomObject.GameObjectName;

                //Config.RoomObject.GameObjectName = obj.name;
                //BundleHandler.InstantiateRoom(Config.AssetBundle.RawPackage.CompileAbsoluteAssetPath(Config.AssetBundle.RawPackage.CompileFilename(), obj.name));
                BundleHandler.InstantiateRoom(Config.AssetBundle.RawPackage.CompileAbsoluteAssetPath(Config.AssetBundle.RawPackage.CompileFilename(), Config.RoomObject.GameObjectName));

                CreateRoomPrefab(GameObject.Find(Config.RoomObject.GameObjectName));

                BundleHandler.RemoveRoomObject(Config.RoomObject.GameObjectName);

                //Config.RoomObject.GameObjectName = originalRoomName;
            }

            UnityEditor.AssetDatabase.Refresh();
#endif
        }
Esempio n. 19
0
        public void Minify()
        {
            var bundles = BundleHandler.GetBundles(TEST_BUNDLE);

            _processor.Process(TEST_BUNDLE, bundles.Where(b => b.OutputFileName == "minify.min.js"));

            string cssResult = File.ReadAllText(new FileInfo("../../../artifacts/minify.min.js").FullName);

            Assert.AreEqual("var i=1,y=3,o={value:1},o2={...o,newValue:2};\n//# sourceMappingURL=minify.min.js.map", cssResult);

            string map = File.ReadAllText(new FileInfo("../../../artifacts/minify.min.js.map").FullName);

            Assert.IsTrue(map.Contains("minify.js"));
        }
Esempio n. 20
0
        private static bool GetConfigFileFromArgs(string[] args, out string configPath)
        {
            int index = args.Length - 1;
            IEnumerable <Bundle> bundles;
            bool fileExists     = false;
            bool fallbackExists = fileExists = File.Exists(DefaultConfigFileName);

            if (index > -1)
            {
                fileExists = File.Exists(args[index]);

                if (BundleHandler.TryGetBundles(args[index], out bundles))
                {
                    configPath = args[index];
                    return(true);
                }
            }

            if (BundleHandler.TryGetBundles(DefaultConfigFileName, out bundles))
            {
                configPath = new FileInfo(DefaultConfigFileName).FullName;
                return(false);
            }

            if (args.Length > 0)
            {
                if (!fileExists)
                {
                    System.Console.WriteLine($"A configuration file called {args[index]} could not be found".Red().Bright());
                }
                else
                {
                    System.Console.WriteLine($"Configuration file {args[index]} has errors".Red().Bright());
                }
            }

            if (!fallbackExists)
            {
                System.Console.WriteLine($"A configuration file called {DefaultConfigFileName} could not be found".Red().Bright());
            }
            else
            {
                System.Console.WriteLine($"Configuration file {DefaultConfigFileName} has errors".Red().Bright());
            }

            configPath = null;
            return(false);
        }
Esempio n. 21
0
        public void AddBundles()
        {
            var bundle = new Bundle();

            bundle.IncludeInProject = true;
            bundle.OutputFileName   = _guid + ".js";
            bundle.InputFiles.AddRange(new[] { "file1.js", "file2.js" });

            string filePath = "../../artifacts/" + _guid + ".json";

            BundleHandler.AddBundle(filePath, bundle);

            var bundles = BundleHandler.GetBundles(filePath);

            Assert.AreEqual(1, bundles.Count());
        }
Esempio n. 22
0
        // 加载单一资源依赖bundle
        private IEnumerator loadDependencies(string bundle_name, BundleHandler cb)
        {
            string[] dependencies = _dependencies_manifest.GetAllDependencies(bundle_name);
            int      len          = dependencies.Length;

            for (int i = 0; i < len; ++i)
            {
                WWW www = new WWW(Config.PathInfo.BUNDLE_URL + dependencies[i]);
                yield return(www);

                visitBundle(www, (AssetBundle bundle) =>
                {
                    bundle.LoadAllAssets();
                    cb(bundle);
                });
            }
        }
Esempio n. 23
0
        private void AddBundle(object sender, EventArgs e)
        {
            var item = ProjectHelpers.GetSelectedItems().FirstOrDefault();

            if (item == null || item.ContainingProject == null)
            {
                return;
            }

            string folder              = item.ContainingProject.GetRootFolder();
            string configFile          = Path.Combine(folder, Constants.FILENAME);
            IEnumerable <string> files = ProjectHelpers.GetSelectedItemPaths().Select(f => MakeRelative(configFile, f));
            string inputFile           = item.Properties.Item("FullPath").Value.ToString();
            string outputFile          = GetOutputFileName(inputFile, Path.GetExtension(files.First()));

            if (string.IsNullOrEmpty(outputFile))
            {
                return;
            }

            BundlerMinifierPackage._dte.StatusBar.Progress(true, "Creating bundle", 0, 3);

            string relativeOutputFile = MakeRelative(configFile, outputFile);
            Bundle bundle             = CreateBundleFile(files, relativeOutputFile);

            BundleHandler bundler = new BundleHandler();

            bundler.AddBundle(configFile, bundle);

            BundlerMinifierPackage._dte.StatusBar.Progress(true, "Creating bundle", 1, 3);

            item.ContainingProject.AddFileToProject(configFile, "None");
            BundlerMinifierPackage._dte.StatusBar.Progress(true, "Creating bundle", 2, 3);

            BundlerMinifierPackage._dte.ItemOperations.OpenFile(configFile);
            BundlerMinifierPackage._dte.StatusBar.Progress(true, "Creating bundle", 3, 3);

            BundleService.Process(configFile);
            BundlerMinifierPackage._dte.StatusBar.Progress(false, "Creating bundle");
            BundlerMinifierPackage._dte.StatusBar.Text = "Bundle created";
        }
Esempio n. 24
0
        private void UpdateSelectedBundle(object sender, EventArgs e)
        {
            var configFile = ProjectHelpers.GetSelectedItemPaths().FirstOrDefault();

            if (string.IsNullOrEmpty(configFile))
            {
                var project = ProjectHelpers.GetActiveProject();
                configFile = project?.GetConfigFile();
            }

            if (string.IsNullOrEmpty(configFile) || !File.Exists(configFile))
            {
                return;
            }

            var bundles = BundleHandler.GetBundles(configFile);

            BundleFileProcessor processor = new BundleFileProcessor();

            processor.Clean(configFile, bundles);
        }
Esempio n. 25
0
        private void RemoveConfig(object sender, EventArgs e)
        {
            var question = MessageBox.Show($"This will remove the file from {Constants.CONFIG_FILENAME}.\r\rDo you want to continue?", Constants.VSIX_NAME, MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

            if (question == DialogResult.Cancel)
            {
                return;
            }

            try
            {
                foreach (Bundle bundle in _bundles)
                {
                    BundleHandler.RemoveBundle(bundle.FileName, bundle);
                }
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
                BundlerMinifierPackage._dte.StatusBar.Text = $"Could not update {Constants.CONFIG_FILENAME}. Make sure it's not write-protected or has syntax errors.";
            }
        }
Esempio n. 26
0
        public BundleHandlerTests()
        {
            _router = Substitute.For <IRouter>();

            var fhirRequestContext = Substitute.For <IFhirRequestContext>();

            fhirRequestContext.BaseUri.Returns(new Uri("https://localhost/"));
            fhirRequestContext.CorrelationId.Returns(Guid.NewGuid().ToString());

            _fhirRequestContextAccessor = Substitute.For <IFhirRequestContextAccessor>();
            _fhirRequestContextAccessor.FhirRequestContext.Returns(fhirRequestContext);

            _httpContextAccessor = Substitute.For <IHttpContextAccessor>();

            _fhirJsonSerializer = new FhirJsonSerializer();
            _fhirJsonParser     = new FhirJsonParser();

            _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();

            _bundleHandler = new BundleHandler(_httpContextAccessor, _fhirRequestContextAccessor, _fhirJsonSerializer, _fhirJsonParser, transactionHandler, _bundleHttpContextAccessor, _resourceIdProvider, NullLogger <BundleHandler> .Instance);
        }
Esempio n. 27
0
        /// <summary>
        /// 减少指定Bundle包中的资源引用计数
        /// </summary>
        /// <param name="bundleIndex"></param>
        private void RemoveAssetDependency(int bundleIndex, int assetIndex)
        {
            BundleHandler bundleHandler = m_BundleHandlers[bundleIndex];

            if (bundleHandler != null)
            {
                BundleAction bundleAction = bundleHandler.RemoveReference();
                if (bundleAction == BundleAction.Unload)
                {
                    m_BundleActionRequests.Enqueue(new BundleActionRequest(bundleIndex, bundleAction));

                    MDebug.LogVerbose(LOG_TAG, $"Add remove bundle action. Bundle:({m_BundleInfos[bundleIndex].BundleName}) Asset:({(AssetKey)assetIndex})");
                }
                else if (bundleAction == BundleAction.Null)
                {
                    // Dont need handle
                }
                else
                {
                    MDebug.Assert(false, "AsestBundle", "Not support BundleAction: " + bundleAction);
                }
            }
        }
Esempio n. 28
0
        private static IEnumerable <Bundle> GetConfigs(string configPath, string file)
        {
            var configs = BundleHandler.GetBundles(configPath);

            if (configs == null || !configs.Any())
            {
                return(null);
            }

            if (file != null)
            {
                if (file.StartsWith("*"))
                {
                    configs = configs.Where(c => Path.GetExtension(c.OutputFileName).Equals(file.Substring(1), StringComparison.OrdinalIgnoreCase));
                }
                else
                {
                    configs = configs.Where(c => c.OutputFileName.Equals(file, StringComparison.OrdinalIgnoreCase));
                }
            }

            return(configs);
        }
Esempio n. 29
0
        private void RemoveConfig(object sender, EventArgs e)
        {
            string prompt   = Resources.Text.promptRemoveBundle.AddParams(Constants.CONFIG_FILENAME);
            var    question = MessageBox.Show(prompt, Vsix.Name, MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

            if (question == DialogResult.Cancel)
            {
                return;
            }

            try
            {
                foreach (Bundle bundle in _bundles)
                {
                    BundleHandler.RemoveBundle(bundle.FileName, bundle);
                }
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
                BundlerMinifierPackage._dte.StatusBar.Text = Resources.Text.ErrorRemoveBundle.AddParams(Constants.CONFIG_FILENAME);
            }
        }
Esempio n. 30
0
        public void GetBundles()
        {
            var bundles = BundleHandler.GetBundles(TEST_BUNDLE);

            Assert.AreEqual(3, bundles.Count());
        }