internal void AddSurrogateReference(StateObjectSurrogate surrogate, IStateObject reference)
 {
     lock (surrogate)
     {
         surrogate.AddReference(new LazyStateObjectReference(_stateManager, reference));
     }
 }
 internal void AddSurrogateReference(StateObjectSurrogate surrogate, string uniqueId)
 {
     lock (surrogate)
     {
         surrogate.AddReference(new LazyStateObjectReference(_stateManager, uniqueId));
     }
 }
 /// <summary>
 /// Registers which pointers are using this surrogate.
 /// This is important because a surrogate with no references should be deleted
 /// </summary>
 /// <param name="surrogate"></param>
 /// <param name="pointer"></param>
 /// <param name="isNewPointer"></param>
 internal void AddSurrogateReference(StateObjectSurrogate surrogate, StateObjectPointer pointer, bool isNewPointer = true)
 {
     //Check if reference already exits
     lock (surrogate)
     {
         surrogate.AddReference(new LazyStateObjectReference(_stateManager, pointer));
     }
     //RegisterSurrogatedObject(surrogate, pointer.UniqueID);
     pointer.Target = surrogate;
     if (isNewPointer)
     {
         _stateManager.AddNewObject(pointer);
     }
     else if (StateManager.AllBranchesAttached(pointer))
     {
         _stateManager.StorageManager.SaveObject(pointer);
     }
     _stateManager.UndoRemove(pointer.UniqueID);
 }