public virtual T CloneInstance <T>(T source) where T : class
        {
            T result = default(T);

            if (source == null)
            {
                // PrintError

                goto Cleanup;
            }

            try
            {
                CloneStream.SetLength(0);

                SharpSerializer.Serialize(source, CloneStream, true);

                CloneStream.Position = 0;

                result = SharpSerializer.Deserialize <T>(CloneStream, true);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                var igb = result as IGameBase;

                if (igb != null)
                {
                    igb.SetParentReferences();
                }
            }

Cleanup:

            return(result);
        }
        public virtual bool CompareInstances <T>(T object1, T object2) where T : class
        {
            var result = false;

            if (object1 == null || object2 == null)
            {
                // PrintError

                goto Cleanup;
            }

            byte[] object1Bytes = null;

            byte[] object2Bytes = null;

            CloneStream.SetLength(0);

            SharpSerializer.Serialize(object1, CloneStream, true);

            object1Bytes = CloneStream.ToArray();

            Debug.Assert(object1Bytes != null);

            CloneStream.SetLength(0);

            SharpSerializer.Serialize(object2, CloneStream, true);

            object2Bytes = CloneStream.ToArray();

            Debug.Assert(object2Bytes != null);

            result = object1Bytes.SequenceEqual(object2Bytes);

Cleanup:

            return(result);
        }