Ejemplo n.º 1
0
        /// <summary>
        /// Gets a deep copy of a specified object and copies referenced files
        /// Deep copying copies all primitive and enumeration properties and the properties for which MetaInfo "ObjectCopy" is set to true
        /// </summary>
        /// <param name="source">The object to be copied</param>
        /// <param name="path">The path in which copied files will be positioned (relative to original position)</param>
        /// <returns>The copied object</returns>
        public static object GetCopy(object source, string path)
        {
            if (source == null)
            {
                return(null);
            }

            if (source is FileSystemInfo)
            {
                if ((path != null) && (!path.Trim().Equals("")))
                {
                    return(CopyFile((FileSystemInfo)source, path));
                }
                else
                {
                    return(ObjectSupport.GetInstance(source.GetType(), source.ToString()));
                }
            }

            object copy = ObjectSupport.GetInstance(source.GetType(), source.ToString());

            if (copy != null)
            {
                ObjectSupport.Copy(source, copy, path);
            }

            return(copy);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets a deep copy of a specified object.
        /// Deep copying copies all primitive and enumeration properties and the properties for which MetaInfo "ObjectCopy" is set to true
        /// </summary>
        /// <param name="source">The object to be copied</param>
        /// <returns>The copied object</returns>
        public static object GetCopy(object source)
        {
            object copy = ObjectSupport.GetInstance(source.GetType());

            if (copy != null)
            {
                ObjectSupport.Copy(source, copy);
            }

            return(copy);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Creates an object which is a deep copy fo a source object, including copying of referenced file
 /// Deep copying copies all primitive and enumeration properties and the properties for which MetaInfo "ObjectCopy" is set to true
 /// </summary>
 /// <param name="source">The object to be copied</param>
 /// <param name="copiedObjects">Lookup table for already copied objects</param>
 /// <param name="path">Path where files are copied to</param>
 /// <returns></returns>
 private static object GetCopy(object source, Hashtable copiedObjects, string path)
 {
     if (copiedObjects[source] != null)
     {
         return(copiedObjects[source]);
     }
     else if (source is FileSystemInfo)
     {
         object copiedFile = CopyFile((FileSystemInfo)source, path);
         copiedObjects.Add(source, copiedFile);
         return(copiedFile);
     }
     else
     {
         object copy = ObjectSupport.GetInstance(source.GetType());
         if (copy != null)
         {
             copiedObjects.Add(source, copy);
             ObjectSupport.Copy(source, copy, copiedObjects, path);
         }
         return(copy);
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Creates a new object using a base value (e.g. a string with its value).
 /// Normally primitives, enumerations and some value types can be instantiated this way.
 /// Also types with constructors having one argument can be instantiated.
 /// </summary>
 /// <param name="type">Class type of the object to be instantiated</param>
 /// <param name="baseValue">Value which is passed as argument to the constructor</param>
 /// <returns>New object, null if not possible</returns>
 public static object GetInstance(Type type, object baseValue)
 {
     return(ObjectSupport.GetInstance(type, baseValue, null));
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Creates a new object using a base value (e.g. a string with its value).
 /// Normally primitives, enumerations and some value types can be instantiated this way.
 /// Also types with constructors having one argument can be instantiated.
 /// </summary>
 /// <param name="classType">Full class name of the object to be instantiated</param>
 /// <param name="baseValue">Value which is passed as argument to the constructor</param>
 /// <returns>New object, null if not possible</returns>
 public static object GetInstance(string classType, object baseValue)
 {
     return(ObjectSupport.GetInstance(ObjectSupport.GetType(classType), baseValue, null));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Creates a new object.
 /// Types with an argumentless constructor can be created this way
 /// </summary>
 /// <param name="classType">Full class name of the object to be instantiated</param>
 /// <returns>New object, null if not possible</returns>
 public static object GetInstance(string classType)
 {
     return(ObjectSupport.GetInstance(ObjectSupport.GetType(classType)));
 }