/// <summary> /// Try to get a value from this dictionary. /// </summary> public bool TryGetValue(TKey key, out TValue value) { var w = new KeyWrapper <TKey>(key, comparer); value = map.Get(w); return(value != null || map.ContainsKey(w)); }
public BarItem(int id, int bar, int key) { ItemId = id; Bar = bar; Key = key; _wrap = new KeyWrapper("Unkown item", "none", bar.ToString(), key.ToString()); }
bool IDictionary <TKey, TValue> .Remove(TKey key) { var w = new KeyWrapper <TKey>(key, comparer); bool ret = map.ContainsKey(w); map.Remove(w); return(ret); }
public virtual Jwk WrapKey(KeyWrapper wrapper, Jwk keyToWrap, out JwtHeader header) { var destination = new byte[wrapper.GetKeyWrapSize()]; header = new JwtHeader(); var cek = wrapper.WrapKey(keyToWrap, header, destination); return(cek); }
private void BatchDequeueProc(KeyWrapper <ServerUri, RpcConnection> key, RpcBatchClientTransaction[] txs) { RpcBatchRequest[] requests = new RpcBatchRequest[txs.Length]; for (int i = 0; i < txs.Length; i++) { requests[i] = txs[i].BatchRequest; } RpcRequest request = new RpcRequest(txs[0].Request.Service, txs[0].Request.Method, null); request.BodyBuffer = new RpcBodyBuffer <RpcBatchRequest[]>(requests); if (key.Token == null) { lock (_syncRoot) { key.Token = RpcProxyFactory.GetConnection(key.Key, txs[0].ServiceRole); } } RpcClientTransaction trans = key.Token.CreateTransaction(request); RpcClientContext ctx = new RpcClientContext(trans); ctx.SendRequest( delegate(long elapseTicks, RpcClientContext c2, bool successed) { try { RpcBatchResponse[] resps = ctx.EndInvoke <RpcBatchResponse[]>(); if (resps.Length != txs.Length) { ProcessFailedTxs(txs, RpcErrorCode.InvaildResponseArgs, new Exception("Batch Length NotMatch")); } else { for (int i = 0; i < resps.Length; i++) { txs[i].BatchResponse = resps[i]; txs[i].OnTransactionEnd(); } } } catch (RpcException ex) { ProcessFailedTxs(txs, ex.RpcCode, ex.InnerException); } catch (Exception ex) { ProcessFailedTxs(txs, RpcErrorCode.ServerError, ex); } }, -1 ); }
/// <summary> /// Gets or sets the value associated with the specified key. /// </summary> /// <param name="key"></param> /// <returns></returns> public TValue this[TKey key] { get { var w = new KeyWrapper <TKey>(key, comparer); var value = map.Get(w); if (Equals(value, default(TValue)) && !map.ContainsKey(w)) { throw new KeyNotFoundException(); } return(value); } set { var w = new KeyWrapper <TKey>(key, comparer); map.Put(w, value); } }
public DbUnitOfWork(TContext context, KeyWrapper <TContext> keyWrapper) { Context = context ?? throw new ArgumentNullException(nameof(context)); _keyWrapper = keyWrapper; }
/// <summary> /// Add the given key and value to the dictionary. /// </summary> public void Add(TKey key, TValue value) { var w = new KeyWrapper <TKey>(key, comparer); map.Put(w, value); }
/// <summary> /// Does this dictionary contain an element with given key? /// </summary> public bool ContainsKey(TKey key) { var w = new KeyWrapper <TKey>(key, comparer); return(map.ContainsKey(w)); }
public void Add(KeyValuePair <TKey, TValue> item) { var w = new KeyWrapper <TKey>(item.Key, comparer); map.Put(w, item.Value); }
/// <summary> /// Removes the given key from the dictionary. /// </summary> public void Remove(TKey key) { var w = new KeyWrapper <TKey>(key, comparer); map.Remove(w); }
private static object API_append(object[] args) { SortedDictionary<KeyWrapper, object> array = args[0] as SortedDictionary<KeyWrapper,object>; object val = args [1]; // Slow but correct way of doing it: int maxArrayIndex = -1; foreach (var keyWrapper in array.Keys) { var key = keyWrapper.value; if (key.GetType () == typeof (float) && maxArrayIndex < (float)key) { maxArrayIndex = (int)(float)key; } else if (key.GetType () == typeof (int) && maxArrayIndex < (int)key) { maxArrayIndex = (int)key; } } //int maxArrayIndex = array.Count; // TODO: this is a bug if the array contains sparse indexes or stuff like that KeyWrapper newIndex = new KeyWrapper((float)maxArrayIndex + 1); if (array.ContainsKey(newIndex)) { throw new Error("Can't append to array"); } array.Add (newIndex, val); return VoidType.voidType; }