コード例 #1
0
ファイル: LocalCacheImpl.cs プロジェクト: tstivers/NCache
        /// <summary>
        /// Add ExpirationHint against the given key
        /// Key must already exists in the cache
        /// </summary>
        /// <param name="key"></param>
        /// <param name="eh"></param>
        /// <returns></returns>
        public override bool Add(object key, ExpirationHint eh, OperationContext operationContext)
        {
            bool result = false;

            if (Internal != null)
            {
                result = Internal.Add(key, eh, operationContext);
            }
            return(result);
        }
コード例 #2
0
ファイル: LocalCacheImpl.cs プロジェクト: tstivers/NCache
        /// <summary>
        /// Adds key and value pairs to the cache. Throws an exception or returns the
        /// list of keys that already exists in the cache.
        /// </summary>
        /// <param name="keys">key of the entry.</param>
        /// <param name="cacheEntries">the cache entry.</param>
        /// <returns>List of keys that are added or that alredy exists in the cache and their status</returns>
        public override Hashtable Add(object[] keys, CacheEntry[] cacheEntries, bool notify, OperationContext operationContext)
        {
            Hashtable table = new Hashtable();

            if (Internal != null)
            {
                table = Internal.Add(keys, cacheEntries, notify, operationContext);
            }
            return(table);
        }
コード例 #3
0
ファイル: LocalCacheImpl.cs プロジェクト: tstivers/NCache
        /// <summary>
        /// Adds a pair of key and value to the cache. Throws an exception or reports error
        /// if the specified key already exists in the cache.
        /// </summary>
        /// <param name="key">key of the entry.</param>
        /// <param name="cacheEntry">the cache entry.</param>
        /// <returns>returns the result of operation.</returns>
        public override CacheAddResult Add(object key, CacheEntry cacheEntry, bool notify, OperationContext operationContext)
        {
            CacheAddResult result = CacheAddResult.Failure;

            if (Internal != null)
            {
                result = Internal.Add(key, cacheEntry, notify, operationContext);
            }
            return(result);
        }
コード例 #4
0
ファイル: LongCounter.cs プロジェクト: Rain0Ash/NetExtender
        public Int64 Add(T item)
        {
            if (item is null)
            {
                throw new ArgumentNullException(nameof(item));
            }

            if (Internal.TryGetValue(item, out Int64 count))
            {
                Internal[item] = ++count;
                return(count);
            }

            Internal.Add(item, ++count);
            return(count);
        }
コード例 #5
0
ファイル: ItemSet.cs プロジェクト: keremer/inFizYon
        public virtual void Add(T item)
        {
            if (Model.IsTransactional && Model.CurrentTransaction == null)
            {
                throw new Exception("Operation out of transaction");
            }

            if (IsEntitySet && item != null && !ReferenceEquals(((IPersistEntity)item).Model, Model))
            {
                throw new XbimException("Cross model entity assignment");
            }

            //activate owning entity for write in case it is not active yet
            if (!OwningEntity.Activated)
            {
                Model.Activate(OwningEntity);
            }

            Action doAction = () =>
            {
                Internal.Add(item);
                NotifyCollectionChanged(NotifyCollectionChangedAction.Add, item);
                NotifyCountChanged();
            };


            if (!Model.IsTransactional)
            {
                doAction();
                return;
            }

            Action undoAction = () =>
            {
                Internal.Remove(item);
                NotifyCollectionChanged(NotifyCollectionChangedAction.Remove, item);
                NotifyCountChanged();
            };

            Model.CurrentTransaction.DoReversibleAction(doAction, undoAction, OwningEntity, ChangeType.Modified, Property);
        }
コード例 #6
0
ファイル: ItemSet.cs プロジェクト: keremer/inFizYon
        public virtual bool Remove(T item)
        {
            if (Model.IsTransactional && Model.CurrentTransaction == null)
            {
                throw new Exception("Operation out of transaction");
            }

            if (!OwningEntity.Activated)
            {
                Model.Activate(OwningEntity);
            }


            Action doAction = () =>
            {
                Internal.Remove(item);
                NotifyCollectionChanged(NotifyCollectionChangedAction.Remove, item);
                NotifyCountChanged();
            };
            Action undoAction = () =>
            {
                Internal.Add(item);
                NotifyCollectionChanged(NotifyCollectionChangedAction.Add, item);
                NotifyCountChanged();
            };

            if (!Model.IsTransactional)
            {
                doAction();
                return(true);
            }

            Model.CurrentTransaction.DoReversibleAction(doAction, undoAction, OwningEntity, ChangeType.Modified, Property);

            return(true);
        }
コード例 #7
0
ファイル: ItemSet.cs プロジェクト: keremer/inFizYon
 //this is to be only used internally to add object outside of any transaction or event firing
 //that is typically during parsing operation
 internal void InternalAdd(T value)
 {
     Internal.Add(value);
 }
コード例 #8
0
ファイル: TestThread.cs プロジェクト: zhonli/odata.net
		//Helpers
		public		virtual TestThread		Add(TestThread thread)
		{
			Internal.Add(thread);
			return thread;
		}