public override void Load() { StorageModule[] dbModules = new StorageModule[1] { new StorageModule() }; this.Kernel.Load(dbModules); }
public static void AtomicIsInAzure(this StorageModule self, IAzureStorageConfig storage, Action <DefaultAtomicStorageStrategyBuilder> config) { var builder = new DefaultAtomicStorageStrategyBuilder(); config(builder); AtomicIsInAzure(self, storage, builder.Build()); }
void AreaView_CurrentChanged(object sender, EventArgs e) { if (this.AreaView.CurrentItem == null) { return; } { if (this._StoragePerAreaCol.Count == 0) { this._StoragePerAreaCol.Add(new StorageModule.Storage(Guid.Empty, "请选择", 0, string.Empty, string.Empty, 42, string.Empty)); } var toBeUserd = this._StoragePerAreaCol.Where(m => m.ID != Guid.Empty).ToArray(); foreach (var item in toBeUserd) { this._StoragePerAreaCol.Remove(item); } var data = StorageModule.GetStorageByArea(ConfigManager.StorageFileName, this.AreaView.CurrentItem.ToString()); if (data == null) { return; } foreach (var item in data) { this._StoragePerAreaCol.Add(item); } } }
public void RemoveTable() { StorageModule module = (StorageModule)storageTestManager.GetModule(typeof(TestClass)); module.RemoveDatabaseTable(); Assert.IsTrue(!File.Exists($@"{ApplicationData.Current.LocalFolder.Path}\{typeof(TestClass).Name}.xml")); }
public JsonResult Remove(string id) { var data = false; var module = new StorageModule(CurrentUser); data = module.Remove(t => t.Id == id); return(Json(new { code = 0, msg = "Ok", data = data })); }
public void PrepareData() { storageTestManager = new StorageModuleManager(typeof(XmlDbAccess), ApplicationData.Current.LocalFolder.Path, false); storageTestModule = new StorageModule(typeof(TestClass), typeof(AtomicItemManager)); storageTestModule2 = new StorageModule(typeof(TestClass2), typeof(AtomicItemManager)); storageTestManager.RegisterModule(storageTestModule); storageTestManager.RegisterModule(storageTestModule2); }
public JObject GetData(string orgId, string name, int page, int rows) { var module = new StorageModule(CurrentUser); var count = 0; var items = module.Page(orgId, name, page, rows, out count); var json = TableStorageDataModel.Model.GetJson(items, count, TableStorageHeaderModel.Header); return(json); }
private void RegisterCommand() { this.StorageQueryCmd = new RelayCommand(() => { this._StorageCol.Clear(); var data = CaculateLibrary.StorageModule.GetStorageByCondition(ConfigManager.StorageFileName, this.Area.Trim(), this.Code.Trim(), this.UserName.Trim(), this.AccountName.Trim(), this.FreeSpace); if (data == null) { return; } foreach (var item in data) { this._StorageCol.Add(new StorageModel(item)); } }); this.GoodsQueryCmd = new RelayCommand(() => { this._GoodsCol.Clear(); var data = GoodsModule.GetGoodsByCondition(ConfigManager.GoodsFileName, ConfigManager.StorageFileName, this.GoodsCode, this.GoodsLeftDay, this.GoodsStorage, this.GoodsStorage == Guid.Empty?this.GoodsArea:string.Empty); if (data == null) { return; } foreach (var item in data) { this._GoodsCol.Add(new GoodsModel(item)); } }); this.DelStorageCmd = new RelayCommand(() => { if (this.StorageView.CurrentItem == null) { return; } StorageModel model = this.StorageView.CurrentItem as StorageModel; StorageModule.DelStorage(ConfigManager.StorageFileName, ConfigManager.GoodsFileName, model.ID.ToString()); this._StorageCol.Remove(model); var target = this._GoodsCol.Where(m => m.StorageId == model.ID).ToArray(); foreach (var item in target) { this._GoodsCol.Remove(item); } }); this.DelGoodsCmd = new RelayCommand(() => { if (this.GoodsView.CurrentItem == null) { return; } GoodsModel model = this.GoodsView.CurrentItem as GoodsModel; GoodsModule.DelGoods(ConfigManager.GoodsFileName, model.ID.ToString()); this._GoodsCol.Remove(model); }); }
public void CreateStorageModuleTest() { AbsolutePathXmlDbAccessTest(); Assert.IsNull(storageMod); storageMod = new StorageModule(typeof(TestClass), typeof(AtomicItemManager)); Assert.IsNotNull(storageMod); }
public JsonResult Tree(string orgId) { var module = new StorageModule(CurrentUser); var items = module.FeatchAll(orgId).Select(t => new ComboTreeModel { children = new ComboTreeModel[0], id = t.Id, text = t.Name }); return(Json(items, JsonRequestBehavior.AllowGet)); }
private void LoadAreaData() { var data = StorageModule.GetAllAreas(ConfigManager.StorageFileName); if (data == null) { return; } foreach (var item in data) { this._AreaCol.Add(item); } }
/// <summary> /// Fill selector /// </summary> /// <param name="selectorContent">Content</param> /// <param name="selectedIds">Selected IDs</param> private void FillContent(ListView selectorContent, List <int> selectedIds) { MethodInfo method = typeof(StorageModule).GetMethod("GetAllItems"); StorageModule linkedModule = GetLinkedUIModule(); MethodInfo genericMethod = method.MakeGenericMethod(linkedModule.ModuleItemType); var allItems = Convert.ChangeType(genericMethod.Invoke(linkedModule, null), genericMethod.ReturnType) as IReadOnlyList <AtomicItem>; if (selectedIds != null && selectedIds.Count != 0) { allItems = allItems.Where(x => !selectedIds.Contains(x.Id)).ToList(); } selectorContent.ItemsSource = allItems; }
public void AddItemIntoDatabase() { StorageModule module = (StorageModule)storageTestManager.GetModule(typeof(TestClass)); module.UpdateDatabaseTable(); TestClass testItem = new TestClass { IntProp = 5, StringProp = "asd" }; module.AddItem(testItem); var item = module.GetItemById <TestClass>(1); Assert.AreEqual("asd", item.StringProp); }
public InternalModules(InternalAccessors accessors, InternalAdditionalLogics additionalLogics, LogicData data, IServerAPI api) { AchievementModule = AchievementModule.CreateClient(accessors.AchievementAccessor, additionalLogics.ScorersLogic, additionalLogics.DropLogic, accessors.FormulaController, additionalLogics.ImpactController); ActivationModule = ActivationModule.CreateClient(accessors.FormulaController, additionalLogics.ImpactController, accessors.ExplorerAccessor, accessors.ScorersAccessor, accessors.PlayerAccessor, accessors.UnitsAccessor, additionalLogics.ApplyChangeLogic); AutowinModule = AutowinModule.CreateClient(additionalLogics.ImpactController, accessors.ExplorerAccessor, accessors.ScorersAccessor, additionalLogics.FormulaLogic, additionalLogics.ExplorerLogic); BattleModule = BattleModule.CreateClient(accessors.BattleAccessor, accessors.ExplorerAccessor, accessors.UnitsAccessor, additionalLogics.ContextLogic, additionalLogics.ImpactController, additionalLogics.TriggerLogic, additionalLogics.BattleLogic, additionalLogics.BuffLogic); CheatModule = CheatModule.CreateClient(accessors.UnitsAccessor, accessors.ScorersAccessor, accessors.BattleAccessor, accessors.InventoryAccessor, accessors.PlayerAccessor, accessors.ExplorerAccessor, accessors.LogAccessor, accessors.SettingsAccessor, additionalLogics.ExplorerLogic, additionalLogics.BattleLogic, additionalLogics.ContextLogic, additionalLogics.ImpactController, additionalLogics.DropLogic, additionalLogics.ScorersLogic); CutSceneModule = CutSceneModule.CreateClient(accessors.CutSceneAccessor, additionalLogics.ImpactController, additionalLogics.ApplyChangeLogic); EquipmentModule = EquipmentModule.CreateClient(accessors.InventoryAccessor, accessors.ScorersAccessor, accessors.UnitsAccessor, additionalLogics.ImpactController, additionalLogics.FormulaLogic); ExplorerProgressModule = ExplorerProgressModule.CreateClient(accessors.ExplorerAccessor, accessors.InventoryAccessor, accessors.UnitsAccessor, accessors.SettingsAccessor, accessors.ScorersAccessor, accessors.BattleAccessor, additionalLogics.ExplorerLogic, additionalLogics.FormulaLogic, additionalLogics.ImpactController); GachaModule = GachaModule.CreateClient(additionalLogics.ImpactController, accessors.ScorersAccessor, accessors.InventoryAccessor, accessors.UnitsAccessor, accessors.ExplorerAccessor, additionalLogics.DropLogic, accessors.ConditionController, additionalLogics.FormulaLogic); SettingsModule = SettingsModule.CreateClient(accessors.SettingsAccessor, accessors.ScorersAccessor, additionalLogics.ImpactController); ShopModule = ShopModule.CreateClient(accessors.ScorersAccessor, accessors.ShopAccessor, additionalLogics.FormulaLogic, additionalLogics.ImpactController, additionalLogics.ShopLogic, additionalLogics.DropLogic); StartSessionModule = StartSessionModule.CreateClient(accessors.UnitsAccessor, accessors.ScorersAccessor, accessors.BattleAccessor, accessors.InventoryAccessor, accessors.PlayerAccessor, accessors.ExplorerAccessor, accessors.LogAccessor, accessors.SettingsAccessor, accessors.ShopAccessor, accessors.LogAccessor, accessors.AchievementAccessor, additionalLogics.BattleLogic, additionalLogics.ShopLogic, additionalLogics.ExplorerLogic, accessors.FormulaController, additionalLogics.ImpactController); StorageModule = StorageModule.CreateClient(accessors.ScorersAccessor, accessors.InventoryAccessor); UnitProgressModule = UnitProgressModule.CreateClient(accessors.UnitsAccessor, accessors.ScorersAccessor, accessors.BattleAccessor, additionalLogics.FormulaLogic, accessors.PlayerAccessor, additionalLogics.ImpactController); }
public static IStorageRegistry CreateDefaultJsonStorageRegistry(string path) { var storageRegistry = StorageModule.CreateDefaultStorageRegistry(); //Projects var projectStorage = new ProjectStorage(path + "/" + ProjectsPath + "/data.json"); projectStorage.Load(); storageRegistry.Register(projectStorage); //Todos var todoStorage = new TodoStorage(path + "/" + TodosPath + "/data.json"); todoStorage.Load(); storageRegistry.Register(todoStorage); return(storageRegistry); }
static void Main(string[] args) { ISettingsProvider settingsProvider = new SettingsProvider(); GameSettings settings = settingsProvider.Get(); IPhraseProvider phraseProvider = new JsonPhraseProvider(settings.language); InputOutputModule ioModule = new ConsoleIOModule(); IDoorsGenerater <List <ulong> > doorsGenerater = new RandomDoorGenetater(); IStorageModule <ulong, List <ulong> > storage = new StorageModule(); Game game = new Game( settings: settings, phraseProvider: phraseProvider, io: ioModule, doorsGenerater: doorsGenerater, storage: storage ); game.Start(); }
/** * Constructor. */ public JobFileIterator(StorageModule s, string filePath) : base(s) { lock (descriptorsLock) { FileStreamRegisteredCounter r; if (fileDescriptors.ContainsKey(filePath)) { fileDescriptors.TryGetValue(filePath, out r); fileStream = r.FileStream; r.Count++; } else { //fileStream = File.Open(filePath, FileMode.OpenOrCreate); fileStream = new FileStream(filePath, FileMode.Open, FileAccess.ReadWrite, System.IO.FileShare.Read); fileDescriptors.Add(filePath, new FileStreamRegisteredCounter(fileStream, 1)); } } this.filePath = filePath; offset = 0; }
static void RegisterAtomicStorage(FileStorageConfig cache, StorageModule c) { c.AtomicIsInFiles(cache.Folder.FullName, cb => { cb.CustomSerializer( JsonSerializer.SerializeToStream, JsonSerializer.DeserializeFromStream); cb.WhereEntityIs <IEntityBase>(); cb.FolderForEntity(t => "views/" + t.Name.ToLowerInvariant()); cb.FolderForSingleton("views"); cb.NameForSingleton(type => type.Name + ".txt"); cb.NameForEntity((type, o) => { var id = o as Identity; if (id != null) { return(id.Tag.ToString("000") + "-" + id.Id.ToString().ToLowerInvariant() + ".txt"); } return(o.ToString() + ".txt"); }); }); }
public JsonResult FormSubmit(string id, string orgId, string name, double lon, double lat) { var stg = new Storage { IsDel = (short)DeleteStatus.No, Lat = lat, Lon = lon, Name = name, OrgId = orgId }; var data = false; var module = new StorageModule(CurrentUser); if (string.IsNullOrWhiteSpace(id)) { data = module.Add(stg); } if (!string.IsNullOrWhiteSpace(id)) { stg.Id = id; data = module.Modify(stg, t => t.Id == id); } return(Json(new { code = 0, msg = "Ok", data = data }, "text/html")); }
/// <summary> /// Convert value to value showed in form /// </summary> /// <param name="prop">Info of property</param> /// <param name="value">Value to be converted</param> /// <returns>Converted value</returns> private static object ConvertValueToFormValue(PropertyInfo prop, object value) { var linkedTableAttribute = prop.GetCustomAttributes(true).ToList().FirstOrDefault(x => x.GetType() == typeof(LinkedTableAttribute)) as LinkedTableAttribute; if (prop.PropertyType == typeof(DateTime)) { var customization = prop.GetCustomAttributes(true).ToList().FirstOrDefault(x => x.GetType() == typeof(UIParamsAttribute)) as UIParamsAttribute; DateTime dateTimeValue = (DateTime)value; if (customization == null) { throw new Base.Exceptions.MissingRequiredAdditionalDataException("DateTime missing UIParams attribute."); } CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture; switch (customization.DateTimeMode) { case Base.Enum.DatePickerMode.Date: return(dateTimeValue.ToString("d", currentCulture)); case Base.Enum.DatePickerMode.Time: return(dateTimeValue.ToString("t", currentCulture)); case Base.Enum.DatePickerMode.DateAndTime: return(dateTimeValue.ToString("g", currentCulture)); default: throw new Base.Exceptions.UnsuccessfulConversionException("DateTime conversion was unsuccessful.\n" + $"Unsupported DateTIme mode: {customization.DateTimeMode.ToString()}"); } } else if (linkedTableAttribute != null) { switch (linkedTableAttribute.LinkedTableRelation) { case Base.Enum.LinkedTableRelation.One: var intValue = (int)value; if (intValue == -1) { return("-"); } MethodInfo method = typeof(StorageModule).GetMethod("GetItemById"); StorageModule linkedModule = ApplicationBase.Current.ModuleManager.GetModule(linkedTableAttribute.LinkedTableType) as StorageModule; MethodInfo genericMethod = method.MakeGenericMethod(linkedModule.ModuleItemType); var linkedTableItem = Convert.ChangeType(genericMethod.Invoke(linkedModule, new object[] { intValue }), genericMethod.ReturnType) as AtomicItem; return(linkedTableItem.ToString()); case Base.Enum.LinkedTableRelation.Many: var intValues = (List <int>)value; if (intValues == null || (intValues != null && intValues.Count == 0)) { return new List <string> { "-" } } ; method = typeof(StorageModule).GetMethod("GetItemById"); linkedModule = ApplicationBase.Current.ModuleManager.GetModule(linkedTableAttribute.LinkedTableType) as StorageModule; genericMethod = method.MakeGenericMethod(linkedModule.ModuleItemType); List <AtomicItem> selectedItems = new List <AtomicItem>(); foreach (var selectedItemValue in intValues) { var selectedLinkedTableItem = Convert.ChangeType(genericMethod.Invoke(linkedModule, new object[] { selectedItemValue }), genericMethod.ReturnType) as AtomicItem; selectedItems.Add(selectedLinkedTableItem); } return(selectedItems); default: throw new Base.Exceptions.NotSupportedException("Unsupported Linked table relation."); } } else { return(value); } }
public static void AtomicIsInAzure(this StorageModule self, IAzureStorageConfig storage) { AtomicIsInAzure(self, storage, builder => { }); }
public static void AtomicIsInAzure(this StorageModule self, IAzureStorageConfig storage, IAtomicStorageStrategy strategy) { self.AtomicIs(new AzureAtomicStorageFactory(strategy, storage)); }
public static void StreamingIsInAzure(this StorageModule self, IAzureStorageConfig storage) { self.StreamingIs(new BlobStreamingRoot(storage.CreateBlobClient())); }
public static ContainerBuilder AddMongoDb(this ContainerBuilder builder, bool seedDatabase, params Assembly[] assemblies) { builder.RegisterModule(StorageModule.For(assemblies, seedDatabase)); return(builder); }
/** * Constructor. */ protected FileIterator(StorageModule storage) { this.storage = storage; }
private static TechType RegisterModule(StorageModule storageModule) { storageModule.Patch(); Modules.Add(storageModule.TechType, storageModule); return(storageModule.TechType); }