protected BaseEnum(TKey key, TValue value) { if (key == null || value == null) { throw new ArgumentNullException(); } Value = value; Key = key; KeyDictionary.Add(key, this); ValueDictionary.Add(value, this); }
private static void AddAnyRu(KeyDictionary dictionary, Keys key, object any, string letter) { if (dictionary.ContainsKey(key)) { throw new Exception("Duplicate key: " + key); } else { dictionary.Add(key, AnyRu(any, letter)); } }
/// <summary> /// Cast key to derived enum /// </summary> /// <param name="key">Key to cast</param> /// <returns>Derived enum matching key OR new enum if not exists</returns> protected new static TDerived From(int key) { if (KeyDictionary.ContainsKey(key)) { return((TDerived)KeyDictionary[key]); } var result = new TDerived { Key = key }; KeyDictionary.Add(key, result); return(result); }
//private void AddToDictionary( // PoeNinjaDataService.ItemJsonResponse.Line line, // string attribute, // bool useNameForKeyGeneration = true, // bool useBaseTypeForKeyGeneration = false) //{ // line.Name = line.Name.Trim(); // var keyNode = new KeyNode // { // Description = line.Name, // Key = FormatStringToKey(line, useNameForKeyGeneration, useBaseTypeForKeyGeneration), // }; // keyNode.Attributes.Add($"[Name(Name = \"{line.Name}\")]"); // if(line.Id != -1) // { // keyNode.Attributes.Add($"[{attribute}(PoeNinjaId = \"{line.Id}\")]"); // keyNode.Attributes.Add($"[PoeNinja]"); // } // else // { // keyNode.Attributes.Add($"[{attribute}()]"); // } // AddToDictionary(keyNode); //} private void AddToDictionary(KeyNode keyNode) { if(!KeyDictionary.ContainsKey(keyNode.Key)) { KeyDictionary.Add(keyNode.Key, keyNode); return; } var existing = (KeyNode)KeyDictionary[keyNode.Key]; foreach(var a in keyNode.Attributes) { if(existing.Attributes.Any(o => o.Equals(a, StringComparison.OrdinalIgnoreCase))) { continue; } existing.Attributes.Add(a); } }
static DbExpressionOptimizer() { _toTranslateMembers.Add(UtilConstants.PropertyInfo_String_Length); _toTranslateMembers.Add(UtilConstants.PropertyInfo_DateTime_Now); //_toTranslateMembers.Add(UtilConstants.PropertyInfo_DateTime_UtcNow); _toTranslateMembers.Add(UtilConstants.PropertyInfo_DateTime_Today); _toTranslateMembers.Add(UtilConstants.PropertyInfo_DateTime_Date); _toTranslateMembers.Add(UtilConstants.PropertyInfo_DateTime_Year); _toTranslateMembers.Add(UtilConstants.PropertyInfo_DateTime_Month); _toTranslateMembers.Add(UtilConstants.PropertyInfo_DateTime_Day); _toTranslateMembers.Add(UtilConstants.PropertyInfo_DateTime_Hour); _toTranslateMembers.Add(UtilConstants.PropertyInfo_DateTime_Minute); _toTranslateMembers.Add(UtilConstants.PropertyInfo_DateTime_Second); _toTranslateMembers.Add(UtilConstants.PropertyInfo_DateTime_Millisecond); _toTranslateMembers.Add(UtilConstants.PropertyInfo_DateTime_DayOfWeek); _toTranslateMembers = _toTranslateMembers.Clone(); }
public void Add(TKey key, TValue value) { KeyDictionary.Add(key, value); ValueDictionary.Add(value, key); }
static EvaluableDbExpressionTransformer() { _toTranslateMembers.Add(UtilConstants.PropertyInfo_String_Length); _toTranslateMembers.Add(UtilConstants.PropertyInfo_DateTime_Now); _toTranslateMembers.Add(UtilConstants.PropertyInfo_DateTime_UtcNow); _toTranslateMembers.Add(UtilConstants.PropertyInfo_DateTime_Today); _toTranslateMembers.Add(UtilConstants.PropertyInfo_DateTime_Date); _toTranslateMembers.Add(UtilConstants.PropertyInfo_DateTime_Year); _toTranslateMembers.Add(UtilConstants.PropertyInfo_DateTime_Month); _toTranslateMembers.Add(UtilConstants.PropertyInfo_DateTime_Day); _toTranslateMembers.Add(UtilConstants.PropertyInfo_DateTime_Hour); _toTranslateMembers.Add(UtilConstants.PropertyInfo_DateTime_Minute); _toTranslateMembers.Add(UtilConstants.PropertyInfo_DateTime_Second); _toTranslateMembers.Add(UtilConstants.PropertyInfo_DateTime_Millisecond); _toTranslateMembers.Add(UtilConstants.PropertyInfo_DateTime_DayOfWeek); _toTranslateMembers.Add(OracleSemantics.PropertyInfo_ROWNUM); _toTranslateMembers = _toTranslateMembers.Clone(); }
static EvaluableDbExpressionTransformer() { _toTranslateMembers.Add(UtilConstants.PropertyInfo_String_Length); _toTranslateMembers.Add(UtilConstants.PropertyInfo_DateTime_Now); _toTranslateMembers.Add(UtilConstants.PropertyInfo_DateTime_UtcNow); _toTranslateMembers.Add(UtilConstants.PropertyInfo_DateTime_Today); _toTranslateMembers.Add(UtilConstants.PropertyInfo_DateTime_Date); _toTranslateMembers.Add(UtilConstants.PropertyInfo_DateTime_Year); _toTranslateMembers.Add(UtilConstants.PropertyInfo_DateTime_Month); _toTranslateMembers.Add(UtilConstants.PropertyInfo_DateTime_Day); _toTranslateMembers.Add(UtilConstants.PropertyInfo_DateTime_Hour); _toTranslateMembers.Add(UtilConstants.PropertyInfo_DateTime_Minute); _toTranslateMembers.Add(UtilConstants.PropertyInfo_DateTime_Second); /* MySql is not supports MILLISECOND */ //_toTranslateMembers.Add(UtilConstants.PropertyInfo_DateTime_Millisecond); _toTranslateMembers.Add(UtilConstants.PropertyInfo_DateTime_DayOfWeek); _toTranslateMembers = _toTranslateMembers.Clone(); }
private void AddToDictionary(RegionMarker regionMarker) { KeyDictionary.Add(RegionMarkerCount.ToString(CultureInfo.InvariantCulture), regionMarker); RegionMarkerCount++; }