public void GetContextReturnsContext() { var controller = new AssetsController(); var context = controller.GetContext(); Assert.IsType <AssetsDBContext>(context); }
//useage //var spicker = new FileSavePicker(); //spicker.FileTypeChoices.Add("XML", new List<String>() { ".xml" }); //var sfs = await spicker.PickSaveFileAsync(); //await DataPacManager.SerializeAsync(sfs, "test"); public static async Task SerializeAsync(StorageFile sf, string serkey) { if (Core.Current.CurrentUser == null) { throw new Exception(); } DataPac dat = new DataPac(); await Task.Run(async() => { //create ser aesobj string pid = Core.Current.CurrentUser.PID; dat.pid = pid; string str1 = pid + serkey; string str2 = serkey + pid; var hashobj = new Helper.HashProvider(); string hstr1 = hashobj.Hash(str1); string hstr2 = hashobj.Hash(str2); string serpwd_hash = hstr1 + hstr2; Helper.AESProvider _AESobj; var ivhash = new Helper.HashProvider(HashAlgorithmNames.Md5); byte[] _iv = ivhash.Hashbytes(pid); //create token string ranstr = (new Helper.RandomGenerator()).getRandomString(20); dat.token = ranstr; string kstr1 = ranstr + serpwd_hash; string kstr2 = serpwd_hash + ranstr; var keyhash = new Helper.HashProvider(); byte[] _key = new byte[128]; byte[] btar = keyhash.Hashbytes(kstr1); Array.Copy(btar, 0, _key, 0, 64); btar = keyhash.Hashbytes(kstr2); Array.Copy(btar, 0, _key, 64, 64); _AESobj = new Helper.AESProvider(_iv, _key); //encrypt dats dat.pwd_hash = _AESobj.Encrypt(Core.Current.CurrentUser.PWD_hash); dat.sertoken = _AESobj.Encrypt(ranstr); dat.vertifystr = _AESobj.Encrypt(AssetsController.getLocalSequenceString(Core.Current.CurrentUser.UID)); List <DataPac.dRow> arr = new List <DataPac.dRow>(); using (APPDbContext db = new APPDbContext()) { foreach (var t in db.Recordings.ToList()) { if (t.uid == Core.Current.CurrentUser.UID) { DataPac.dRow obj = new DataPac.dRow() { key = _AESobj.Encrypt(t.key), value = _AESobj.Encrypt(t.value) }; arr.Add(obj); } } } dat.dRows = arr.ToArray(); await dat.SerializeAsync(sf); }); }
public async void PlayMusic() { var random = new Random().Next(0, _musicList.Count); var clipRef = _musicList[random].ClipRef; var audioClip = await AssetsController.LoadAsset <AudioClip>(clipRef); Debug.Log($"<color=#ffb3ff>Audio Manager: Playing sound {audioClip.name}</color>"); _audioSource.PlayOneShot(audioClip); }
public async void SetSchemeData() { var productData = _craftMenuController.Scheme.items.ActiveItem.ItemData; var sprite = await AssetsController.LoadAsset <Sprite>(productData.IconRef); SetProductIcon(sprite); parts.SetPartsData(); }
public async void SetProductInfo() { var productData = _storageMenuController.Items.ActiveItem.ItemData; var sprite = await AssetsController.LoadAsset <Sprite>(productData.IconRef); SetProductIcon(sprite); SetProductTitle(productData.Key); specifications.SetSpecificationsData(); }
private async void SetProductionCellInfo() { var craftObj = _productionController.GetProduction(_productionCell.Id); var craftItem = _productsController.GetProduct(craftObj.Key); var sprite = await AssetsController.LoadAsset <Sprite>(craftItem.IconRef); _productionCell.SetCellIcon(sprite); }
public async void SetSidebarData() { var unitData = _unitsMenuController.Roster.ActiveUnit.UnitData; unitName.text = _localisationController.GetLanguageValue(unitData.Key); unitIcon.sprite = await AssetsController.LoadAsset <Sprite>(unitData.IconRef); specification.SetSpecificationData(); }
public async void SetItemData() { var sprite = await AssetsController.LoadAsset <Sprite>(ActiveItem.ItemData.IconRef); SetItemTitle(ActiveItem.ItemData.Key); SetItemIcon(sprite); specification.SetSpecificationData(); }
public async void SetUnitData(BattleUnitObject unit) { Unit = unit; var sprite = await AssetsController.LoadAsset <Sprite>(unit.Data.IconRef); SetUnitIcon(sprite); SetUnitTeam(unit.Team); Unit.OnSetHealth += StartHealthBarAnimation; }
public async void SetData(RawType raw) { var sprite = await AssetsController.LoadAsset <Sprite>(_iconUtil.GetRawIcon(raw)); var rawCountKey = LocalisationKeys.RawKeys[raw]; var rawCount = _controllersResolver.GetStoreByType(ItemType.Raw).GetItem(rawCountKey).GetCount(); SetIcon(sprite); SetCount(rawCount); }
public async void SetSidebarData() { var data = ActiveItem.Equipment; var sprite = await AssetsController.LoadAsset <Sprite>(data.IconRef); SetItemTitle(data.Key); SetItemIcon(sprite); specs.SetSpecData(); select.SetButtonInteractable(); }
public void addPlayer() { if (sceneDataControl.isForcedPlayerLayer()) { playerImagePath = Controller.getInstance().getPlayerImagePath(); ElementContainer ec = new ElementContainer(null, 0, AssetsController.getImage(this.playerImagePath)); int layer = insertInOrder(ec, true); reassignLayerAllReferencesDataControl(layer); sceneDataControl.setPlayerLayer(layer); } }
public void TestRobotsTxtContent() { _blogConfigMock.Setup(bc => bc.AdvancedSettings).Returns(new Configuration.AdvancedSettings { RobotsTxtContent = "996" }); var ctl = new AssetsController(_loggerMock.Object, _appSettingsMock.Object, _blogConfigMock.Object); var result = ctl.RobotsTxt(); Assert.IsInstanceOf(typeof(ContentResult), result); }
public async void SetEquipmentData(ProductObject product, ItemQuality quality = ItemQuality.Common) { var sprite = await AssetsController.LoadAsset <Sprite>(product?.IconRef); var active = (bool)sprite; SetEquipmentIcon(sprite, active); SetQualityIcon(quality, active); plusIcon.enabled = !active; itemTypeImage.enabled = !active; }
public void CallingGetAssetsWithIdentifierReturnsSingleAsset() { var sut = new AssetsController(); var result = sut.Get("12345"); Assert.NotNull(result); Assert.IsInstanceOf <IActionResult>(result); Assert.IsInstanceOf <OkObjectResult>(result); var okResult = result as OkObjectResult; StringAssert.Contains("\"identifier\":\"12345\"", okResult.Value.ToString()); }
public void CallingGetAssetsWithoutIdentifierReturnsAssetList() { var sut = new AssetsController(); var result = sut.Get(); Assert.NotNull(result); Assert.IsInstanceOf <IActionResult>(result); Assert.IsInstanceOf <OkObjectResult>(result); var okResult = result as OkObjectResult; StringAssert.Contains("_links", okResult.Value.ToString()); }
public void OnDialogOk(string message, object workingObject = null, object workingObjectSecond = null) { switch ((BaseFileOpenDialog.FileType)workingObject) { case BaseFileOpenDialog.FileType.ITEM_IMAGE: element.Image = message; Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[ GameRources.GetInstance().selectedSceneIndex].setPreviewBackground(message); if (element.Image != null && !element.Image.Equals("")) imagePreview = AssetsController.getImage(element.Image).texture; break; } }
protected GameObject Instantiate(T control, C configuration, Component parent, bool active) { var prefab = configuration.bundleInfo != null ? AssetsController.GetAsset <GameObject>(configuration.bundleInfo, configuration.prefabName) : AssetsController.GetAsset <GameObject>(configuration.bundleId, configuration.prefabName); prefab.SetActive(active); var instance = Object.Instantiate(prefab, parent.transform); instance.name = control.name; return(instance); }
public PortfolioTable() { this.Build(); _DeltasController = new DeltasController(this); _AssetsController = new AssetsController(this); foreach (Widget w in new Widget[] { eventbox4, eventbox7 }) { w.ModifyBg(Gtk.StateType.Normal, Colors.Base.Gdk); } ConfigureList(); }
public void Awake() { this._countdownText = GameObject.Find("ui_countdown").GetComponent <TextMeshPro>(); this._source = GetComponent <AudioSource>(); this._source.playOnAwake = false; this._audioClips = new AudioClip[] { AssetsController.GetResource <AudioClip>("Sounds/countdown_dos_sec1"), AssetsController.GetResource <AudioClip>("Sounds/countdown_dos_sec2"), AssetsController.GetResource <AudioClip>("Sounds/countdown_dos_sec3"), AssetsController.GetResource <AudioClip>("Sounds/countdown_dos_sec4"), AssetsController.GetResource <AudioClip>("Sounds/countdown_dos_sec5") }; }
public async Task TestGetImageAsyncInvalidFileNames(string filename) { var ctl = new AssetsController( _loggerMock.Object, _appSettingsMock.Object, _imageStorageSettingsMock.Object, _asyncImageStorageProviderMock.Object, _blogConfigMock.Object, _siteIconGeneratorMock.Object); var memCacheMock = new Mock <IMemoryCache>(); var result = await ctl.GetImageAsync(filename, memCacheMock.Object); Assert.IsInstanceOf(typeof(BadRequestObjectResult), result); }
public Sprite getPlayerImage() { //CHANGE: Now, the image of the player must be taken from return(AssetsController.getImage(Controller.getInstance().getPlayerImagePath())); /*if (playerPositionInAllReferences==NO_PLAYER) * return AssetsController.getImage(Controller.getInstance().getPlayerImagePath()); * else{ * if (imagePathHasChanged){ * allReferencesDataControl.get(playerPositionInAllReferences).setImage(AssetsController.getImage( this.playerImagePath )); * imagePathHasChanged = false; * } * // if (allReferences!=null) * return allReferencesDataControl.get(playerPositionInAllReferences).getImage(); * }*/ }
public void playClip(string source, float volume) { if (this._audio == null) { return; } AudioClip clip = AssetsController.GetResource <AudioClip>("Sounds/" + source); if (clip == null) { throw new UnityException("Failed to find clip {" + source + "}"); } this._audio.volume = Mathf.Clamp(OptionsController.effectsVolume / 1f * volume, 0f, 1f); this._audio.clip = clip; this._audio.Play(); }
public void CallingPostAssetsReturnsCreatedResponse() { var sut = new AssetsController(); var assetToPost = new DocumentAsset { Identifier = "54321", DocumentType = "Doc Type" }; var result = sut.Post(assetToPost.SerialiseToJson()); Assert.NotNull(result); Assert.IsInstanceOf <IActionResult>(result); Assert.IsInstanceOf <ObjectResult>(result); var actionResult = result as ObjectResult; Assert.AreEqual(201, actionResult.StatusCode); StringAssert.Contains("\"identifier\":\"54321\"", actionResult.Value.ToString()); }
public void TestRobotsTxtEmpty() { _blogConfigMock.Setup(bc => bc.AdvancedSettings).Returns(new Configuration.AdvancedSettings { RobotsTxtContent = string.Empty }); var ctl = new AssetsController( _loggerMock.Object, _appSettingsMock.Object, _imageStorageSettingsMock.Object, _asyncImageStorageProviderMock.Object, _blogConfigMock.Object, _siteIconGeneratorMock.Object); var result = ctl.RobotsTxt(); Assert.IsInstanceOf(typeof(NotFoundResult), result); }
/** * Shows a dialog to choose a new path for the given asset. * * @param index * Index of the asset */ public void editImagePath() { // Get the list of assets from the ZIP file string selectedAsset = null; //TODO: implement //AssetChooser chooser = AssetsController.getAssetChooser(AssetsConstants.CATEGORY_IMAGE, AssetsController.FILTER_NONE); //int option = chooser.showAssetChooser(controller.peekWindow()); ////In case the asset was selected from the zip file //if (option == AssetChooser.ASSET_FROM_ZIP) //{ // selectedAsset = chooser.getSelectedAsset(); //} ////In case the asset was not in the zip file: first add it //else if (option == AssetChooser.ASSET_FROM_OUTSIDE) //{ // bool added = AssetsController.addSingleAsset(AssetsConstants.CATEGORY_IMAGE, chooser.getSelectedFile().getAbsolutePath()); // if (added) // { // selectedAsset = chooser.getSelectedFile().getName(); // } //} // If a file was selected if (selectedAsset != null) { // Take the index of the selected asset string[] assetFilenames = AssetsController.getAssetFilenames(AssetsConstants.CATEGORY_IMAGE); string[] assetPaths = AssetsController.getAssetsList(AssetsConstants.CATEGORY_IMAGE); int assetIndex = -1; for (int i = 0; i < assetFilenames.Length; i++) { if (assetFilenames[i].Equals(selectedAsset)) { assetIndex = i; } } Controller.getInstance().addTool(new ChangeParagraphContentTool(bookParagraph, assetPaths[assetIndex])); } }
public void TestManifest() { _blogConfigMock.Setup(bc => bc.GeneralSettings).Returns(new Configuration.GeneralSettings() { SiteTitle = "Fake Title" }); var ctl = new AssetsController(_loggerMock.Object, _appSettingsMock.Object, _blogConfigMock.Object); var result = ctl.Manifest(); Assert.IsInstanceOf(typeof(JsonResult), result); if (result is JsonResult jsonResult) { if (jsonResult.Value is ManifestModel model) { Assert.IsTrue(model.ShortName == _blogConfigMock.Object.GeneralSettings.SiteTitle); Assert.IsTrue(model.Name == _blogConfigMock.Object.GeneralSettings.SiteTitle); } } }
public void GetAssets_Test() { AssetsController controler = new AssetsController(); RavenSession.Store(new Owner { Email = "*****@*****.**", Id = 1, Name = "Tester", UserName = "******" }); RavenSession.Store(new Asset { OwnerId = 1, Id = 1, Name = "Asset1" }); RavenSession.SaveChanges(); controler.RavenSession = RavenSession; var result = controler.Get(); Assert.AreEqual(result.Count(), 1); CleanUp(); }
public async Task TestGetImageAsyncCDN() { const string filename = "test.png"; var ctl = new AssetsController( _loggerMock.Object, _appSettingsMock.Object, _imageStorageSettingsMock.Object, _asyncImageStorageProviderMock.Object, _blogConfigMock.Object, _siteIconGeneratorMock.Object); var memCacheMock = new Mock <IMemoryCache>(); var result = await ctl.GetImageAsync(filename, memCacheMock.Object); Assert.IsInstanceOf(typeof(RedirectResult), result); if (result is RedirectResult rdResult) { var resultUrl = Utils.CombineUrl(_imageStorageSettingsMock.Object.Value.CDNSettings.CDNEndpoint, filename); Assert.That(rdResult.Url, Is.EqualTo(resultUrl)); } }
public async void SetPartInfo(OrderObject order) { var index = transform.GetSiblingIndex(); if (index < order.parts.Count) { var part = order.parts[index]; var data = part.data; var store = _controllersResolver.GetStoreByType(data.ItemType); var itemCount = store.GetItem(data.Slug).GetCount(part.quality); var sprite = await AssetsController.LoadAsset <Sprite>(data.Icon); SetPartIcon(sprite); SetPartText($"{itemCount}/{part.count}"); SetPartQuality(part.quality); } else { ResetPartInfo(); } }