示例#1
0
        /// <summary>
        /// Creates a new object that is a copy of the current instance.
        /// </summary>
        /// <returns>
        /// A new object that is a copy of this instance.
        /// </returns>
        public object Clone()
        {
            var clonedContext = new DynamicContext();

            foreach (var value in _dynamicContext)
            {
                clonedContext._dynamicContext.Add(value.Key, value.Value);
            }

            return(clonedContext);
        }
示例#2
0
 /// <summary>
 /// Saves the specified object.
 /// </summary>
 /// <typeparam name="T">The type of class this object is saved on. Used to derive a filename.</typeparam>
 /// <param name="objectToSave">The object to save.</param>
 public static void Save <T>(DynamicContext objectToSave)
 {
     Task.Run(() =>
     {
         var type = GetSerializationName(typeof(T));
         using (var file = File.Create(type))
         {
             var formatter = new BinaryFormatter();
             formatter.Serialize(file, objectToSave);
         }
     });
 }