private bool PredicateFunc(ITableItem tableItem) { if (this.Type != null && this.Type.IsAssignableFrom(tableItem.GetType()) == false) { return(false); } if (this.HasParent == true && tableItem.Parent == null) { return(false); } if (this.HasChilds == true && tableItem.Childs.Any() == false) { return(false); } if (this.IsLeaf == true && tableItem.Childs.Any() == true) { return(false); } if (this.TargetToMove != null && CanMove(this.TargetToMove, tableItem.Path) == false) { return(false); } if (this.ExcludedItems != null && this.ExcludedItems.Contains(tableItem) == true) { return(false); } if (this.Predicate != null && this.Predicate(tableItem) == false) { return(false); } return(true); }
private LogViewModel(Authentication authentication, ITableItem tableItem) { this.authentication = authentication; this.tableItem = tableItem; this.DisplayName = Resources.Title_ViewLog; this.previewCommand = new DelegateCommand((p) => this.Preview(), (p) => this.CanPreview); }
private void DrawLeftExpandedSettingsColumn(Rect canvas, [NotNull] ITableItem <TraitItem> trait) { (Rect addKarmaLabel, Rect addKarmaField) = new Rect(0f, 0f, canvas.width, RowLineHeight).Split(); UiHelper.Label(addKarmaLabel, _addKarmaTypeText); if (Widgets.ButtonText(addKarmaField, trait.Data.Data.KarmaType == null ? _defaultKarmaTypeText : trait.Data.Data.KarmaType.ToString())) { Find.WindowStack.Add( new FloatMenu(ToolkitUtils.Data.KarmaTypes.Values.Select(i => new FloatMenuOption(i.ToString(), () => trait.Data.Data.KarmaType = i)).ToList()) ); } if (trait.Data.Data.KarmaType != null && UiHelper.FieldButton(addKarmaLabel, Textures.Reset, _resetTraitKarmaTooltip)) { trait.Data.Data.KarmaType = null; } (Rect removeKarmaLabel, Rect removeKarmaField) = new Rect(0f, RowLineHeight, canvas.width, RowLineHeight).Split(); UiHelper.Label(removeKarmaLabel, _removeKarmaTypeText); if (Widgets.ButtonText( removeKarmaField, trait.Data.TraitData !.KarmaTypeForRemoving == null ? _defaultKarmaTypeText : trait.Data.TraitData.KarmaTypeForRemoving.ToString() )) { Find.WindowStack.Add( new FloatMenu(ToolkitUtils.Data.KarmaTypes.Values.Select(i => new FloatMenuOption(i.ToString(), () => trait.Data.TraitData.KarmaTypeForRemoving = i)).ToList()) ); } if (trait.Data.TraitData.KarmaTypeForRemoving != null && UiHelper.FieldButton(removeKarmaLabel, Textures.Reset, _resetTraitKarmaTooltip)) { trait.Data.TraitData.KarmaTypeForRemoving = null; } }
public LogInfoViewModel(Authentication authentication, ITableItem tableItem, LogInfo logInfo) { this.authentication = authentication; this.tableItem = tableItem; this.logInfo = logInfo; this.Target = tableItem; }
public static string GetAccessInfoPath(this ITableItem tableItem, string categoryPath) { var tableContext = GetTableContext(tableItem); var uriString = UriUtility.Combine(tableContext.BasePath, categoryPath.TrimStart(PathUtility.SeparatorChar) + tableItem.Name + extension); var uri = new Uri(uriString); return(uri.LocalPath); }
private void DrawRightExpandedSettingsColumn(Rect canvas, [NotNull] ITableItem <TraitItem> trait) { bool proxy = trait.Data.TraitData !.CanBypassLimit; if (UiHelper.LabeledPaintableCheckbox(new Rect(0f, 0f, canvas.width, RowLineHeight), _bypassLimitText, ref proxy)) { trait.Data.TraitData.CanBypassLimit = proxy; } }
private TableItemViewModel CreateNewTableItem(ITableItem expense) { TableItemViewModel result = new ViewModels.TableItemViewModel(expense); result.DoubleValue = expense.DoubleValue; result.ExpenseName = expense.Item.ToString(); result.StringValue = expense.StringValue; result.StringValues = expense.StringValues; return(result); }
public bool TryGetItem(string id, out ITableItem item) { var r = data.TryGetValue(id, out item); if (!r) { Debug.Log($"{id} is not in {typeof(T).Name}"); } return(r); }
public bool CreateItem(ITableItem currentGame) { if (currentGame is null) { return(false); } context.Games.Add((Game)currentGame); context.SaveChanges(); return(true); }
public void InvokeTableItemDelete(Authentication authentication, ITableItem tableItem) { if (tableItem.AccessInfo.Path == tableItem.Path) { var accessInfoPath = tableItem.GetAccessInfoPath(); if (File.Exists(accessInfoPath) == true) { this.repository.Delete(accessInfoPath); } } }
public void AddItem(string id, ITableItem item) { try { data.Add(id, item); } catch (Exception e) { Debug.Log(e.ToString()); } }
public void InvokeTableItemMove(Authentication authentication, ITableItem tableItem, string newCategoryPath) { if (tableItem.AccessInfo.Path == tableItem.Path) { var accessInfoPath1 = tableItem.GetAccessInfoPath(); var accessInfoPath2 = tableItem.GetAccessInfoPath(newCategoryPath); if (File.Exists(accessInfoPath1) == true) { this.repository.Move(accessInfoPath1, accessInfoPath2); } } }
public void InvokeTableItemRename(Authentication authentication, ITableItem tableItem, string newName) { if (tableItem.AccessInfo.Path == tableItem.Path) { var accessInfoPath1 = tableItem.GetAccessInfoPath(); var directoryName = Path.GetDirectoryName(accessInfoPath1); var extension = Path.GetExtension(accessInfoPath1); var accessInfoPath2 = Path.Combine(directoryName, newName + extension); if (File.Exists(accessInfoPath1) == true && accessInfoPath1 != accessInfoPath2) { this.repository.Move(accessInfoPath1, accessInfoPath2); } } }
private static TableContext GetTableContext(this ITableItem tableItem) { if (tableItem is Table table) { return(table.Context); } else if (tableItem is TableCategory category) { return(category.Context); } else { throw new NotImplementedException(); } }
public static void ClassInit(TestContext context) { app = new CremaBootstrapper(); app.Initialize(context, nameof(ITableItem_DispatcherTest)); cremaHost = app.GetService(typeof(ICremaHost)) as ICremaHost; cremaHost.Dispatcher.Invoke(() => { authentication = cremaHost.Start(); dataBase = cremaHost.DataBases.Random(); dataBase.Load(authentication); dataBase.Enter(authentication); dataBase.Initialize(authentication); tableItem = dataBase.TableContext.Random(); }); }
public static void WriteAccessInfo(this ITableItem tableItem, string accessInfoPath, AccessInfo accessInfo) { if (tableItem is Table table) { WriteAccessInfo(accessInfoPath, accessInfo); } else if (tableItem is TableCategory category) { WriteAccessInfo(accessInfoPath, accessInfo); } else { throw new NotImplementedException(); } }
public void setup() { // Creates Substitutes _db = Substitute.For <IDatabaseService>(); _tableItem = Substitute.For <ITableItem>(); _tableFloorplan = Substitute.For <ITableFloorplan>(); _tableItemGroup = Substitute.For <ITableItemGroup>(); _tablePlacement = Substitute.For <ITableItemSectionPlacement>(); _tableStoreSection = Substitute.For <ITableStoreSection>(); _searcher = Substitute.For <ISearcher>(); // Sets common empty returns _tablePlacement.FindPlacementsByItem(Arg.Any <long>()).Returns(new List <StoreSection>()); _tableItemGroup.GetItemGroup(Arg.Any <long>()).Returns(new ItemGroup("", 0, 0)); LoadBLL(); }
private static bool CanMove(ITableItem tableItem, string parentPath) { if (tableItem.Parent == null) { return(false); } if (tableItem.Parent.Path == parentPath) { return(false); } if (NameValidator.VerifyCategoryPath(parentPath) == false) { return(false); } return(parentPath.StartsWith(tableItem.Path) == false); }
public void InvokeTableItemRemoveAccessMember(Authentication authentication, ITableItem tableItem, AccessInfo accessInfo, string memberID) { this.CremaHost.DebugMethod(authentication, this, nameof(InvokeTableItemRemoveAccessMember), tableItem, memberID); var accessInfoPath = tableItem.GetAccessInfoPath(); try { accessInfo.Remove(authentication.SignatureDate, memberID); tableItem.WriteAccessInfo(accessInfoPath, accessInfo); } catch (Exception e) { this.CremaHost.Error(e); this.repository.Revert(); throw e; } }
private void DrawLeftExpandedSettingsColumn(Rect region, [NotNull] ITableItem <PawnKindItem> item) { (Rect karmaLabel, Rect karmaField) = new Rect(0f, 0f, region.width, RowLineHeight).Split(0.6f); UiHelper.Label(karmaLabel, _karmaTypeText); if (Widgets.ButtonText(karmaField, item.Data.Data.KarmaType == null ? _defaultKarmaTypeText : item.Data.Data.KarmaType.ToString())) { Find.WindowStack.Add( new FloatMenu(ToolkitUtils.Data.KarmaTypes.Values.Select(i => new FloatMenuOption(i.ToString(), () => item.Data.Data.KarmaType = i)).ToList()) ); } if (item.Data.Data.KarmaType != null && UiHelper.FieldButton(karmaLabel, Textures.Reset, _resetPawnKarmaTooltip)) { item.Data.Data.KarmaType = null; } }
public void InvokeTableItemSetPublic(Authentication authentication, ITableItem tableItem, AccessInfo accessInfo) { this.CremaHost.DebugMethod(authentication, this, nameof(InvokeTableItemSetPrivate), tableItem); var accessInfoPath = tableItem.GetAccessInfoPath(); try { accessInfo.SetPublic(); this.repository.Delete(accessInfoPath); } catch (Exception e) { this.CremaHost.Error(e); this.repository.Revert(); throw e; } }
public void InvokeTableItemSetPrivate(Authentication authentication, ITableItem tableItem, AccessInfo accessInfo) { this.CremaHost.DebugMethod(authentication, this, nameof(InvokeTableItemSetPrivate), tableItem); var accessInfoPath = tableItem.GetAccessInfoPath(); try { accessInfo.SetPrivate(tableItem.GetType().Name, authentication.SignatureDate); tableItem.WriteAccessInfo(accessInfoPath, accessInfo); this.repository.Add(accessInfoPath); } catch (Exception e) { this.CremaHost.Error(e); this.repository.Revert(); throw e; } }
public int Update(ITableItem item) { Hraci hrac = (Hraci)item; List <Hraci> hraci; List <Hraci> temp = DeserializeFromXml <List <Hraci> >(GetContentOfXML("hraci.xml")); hraci = temp ?? new List <Hraci>(); for (int i = 0; i < hraci.Count; i++) { if (hraci[i].hID == hrac.hID) { hraci.RemoveAt(i); } } hraci.Add(hrac); hraci = hraci.OrderBy(x => x.hID).ToList(); SerializeToXml(hraci, "hraci.xml"); return(0); }
public int Update(ITableItem item) { Trener tren = (Trener)item; List <Trener> treneri; List <Trener> temp = DeserializeFromXml <List <Trener> >(GetContentOfXML("trener.xml")); treneri = temp ?? new List <Trener>(); for (int i = 0; i < treneri.Count; i++) { if (treneri[i].ID_Trenera == tren.ID_Trenera) { treneri.RemoveAt(i); } } treneri.Add(tren); treneri = treneri.OrderBy(x => x.ID_Trenera).ToList(); SerializeToXml(treneri, "trener.xml"); return(0); }
public static void ReadAccessInfo(this ITableItem tableItem, string accessInfoPath) { if (tableItem is Table table) { if (ReadAccessInfo(accessInfoPath, out var accessInfo)) { table.SetAccessInfo(accessInfo); } } else if (tableItem is TableCategory category) { if (ReadAccessInfo(accessInfoPath, out var accessInfo)) { category.SetAccessInfo(accessInfo); } } else { throw new NotImplementedException(); } }
public int Insert(ITableItem item) { Trener tren = (Trener)item; List <Trener> treneri; List <Trener> temp = DeserializeFromXml <List <Trener> >(GetContentOfXML("trener.xml")); treneri = temp ?? new List <Trener>(); int id; if (treneri.Count > 0) { id = treneri.Last().ID_Trenera + 1; } else { id = 1; } tren.ID_Trenera = id; treneri.Add(tren); SerializeToXml(treneri, "hraci.xml"); return(0); }
public int Insert(ITableItem item) { Hraci hrac = (Hraci)item; List <Hraci> hraci; List <Hraci> temp = DeserializeFromXml <List <Hraci> >(GetContentOfXML("hraci.xml")); hraci = temp ?? new List <Hraci>(); int id; if (hraci.Count > 0) { id = hraci.Last().hID + 1; } else { id = 1; } hrac.hID = id; hraci.Add(hrac); SerializeToXml(hraci, "hraci.xml"); return(0); }
public int Insert(ITableItem item) { return(TableData.NonQuerry(SqlInsert, item.GetArgs())); }
public int Delete(ITableItem item) { return(TableData.NonQuerry(SqlDelete, item.GetArgs())); }
private static bool DefaultPredicate(ITableItem _) => true;
public bool Equals(ITableItem other) { return Id == other.Id; }