Exemplo n.º 1
0
        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);
 }
Exemplo n.º 3
0
        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"));
            }
        }