public PropertyValue(SolidObject target, SolidProperty property) { this.solidProperty = property; this.target = target; this.target.PropertyChanging += Target_PropertyChanging; this.target.PropertyChanged += Target_PropertyChanged; this.hierarchy = this.target as IHierarchicalObject; }
/// <summary> /// Appends the object property /// </summary> /// <param name="root">Root node</param> /// <param name="isPriorityTree">Flag indicating if the tree is a priority tree</param> /// <param name="hc">Object</param> /// <param name="col">Property name</param> private void AddProperty(TreeNode root, bool isPriorityTree, IHierarchicalObject hc, string col) { // Add the property try { // Disable license error when macro evaluation tries to load objects that are not included in current license using (new CMSActionContext { EmptyDataForInvalidLicense = true }) { EvaluationResult result = ContextResolver.GetObjectValue(hc, col, new EvaluationContext(ContextResolver, "")); // Append the child value AppendChild(root, col, result.Result, false, isPriorityTree); } } catch (Exception ex) { EventLogProvider.LogException("MacroTree", "EXPAND", ex); // Append the exception as child value AppendChild(root, col, ex, false, isPriorityTree); } }
private void BindObject(object obj, TreeNode root) { int index = 0; if (obj is DataRow) { // DataRow source, bind column names DataRow dr = (DataRow)obj; // Create tree structure foreach (DataColumn col in dr.Table.Columns) { // Stop on max nodes if (index++ >= MacroResolver.MaxMacroNodes) { AppendMore(root); break; } // Add the column object childObj = dr[col.ColumnName]; AppendChild(root, col.ColumnName, childObj, false); } } else if (obj is DataRowView) { // DataRowView source, bind column names DataRowView dr = (DataRowView)obj; // Create tree structure foreach (DataColumn col in dr.DataView.Table.Columns) { // Stop on max nodes if (index++ >= MacroResolver.MaxMacroNodes) { AppendMore(root); break; } // Add the column object childObj = dr[col.ColumnName]; AppendChild(root, col.ColumnName, childObj, false); } } else if (obj is AbstractContext) { AbstractContext context = (AbstractContext)obj; // Create tree structure foreach (string col in context.Properties) { // Stop on max nodes if (index >= MacroResolver.MaxMacroNodes) { AppendMore(root); break; } // Add the property object childObj = context.GetProperty(col); AppendChild(root, col, childObj, false); } } else if (obj is IHierarchicalObject) { // Data container source IHierarchicalObject hc = (IHierarchicalObject)obj; // Create tree structure foreach (string col in hc.Properties) { // Stop on max nodes if (index++ >= MacroResolver.MaxMacroNodes) { AppendMore(root); break; } // Add the property object childObj = null; try { hc.TryGetProperty(col, out childObj); } catch { } AppendChild(root, col, childObj, false); } } else if (obj is IDataContainer) { // Data container source IDataContainer dc = (IDataContainer)obj; // Create tree structure foreach (string col in dc.ColumnNames) { // Stop on max nodes if (index++ >= MacroResolver.MaxMacroNodes) { AppendMore(root); break; } // Add the column object childObj = null; dc.TryGetValue(col, out childObj); AppendChild(root, col, childObj, false); } } // Enumerable objects if ((obj is IEnumerable) && !(obj is string)) { IEnumerable collection = (IEnumerable)obj; IEnumerator enumerator = null; bool indexByName = false; INamedEnumerable namedCol = null; if (obj is INamedEnumerable) { // Collection with name enumerator namedCol = (INamedEnumerable)collection; if (namedCol.ItemsHaveNames) { enumerator = namedCol.GetNamedEnumerator(); indexByName = true; } } if (!indexByName) { // Standard collection enumerator = collection.GetEnumerator(); } int i = 0; while (enumerator.MoveNext()) { // Stop on max nodes if (index++ >= MacroResolver.MaxMacroNodes) { AppendMore(root); break; } // Add the item object item = SqlHelperClass.EncapsulateObject(enumerator.Current); if (indexByName) { // Convert the name with dot to indexer string name = namedCol.GetObjectName(item); if (!ValidationHelper.IsIdentifier(name)) { name = "[\"" + name + "\"]"; } AppendChild(root, name, item, false); } else { // Indexed item AppendChild(root, i.ToString(), item, true); } i++; } } }
private void BindObject(object obj, TreeNode root, bool isPriorityTree) { int index = 0; try { if (obj is DataRow) { // DataRow source, bind column names DataRow dr = (DataRow)obj; // Create tree structure foreach (DataColumn col in dr.Table.Columns) { // Stop on max nodes if (index++ >= MacroResolver.MaxMacroNodes) { AppendMore(root); break; } // Add the column object childObj = dr[col.ColumnName]; AppendChild(root, col.ColumnName, childObj, false, isPriorityTree); } } else if (obj is DataRowView) { // DataRowView source, bind column names DataRowView dr = (DataRowView)obj; // Create tree structure foreach (DataColumn col in dr.DataView.Table.Columns) { // Stop on max nodes if (index++ >= MacroResolver.MaxMacroNodes) { AppendMore(root); break; } // Add the column object childObj = dr[col.ColumnName]; AppendChild(root, col.ColumnName, childObj, false, isPriorityTree); } } else if (obj is IHierarchicalObject) { // Data container source IHierarchicalObject hc = (IHierarchicalObject)obj; // Create tree structure foreach (string col in hc.Properties) { // Stop on max nodes if (index++ >= MacroResolver.MaxMacroNodes) { AppendMore(root); break; } // Add the property object childObj = null; try { ContextResolver.GetObjectValue(hc, col, ref childObj); // Append the child value AppendChild(root, col, childObj, false, isPriorityTree); } catch (Exception ex) { EventLogProvider.LogException("MacroTree", "EXPAND", ex); // Append the exception as child value AppendChild(root, col, ex, false, isPriorityTree); } } } else if (obj is IDataContainer) { // Data container source IDataContainer dc = (IDataContainer)obj; // Create tree structure foreach (string col in dc.ColumnNames) { // Stop on max nodes if (index++ >= MacroResolver.MaxMacroNodes) { AppendMore(root); break; } // Add the column object childObj = null; dc.TryGetValue(col, out childObj); AppendChild(root, col, childObj, false, isPriorityTree); } } // Enumerable objects if ((obj is IEnumerable) && !(obj is string)) { IEnumerable collection = (IEnumerable)obj; IEnumerator enumerator = null; bool indexByName = false; INamedEnumerable namedCol = null; if (obj is INamedEnumerable) { // Collection with name enumerator namedCol = (INamedEnumerable)collection; if (namedCol.ItemsHaveNames) { enumerator = namedCol.GetNamedEnumerator(); indexByName = true; } } if (!indexByName) { // Standard collection enumerator = collection.GetEnumerator(); } int i = 0; List <string> addedItems = new List <string>(); addedItems.Add("trees"); addedItems.Add("documents"); while (enumerator.MoveNext()) { // Stop on max nodes if (index++ >= MacroResolver.MaxMacroNodes) { AppendMore(root); break; } // Add the item object item = SqlHelperClass.EncapsulateObject(enumerator.Current); if (indexByName) { // Convert the name with dot to indexer string name = namedCol.GetObjectName(item); if (!ValidationHelper.IsIdentifier(name)) { name = "[\"" + name + "\"]"; } string nameToLower = name.ToLowerCSafe(); if (!addedItems.Contains(nameToLower)) { addedItems.Add(nameToLower); AppendChild(root, name, item, false, isPriorityTree); } } else { // Indexed item AppendChild(root, i.ToString(), item, true, isPriorityTree); } i++; } } } catch (Exception ex) { EventLogProvider.LogException("MacroTree", "EXPAND", ex); throw ex; } }
/// <summary> /// Fills given list with properties of given object. /// </summary> /// <param name="properties">List to fill</param> /// <param name="dataProperties">List of data properties</param> /// <param name="obj">Object the properties of which should be added to the list</param> private static void FillObjectProperties(List <string> properties, List <string> dataProperties, object obj) { if (obj != null) { if (obj is DataRow) { // DataRow source, bind column names DataRow dr = (DataRow)obj; foreach (DataColumn col in dr.Table.Columns) { properties.Add(col.ColumnName); } } else if (obj is DataRowView) { // DataRowView source, bind column names DataRowView dr = (DataRowView)obj; foreach (DataColumn col in dr.DataView.Table.Columns) { properties.Add(col.ColumnName); } } else if (obj is AbstractContext) { AbstractContext context = (AbstractContext)obj; properties.AddRange(context.Properties); } else if (obj is IHierarchicalObject) { // Data container source IHierarchicalObject hc = (IHierarchicalObject)obj; properties.AddRange(hc.Properties); } else if (obj is IDataContainer) { // Data container source IDataContainer dc = (IDataContainer)obj; properties.AddRange(dc.ColumnNames); } // Named enumerable objects if (obj is INamedEnumerable) { INamedEnumerable namedCol = (INamedEnumerable)obj; if (namedCol.ItemsHaveNames) { IEnumerator enumerator = namedCol.GetNamedEnumerator(); while (enumerator.MoveNext()) { // Named item string name = namedCol.GetObjectName(enumerator.Current); if (ValidationHelper.IsIdentifier(name)) { dataProperties.Add(name); } else { dataProperties.Add("[\"" + name + "\"]"); } } } } // Special case for TreeNode and PageInfo - append ediable parts if ((obj is CMS.TreeEngine.TreeNode) || (obj is PageInfo)) { EditableItems eItems = null; if (obj is CMS.TreeEngine.TreeNode) { // TreeNode editable fields CMS.TreeEngine.TreeNode node = (CMS.TreeEngine.TreeNode)obj; eItems = node.DocumentContent; } else { PageInfo pi = (PageInfo)obj; eItems = pi.EditableItems; } // Editable regions foreach (string item in eItems.EditableRegions.Keys) { properties.Add(item); } // Editable webparts foreach (string item in eItems.EditableWebParts.Keys) { properties.Add(item); } } } }
public ParentChangedEventArgs(IHierarchicalObject oldParent, IHierarchicalObject newParent) { this.NewParent = newParent; this.OldParent = oldParent; }