private static string GetTsvForObject(TabularObject obj, string properties) { var props = properties.Split(','); var sb = new StringBuilder(); sb.Append(obj.GetObjectPath()); foreach (var prop in props) { sb.Append('\t'); var pInfo = obj.GetType().GetProperty(prop); if (pInfo != null) { var pValue = pInfo.GetValue(obj); if (pValue == null) { continue; } else if (pValue is TabularObject) { // Improve GetObjectPath to always provide unique path, and create corresponding method to resolve a path sb.Append((pValue as TabularObject).GetObjectPath()); } else { sb.Append(pValue.ToString().Replace("\n", "\\n").Replace("\t", "\\t")); } } } return(sb.ToString()); }
public UndoPropertyChangedAction(TabularObject tabularObject, string propertyName, object oldValue, object newValue, string index = null) { this.tabularObject = tabularObject; this.oldValue = oldValue; this.newValue = newValue; this.objectType = tabularObject.GetType(); this.prop = objectType.GetProperty(propertyName); this.index = index; this.ActionName = GetActionNameFromProperty(propertyName); }
private static void ShowTabularObject(TabularObject obj) { DormantForm.DataProperties.Visible = true; DormantForm.DataListView.Visible = false; DormantForm.DataListView.VirtualListSize = 0; DormantForm.DataSplitter.Visible = false; DormantForm.DataTextBox.Visible = false; DormantForm.DataTextBox.Text = ""; DormantForm.DataPropertyGrid.SelectedObject = obj; }
private static string GetTsvForObject(TabularObject obj, Property[] properties) { var sb = new StringBuilder(); sb.Append(obj.GetObjectPath()); foreach (var prop in properties) { sb.Append('\t'); var pInfo = obj.GetType().GetProperty(prop.Name); if (pInfo != null) { var pValue = pInfo.GetValue(obj); if (pValue == null) { continue; } else if (pValue is TabularObject) { // Improve GetObjectPath to always provide unique path, and create corresponding method to resolve a path sb.Append((pValue as TabularObject).GetObjectPath()); } else if (prop.IsIndexer && pValue is IExpandableIndexer indexer) { sb.Append(indexer.Keys.Contains(prop.Key) ? ToString(indexer[prop.Key]) : string.Empty); } else { sb.Append(ToString(pValue)); } } } return(sb.ToString()); string ToString(object value) { return(Convert.ToString(value).Replace("\n", "\\n").Replace("\r", "\\r").Replace("\t", "\\t")); } }
private static TabularObject ResolveObjectPath(string path) { var parts = path.Split('.'); var model = UI.UIController.Current.Handler?.Model; if (model == null) { return(null); } TabularObject obj = model; foreach (var part in parts) { if (part == "Model") { continue; } if (obj is Model) { obj = model.Tables[part]; continue; } if (obj is Table) { obj = (obj as Table).GetChildren().OfType <TabularNamedObject>().FirstOrDefault(c => c.Name == part); continue; } if (obj is Hierarchy) { obj = (obj as Hierarchy).Levels.FirstOrDefault(l => l.Name == part); continue; } obj = null; break; } return(obj); }
public static string GetObjectPath(this TabularObject obj) { return(TabularObjectHelper.GetObjectPath(obj)); }
public static TabularObject ResolveObjectPath(string path) { var parts = path.Split('.'); var partsFixed = new List <string>(); // Objects that have "." in their name, will be enclosed by square brackets. So let's traverse the array // and concatenate any parts between a set of square brackets: string partFraction = null; foreach (var p in parts) { if (partFraction == null) { if (p.StartsWith("[")) { partFraction = p.Substring(1); } else { partsFixed.Add(p); } } else { if (p.EndsWith("]")) { partFraction += "." + p.Substring(0, p.Length - 1); partsFixed.Add(partFraction); partFraction = null; } else { partFraction += "." + p; } } } parts = partsFixed.ToArray(); var model = UI.UIController.Current.Handler?.Model; if (model == null) { return(null); } TabularObject obj = model; foreach (var part in parts) { if (part == "Model") { continue; } if (obj is Model) { obj = model.Tables[part]; continue; } if (obj is Table) { obj = (obj as Table).GetChildren().OfType <TabularNamedObject>().FirstOrDefault(c => c.Name == part); continue; } if (obj is Hierarchy) { obj = (obj as Hierarchy).Levels.FirstOrDefault(l => l.Name == part); continue; } obj = null; break; } return(obj); }