コード例 #1
0
ファイル: MainApp.cs プロジェクト: lebkovy/DesignPatterns
        static void Main(string[] args)
        {
            PersistenceImplementor implementor = null;

            if (databaseDriverExists())
            {
                implementor = new DabatasePersistenceImplementor();
            }
            else
            {
                implementor = new FileSystemPersistenceImplementor();
            }

            Persistence persistenceAPI = new PersistenceImp(implementor);
            Object      o = persistenceAPI.findById("12343755");

            // do changes to the object
            // then persist
            persistenceAPI.persist(o);
            // can also change implementor
            persistenceAPI = new PersistenceImp(new DabatasePersistenceImplementor());
            persistenceAPI.deleteById("2323");
        }
コード例 #2
0
 public PersistenceImp(PersistenceImplementor imp)
 {
     this.implementor = imp;
 }