コード例 #1
0
ファイル: PersistenceMapper.cs プロジェクト: klod68/kpsf
        /// <summary>
        /// Store a new object in a persistent storage.
        /// </summary>
        /// <param name="oid"></param>
        /// <param name="appObject"></param>
        /// <returns></returns>
        public bool Put(ObjectIdentifier oid, Object appObject)
        {
            bool success = PutObjectInStorage(oid, appObject);
            IPersistable pObject = MakePersistable(appObject, oid);
            _cachedObjects.Add(oid, pObject);

            return success;
        }
コード例 #2
0
ファイル: PersistenceMapper.cs プロジェクト: klod68/kpsf
 /// <summary>
 /// Retrieve a persistent object from a storage.
 /// </summary>
 /// <param name="oid"></param>
 /// <returns></returns>
 public IPersistable Get(ObjectIdentifier oid)
 {
     IPersistable obj = _cachedObjects[oid];
     if (obj == null)
     {
         obj = GetObjectFromStorage(oid);
         _cachedObjects.Add(oid, obj);
     }
     return obj;
 }
コード例 #3
0
ファイル: PersistenceServer.cs プロジェクト: klod68/kpsf
 //retrieve with oid and custom command
 protected abstract PersistenceCommand MakeRetrieveCommand(Map map, ObjectIdentifier oid, Type type, string cmdType);
コード例 #4
0
 //used for Retrieve and delete with an OID and a well-known command type
 public SqlServerPersistenceCommand(Map map, ObjectIdentifier oid, SqlCommand command, CRUD cmdType)
     : base(map, oid, command, cmdType)
 {
 }
コード例 #5
0
ファイル: PersistenceServer.cs プロジェクト: klod68/kpsf
 //update and object with default command type (update)
 protected abstract PersistenceCommand MakeChangeCommand(Map map, ObjectIdentifier oid, object appObject);
コード例 #6
0
ファイル: PersistenceServer.cs プロジェクト: klod68/kpsf
 protected abstract PersistenceCommand MakeDeleteCommand(Map map, ObjectIdentifier oid, string cmdType);
コード例 #7
0
ファイル: PersistenceServer.cs プロジェクト: klod68/kpsf
        /// <summary>
        /// Custom command for destroying a persisent object using its identifier.
        /// </summary>
        /// <param name="objectId"></param>
        /// <param name="type"></param>
        /// <param name="cmdType"></param>
        /// <returns></returns>
        public bool Destroy(ObjectIdentifier oid, Type type, string cmdType)
        {
            try
            {
                GetMap(type);

                _cmd = MakeDeleteCommand(_map, oid, cmdType);
                if (_cmd == null)
                    throw new Exception(NO_CMD_MAP);

                return (bool)_cmd.Run();
            }
            catch (Exception ex)
            {

                throw new Exception(CANNOT_DESTROY, ex);
            }
        }
コード例 #8
0
ファイル: PersistenceServer.cs プロジェクト: klod68/kpsf
        //ok crr 2009.10.31
        /// <summary>
        ///Retrieve method for custom retrieve operations giving an OID. 
        /// </summary>
        /// <param name="objectId"></param>
        /// <param name="type"></param>
        /// <param name="cmdType"></param>
        /// <returns></returns>
        public IPersistable Retrieve(ObjectIdentifier objectId, Type type, string cmdType)
        {
            try
            {
                GetMap(type);

                _cmd = MakeRetrieveCommand(_map, objectId, type, cmdType);
                if (_cmd == null)
                    throw new Exception(NO_CMD_MAP);

                return (IPersistable)_cmd.Run();
            }
            catch (Exception ex)
            {

                throw new Exception(CANNOT_RETRIEVE, ex);
            }
        }
コード例 #9
0
ファイル: PersistenceCommand.cs プロジェクト: klod68/kpsf
 public abstract IPersistable MakePersistable(object persistableObj, ObjectIdentifier oid);
