Ejemplo n.º 1
0
        internal static void InsertByIndex(CacheObject obj, Dictionary <String, Object> dic)
        {
            Type   t             = obj.GetType();
            String _typeFullName = t.FullName;

            IList list = FindAll(t);

            obj.Id = getNextId(list);
            int index = list.Add(obj);

            addIdIndex(_typeFullName, obj.Id, index);
            UpdateObjects(_typeFullName, list);

            foreach (KeyValuePair <String, Object> kv in dic)
            {
                makeIndexByInsert(obj, kv.Key, kv.Value);
            }

            if (isInMemory(t))
            {
                return;
            }

            Serialize(t);
        }
Ejemplo n.º 2
0
        private static void addNewValueMap(NameValueCollection valueCollection, CacheObject cacheObject, PropertyInfo p)
        {
            Attribute attr = rft.GetAttribute(p, typeof(NotSaveAttribute));

            if (attr != null)
            {
                return;
            }

            String propertyKey = getPropertyKey(cacheObject.GetType().FullName, p.Name);

            if (p.CanRead == false)
            {
                return;
            }
            Object pValue = rft.GetPropertyValue(cacheObject, p.Name);

            if (pValue == null || strUtil.IsNullOrEmpty(pValue.ToString()))
            {
                return;
            }

            valueCollection.Add(pValue.ToString(), cacheObject.Id.ToString());
            indexList[propertyKey] = valueCollection;
        }
Ejemplo n.º 3
0
 private static void makeIndexByInsert( CacheObject cacheObject, String propertyName, Object pValue ) {
     if (cacheObject == null || pValue == null) return;
     Type t = cacheObject.GetType();
     String propertyKey = getPropertyKey( t.FullName, propertyName );
     lock (objIndexLock) {
         NameValueCollection valueCollection = getValueCollection( propertyKey );
         valueCollection.Add( pValue.ToString(), cacheObject.Id.ToString() );
         indexList[propertyKey] = valueCollection;
     }
 }
Ejemplo n.º 4
0
        private static void makeIndexByUpdate(CacheObject cacheObject, String propertyName, Object pValue)
        {
            Type t = cacheObject.GetType();

            String propertyKey = getPropertyKey(t.FullName, propertyName);

            lock (objIndexLockUpdate) {
                NameValueCollection valueCollection = getValueCollection(propertyKey);
                deleteOldValueIdMap(valueCollection, cacheObject.Id);
                valueCollection.Add(pValue.ToString(), cacheObject.Id.ToString());
                indexList[propertyKey] = valueCollection;
            }
        }
Ejemplo n.º 5
0
        private static void makeIndexByDelete( CacheObject cacheObject ) {
            if (cacheObject == null) return;
            Type t = cacheObject.GetType();
            PropertyInfo[] properties = getProperties( t );
            foreach (PropertyInfo p in properties) {

                String propertyKey = getPropertyKey( t.FullName, p.Name );
                lock (objIndexLockDelete) {
                    NameValueCollection valueCollection = getValueCollection( propertyKey );
                    deleteOldValueIdMap( valueCollection, cacheObject.Id );
                }
            }
        }
Ejemplo n.º 6
0
        private static void makeIndexByInsert(CacheObject cacheObject)
        {
            Type t = cacheObject.GetType();

            PropertyInfo[] properties = getProperties(t);
            foreach (PropertyInfo p in properties)
            {
                String propertyKey = getPropertyKey(t.FullName, p.Name);
                lock (objIndexLockInsert) {
                    NameValueCollection valueCollection = getValueCollection(propertyKey);
                    addNewValueMap(valueCollection, cacheObject, p);
                }
            }
        }
Ejemplo n.º 7
0
        internal static Result Update( CacheObject obj ) {

            Type t = obj.GetType();

            makeIndexByUpdate( obj );

            if (isInMemory( t )) return new Result();

            try {
                Serialize( t );
                return new Result();
            }
            catch (Exception ex) {
                throw ex;
            }
        }
Ejemplo n.º 8
0
        internal static Result updateByIndex( CacheObject obj, Dictionary<String, Object> dic ) {

            Type t = obj.GetType();

            makeIndexByUpdate( obj );

            if (isInMemory( t )) return new Result();

            try {
                Serialize( t );
                return new Result();
            }
            catch (Exception ex) {
                throw ex;
            }
        }
Ejemplo n.º 9
0
        internal static void Delete( CacheObject obj ) {

            Type t = obj.GetType();
            String _typeFullName = t.FullName;

            makeIndexByDelete( obj );

            IList list = FindAll( t );
            list.Remove( obj );
            UpdateObjects( _typeFullName, list );

            deleteIdIndex( _typeFullName, obj.Id );

            if (isInMemory( t )) return;

            Serialize( t, list );
        }
Ejemplo n.º 10
0
        internal static void Delete( CacheObject obj )
        {
            Type t = obj.GetType();
            String _typeFullName = t.FullName;

            makeIndexByDelete( obj );

            IList list = FindAll( t );
            list.Remove( obj );
            UpdateObjects( _typeFullName, list );

            deleteIdIndex( _typeFullName, obj.Id );

            if (isInMemory( t )) return;

            Serialize( t, list );
        }
