/// <summary> /// Process the given entry. /// </summary> /// <param name="entry"> /// The <b>IInvocableCacheEntry</b> to process. /// </param> /// <param name="valueNew"> /// The new value to update an entry with. /// </param> /// <param name="insert"> /// Specifies whether or not an insert is allowed. /// </param> /// <param name="ret"> /// Specifies whether or not a return value is required. /// </param> /// <returns> /// The result of the processing, if any. /// </returns> protected object processEntry(IInvocableCacheEntry entry, IVersionable valueNew, bool insert, bool ret) { bool match; IVersionable valueCur = (IVersionable)entry.Value; if (valueCur == null) { match = insert; } else { IComparable verCur = valueCur.VersionIndicator; IComparable verNew = valueNew.VersionIndicator; match = (verCur.CompareTo(verNew) == 0); } if (match) { valueNew.IncrementVersion(); entry.SetValue(valueNew, false); return(NO_RESULT); } return(ret ? valueCur : NO_RESULT); }
/// <summary> /// Process an Remove entry processor. /// </summary> /// <param name="entry"> /// The <b>IInvocableCacheEntry</b> to process. /// </param> /// <returns> /// The value removed. /// </returns> public override Object Process(IInvocableCacheEntry entry) { Object value = entry.Value; entry.Remove(false); return(value); }
/// <summary> /// Process an Replace entry processor. /// </summary> /// <param name="entry"> /// The <b>IInvocableCacheEntry</b> to process. /// </param> /// <returns> /// The result of the processing. /// </returns> public override object Process(IInvocableCacheEntry entry) { object oldValue = entry.Value; entry.Value = m_value; return(oldValue); }
/// <see cref="AbstractProcessor"/> public override object Process(IInvocableCacheEntry entry) { Contact contact = (Contact)entry.Value; contact.WorkAddress = m_addrWork; entry.SetValue(contact, false); return(null); }
/// <summary> /// Process an <see cref="IInvocableCacheEntry"/>. /// </summary> /// <param name="entry"> /// The <b>IInvocableCacheEntry</b> to process. /// </param> /// <returns> /// The result of the processing, if any. /// </returns> public override object Process(IInvocableCacheEntry entry) { if (InvocableCacheHelper.EvaluateEntry(m_filter, entry)) { return(m_processor.Process(entry)); } return(null); }
/// <summary> /// Process an <see cref="IInvocableCacheEntry"/>. /// </summary> /// <param name="entry"> /// The <b>IInvocableCacheEntry</b> to process. /// </param> /// <returns> /// The result of the processing, if any. /// </returns> public override object Process(IInvocableCacheEntry entry) { if (!entry.IsPresent) { object o = entry.Value; } return(null); }
/// <summary> /// Process an InsertIfAbsent entry processor. /// </summary> /// <param name="entry"> /// The <b>IInvocableCacheEntry</b> to process. /// </param> /// <returns> /// If value is present, return the value; otherwise, return null. /// </returns> public override object Process(IInvocableCacheEntry entry) { if (entry.IsPresent && entry.Value != null) { return(entry.Value); } entry.SetValue(m_value, false); return(null); }
/// <summary> /// Process an <see cref="IInvocableCacheEntry"/>. /// </summary> /// <param name="entry"> /// The <b>IInvocableCacheEntry</b> to process. /// </param> /// <returns> /// The result of the processing, if any. /// </returns> public override object Process(IInvocableCacheEntry entry) { if (entry.IsPresent && InvocableCacheHelper.EvaluateEntry(m_filter, entry)) { entry.Remove(false); return(null); } return(m_return ? entry.Value : null); }
/// <summary> /// Process an <see cref="IInvocableCacheEntry"/>. /// </summary> /// <param name="entry"> /// The <b>IInvocableCacheEntry</b> to process. /// </param> /// <returns> /// The result of the processing, if any. /// </returns> public override object Process(IInvocableCacheEntry entry) { if (InvocableCacheHelper.EvaluateEntry(m_filter, entry)) { entry.SetValue(m_value, false); return(null); } return(m_return ? entry.Value : null); }
/// <summary> /// Process an <see cref="IInvocableCacheEntry"/>. /// </summary> /// <param name="entry"> /// The <b>IInvocableCacheEntry</b> to process. /// </param> /// <returns> /// The result of the processing, if any. /// </returns> public override object Process(IInvocableCacheEntry entry) { IDictionary dictionary = m_dictionary; object key = entry.Key; if (dictionary.Contains(key) && InvocableCacheHelper.EvaluateEntry(m_filter, entry)) { entry.SetValue(dictionary[key], false); } return(null); }
/// <summary> /// Process an <see cref="IInvocableCacheEntry"/>. /// </summary> /// <param name="entry"> /// The <b>IInvocableCacheEntry</b> to process. /// </param> /// <returns> /// The result of the processing, if any. /// </returns> public override object Process(IInvocableCacheEntry entry) { IEntryProcessor[] processors = m_processors; int count = processors.Length; object[] result = new object[count]; for (int i = 0; i < count; i++) { result[i] = processors[i].Process(entry); } return(result); }
/// <summary> /// Process an <b>ReplaceValue</b> entry processor. /// </summary> /// <param name="entry"> /// The <b>IInvocableCacheEntry</b> to process. /// </param> /// <returns> /// The result of the processing: true, if the entry is found and /// value is replaced; false, otherwise. /// </returns> public override object Process(IInvocableCacheEntry entry) { if (entry.IsPresent) { object valueCurrent = entry.Value; if (Equals(valueCurrent, m_oldValue)) { entry.Value = m_newValue; return(true); } } return(false); }
/// <summary> /// Set the property value into the passed entry object. /// </summary> /// <param name="entry"> /// The entry object. /// </param> /// <param name="value"> /// A new property value. /// </param> /// <seealso cref="IValueUpdater.Update"/> protected virtual void Set(IInvocableCacheEntry entry, object value) { IValueManipulator manipulator = m_manipulator; if (m_manipulator != null) { IValueUpdater updater = manipulator.Updater; if (updater != null) { entry.Update(updater, value); return; } } entry.SetValue(value, false); }
/// <summary> /// Invoke the passed <see cref="IEntryProcessor"/> against the /// specified <see cref="IInvocableCacheEntry"/>. /// </summary> /// <remarks> /// The invocation is made thread safe by locking the corresponding key /// on the cache. /// </remarks> /// <param name="cache"> /// The <see cref="IConcurrentCache"/> that the /// <b>IEntryProcessor</b> works against. /// </param> /// <param name="entry"> /// The <b>IInvocableCacheEntry</b> to process; it is not required to /// exist within the cache. /// </param> /// <param name="agent"> /// The <b>IEntryProcessor</b> to use to process the specified key. /// </param> /// <returns> /// The result of the invocation as returned from the /// <b>IEntryProcessor</b>. /// </returns> public static object InvokeLocked(IConcurrentCache cache, IInvocableCacheEntry entry, IEntryProcessor agent) { var key = entry.Key; cache.Lock(key, -1); try { return(agent.Process(entry)); } finally { cache.Unlock(key); } }
/// <summary> /// Process an <see cref="IInvocableCacheEntry"/>. /// </summary> /// <param name="entry"> /// The <b>IInvocableCacheEntry</b> to process. /// </param> /// <returns> /// The result of the processing, if any. /// </returns> public override object Process(IInvocableCacheEntry entry) { IValueUpdater updater = m_updater; if (updater == null) { entry.SetValue(m_value, true); } else if (entry.IsPresent) { object target = entry.Value; updater.Update(target, m_value); entry.SetValue(target, true); } return(true); }
/// <summary> /// Get the property value from the passed entry object. /// </summary> /// <param name="entry"> /// The Entry object. /// </param> /// <returns> /// The property value. /// </returns> /// <seealso cref="IValueExtractor.Extract"/> protected virtual object Get(IInvocableCacheEntry entry) { IValueManipulator manipulator = m_manipulator; if (manipulator != null) { IValueExtractor extractor = manipulator.Extractor; if (extractor == null) { throw new InvalidOperationException("The IValueManipulator (" + manipulator + ") failed to provide an IValueExtractor"); } else { return(entry.Extract(extractor)); } } return(entry.Value); }
/// <summary> /// Process an <see cref="IInvocableCacheEntry"/>. /// </summary> /// <param name="entry"> /// The <b>IInvocableCacheEntry</b> to process. /// </param> /// <returns> /// The result of the processing, if any. /// </returns> public override object Process(IInvocableCacheEntry entry) { if (!entry.IsPresent) { return(null); } object numFactor = m_numFactor; object numOld = Get(entry); if (numOld == null) { if (NumberUtils.IsNumber(numFactor)) { numOld = 0; } } object numNew; if (numOld is Int32) { Int32 i_32 = (Int32)numOld; if (numFactor is Double || numFactor is Single) { i_32 = (Int32)(i_32 * (Double)numFactor); } else { i_32 *= Convert.ToInt32(numFactor); } numNew = i_32; } else if (numOld is Int64) { Int64 i_64 = (Int64)numOld; if (numFactor is Double || numFactor is Single) { i_64 = (Int64)(i_64 * (Double)numFactor); } else { i_64 *= Convert.ToInt64(numFactor); } numNew = i_64; } else if (numOld is Double) { numNew = Convert.ToDouble(numOld) * Convert.ToDouble(numFactor); } else if (numOld is Single) { numNew = Convert.ToSingle(numOld) * Convert.ToSingle(numFactor); } else if (numOld is Decimal) { numNew = Decimal.Multiply((Decimal)numOld, Convert.ToDecimal(numFactor)); } else if (numOld is Int16) { Int16 i_16 = (Int16)numOld; if (numFactor is Double || numFactor is Single) { i_16 = (Int16)(i_16 * (Double)numFactor); } else { i_16 *= Convert.ToInt16(numFactor); } numNew = i_16; } else if (numOld is Byte) { byte b = (Byte)numOld; if (numFactor is Double || numFactor is Single) { b = (Byte)(b * (Double)numFactor); } else { b *= Convert.ToByte(numFactor); } numNew = b; } else if (numOld is RawInt128) { Decimal newDec = Decimal.Multiply(((RawInt128)numOld).ToDecimal(), Convert.ToDecimal(numFactor)); numNew = NumberUtils.DecimalToRawInt128(newDec); } else { throw new Exception("Unsupported type:" + (numOld == null ? numFactor.GetType().Name : numOld.GetType().Name)); } if (!numNew.Equals(numOld)) { Set(entry, numNew); } return(m_postFactor ? numOld : numNew); }
/// <summary> /// Process an <see cref="IInvocableCacheEntry"/>. /// </summary> /// <param name="entry"> /// The <b>IInvocableCacheEntry</b> to process. /// </param> /// <returns> /// Null. /// </returns> public override object Process(IInvocableCacheEntry entry) { return(null); }
/// <summary> /// Process an Get entry processor. /// </summary> /// <param name="entry"> /// The <b>IInvocableCacheEntry</b> to process. /// </param> /// <returns> /// The result of the processing. /// </returns> public override object Process(IInvocableCacheEntry entry) { return(entry.Value); }
/// <summary> /// Process an <see cref="IInvocableCacheEntry"/>. /// </summary> /// <param name="entry"> /// The <b>IInvocableCacheEntry</b> to process. /// </param> /// <returns> /// The result of the processing, if any. /// </returns> public override object Process(IInvocableCacheEntry entry) { return(entry.Extract(m_extractor)); }
/// <summary> /// Process an GetOrDefault entry processor. /// </summary> /// <param name="entry"> /// The <b>IInvocableCacheEntry</b> to process. /// </param> /// <returns> /// The result of the processing. /// </returns> public override object Process(IInvocableCacheEntry entry) { return(entry == null?Optional.Empty() : Optional.OfNullable(entry.Value)); }
/// <summary> /// Process an GetOrDefault entry processor. /// </summary> /// <param name="entry"> /// The <b>IInvocableCacheEntry</b> to process. /// </param> /// <returns> /// The result of the processing. /// </returns> public override Object Process(IInvocableCacheEntry entry) { entry.Value = m_value; return(m_value); }
/// <summary> /// Process an InsertAll entry processor. /// </summary> /// <param name="entry"> /// The <b>IInvocableCacheEntry</b> to process. /// </param> /// <returns> /// Null. /// </returns> public override object Process(IInvocableCacheEntry entry) { entry.Value = m_map[entry.Key]; return(null); }
/// <summary> /// Process an <see cref="IInvocableCacheEntry"/>. /// </summary> /// <param name="entry"> /// The <b>IInvocableCacheEntry</b> to process. /// </param> /// <returns> /// The result of the processing, if any. /// </returns> public override object Process(IInvocableCacheEntry entry) { return(((Int32)entry.Value) * ((Int32)entry.Value)); }
/// <summary> /// Process an RemoveBlind entry processor. /// </summary> /// <param name="entry"> /// The <b>IInvocableCacheEntry</b> to process. /// </param> /// <returns> /// The result of the processing. /// </returns> public override object Process(IInvocableCacheEntry entry) { entry.Remove(false); return(null); }
/// <summary> /// Process an <see cref="IInvocableCacheEntry"/>. /// </summary> /// <param name="entry"> /// The <b>IInvocableCacheEntry</b> to process. /// </param> /// <returns> /// The result of the processing, if any. /// </returns> public override object Process(IInvocableCacheEntry entry) { if (!entry.IsPresent) { return(null); } object numInc = m_numInc; if (numInc == null) { throw new ArgumentNullException("Incorrectly constructed NumberIncrementor."); } object numOld = Get(entry); if (numOld == null) { if (NumberUtils.IsNumber(numInc)) { numOld = 0; } } object numNew; if (numOld is Int32) { numNew = (Int32)numOld + Convert.ToInt32(numInc); } else if (numOld is Int64) { numNew = (Int64)numOld + Convert.ToInt64(numInc); } else if (numOld is Double) { numNew = (Double)numOld + Convert.ToDouble(numInc); } else if (numOld is Single) { numNew = (Single)numOld + Convert.ToSingle(numInc); } else if (numOld is Decimal) { numNew = Decimal.Add((Decimal)numOld, Convert.ToDecimal(numInc)); } else if (numOld is Int16) { numNew = Convert.ToInt16((Int16)numOld + Convert.ToInt16(numInc)); } else if (numOld is Byte) { numNew = Convert.ToByte((Byte)numOld + Convert.ToByte(numInc)); } else if (numOld is RawInt128) { Decimal newDec = Decimal.Add(((RawInt128)numOld).ToDecimal(), Convert.ToDecimal(numInc)); numNew = NumberUtils.DecimalToRawInt128(newDec); } else { throw new Exception("Unsupported type:" + (numOld == null ? numInc.GetType().Name : numOld.GetType().Name)); } Set(entry, numNew); return(m_postInc ? numOld : numNew); }
/// <summary> /// Process an <see cref="IInvocableCacheEntry"/>. /// </summary> /// <param name="entry"> /// The <b>IInvocableCacheEntry</b> to process. /// </param> /// <returns> /// The result of the processing, if any. /// </returns> public object Process(IInvocableCacheEntry entry) { return(m_processor.Process(entry)); }
/// <summary> /// Process an <see cref="IInvocableCacheEntry"/>. /// </summary> /// <param name="entry"> /// The <b>IInvocableCacheEntry</b> to process. /// </param> /// <returns> /// The result of the processing, if any. /// </returns> public override object Process(IInvocableCacheEntry entry) { object result = processEntry(entry, m_value, m_insert, m_return); return(result == NO_RESULT ? null : result); }
/// <summary> /// Process an <see cref="IInvocableCacheEntry"/>. /// </summary> /// <remarks> /// This implementation throws a NotSupportedException. /// </remarks> /// <param name="entry"> /// The <b>IInvocableCacheEntry</b> to process. /// </param> /// <returns> /// The result of the processing, if any. /// </returns> /// <since>12.2.1.3</since> public virtual object Process(IInvocableCacheEntry entry) { throw new NotSupportedException( "This entry processor cannot be invoked on the client."); }