/// <summary> /// 是否匹配 /// </summary> /// <param name="item"></param> /// <returns></returns> private bool Match(KeyValueTuple <string, object> item) { if (item != null) { if (item.Value == null) { return(true); } if (item.Value is INullableParameter) { var @null = (INullableParameter)item.Value; if (@null.HasValue) { return(false); } return(true); } return(false); } return(false); }
public static bool Dammi(FrameworkElement ogg, KeyValueTuple <string, object> tag, ref object valore, bool errSeMancante = true) { if (CtrlParametri(ogg, tag) == false) { return(false); } if (ogg.Tag == null) { if (errSeMancante == true) { Log.main.Add(new Mess(LogType.ERR, Log.main.errUserText, "Nel controllo ogg.Name:<" + ogg.Name + "> manca la tag di nome:<" + tag.Key + ">, ogg.Tag è a nothing ")); } return(false); } bool esiste; if (Concur.Dictionary_TryGet((ConcurrentDictionary <string, object>)ogg.Tag, tag.Key, ref valore, out esiste) == false) { if (esiste == true) { Log.main.Add(new Mess(LogType.ERR, Log.main.errUserText, "Non sono riuscito a leggere la tag di nome:<" + tag.Key + "> sul controllo ogg.Name:<" + ogg.Name + ">")); } else { if (errSeMancante == true) { Log.main.Add(new Mess(LogType.ERR, Log.main.errUserText, "Nel controllo ogg.Name:<" + ogg.Name + "> manca la tag di nome:<" + tag.Key + ">")); } } return(false); } return(true); }
public void Add(K1 key1, K2 key2, V value) { var tuple = new KeyValueTuple(key1, key2, value); var key1Key2 = new Tuple <K1, K2>(key1, key2); this.byKey1[key1].Add(tuple); this.byKey2[key2].Add(tuple); this.byKey1Key2[key1Key2].Add(tuple); }
public KeyValueTuple GetTuple(string key) { KeyValueTuple value = null; if (cache.TryGetValue(key, out value)) { return(value); } return(null); }
public void Add <T>(string key, T value) { var tuple = new KeyValueTuple() { key = key, value = value.ToString(), }; data.Add(tuple); }
public static bool Elimina(FrameworkElement ogg, KeyValueTuple <string, object> tag) { if (CtrlParametri(ogg, tag) == false) { return(false); } if (Concur.Dictionary_TryRemove((ConcurrentDictionary <string, object>)ogg.Tag, tag) == false) { Log.main.Add(new Mess(LogType.ERR, Log.main.errUserText, "Non sono riuscito a rimuovere la tag di nome:<" + tag.Key + "> sul controllo ogg.Name:<" + ogg.Name + ">")); return(false); } return(true); }
/// <summary> /// 是否匹配 /// </summary> /// <param name="item"></param> /// <returns></returns> private bool Match(KeyValueTuple <string, object> item) { if (item != null) { if (item.Value == null) { return(true); } if (item.Value is string && ((string)item.Value).IsNullOrEmpty()) { return(true); } if (item.Value is IGenericeNullableParameter <string> ) { var @null = (IGenericeNullableParameter <string>)item.Value; if ([email protected]) { return(true); } return(false); } if (item.Value is Guid && ((Guid)item.Value) == Guid.Empty) { return(true); } if (item.Value is IGenericeNullableParameter <Guid> ) { var @null = (IGenericeNullableParameter <Guid>)item.Value; if ([email protected]) { return(true); } return(false); } return(false); } return(true); }
/// <summary> /// 是否匹配 /// </summary> /// <param name="item"></param> /// <returns></returns> private bool Match(KeyValueTuple<string, object> item) { if (item != null) { if (item.Value is INullableParameter) { if (((INullableParameter)item.Value).HasValue) return true; return false; } return true; } return false; }
/// <summary> /// 新加参数 /// </summary> /// <param name="parameter"></param> internal void AddParameter(KeyValueTuple <string, object> parameter) { if (this.Keys.Any(o => o == parameter.Key)) { return; } if (parameter.Value is IReferceNullableParameter) { this.Keys.Add(parameter.Key); var value = ((IReferceNullableParameter)parameter.Value).Value; this.Parameters.Add(new KeyValuePair <string, object>(parameter.Key, value)); } else { this.Keys.Add(parameter.Key); this.Parameters.Add(new KeyValuePair <string, object>(parameter.Key, parameter.Value)); } }
/// <summary> /// 是否匹配 /// </summary> /// <param name="item"></param> /// <returns></returns> private bool Match(KeyValueTuple <string, object> item) { if (item != null && item.Value != null) { if (item.Value is INullableParameter) { if (((INullableParameter)item.Value).HasValue) { return(true); } return(false); } return(true); } return(false); }
private static bool CtrlParametri(FrameworkElement ogg, KeyValueTuple <string, object> tag) { if (ogg == null) { Log.main.Add(new Mess(LogType.ERR, Log.main.errUserText, "Ricevuto parametro ogg a nothing")); return(false); } //Una struttura non può essere null //if (tag == null) //{ log.Acc(new Mess(Tipi.err, log.errUserText, "Ricevuto parametro tag a nothing")); // return false; } if (tag.Key == null) { Log.main.Add(new Mess(LogType.ERR, Log.main.errUserText, "La key del parametro tag è nothing")); return(false); } return(true); }
/// <summary> /// 格式化sql语句,是数组使用的 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="format"></param> /// <param name="parameter"></param> /// <param name="convert"></param> /// <param name="arrayLabel"></param> public void FormatArray <T>(SqlTagFormat format, ArrayLabel arrayLabel, EasySqlParameter <T> parameter, KeyValueTuple <string, object> convert) { if (this.SqlText.IsNullOrEmpty()) { return; } if (this.parameterPositions == null || this.parameterPositionCount == 0) { format.Write(this.SqlText); return; } var copy = this.Copy(); for (var i = 0; i < this.SqlText.Length; i++) { var para = this.MathPosition(copy, i); if (para == null) { format.Write(this.SqlText[i]); continue; } var value = convert.Value; if (convert.Value is IReferceNullableParameter) { value = ((IReferceNullableParameter)convert.Value).Value; } var item = value as System.Collections.IEnumerable; var ator = item.GetEnumerator(); var hadA = false; var arrayLevel = 0; if (format.IfTextParameter(para)) { while (ator.MoveNext()) { if (ator.Current == null || ator.Current == DBNull.Value) { continue; } if (hadA) { format.WriteOnTextMode(arrayLabel.Split); } //format.WriteOnTextMode('\''); format.WriteOnTextMode(ator.Current.ToString()); //format.WriteOnTextMode('\''); hadA = true; } i += para.PositionLength + 1; if (i < this.SqlText.Length) { format.WriteOnTextMode(this.SqlText[i]); } } else { format.Write(this.SqlText[i]); while (ator.MoveNext()) { if (ator.Current == null || ator.Current == DBNull.Value) { continue; } var newvalue = (ator.Current == null || ator.Current == DBNull.Value) ? DBNull.Value : ator.Current; var newkey = string.Format("{0}x{1}z", para.Name, arrayLevel); if (hadA) { format.Write(arrayLabel.Split); format.Write(para.ActualPrefix); } format.Write(newkey); arrayLevel++; format.AddParameter(newkey, newvalue); hadA = true; } i += para.PositionLength + 1; if (i < this.SqlText.Length) { format.Write(this.SqlText[i]); } } } }