private IPersistenceStore GetStore(IScope scope, bool persistent) { IPersistenceStore store = null; if (!persistent) { // Use special store for non-persistent shared objects if (!scope.HasAttribute(SO_TRANSIENT_STORE)) { store = new MemoryStore(scope); scope.SetAttribute(SO_TRANSIENT_STORE, store); return(store); } return(scope.GetAttribute(SO_TRANSIENT_STORE) as IPersistenceStore); } // Evaluate configuration for persistent shared objects if (!scope.HasAttribute(SO_PERSISTENCE_STORE)) { try { Type type = ObjectFactory.Locate(_configuration.PersistenceStore.Type); store = Activator.CreateInstance(type, new object[] { scope }) as IPersistenceStore; if (_log.IsInfoEnabled) { _log.Info(__Res.GetString(__Res.SharedObjectService_CreateStore, store)); } } catch (Exception exception) { if (_log.IsErrorEnabled) { _log.Error(__Res.GetString(__Res.SharedObjectService_CreateStoreError), exception); } store = new MemoryStore(scope); } scope.SetAttribute(SO_PERSISTENCE_STORE, store); return(store); } return(scope.GetAttribute(SO_PERSISTENCE_STORE) as IPersistenceStore); }
private IPersistenceStore GetStore(IScope scope, bool persistent) { IPersistenceStore store = null; if (!persistent) { if (!scope.HasAttribute(SO_TRANSIENT_STORE)) { store = new MemoryStore(scope); scope.SetAttribute(SO_TRANSIENT_STORE, store); return(store); } return(scope.GetAttribute(SO_TRANSIENT_STORE) as IPersistenceStore); } if (!scope.HasAttribute(SO_PERSISTENCE_STORE)) { try { store = Activator.CreateInstance(ObjectFactory.Locate(this._configuration.PersistenceStore.Type), new object[] { scope }) as IPersistenceStore; if (this._log.get_IsInfoEnabled()) { this._log.Info(__Res.GetString("SharedObjectService_CreateStore", new object[] { store })); } } catch (Exception exception) { if (this._log.get_IsErrorEnabled()) { this._log.Error(__Res.GetString("SharedObjectService_CreateStoreError"), exception); } store = new MemoryStore(scope); } scope.SetAttribute(SO_PERSISTENCE_STORE, store); return(store); } return(scope.GetAttribute(SO_PERSISTENCE_STORE) as IPersistenceStore); }
private IPersistenceStore GetStore(IScope scope, bool persistent) { IPersistenceStore store = null; if(!persistent) { // Use special store for non-persistent shared objects if(!scope.HasAttribute(SO_TRANSIENT_STORE)) { store = new MemoryStore(scope); scope.SetAttribute(SO_TRANSIENT_STORE, store); return store; } return scope.GetAttribute(SO_TRANSIENT_STORE) as IPersistenceStore; } // Evaluate configuration for persistent shared objects if(!scope.HasAttribute(SO_PERSISTENCE_STORE)) { try { Type type = ObjectFactory.Locate(_configuration.PersistenceStore.Type); store = Activator.CreateInstance(type, new object[]{scope}) as IPersistenceStore; if( _log.IsInfoEnabled ) _log.Info(__Res.GetString(__Res.SharedObjectService_CreateStore, store)); } catch(Exception exception) { if( _log.IsErrorEnabled ) _log.Error(__Res.GetString(__Res.SharedObjectService_CreateStoreError), exception); store = new MemoryStore(scope); } scope.SetAttribute(SO_PERSISTENCE_STORE, store); return store; } return scope.GetAttribute(SO_PERSISTENCE_STORE) as IPersistenceStore; }
/// <summary> /// Sets an attribute on this object. /// </summary> /// <param name="name">The attribute name.</param> /// <param name="value">The attribute value.</param> /// <returns>true if the attribute value changed otherwise false</returns> public bool SetAttribute(string name, object value) { return(_scope.SetAttribute(name, value)); }