public CmsAssetVM AddCmsAsset(CmsAsset cmsAsset) { var cmsAssetVM = new CmsAssetVM(cmsAsset); Assets.Add(cmsAssetVM); return(cmsAssetVM); }
private void OnAddAsset() { if (!ValidateProperty("AssetName")) { return; } IsFlyoutOpen = false; var asset = new Asset() { UserId = User.Id, Name = AssetName, Type = (int)AssetType.Default, }; using (var uow = new UnitOfWork()) { uow.AssetRepository.Insert(asset); uow.Commit(); } Assets.Add(new AssetViewModel() { Id = asset.Id, Cost = 0, Name = asset.Name, UserId = asset.UserId }); AssetName = string.Empty; Errors.SetAllErrors(new Dictionary <string, ReadOnlyCollection <string> >()); }
async Task ExecuteLoadItemsCommand() { if (IsBusy) { return; } IsBusy = true; try { Assets.Clear(); var assets = await DataStore.GetAsync(true); foreach (var asset in assets) { Assets.Add(asset); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
protected override void OnInitialize() { base.OnInitialize(); foreach (KeyValuePair <string, IAssetLoader> pair in Description.Loaders) { Loaders.Add(pair.Key, pair.Value); } foreach (KeyValuePair <string, IAssetInfo> pair in Description.Assets) { Assets.Add(pair.Key, pair.Value); } Log.Debug("Assets Module initialized", new { loadersCount = Loaders.Entries.Count, assetsCount = Assets.Entries.Count }); for (int i = 0; i < Description.PreloadAssets.Count; i++) { string id = Description.PreloadAssets[i]; this.Load <Object>(id); } Log.Debug("Assets Module preload", new { count = Description.PreloadAssets.Count }); }
/// <summary> /// Initializes a new instance of the <see cref="GitHubUpdateInfo"/> class. /// </summary> /// <param name="element"></param> public GitHubUpdateInfo(JsonElement element) : base( element.GetProperty("name").GetString(), element.GetProperty("tag_name").GetString(), element.GetProperty("body").GetString(), element.GetProperty("published_at").GetDateTime(), element.GetProperty("html_url").GetString() ) { var assetsElement = element.GetProperty("assets"); using (var enumerator = assetsElement.EnumerateArray()) { while (enumerator.MoveNext()) { var assetElement = enumerator.Current; var name = assetElement.GetProperty("name").GetString(); var uri = assetElement.GetProperty("browser_download_url").GetString(); var extension = Path.GetExtension(name).ToLower(); switch (extension) { case ".zip": Assets.Add(new AssetZip(name, uri)); break; default: Assets.Add(new AssetFile(name, uri)); break; } } } }
public void PurchaseAsset(Asset asset) { LogEvent("Purchse", asset.Name); if (Money < asset.Price) { throw new ApplicationException("Player could not afford " + asset.Name); } if ((asset.Owner is Bank) == false) { if (asset.Owner == this) { throw new ApplicationException("Player tried to purchase, but they already own " + asset.Name); } else { throw new ApplicationException("Player tried to purchase, but someone else owns " + asset.Name); } } asset.Owner.Assets.Remove(asset); asset.Owner = this; Assets.Add(asset); Money -= asset.Price; }
/// <summary> /// The object factory for a particular data collection instance. /// </summary> public virtual void CreateObjectsFromData(Assets assets, System.Data.DataSet data) { // Do nothing if we have nothing if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0) { return; } // Create a local variable for the new instance. Asset newobj = null; // Create a local variable for the data row instance. System.Data.DataRow dr = null; // Iterate through the table rows for (int i = 0; i < data.Tables[0].Rows.Count; i++) { // Get a reference to the data row dr = data.Tables[0].Rows[i]; // Create a new object instance newobj = System.Activator.CreateInstance(assets.ContainsType[0]) as Asset; // Let the instance set its own members newobj.SetMembers(ref dr); // Add the new object to the collection instance assets.Add(newobj); } }
private void SetAssets() { Assets.Clear(); ExpandoObject ex; if (TryGetMetadataValue("thumbnails", out ex)) { if (ex != null) { foreach (object o in ex) { string[] str1 = new[] { "source", "small", "medium", "large" }; string[] str2 = new[] { ":thumbnail{0}", ":thumbnail{0}small", ":thumbnail{0}medium", ":thumbnail{0}large" }; IList <object> lms = (IList <object>)o; int cnt = 0; foreach (object thumb in lms) { IDictionary <string, object> dic = (IDictionary <string, object>)o; for (int x = 0; x < str1.Length; x++) { if (dic.ContainsKey(str1[x])) { string rname = string.Format(str2[x], cnt == 0 ? string.Empty : cnt.ToString()); Assets.Add(FromThumbnail(rname, thumb)); } } } } } } }
//public static SalesContext db = new SalesContext(); //public static Customer CloneCustomer(Customer SelectedItem) //{ // using (var db = new SalesContext()) // { // var item = db.Customers.Find(SelectedItem.Id); // item.CustomerRank = CustomerRanks.Where(p => p.Id == item.CustomerRankID).Single(); // return item; // } //} #endregion #region Asset public async static Task GetAllAssets() { Assets.Clear(); AssetCategories.Clear(); using (var db = new SalesContext()) { var result = await(from c in db.Assets select c).ToListAsync(); var result1 = await(from c in db.AssetCategories.Include("Assets") select c).ToListAsync(); var result2 = await(from c in db.Departments.Include("Assets") select c).ToListAsync(); var result3 = await(from c in db.InstallationLocations.Include("Assets") select c).ToListAsync(); foreach (Asset item in result) { Assets.Add(item); } foreach (AssetCategory item in result1) { AssetCategories.Add(item); } foreach (Department item in result2) { Departments.Add(item); } foreach (InstallationLocation item in result3) { InstallationLocations.Add(item); } } }
private void LoadUnityFs(UnityDataReader reader) { unityfsDescriptor = new UnityfsDescriptor(); unityfsDescriptor.fsFileSize = reader.ReadInt64(); unityfsDescriptor.ciblockSize = reader.ReadUInt32(); unityfsDescriptor.uiblockSize = reader.ReadUInt32(); var flags = reader.ReadUInt32(); var compression = (CompressionType)(flags & 0x3F); var blk = new UnityDataArrayReader(ReadCompressedData(reader, (int)unityfsDescriptor.ciblockSize, (int)unityfsDescriptor.uiblockSize, compression)); blk.ReadBytes(16); // guid // read Archive block infos var numBlocks = blk.ReadInt32(); ArchiveBlockInfo[] blocks = new ArchiveBlockInfo[numBlocks]; for (int i = 0; i < numBlocks; i++) { var busize = blk.ReadInt32(); var bcsize = blk.ReadInt32(); var bflags = blk.ReadInt16(); blocks[i] = new ArchiveBlockInfo(busize, bcsize, bflags); } // Read Asset data infos var numNodes = blk.ReadInt32(); AssetDataInfo[] nodes = new AssetDataInfo[numNodes]; for (int i = 0; i < numNodes; i++) { var offset = blk.ReadInt64(); var size = blk.ReadInt64(); var status = blk.ReadInt32(); var name = blk.ReadString(); nodes[i] = new AssetDataInfo(offset, size, status, name); } // read block storage var storage = new ArchiveBlockStorage(blocks, reader); foreach (var info in nodes) { storage.Seek(info.Offset); var asset = new Asset(this, storage, info.Name); Assets.Add(asset); } if (Assets.Count > 0) { Name = Assets[0].Name; } }
internal bool AddItem(TradeAsset asset) { if (!Assets.Contains(asset)) { Assets.Add(asset); return(true); } return(false); }
private void ClearRenderStack() { foreach (KeyValuePair <int, IRenderer> asset in InitObjectStack) { asset.Value.InitBuffers(D3D.Device, D3D.DeviceContext); Assets.Add(asset.Key, asset.Value); } InitObjectStack.Clear(); }
/// <summary> /// Adds the content. /// </summary> /// <param name="key">Key.</param> /// <param name="o">Object.</param> internal void AddContent(string key, object o) { if (!CanResolve(o.GetType())) { throw new ContentLoadException(string.Format("Can't find a resolver for resource {0}", key)); } Assets.Add(key, o); }
public void AddPlaceholder() { Assets.Add(new AssetViewModel(new AssetObject { Name = Resources.Asset_PlaceholderName }) { Parent = this, IsPlaceholder = true }); }
public void AddAsset(Object Obj) { if (Assets.Contains(Obj)) { return; } Assets.Add(Obj); UpdateAssetDictionary(); }
/// <summary> /// Load the specified assetFileKey and caching. /// </summary> /// <param name="assetFileKey">Asset file key.</param> /// <param name="caching">If set to <c>true</c> caching.</param> /// <typeparam name="T">The 1st type parameter.</typeparam> public T Load <T>(string assetFileKey, bool caching = true) { try { if (string.IsNullOrEmpty(assetFileKey)) { throw new ArgumentException("Asset file name can't be empty or null"); } var assetType = typeof(T); object obj; var hasAsset = Assets.Keys.Any(a => String.Compare(assetFileKey, a, StringComparison.OrdinalIgnoreCase) == 0); if (hasAsset) { obj = Assets[assetFileKey]; } if (!CanResolve(assetType)) { throw new ContentLoadException(string.Format("Can't find a resolver for resource {0}", assetFileKey)); } var resolver = FindResolver(assetType); var assetFileName = string.Format("{0}{1}{2}", RootDirectory, Path.DirectorySeparatorChar, assetFileKey); if (LazyLoading) //auto find extension { foreach (var extension in resolver.SupportFileExtensions) { var lazyAssetFileName = string.Format("{0}.{1}", assetFileName, extension); if (File.Exists(lazyAssetFileName)) { assetFileName = lazyAssetFileName; break; } } } obj = resolver.Load(assetFileName); if (caching) { Assets.Add(assetFileKey, obj); } return((T)Convert.ChangeType(obj, assetType)); } catch (Exception ex) { throw new ContentLoadException(string.Format("Failed to load {0}", assetFileKey), ex); } }
public DataContext() { if (Assets == null) { Assets = new List <Asset>(); } if (Strikes == null) { Strikes = new List <Strike>(); } // This will get the base path of the application. _path = Path .GetDirectoryName(Assembly.GetExecutingAssembly().Location) .Replace("\\bin\\Debug\\netcoreapp3.1", string.Empty); // This will read the asset data. var assetData = File.ReadAllText($"{_path}/Data/Seed/assets.json"); // This will deserialize the json data. dynamic assets = JsonConvert.DeserializeObject(assetData); // This will map the deserialized json data to a collection of Asset objects. foreach (var item in assets) { Assets.Add(new Asset { AssetName = item["assetName"].ToString(), QuadKey = item["quadKey"].ToString(), AssetOwner = item["assetOwner"].ToString() }); } // This will read the lightning data. var strikeData = File.ReadAllText($"{_path}/Data/Seed/lightning.json"); // This will deserialize the json data. dynamic strikes = JsonConvert.DeserializeObject(strikeData); // This will map the deserialized json data to a collection of Strike objects. foreach (var item in strikes) { Strikes.Add(new Strike { FlashType = (FlashType)item["flashType"], StrikeTime = Convert.ToInt64(item["strikeTime"]), Latitude = Convert.ToDouble(item["latitude"]), Longitude = Convert.ToDouble(item["longitude"]), PeakAmps = Convert.ToInt32(item["peakAmps"]), Reserved = item["reserved"].ToString(), ICHeight = Convert.ToInt32(item["icHeight"]), ReceivedTime = Convert.ToInt64(item["receivedTime"]), NumberOfSensors = Convert.ToInt32(item["numberOfSensors"]), Multiplicity = Convert.ToInt32(item["multiplicity"]) }); } }
//--------------------------------------------------------------------------- public void Add(string name, string sourcePath, string targetPath, EAssetType assetType) { if (AddFile(sourcePath, targetPath)) { string absolutePath = Path.Combine(RootPath, targetPath); if (File.Exists(absolutePath)) { Assets.Add(new Asset(name, targetPath, assetType)); } } }
public Asset NewAsset(string[] hierarchy, string name, string extension) { var asset = new Asset() { Hierarchy = hierarchy, Name = GetUniqueFileName(hierarchy, name, extension), Extension = extension }; Assets.Add(asset); return(asset); }
private void Include <T>(Func <string, T> factory, params string[] paths) where T : AssetBase { foreach (string path in paths.Reverse()) { if (string.IsNullOrWhiteSpace(path)) { continue; } Assets.Add(factory(path)); } }
public void SetCmsAssets(List <CmsAsset> assets) { _cmsAlbum.Assets = assets; Assets.Clear(); if (_cmsAlbum.Assets != null) { foreach (var asset in _cmsAlbum.Assets) { Assets.Add(new CmsAssetVM(asset)); } } }
/// <summary> /// Constructor. /// </summary> /// <param name="assets"></param> /// <param name="downloadTypes"></param> public Configuration(IEnumerable <string> assets, IEnumerable <DownloadType> downloadTypes) { assets.ForEach(str => Assets.Add(str)); DownloadTypes = downloadTypes.ToArray(); if (!DownloadTypes.Any()) { DownloadTypes = new DownloadType[] { DownloadType.Jpg2k } } ; } }
public bool PreInit(IntPtr WindowHandle) { D3D = new DirectX11Class(); if (!D3D.Init(WindowHandle)) { MessageBox.Show("Failed to initialize DirectX11!"); return(false); } Timer = new TimerClass(); FPS = new FPSClass(); Timer.Init(); FPS.Init(); RenderStorageSingleton.Instance.Prefabs = new RenderPrefabs(); if (!RenderStorageSingleton.Instance.ShaderManager.Init(D3D.Device)) { MessageBox.Show("Failed to initialize Shader Manager!"); return(false); } //this is backup! RenderStorageSingleton.Instance.TextureCache.Add(0, TextureLoader.LoadTexture(D3D.Device, D3D.DeviceContext, "texture.dds")); var structure = new M2TStructure(); //import gizmo RenderModel model = new RenderModel(); structure.ReadFromM2T("Resources/GizmoModel.m2t"); model.ConvertMTKToRenderModel(structure); model.InitBuffers(D3D.Device, D3D.DeviceContext); model.DoRender = false; RenderModel sky = new RenderModel(); structure = new M2TStructure(); structure.ReadFromM2T("Resources/sky_backdrop.m2t"); sky.ConvertMTKToRenderModel(structure); sky.InitBuffers(D3D.Device, D3D.DeviceContext); sky.DoRender = false; Assets.Add(1, sky); RenderModel clouds = new RenderModel(); structure = new M2TStructure(); structure.ReadFromM2T("Resources/weather_clouds.m2t"); clouds.ConvertMTKToRenderModel(structure); clouds.InitBuffers(D3D.Device, D3D.DeviceContext); clouds.DoRender = false; Assets.Add(2, clouds); return(true); }
public void AddAsset(string path) { if (string.IsNullOrEmpty(path)) { return; } Assets.Add(new Asset { Name = System.IO.Path.GetFileName(path), Path = path, }); }
public void AddArchiveAssetPaths(string archiveFileName, List <string> archiveAssetPaths) { string archivePath = Assets.Find(asset => Path.GetFileName(asset) == archiveFileName); if (archivePath == null) { return; } foreach (string archiveAssetPath in archiveAssetPaths) { string mappedPath = MapArchiveAssetPath(archiveAssetPath, archiveFileName, archivePath); Assets.Add(mappedPath); } }
/* ----------------------------------------------------------------- */ /// /// ProgressViewModel /// /// <summary> /// Initializes a new instance of the ProgressViewModel class /// with the specified arguments. /// </summary> /// /// <param name="src">Model object.</param> /// <param name="aggregator">Message aggregator.</param> /// <param name="context">Synchronization context.</param> /// /* ----------------------------------------------------------------- */ public ProgressViewModel(ProgressFacade src, Aggregator aggregator, SynchronizationContext context) : base(src, aggregator, context) { Assets.Add(Facade.Subscribe(e => { if (e == nameof(Facade.Report)) { Refresh(nameof(Title)); } else { Refresh(e); } })); }
/// <summary> /// Adds the specified asset. /// </summary> /// <param name="asset">The asset.</param> public void Add(Asset asset) { if (Assets.Contains(asset)) { Debug.LogWarning(string.Format("Asset {0} was already added as an asset, can't add twice.", asset.Name)); } Assets.Add(asset); asset.GameObject.SetActive(true); GameObjectHashMap.Instance.Set(asset.Guid, asset.GameObject); LayOutAssets(); }
public void AddAssetAdministationShell(IAssetAdministrationShell aas) { AssetAdministrationShells.Add(aas); Assets.Add(aas.Asset); if (aas.Submodels?.Count > 0) { Submodels.AddRange(aas.Submodels); foreach (var submodel in aas.Submodels) { ExtractAndClearConceptDescriptions(submodel.SubmodelElements); ExtractSupplementalFiles(submodel.SubmodelElements); ResetConstraints(submodel.SubmodelElements); DeleteEvents(submodel.SubmodelElements); } } }
public async static Task AddAsset(Asset itemPara) { using (var db = new SalesContext()) { if (itemPara.AssetCategory != null) { itemPara.AssetCategoryID = itemPara.AssetCategory.Id; //NOT DELETE - IMPORTANT itemPara.InstallationLocationID = itemPara.InstallationLocation.Id; itemPara.DepartmentID = itemPara.Department.Id; db.Entry(itemPara).State = EntityState.Unchanged; } db.Assets.Add(itemPara); await UpdateDatabase(db); Assets.Add(itemPara); } }
protected virtual Asset AssetChange(JToken data) { Console.WriteLine("AssetChange"); Asset retVal = null; try { retVal = Assets[data[0].Value <string>()]; retVal.Change(data); } catch { retVal = new Asset(data); Assets.Add(retVal.InstrumentId, retVal); } return(retVal); }