Пример #1
0
        private void WriteObject( BaseEntity entity )
        {
            string filePath = this.GetFilePath( entity.EntityKey );

            try
            {
                using ( FileStream file = File.Create( filePath ) )
                {
                    formatter.Serialize( file, entity );
                }
            }
            catch
            {
                File.Delete( filePath );
                throw;
            }
        }
Пример #2
0
        public void Update( BaseEntity entity )
        {
            if ( entity == null )
                throw new ArgumentNullException( "entity" );
            if ( entity.EntityKey.IsNull )
                throw new ArgumentException( "Cannot update an entity that has no identifier.", "entity" );

            entity.Validate();

            this.Enlist();

            BaseEntity entityClone = entity.Clone();
            this.InternalSet( entityClone );

            if ( this.redoLog != null )
            {
                this.redoLog.Add( new StorageOperation( StorageOperationKind.Update, entityClone ) );
            }
        }
Пример #3
0
        public EntityKey Insert( BaseEntity entity )
        {
            if ( entity == null )
                throw new ArgumentNullException( "entity" );
            if ( !entity.EntityKey.IsNull )
                throw new ArgumentException( "Cannot insert an entity that has an identifier.", "entity" );

            entity.Validate();

            this.Enlist();

            entity.EntityKey = Storage.MakeEntityKey();
            BaseEntity entityClone = entity.Clone();

            this.InternalSet( entityClone );

            if ( this.redoLog != null )
            {
                this.redoLog.Add( new StorageOperation( StorageOperationKind.Insert, entityClone ) );
            }


            return entity.EntityKey;
        }
Пример #4
0
 /// <summary>
 /// Copy, into another object of the same type as the current one,
 /// all cloneable members.
 /// </summary>
 /// <param name="clone">Target objects.</param>
 /// <remarks>
 /// This method is implemented automatically at post-compile time
 /// in derived classes.
 /// </remarks>
 protected virtual void CopyTo( BaseEntity clone )
 {
 }