/// <summary>
 /// A static utility method to find a child data object in the given object by the specified
 /// dot-delimited path to the child object.
 /// </summary>
 /// <param name="obj">The parent object to find the child object in.</param>
 /// <param name="childPath">A dot-delimited path to the child object.</param>
 /// <returns></returns>
 public static IDataObject FindChildObject(DataObject obj, string childPath)
 {
     if (string.IsNullOrEmpty(childPath) || obj == null) return obj;
     int idx = childPath.IndexOf(".");
     if (idx < 0) return obj.GetChildObject(childPath);
     DataObject child = obj.GetChildObject(childPath.Substring(0, idx)) as DataObject;
     return FindChildObject(child, childPath.Substring(idx + 1));
 }
Example #2
0
        /// <summary>
        /// A static utility method to find a child data object in the given object by the specified
        /// dot-delimited path to the child object.
        /// </summary>
        /// <param name="obj">The parent object to find the child object in.</param>
        /// <param name="childPath">A dot-delimited path to the child object.</param>
        /// <returns></returns>
        public static DataObject FindChildObject(DataObject obj, string childPath)
        {
            if (string.IsNullOrEmpty(childPath) || obj == null)
            {
                return(obj);
            }
            int idx = childPath.IndexOf(".");

            if (idx < 0)
            {
                return(obj.GetChildObject(childPath));
            }
            DataObject child = obj.GetChildObject(childPath.Substring(0, idx));

            return(FindChildObject(child, childPath.Substring(idx + 1)));
        }
Example #3
0
        /// <summary>
        /// Perform a deep copy of the state from another data object (presumably of the same type).
        /// </summary>
        /// <param name="obj">The object to copy the state from.</param>
        public virtual void CopyFrom(DataObject obj)
        {
            DataObject dObj = obj as DataObject;

            if (dObj == null)
            {
                return;
            }
            foreach (DataProperty p in properties.Values)
            {
                p.CopyFrom(dObj[p.Name]);
            }
            foreach (string chName in childObjects.Keys)
            {
                childObjects[chName].CopyFrom(dObj.GetChildObject(chName));
            }
        }