Exemple #1
0
 /// <summary>
 /// Performs real shallow object clone
 /// </summary>
 public static object CloneObject(object obj)
 {
     if (obj == null)
     {
         return(null);
     }
     if (obj is string)
     {
         return(obj);
     }
     return(_instance.DoCloneObject(obj));
 }
Exemple #2
0
        static ShallowObjectCloner()
        {
#if !NETCORE
            _unsafeInstance = GenerateUnsafeCloner();
            _instance       = _unsafeInstance;
            try
            {
                _instance.DoCloneObject(new object());
            }
            catch (Exception)
            {
                // switching to safe
                _instance = new ShallowSafeObjectCloner();
            }
#else
            _instance = new ShallowSafeObjectCloner();
            // no unsafe variant for core
            _unsafeInstance = _instance;
#endif
        }