public StoreOperation(MemoryPool <byte> allocator, string key, IKeyFormatter keyFormatter, StoreMode mode, uint flags, SequenceBuilder value) : base(allocator, key, keyFormatter, 8) { Mode = mode; this.flags = flags; this.value = value; }
/// <summary> /// Inserts an item into the cache with a cache key to reference its location. /// </summary> /// <param name="mode">Defines how the item is stored in the cache.</param> /// <param name="key">The key used to reference the item.</param> /// <param name="value">The object to be inserted into the cache.</param> /// <param name="expiresAt">The time when the item is invalidated in the cache.</param> /// <returns>true if the item was successfully stored in the cache; false otherwise.</returns> public bool Store(StoreMode mode, string key, object value, DateTime expiresAt) { ulong tmp = 0; int status; return this.PerformStore(mode, key, value, MemcachedClient.GetExpiration(expiresAt), ref tmp, out status).Success; }
protected OpCode GetOpCode(StoreMode mode) { if (Silent) { switch (mode) { case StoreMode.Add: return(OpCode.AddQ); case StoreMode.Replace: return(OpCode.ReplaceQ); case StoreMode.Set: return(OpCode.SetQ); } } else { switch (mode) { case StoreMode.Add: return(OpCode.Add); case StoreMode.Replace: return(OpCode.Replace); case StoreMode.Set: return(OpCode.Set); } } throw new ArgumentOutOfRangeException(nameof(mode), $"StoreMode {mode} is unsupported"); }
IStoreOperation IOperationFactory.Store(StoreMode mode, string key, CacheItem value, uint expires, ulong cas) { return(new VBStore(locator, mode, key, value, expires) { Cas = cas }); }
/// <summary> /// Inserts an item into the cache with a cache key to reference its location. /// </summary> /// <param name="mode">Defines how the item is stored in the cache.</param> /// <param name="key">The key used to reference the item.</param> /// <param name="value">The object to be inserted into the cache.</param> /// <remarks>The item does not expire unless it is removed due memory pressure.</remarks> /// <returns>true if the item was successfully stored in the cache; false otherwise.</returns> public IStoreOperationResult ExecuteStore(StoreMode mode, string key, object value) { ulong tmp = 0; int status; return(this.PerformStore(mode, key, value, 0, ref tmp, out status)); }
protected void Test(Action<PropertyMap<Sample>> setStoreMode, StoreMode expectedStoreMode) { setStoreMode(map.Property(x => x.Name)); var mapper = GetMappingInfo("Name"); Assert.That(mapper.Store, Is.EqualTo(expectedStoreMode)); }
protected void Test(Action <PropertyMap <Sample> > setStoreMode, StoreMode expectedStoreMode) { setStoreMode(map.Property(x => x.Name)); var mapper = GetMappingInfo("Name"); Assert.That(mapper.Store, Is.EqualTo(expectedStoreMode)); }
public StoreOperation(StoreMode mode, string key, CacheItem value, uint expires) : base(key) { this.mode = mode; this.value = value; this.expires = expires; }
public virtual async Task StoreAsync(string messageset, StoreMode mode, string flags) { await CheckMailboxSelectedAsync(); await IdlePauseAsync(); string prefix = null; if (messageset.StartsWith("UID ", StringComparison.OrdinalIgnoreCase)) { messageset = messageset.Substring(4); prefix = "UID "; } string modeString = string.Empty; if (mode == StoreMode.Add) { modeString = "+"; } else if (mode == StoreMode.Remove) { modeString = "-"; } string command = string.Concat(GetTag(), prefix, "STORE ", messageset, " ", modeString, "FLAGS.SILENT (" + flags + ")"); string response = await SendCommandGetResponseAsync(command); while (response.StartsWith("*")) { response = await GetResponseAsync(); } CheckResultOK(response); await IdleResumeAsync(); }
IStoreOperation IOperationFactory.Store(StoreMode mode, string key, CacheItem value, uint expires, ulong cas) { if (cas == 0) return new StoreOperation(mode, key, value, expires); return new CasOperation(key, value, expires, (uint)cas); }
protected override IStoreOperationResult PerformStore(StoreMode mode, string key, object value, uint expires, ref ulong cas, out int statusCode) { ulong tmp = cas; var result = base.PerformStore(mode, key, value, expires, ref cas, out statusCode); if (!result.Success) { StringBuilder message = new StringBuilder(); StringBuilder errorMessage = new StringBuilder(); IOperationResult nextResult = result; while (nextResult != null) { message.Append(nextResult.Message).AppendLine(); if (nextResult.Exception != null) { errorMessage.Append(nextResult.Exception.ToString()).AppendLine(); } nextResult = nextResult.InnerResult; } if (errorMessage.Length > 0) { logger.Error(string.Format("缓存设置失败,key:{0},方式:{1},错误信息:{2}", key, mode.ToString(), message.ToString()), statusCode, errorMessage.ToString()); } else if (mode != StoreMode.Add && tmp == 0) { logger.Error(string.Format("缓存设置失败,key:{0},方式:{1},错误信息:{2}", key, mode.ToString(), message.ToString()), statusCode, errorMessage.ToString()); } } return(result); }
protected Task<bool> Store(StoreMode mode = StoreMode.Set, string key = null, object value = null) { if (key == null) key = GetUniqueKey("store"); if (value == null) value = GetRandomString(); return client.StoreAsync(mode, key, value, Expiration.Never); }
/// <summary> /// Inserts an item into the cache with a cache key to reference its location. /// </summary> /// <param name="mode">Defines how the item is stored in the cache.</param> /// <param name="key">The key used to reference the item.</param> /// <param name="value">The object to be inserted into the cache.</param> /// <param name="validFor">The interval after the item is invalidated in the cache.</param> /// <returns>true if the item was successfully stored in the cache; false otherwise.</returns> public IStoreOperationResult ExecuteStore(StoreMode mode, string key, object value, TimeSpan validFor) { ulong tmp = 0; int status; return(this.PerformStore(mode, key, value, MemcachedClient.GetExpiration(validFor, null), ref tmp, out status)); }
protected bool Store(StoreMode mode = StoreMode.Set, string key = null, object value = null) { if (key == null) key = GetUniqueKey("store"); if (value == null) value = GetRandomString(); return client.Store(mode, key, value); }
/// <summary> /// Inserts an item into the cache with a cache key to reference its location. /// </summary> /// <param name="mode">Defines how the item is stored in the cache.</param> /// <param name="key">The key used to reference the item.</param> /// <param name="value">The object to be inserted into the cache.</param> /// <param name="expiresAt">The time when the item is invalidated in the cache.</param> /// <returns>true if the item was successfully stored in the cache; false otherwise.</returns> public IStoreOperationResult ExecuteStore(StoreMode mode, string key, object value, DateTime expiresAt) { ulong tmp = 0; int status; return(this.PerformStore(mode, key, value, MemcachedClient.GetExpiration(null, expiresAt), ref tmp, out status)); }
public bool Store(StoreMode mode, string key, object value, TimeSpan validFor) { var expiresAt = this.CurrentDateTime.Add(validFor); var result = ExecuteStoreInternal(mode, key, value, expiresAt); return(result.Success); }
public IStoreOperationResult ExecuteStore(StoreMode mode, string key, object value, TimeSpan validFor, PersistTo persistTo, ReplicateTo replicateTo) { var expiresAt = this.CurrentDateTime.Add(validFor); return(ExecuteStore(mode, key, value, expiresAt)); }
public AssignFunctionNode(string name, IEnumerable <string> arguments, INode body, StoreMode mode) { this.arguments = arguments.ToArray(); this.body = body; this.mode = mode; this.name = name; }
public void Store(GameObject root, StoreMode mode) { if (root == null) { return; } data = new List <TransformData>(); if (mode == StoreMode.RootOnly) { var transform = root.transform; data.Add(new TransformData(transform, transform.parent, transform.localPosition, transform.localRotation, transform.localScale)); return; } var allTransforms = root.GetComponentsInChildren <Transform>(true); for (var i = 0; i < allTransforms.Length; i++) { var transform = allTransforms[i]; if (transform != root.transform || mode == StoreMode.All) { data.Add(new TransformData(transform, transform.parent, transform.localPosition, transform.localRotation, transform.localScale)); } } }
/// <summary> /// Store the given value with the given key /// </summary> /// <param name="mode">See @StoreMode values</param> /// <param name="key" /> /// <param name="value" /> /// <param name="expire">Expiration of the value</param> /// <returns></returns> public bool Store(StoreMode mode, string key, byte[] value, TimeSpan expire) { var taskSource = new TaskCompletionSource <bool>(); if (!_client.Store( mode: mode, key: key, message: value, expiration: expire, callback: s => { if (s == Status.NoError) { taskSource.SetResult(true); } else { taskSource.SetResult(false); } })) { taskSource.SetResult(false); } if (taskSource.Task.Wait(_receiveTimeout)) { return(taskSource.Task.Result); } else { return(false); } }
/// <summary> /// Inserts an item into the cache with a cache key to reference its location. /// </summary> /// <param name="mode">Defines how the item is stored in the cache.</param> /// <param name="key">The key used to reference the item.</param> /// <param name="value">The object to be inserted into the cache.</param> /// <remarks>The item does not expire unless it is removed due memory pressure.</remarks> /// <returns>true if the item was successfully stored in the cache; false otherwise.</returns> public bool Store(StoreMode mode, string key, object value) { ulong tmp = 0; int status; return(this.PerformStore(mode, key, value, 0, ref tmp, out status)); }
public override void Set(Value symbol, Value value, StoreMode mode) { Stack <Value> stack; if (!this.stacks.TryGetValue(symbol, out stack)) { stack = new Stack <Value> (); this.stacks[symbol] = stack; } switch (mode) { case StoreMode.Global: if (stack.Count > 0) { stack.Pop(); } break; case StoreMode.Local: if (this.levels.Count > 0 && !this.levels.Peek().Add(symbol)) { stack.Pop(); } break; } stack.Push(value); }
public static bool Set(string key, object value, TimeSpan validFor, StoreMode mode = StoreMode.Set) { if (string.IsNullOrEmpty(key)) { key = GetUniqueKey(); } return(client.Store(mode, key, value, validFor)); }
public static bool Set(string key, object value, DateTime expiresAt, StoreMode mode = StoreMode.Set) { if (string.IsNullOrEmpty(key)) { key = GetUniqueKey(); } return(client.Store(mode, key, value, expiresAt)); }
public static CasResult <bool> Cas(string key, object value, StoreMode mode = StoreMode.Set) { if (string.IsNullOrEmpty(key)) { key = GetUniqueKey(); } return(client.Cas(mode, key, value)); }
public IStoreOperation Store(StoreMode mode, Key key, CacheItem value, uint expires, ulong cas) { return new StoreOperation(allocator, mode, key, value) { Cas = cas, Expires = expires }; }
public IStoreOperation Store(StoreMode mode, Key key, CacheItem value, uint expires, ulong cas) { return(new StoreOperation(allocator, mode, key, value) { Cas = cas, Expires = expires }); }
private CasResult <bool> PerformStore(StoreMode mode, string key, object value, uint expires, ulong cas) { ulong tmp = cas; var retval = this.PerformStore(mode, key, value, expires, ref tmp); return(new CasResult <bool> { Cas = tmp, Result = retval }); }
public ReflectionFieldMapper(PropertyInfo propertyInfo, StoreMode store, IndexMode index, TypeConverter converter, string fieldName, bool caseSensitive) { this.propertyInfo = propertyInfo; this.store = store; this.index = index; this.converter = converter; this.fieldName = fieldName; this.caseSensitive = caseSensitive; }
IStoreOperation IOperationFactory.Store(StoreMode mode, string key, CacheItem value, uint expires, ulong cas) { if (cas == 0) { return(new StoreOperation(mode, key, value, expires)); } return(new CasOperation(key, value, expires, (uint)cas)); }
protected override IStoreOperationResult PerformStore(StoreMode mode, string key, object value, uint expires, ref ulong cas, out int statusCode) { var hashedKey = this.KeyTransformer.Transform(key); var node = this.Pool.Locate(hashedKey); var result = StoreOperationResultFactory.Create(); statusCode = -1; if (node != null) { CacheItem item; try { item = this.Transcoder.Serialize(value); } catch (Exception e) { log.Error(e); if (this.PerformanceMonitor != null) { this.PerformanceMonitor.Store(mode, 1, false); } result.Fail("Store operation failed during serialization", e); return(result); } var command = this.Pool.OperationFactory.Store(mode, hashedKey, item, expires, cas); var commandResult = ExecuteWithRedirect(node, command); result.Cas = cas = command.CasValue; result.StatusCode = statusCode = command.StatusCode; if (!commandResult.Success) { result.InnerResult = commandResult; result.Fail("Store operation failed, see InnerResult or StatusCode for details"); return(result); } if (this.PerformanceMonitor != null) { this.PerformanceMonitor.Store(mode, 1, true); } result.Pass(); return(result); } if (this.PerformanceMonitor != null) { this.PerformanceMonitor.Store(mode, 1, false); } result.Fail("Failed to locate node"); return(result); }
/// <summary> /// Gets the url required to begin checkout /// </summary> /// <param name="isAuthenticated">A flag indicating whether the URL should be returned for an authenticated user.</param> /// <returns>A string containing the checkout url</returns> /// <remarks>Authenticated users may have a different checkout starting point than anonymous users.</remarks> public static string GetCheckoutUrl(bool isAuthenticated) { StoreMode mode = AbleContext.Current.StoreMode; if (isAuthenticated) { return(mode == StoreMode.Standard ? GetStandardCheckoutUrl(true) : GetMobileStoreUrl("~/Checkout/EditBillAddress.aspx")); } return(mode == StoreMode.Standard ? GetStandardCheckoutUrl(false) : GetMobileStoreUrl("~/Checkout/Default.aspx")); }
public static CasResult <bool> CasJson(this CouchbaseClient client, StoreMode storeMode, string key, object value) { var json = JsonConvert.SerializeObject(value, Formatting.None, new JsonSerializerSettings { ContractResolver = new DocumentIdContractResolver() }); return(client.Cas(storeMode, key, json)); }
public IStoreOperation Store(StoreMode mode, Key key, CacheItem value, uint expires, ulong cas) { return(new StoreOperation(allocator, key) { Mode = mode, Value = value, Cas = cas, Expires = expires, Silent = silent }); }
public ReflectionFieldMapper(PropertyInfo propertyInfo, StoreMode store, IndexMode index, TermVectorMode termVector, TypeConverter converter, string fieldName, bool caseSensitive, Analyzer analyzer, float boost) { this.propertyInfo = propertyInfo; this.store = store; this.index = index; this.termVector = termVector; this.converter = converter; this.fieldName = fieldName; this.caseSensitive = caseSensitive; this.analyzer = analyzer; this.boost = boost; }
public static IStoreOperationResult Store(ICouchbaseClient client, StoreMode mode = StoreMode.Set, string key = null, string value = null) { if (string.IsNullOrEmpty(key)) { key = GetUniqueKey("store"); } if (value == null) { value = GetRandomString(); } return client.ExecuteStore(mode, key, value); }
protected IStoreOperationResult Store(StoreMode mode = StoreMode.Set, string key = null, object value = null) { if (string.IsNullOrEmpty(key)) { key = GetUniqueKey("store"); } if (value == null) { value = GetRandomString(); } return _Client.ExecuteStore(mode, key, value); }
public StoreCommand(CacheItem item, TimeToLive timeToLive, ulong uniqueID) { Condition.Requires(item).IsNotNull( "When storing item, item should be specified."); Condition.Requires(timeToLive).IsNotNull( "When storing item '{0}', item's time to live should be specified".FormatString(item)); Condition.Requires(item.Data).IsNotNull( "When storing item '{0}', item's value should be specified.".FormatString(item)); _item = item; _timeToLive = timeToLive; _storeMode = StoreMode.CheckAndSet; _uniqueID = uniqueID; }
public StoreCommand(CacheItem item, TimeToLive timeToLive, StoreMode storeMode) { Condition.Requires(item).IsNotNull( "When storing item, item should be specified."); Condition.Requires(item.Data).IsNotNull( "When storing item '{0}', item's value should be specified.".FormatString(item)); Condition.Requires(timeToLive).IsNotNull( "When storing item '{0}', item's time to live should be specified.".FormatString(item)); Condition.Requires(storeMode).IsNotEqualTo(StoreMode.CheckAndSet, "To initialize 'Check and Set' command use another constructor, which accepts unique ID."); _item = item; _timeToLive = timeToLive; _storeMode = storeMode; _uniqueID = null; }
public virtual async Task StoreAsync(string messageset, StoreMode mode, string flags) { await CheckMailboxSelectedAsync(); await IdlePauseAsync(); string prefix = null; if (messageset.StartsWith("UID ", StringComparison.OrdinalIgnoreCase)) { messageset = messageset.Substring(4); prefix = "UID "; } string modeString = string.Empty; if (mode == StoreMode.Add) modeString = "+"; else if (mode == StoreMode.Remove) modeString = "-"; string command = string.Concat(GetTag(), prefix, "STORE ", messageset, " ", modeString, "FLAGS.SILENT (" + flags + ")"); string response = await SendCommandGetResponseAsync(command); while (response.StartsWith("*")) { response = await GetResponseAsync(); } CheckResultOK(response); await IdleResumeAsync(); }
/// <summary> /// Synchronously Put a bank card object with possible association to a merchant /// </summary> /// <param name="bc">Bank card object</param> /// <param name="creatorReference">On optional value to be used by the sender for future reference</param> /// <param name="saveCVV">Whether to save the Security code with the card</param> /// <param name="merchantId">Optional value allowing access to the given merchant Id (pciBooking user Id of the hotel)</param> /// <param name="storeMode">Where to store the card data</param> public Entities.Result<Uri> PutCardDetails(Entities.BankCardDetails bc, string creatorReference, bool saveCVV, string merchantId, StoreMode storeMode) { return ToAsync<Entities.Result<Uri>, Entities.BankCardDetails, string,bool, string, StoreMode>(bc, creatorReference, saveCVV,merchantId, storeMode, PutCardDetailsAsync); }
/// <summary> /// Toes the set opcode. /// </summary> /// <param name="tag">The tag.</param> /// <param name="name">The name.</param> /// <param name="cas">The cas.</param> /// <param name="opvalue">The opvalue.</param> /// <param name="storeMode">The store mode.</param> /// <returns></returns> public SetOpcode ToSetOpcode(object tag, ref string name, out ulong cas, out object opvalue, out StoreMode storeMode) { if (name == null) throw new ArgumentNullException("name"); // determine flag, striping name if needed bool flag = name.StartsWith("#"); if (flag) { storeMode = StoreMode.Replace; name = name.Substring(1); } else storeMode = StoreMode.Set; // store if (tag == null) { cas = 0; opvalue = null; return SetOpcode.Store; } // if (tag is CasResult<object>) { var plainCas = (CasResult<object>)tag; cas = plainCas.Cas; opvalue = null; return SetOpcode.Cas; } // prepend if (tag is ArraySegment<byte>) { cas = 0; opvalue = tag; return SetOpcode.Prepend; } else if (tag is CasResult<ArraySegment<byte>>) { var appendCas = (CasResult<ArraySegment<byte>>)tag; cas = appendCas.Cas; opvalue = appendCas.Result; return SetOpcode.PrependCas; } // decrement else if (tag is DecrementTag) { cas = 0; opvalue = (DecrementTag)tag; return SetOpcode.Decrement; } else if (tag is CasResult<DecrementTag>) { var decrementCas = (CasResult<DecrementTag>)tag; cas = decrementCas.Cas; opvalue = decrementCas.Result; return SetOpcode.DecrementCas; } // increment else if (tag is IncrementTag) { cas = 0; opvalue = (IncrementTag)tag; return SetOpcode.Increment; } else if (tag is CasResult<IncrementTag>) { var incrementCas = (CasResult<IncrementTag>)tag; cas = incrementCas.Cas; opvalue = incrementCas.Result; return SetOpcode.IncrementCas; } throw new InvalidOperationException(); }
public static Task<IOperationResult> StoreAsync(this IMemcachedClient self, StoreMode mode, string key, object value, Expiration expiration) { return self.StoreAsync(mode, key, value, expiration, Protocol.NO_CAS); }
/// <summary> /// Asynchronously Put a payment Info object with possible association to a merchant /// </summary> /// <param name="cardDetailsContent">HTTP Contennt already containing the payment Info object</param> /// <param name="creatorReference">On optional value to be used by the sender for future reference</param> /// <param name="saveCVV">Whether to save the Security code with the card</param> /// <param name="merchantId">Optional value allowing access to the given merchant Id (pciBooking user Id of the hotel)</param> /// <param name="storeMode">Where to store the card data</param> /// <param name="userData">User data (piggyback)</param> /// <param name="ct">Cancelation token</param> /// <param name="callback">callback method to invoke upon completion. Will be invoked also after cancelation</param> /// <remarks>Only bank cards are supported</remarks> private void PutCardDetailsAsync (HttpContent cardDetailsContent, string creatorReference, bool saveCVV, string merchantId, StoreMode storeMode, Object userData, CancellationToken ct, Action<Entities.Result<Uri>> callback) { var baseUri = string.Format( "{0}?ref={1}&merchant={2}&storeMode={3}&saveCVV={4}", PAYCARDS_URL_PATH, Uri.EscapeDataString(creatorReference), Uri.EscapeDataString(merchantId), Uri.EscapeDataString(storeMode.ToString()), Uri.EscapeDataString(saveCVV.ToString()) ); HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Post, baseUri); requestMessage.Content = cardDetailsContent; Entities.Result<Uri> result = new Entities.Result<Uri>(); result.Status.userData = userData; sendAsync(requestMessage, result.Status, ct, (response) => { if (result.Status.IsSuccess) { result.responsePayload = response.Headers.Location; } if (callback != null) callback(result); }); }
IStoreOperation IOperationFactory.Store(StoreMode mode, string key, CacheItem value, uint expires, ulong cas) { return new StoreOperation(mode, key, value, expires) { Cas = cas }; }
public static IOperationResult Store(this IMemcachedClient self, StoreMode mode, string key, object value, Expiration expiration, ulong cas = Protocol.NO_CAS) { return self.StoreAsync(mode, key, value, expiration, cas).RunAndUnwrap(); }
/// <summary> /// Stores the data contained in the given file into the file. /// </summary> /// <param name="file">The file in which to store the data.</param> /// <param name="data">The path of the data file.</param> public bool WriteFile(StoreFile file, string dataPath, StoreMode storeMode) { if(file == null || dataPath == null) { throw new ArgumentNullException("file"); } if(File.Exists(dataPath)) { try { byte[] buffer = File.ReadAllBytes(dataPath); SetFileData(file, buffer, storeMode); } catch { file.ResetData(); return false; } } return true; }
private void SetFileData(StoreFile file, byte[] data, StoreMode storeMode) { if(data == null) { file.ResetData(); } byte[] buffer = data; // compress if((storeMode & StoreMode.Compressed) == StoreMode.Compressed) { buffer = CompressData(buffer); } // encrypt if((storeMode & StoreMode.Encrypted) == StoreMode.Encrypted) { buffer = EncryptData(buffer); } file.StoreMode = storeMode; file.SetData(buffer, data.Length); }
/// <summary> /// Generates code for the object scope /// </summary> /// <param name="objectIdentifier"></param> internal void GenerateObjectScope(IdentifierRecord objectIdentifier, StoreMode mode) { if (objectIdentifier.symbol.symbolType != SymbolType.FunctionSymbol || mode == StoreMode.Load) { if (symbolTableStack.Count == 1) { cilOutput.WriteLine(" ldloc.0"); } else { int nestingLevelDifference = symbolTableStack.Count - 1 - objectIdentifier. symbolTable.nestingLevel; if (nestingLevelDifference < 1) { cilOutput.WriteLine(" ldloc.0"); } else { cilOutput.WriteLine(" ldarg.0"); if (nestingLevelDifference > 1) { cilOutput.WriteLine(" ldfld\tclass " + objectIdentifier.symbolTable. cilScope + "/c__" + objectIdentifier.symbolTable.name + " " + symbolTableStack.Peek().cilScope + "::c__" + objectIdentifier.symbolTable.name + "Obj"); } } } } if (objectIdentifier.symbol is ParameterSymbol) { if ((objectIdentifier.symbol as ParameterSymbol).parameter.mode == IOMode.InOut && mode == StoreMode.Store) { cilOutput.WriteLine(" ldfld\t" + Enumerations.GetDescription<VariableType> (objectIdentifier.symbol.variableType) + "* " + objectIdentifier.symbolTable.cilScope + "/c__" + objectIdentifier. symbolTable.name + "::" + objectIdentifier.symbol.name); } } }
/// <summary> /// Stores the given data into the file. /// </summary> /// <param name="file">The file in which to store the data.</param> /// <param name="data">The Stream to store.</param> public void WriteFile(StoreFile file, Stream stream, StoreMode storeMode) { if(file == null || stream == null) { throw new ArgumentNullException("file | stream"); } if(stream.Length > 0) { // allocate buffer byte[] buffer = new byte[(int)stream.Length]; // read from stream if(stream.Read(buffer, 0, (int)stream.Length) != 0) { SetFileData(file, buffer, storeMode); } } else { file.ResetData(); } }
/// <summary> /// Asynchronously Put a payment Info object from stream with possible association to a merchant /// </summary> /// <param name="st">Stream containing the payment Info object</param> /// <param name="creatorReference">On optional value to be used by the sender for future reference</param> /// <param name="saveCVV">Whether to save the Security code with the card</param> /// <param name="merchantId">Optional value allowing access to the given merchant Id (pciBooking user Id of the hotel)</param> /// <param name="storeMode">Where to store the card data</param> /// <param name="userData">User data (piggyback)</param> /// <param name="ct">Cancelation token</param> /// <param name="callback">callback method to invoke upon completion. Will be invoked also after cancelation</param> public void PutCardDetailsAsync(Stream st, string creatorReference, bool saveCVV, string merchantId, StoreMode storeMode, Object userData, CancellationToken ct, Action<Entities.Result<Uri>> callback) { StreamContent c = new StreamContent(st); c.Headers.ContentType = new MediaTypeHeaderValue("text/xml"); c.Headers.ContentType.CharSet = Encoding.UTF8.WebName; PutCardDetailsAsync(c, creatorReference, saveCVV, merchantId, storeMode, userData, ct, callback); }
/// <summary> /// Asynchronously Put a payment Info object from XML with possible association to a merchant /// </summary> /// <param name="bc">Bank card object</param> /// <param name="creatorReference">On optional value to be used by the sender for future reference</param> /// <param name="saveCVV">Whether to save the Security code with the card</param> /// <param name="merchantId">Optional value allowing access to the given merchant Id (pciBooking user Id of the hotel)</param> /// <param name="storeMode">Where to store the card data</param> /// <param name="userData">User data (piggyback)</param> /// <param name="ct">Cancelation token</param> /// <param name="callback">callback method to invoke upon completion. Will be invoked also after cancelation</param> public void PutCardDetailsAsync(Entities.BankCardDetails bc, string creatorReference, bool saveCVV, string merchantId, StoreMode storeMode, Object userData, CancellationToken ct, Action<Entities.Result<Uri>> callback) { PutCardDetailsAsync(bc.ToXML(true), creatorReference, saveCVV, merchantId, storeMode, userData, ct, callback); }
/// <summary> /// Asynchronously Put a payment Info object from XML with possible association to a merchant /// </summary> /// <param name="doc">XML Document containing the payment Info object</param> /// <param name="creatorReference">On optional value to be used by the sender for future reference</param> /// <param name="saveCVV">Whether to save the Security code with the card</param> /// <param name="merchantId">Optional value allowing access to the given merchant Id (pciBooking user Id of the hotel)</param> /// <param name="storeMode">Where to store the card data</param> /// <param name="userData">User data (piggyback)</param> /// <param name="ct">Cancelation token</param> /// <param name="callback">callback method to invoke upon completion. Will be invoked also after cancelation</param> public void PutCardDetailsAsync(XDocument doc, string creatorReference, bool saveCVV, string merchantId, StoreMode storeMode, Object userData, CancellationToken ct, Action<Entities.Result<Uri>> callback) { MemoryStream ms = new MemoryStream(); StreamWriter sw = new StreamWriter(ms, new UTF8Encoding(false)); doc.Save(sw); sw.Flush(); ms.Seek(0, SeekOrigin.Begin); PutCardDetailsAsync(ms, creatorReference, saveCVV, merchantId, storeMode, userData, ct, callback); }
public override void Set(Value symbol, Value value, StoreMode mode) { this.store.Set (symbol, value, mode); }
void IPerformanceMonitor.Store(StoreMode mode, int amount, bool success) { switch (mode) { case StoreMode.Add: this.pcAdd.Increment(amount, success); break; case StoreMode.Replace: this.pcReplace.Increment(amount, success); break; case StoreMode.Set: this.pcSet.Increment(amount, success); break; } }
/// <summary> /// Asynchronously Put a payment Info object from XML with possible association to a merchant /// </summary> /// <param name="xmlString">String in XML format containing the payment Info object</param> /// <param name="creatorReference">On optional value to be used by the sender for future reference</param> /// <param name="saveCVV">Whether to save the Security code with the card</param> /// <param name="merchantId">Optional value allowing access to the given merchant Id (pciBooking user Id of the hotel)</param> /// <param name="storeMode">Where to store the card data</param> /// <param name="userData">User data (piggyback)</param> /// <param name="ct">Cancelation token</param> /// <param name="callback">callback method to invoke upon completion. Will be invoked also after cancelation</param> public void PutCardDetailsAsync(string xmlString, string creatorReference,bool saveCVV, string merchantId, StoreMode storeMode, Object userData, CancellationToken ct, Action<Entities.Result<Uri>> callback) { // set content StringContent c = new StringContent(xmlString, new UTF8Encoding(false), "text/xml"); PutCardDetailsAsync(c, creatorReference, saveCVV, merchantId, storeMode, userData, ct, callback); }
public VBStore(VBucketNodeLocator locator, StoreMode mode, string key, CacheItem value, uint expires) : base(mode, key, value, expires) { this.locator = locator; }
/// <summary> /// Stores the given data into the file. /// </summary> /// <param name="file">The file in which to store the data.</param> /// <param name="data">The data to store.</param> public void WriteFile(StoreFile file, byte[] data, StoreMode storeMode) { if(file == null) { throw new ArgumentNullException("file"); } SetFileData(file, data, storeMode); }
internal StoreOperation(StoreMode mode, string key, CacheItem value, uint expires) : base((StoreCommand)mode, key, value, expires, 0) { this.mode = mode; }