コード例 #10
0
ファイル: PersistenceServer.cs プロジェクト: klod68/kpsf
        /// <summary>
        /// Update a persistentObject using a particular Type for mapping.
        /// </summary>
        /// <param name="oid"></param>
        /// <param name="appObject"></param>
        /// <param name="mapType"></param>
        /// <returns></returns>
        public bool Change(ObjectIdentifier oid, object appObject, Type mapType)
        {
            try
            {
                GetMap(mapType);

                //make the specific command to execute an Update
                _cmd = MakeChangeCommand(_map, oid, appObject);
                if (_cmd == null)
                    throw new Exception(NO_CMD_MAP);

                //Command Pattern: A request is encapsulated in a class.
                //Subtypes will take into account the concurrency support
                return (bool)_cmd.Run();

            }
            catch (Exception ex)
            {

                throw new Exception(CANNOT_UPDATE, ex);
            }
        }
コード例 #11
0
ファイル: PersistenceMapper.cs プロジェクト: klod68/kpsf
 /// <summary>
 /// Destroy a persistent object in a storage.
 /// </summary>
 /// <param name="oid"></param>
 /// <returns></returns>
 public bool Destroy(ObjectIdentifier oid)
 {
     bool success = DestroyObjectInStorage(oid);
     _cachedObjects.Remove(oid);
     return success;
 }
コード例 #12
0
 //used for Retrieve and Delete with an OID, a custom command type and concurrency support
 public SqlServerPersistenceCommand(Map map, ObjectIdentifier oid, SqlCommand command, string cmdType, ConcurrencySupportType concurrency)
     : base(map, oid, command, cmdType, concurrency)
 {
 }
コード例 #13
0
ファイル: PersistenceMapper.cs プロジェクト: klod68/kpsf
 //create
 protected abstract bool PutObjectInStorage(ObjectIdentifier oid, Object appObject);
コード例 #14
0
ファイル: PersistenceMapper.cs プロジェクト: klod68/kpsf
 protected abstract IPersistable MakePersistable(object appObject, ObjectIdentifier oid);
コード例 #15
0
ファイル: PersistenceMapper.cs プロジェクト: klod68/kpsf
 //retrieve
 protected abstract IPersistable GetObjectFromStorage(ObjectIdentifier oid);
コード例 #16
0
ファイル: PersistenceMapper.cs プロジェクト: klod68/kpsf
 //delete
 protected abstract bool DestroyObjectInStorage(ObjectIdentifier oid);
コード例 #17
0
ファイル: PersistenceCommand.cs プロジェクト: klod68/kpsf
 //TEST
 /// <summary>
 /// PersistentCommand for new records with identifier.
 /// </summary>
 /// <param name="map"></param>
 /// <param name="oid"></param>
 /// <param name="objectForProcess"></param>
 /// <param name="providerCommand"></param>
 public PersistenceCommand(Map map, ObjectIdentifier oid,object objectForProcess, object providerCommand)
 {
     _providerCommand = providerCommand;
     _objectForProcess = objectForProcess;
     _pObj = MakePersistable(objectForProcess, oid);
     _cmdMap = map.GetCommandMap(CRUD.Create.ToString());
 }
コード例 #18
0
 public override IPersistable MakePersistable(object persistableObj, ObjectIdentifier oid)
 {
     return new PersistentObject(persistableObj, oid);
 }
コード例 #19
0
ファイル: PersistenceCommand.cs プロジェクト: klod68/kpsf
        /// <summary>
        /// PersistentObject for retrieve operations, custom command and concurrency support.
        /// </summary>
        /// <param name="map"></param>
        /// <param name="oid"></param>
        /// <param name="providerCommand"></param>
        /// <param name="cmdType"></param>
        /// <param name="concurrency"></param>
        public PersistenceCommand(Map map, ObjectIdentifier oid, object providerCommand, string cmdType, ConcurrencySupportType concurrency)
        {
            _providerCommand = providerCommand;
            _pObj = MakePersistable(null, oid);// Retrieve operations need only the OID
            _cmdMap = map.GetCommandMap(cmdType);   //must get the proper command instruction from the map

            SetConcurrencySupport(concurrency);
        }