Ejemplo n.º 11
0
        internal static void InsertByIndex( CacheObject obj, String propertyName, Object pValue ) {

            Type t = obj.GetType();
            String _typeFullName = t.FullName;

            IList list = FindAll( t );
            obj.Id = getNextId( list );
            int index = list.Add( obj );

            addIdIndex( _typeFullName, obj.Id, index );
            UpdateObjects( _typeFullName, list );

            makeIndexByInsert( obj, propertyName, pValue );

            if (isInMemory( t )) return;

            Serialize( t );
        }
Ejemplo n.º 12
0
        private static void addNewValueMap( NameValueCollection valueCollection, CacheObject cacheObject, PropertyInfo p )
        {
            Attribute attr = rft.GetAttribute( p, typeof( NotSaveAttribute ) );
            if (attr != null) return;

            String propertyKey = getPropertyKey( cacheObject.GetType().FullName, p.Name );

            Object pValue = rft.GetPropertyValue( cacheObject, p.Name );
            if (pValue == null || strUtil.IsNullOrEmpty( pValue.ToString() )) return;

            valueCollection.Add( pValue.ToString(), cacheObject.Id.ToString() );
            indexList[propertyKey] = valueCollection;
        }
Ejemplo n.º 13
0
 private static void makeIndexByInsert( CacheObject cacheObject, String propertyName, Object pValue )
 {
     if (cacheObject == null || pValue == null) return;
     Type t = cacheObject.GetType();
     String propertyKey = getPropertyKey( t.FullName, propertyName );
     lock (objIndexLock) {
         NameValueCollection valueCollection = getValueCollection( propertyKey );
         valueCollection.Add( pValue.ToString(), cacheObject.Id.ToString() );
         indexList[propertyKey] = valueCollection;
     }
 }
Ejemplo n.º 14
0
        private static void makeIndexByUpdate( CacheObject cacheObject )
        {
            Type t = cacheObject.GetType();
            PropertyInfo[] properties = getProperties( t );
            foreach (PropertyInfo p in properties) {

                String propertyKey = getPropertyKey( t.FullName, p.Name );

                lock (objIndexLockUpdate) {
                    NameValueCollection valueCollection = getValueCollection( propertyKey );
                    deleteOldValueIdMap( valueCollection, cacheObject.Id );
                    addNewValueMap( valueCollection, cacheObject, p );
                }

            }
        }
Ejemplo n.º 15
0
        private static void makeIndexByUpdate( CacheObject cacheObject, String propertyName, Object pValue )
        {
            Type t = cacheObject.GetType();

            String propertyKey = getPropertyKey( t.FullName, propertyName );

            lock (objIndexLockUpdate) {

                NameValueCollection valueCollection = getValueCollection( propertyKey );
                deleteOldValueIdMap( valueCollection, cacheObject.Id );
                valueCollection.Add( pValue.ToString(), cacheObject.Id.ToString() );
                indexList[propertyKey] = valueCollection;

            }
        }
Ejemplo n.º 16
0
        private static void makeIndexByInsert( CacheObject cacheObject )
        {
            if (cacheObject == null) return;
            Type t = cacheObject.GetType();
            PropertyInfo[] properties = getProperties( t );
            foreach (PropertyInfo p in properties) {

                String propertyKey = getPropertyKey( t.FullName, p.Name );
                lock (objIndexLockInsert) {
                    NameValueCollection valueCollection = getValueCollection( propertyKey );
                    addNewValueMap( valueCollection, cacheObject, p );
                }
            }
        }
Ejemplo n.º 17
0
        internal static Result updateByIndex( CacheObject obj, Dictionary<String, Object> dic )
        {
            Type t = obj.GetType();

            makeIndexByUpdate( obj );

            if (isInMemory( t )) return new Result();

            try {
                Serialize( t );
                return new Result();
            }
            catch (Exception ex) {
                throw ex;
            }
        }
Ejemplo n.º 18
0
        internal static Result Update( CacheObject obj )
        {
            Type t = obj.GetType();

            makeIndexByUpdate( obj );

            if (isInMemory( t )) return new Result();

            try {
                Serialize( t );
                return new Result();
            }
            catch (Exception ex) {
                throw ex;
            }
        }
Ejemplo n.º 19
0
        internal static void InsertByIndex( CacheObject obj, Dictionary<String, Object> dic )
        {
            Type t = obj.GetType();
            String _typeFullName = t.FullName;

            IList list = FindAll( t );
            obj.Id = getNextId( list );
            int index = list.Add( obj );

            addIdIndex( _typeFullName, obj.Id, index );
            UpdateObjects( _typeFullName, list );

            foreach (KeyValuePair<String, Object> kv in dic) {
                makeIndexByInsert( obj, kv.Key, kv.Value );
            }

            if (isInMemory( t )) return;

            Serialize( t );
        }
Ejemplo n.º 20
0
        internal static void InsertByIndex( CacheObject obj, String propertyName, Object pValue )
        {
            Type t = obj.GetType();
            String _typeFullName = t.FullName;

            IList list = FindAll( t );
            obj.Id = getNextId( list );
            int index = list.Add( obj );

            addIdIndex( _typeFullName, obj.Id, index );
            UpdateObjects( _typeFullName, list );

            makeIndexByInsert( obj, propertyName, pValue );

            if (isInMemory( t )) return;

            Serialize( t );
        }