public bool Validate(string dlcName, GameTarget target, CaseInsensitiveDictionary <string> loadedFiles) { foreach (var outfit in Outfits) { // Check packages if (!loadedFiles.ContainsKey($@"{outfit.HenchPackage}.pcc")) { Log.Error($@"SquadmateMergeInfo failed validation: {outfit.HenchPackage}.pcc not found in game"); return(false); } if (Game.IsGame3()) { if (!loadedFiles.ContainsKey($@"{outfit.HenchPackage}_Explore.pcc")) { Log.Error($@"SquadmateMergeInfo failed validation: {outfit.HenchPackage}_Explore.pcc not found in game"); return(false); } } if (!loadedFiles.ContainsKey($@"SFXHenchImages_{dlcName}.pcc")) { Log.Error($@"SquadmateMergeInfo failed validation: SFXHenchImages_{dlcName}.pcc not found in game"); return(false); } } return(true); }
/// <summary> /// Creates a new <see cref="DataTable"/> with /// the specified name and adds it to the list /// of <see cref="Tables"/>. /// </summary> /// <param name="tableName"></param> /// <returns></returns> public DataTable AddTable(string tableName) { if (Tables.ContainsKey(tableName)) { throw new ArgumentException("Table already exists.", "tableName"); } return(AddTable(new DataTable(tableName))); }
public static void SelectSkin(string skinName, string defaultSkinName) { if ((s_AllowedSkinNames != null) && !s_AllowedSkinNames.ContainsKey(skinName)) { skinName = defaultSkinName; } string selectedSkinName = SkinManager.Default.GetValidSkinName(skinName); if (UserLookAndFeel.Default.SkinName != selectedSkinName) { UserLookAndFeel.Default.SkinName = selectedSkinName; } }
private void CheckObjectType(SchemaObject propertySchemaObject, KeyValuePair <string, object> kv, TestMessageResult testMessageResult, bool allowSubset) { CaseInsensitiveDictionary <object> innerObject = null; try { var json = JsonConvert.SerializeObject(kv.Value); innerObject = JsonConvert.DeserializeObject <CaseInsensitiveDictionary <object> >(json); } catch (Exception) { AddTypeError(testMessageResult, kv.Value.ToString(), kv.Key, "Object"); } if (propertySchemaObject.Properties != null) { foreach (var innerProperty in propertySchemaObject.Properties) { if (innerObject != null && innerObject.ContainsKey(innerProperty.Key)) { ChecksForMessage(innerProperty.Value, new KeyValuePair <string, object>($"{kv.Key}{ParentOfSymbol}{innerProperty.Key}", innerObject[innerProperty.Key]), testMessageResult, allowSubset); } else { if (!allowSubset) { AddNotFoundError(testMessageResult, $"{kv.Key}{ParentOfSymbol}{innerProperty.Key}"); } } } } }
/// <summary> ///A test for ContainsKey ///</summary> public void ContainsKeyTestHelper <TValue>() { var target = new CaseInsensitiveDictionary <TValue>(); string key = "a"; target.Add(key, default(TValue)); bool actual; actual = target.ContainsKey(key); Assert.IsTrue(actual); }
public void CaseInsensitiveDictionary_Construction_2() { CaseInsensitiveDictionary <int> dictionary = new CaseInsensitiveDictionary <int>(100); Assert.AreEqual(0, dictionary.Count); dictionary.Add("first", 1); dictionary.Add("second", 2); dictionary.Add("third", 3); Assert.AreEqual(3, dictionary.Count); Assert.IsTrue(dictionary.ContainsKey("first")); Assert.IsTrue(dictionary.ContainsKey("FIRST")); Assert.IsTrue(dictionary.ContainsKey("second")); Assert.IsTrue(dictionary.ContainsKey("SECOND")); Assert.IsTrue(dictionary.ContainsKey("third")); Assert.IsTrue(dictionary.ContainsKey("THIRD")); Assert.IsFalse(dictionary.ContainsKey("fourth")); Assert.IsFalse(dictionary.ContainsKey("FOURTH")); }
static void ProcessRecord ( [NotNull] MarcRecord record ) { string index = record.FM(903); if (string.IsNullOrEmpty(index)) { return; } if (_indexes.ContainsKey(index)) { Console.WriteLine("Repeating index: {0}", index); return; } _indexes.Add(index, false); string description = _GetDescription(record); if (string.IsNullOrEmpty(description)) { return; } description = description.Limit(500); IrbisData data = new IrbisData { Index = index.Limit(32), Description = description, Heading = _GetHeading(record), Title = _GetTitle(record), Author = _GetAuthors(record), Count = _GetExemplars(record), Year = _GetYear(record), Link = _GetLink(record), Type = _GetType(record) }; _database.Insert(data); Console.WriteLine("[{0}] {1}", record.Mfn, data.Description); }
public static string ContractDetails(CaseInsensitiveDictionary <SchemaObject> schema, bool fullDetails = false) { _displayContractRows = new List <string>(); var displayText = ""; if (!schema.ContainsKey("Contract")) { return(displayText); } var properties = schema["Contract"].Properties; BuildDisplayText(properties, fullDetails); displayText = string.Join("", _displayContractRows); return(displayText); }
/// <summary> /// Is given word is stopword? /// </summary> public bool IsStopWord ( [CanBeNull] string word ) { if (string.IsNullOrEmpty(word)) { return(true); } word = word.Trim(); if (string.IsNullOrEmpty(word)) { return(true); } return(_dictionary.ContainsKey(word)); }
public void CaseInsensitiveDictionary_Construction_3() { CaseInsensitiveDictionary <int> first = new CaseInsensitiveDictionary <int> { ["first"] = 1, ["second"] = 2, ["third"] = 3, }; CaseInsensitiveDictionary <int> second = new CaseInsensitiveDictionary <int>(first); Assert.AreEqual(first.Count, second.Count); Assert.IsTrue(second.ContainsKey("first")); Assert.IsTrue(second.ContainsKey("FIRST")); Assert.IsTrue(second.ContainsKey("second")); Assert.IsTrue(second.ContainsKey("SECOND")); Assert.IsTrue(second.ContainsKey("third")); Assert.IsTrue(second.ContainsKey("THIRD")); Assert.IsFalse(second.ContainsKey("fourth")); Assert.IsFalse(second.ContainsKey("FOURTH")); }
private static IList <string> GetDynamicClassInfoFromTable(DataTable table, string primaryKeyName, IList <string> displayColumnNames, CaseInsensitiveDictionary <string> filterColumnNamesAndValues, out XPClassInfo classInfo, out ReflectionDictionary reflectionDictionary) { reflectionDictionary = new ReflectionDictionary(); classInfo = new XPDataObjectClassInfo(reflectionDictionary.GetClassInfo(typeof(DynamicXpoObject)), table.TableName); DataColumn primaryKeyColumn = null; if (string.IsNullOrEmpty(primaryKeyName)) { primaryKeyColumn = table.Columns[0]; } else { foreach (DataColumn col in table.Columns) { if (string.Equals(col.ColumnName, primaryKeyName, StringComparison.OrdinalIgnoreCase)) { primaryKeyColumn = col; break; } } if (primaryKeyColumn == null) { throw new ArgException("The primary key column named \"{0}\" could not be found in the view \"{1}\"", primaryKeyName, table.TableName); } } if (CollectionUtils.IsNullOrEmpty(displayColumnNames)) { // Add all columns from the view, ignoring filterColumnNames as displayable, if found if (!CollectionUtils.IsNullOrEmpty(filterColumnNamesAndValues)) { displayColumnNames = new List <string>(table.Columns.Count); } else { displayColumnNames = null; } bool foundAnyFilterColumns = false; foreach (DataColumn col in table.Columns) { if (col == primaryKeyColumn) { XPCustomMemberInfo pkMemberInfo = classInfo.CreateMember(col.ColumnName, col.DataType, new KeyAttribute()); } else { classInfo.CreateMember(col.ColumnName, col.DataType); } if (displayColumnNames != null) { if (filterColumnNamesAndValues.ContainsKey(col.ColumnName)) { foundAnyFilterColumns = true; } else { displayColumnNames.Add(col.ColumnName); } } } return(foundAnyFilterColumns ? displayColumnNames : null); } else { bool addedPrimaryKeyCol = false; List <string> notFoundFilterColumnNames = null; if (!CollectionUtils.IsNullOrEmpty(filterColumnNamesAndValues)) { notFoundFilterColumnNames = new List <string>(filterColumnNamesAndValues.Keys); } foreach (string colName in displayColumnNames) { DataColumn foundColumn = FindColumn(table, colName); if (foundColumn == null) { throw new ArgException("The display column named \"{0}\" could not be found in the view \"{1}\"", colName, table.TableName); } if (foundColumn == primaryKeyColumn) { XPCustomMemberInfo pkMemberInfo = classInfo.CreateMember(foundColumn.ColumnName, foundColumn.DataType, new KeyAttribute()); addedPrimaryKeyCol = true; } else { classInfo.CreateMember(foundColumn.ColumnName, foundColumn.DataType); } RemoveNameFromList(notFoundFilterColumnNames, foundColumn.ColumnName); } if (!addedPrimaryKeyCol) { classInfo.CreateMember(primaryKeyColumn.ColumnName, primaryKeyColumn.DataType, new KeyAttribute()); RemoveNameFromList(notFoundFilterColumnNames, primaryKeyColumn.ColumnName); } if (!CollectionUtils.IsNullOrEmpty(notFoundFilterColumnNames)) { for (int i = notFoundFilterColumnNames.Count - 1; i >= 0; --i) { string colName = notFoundFilterColumnNames[i]; DataColumn foundColumn = FindColumn(table, colName); if (foundColumn != null) { classInfo.CreateMember(foundColumn.ColumnName, foundColumn.DataType); notFoundFilterColumnNames.RemoveAt(i); } } } return(displayColumnNames); } }
public async Task RunAsync() { var lineWithCommand = new Regex($"^{_context.CommandPrefix} (\\S+)(?: (\\S+))*$"); using (var stream = new StreamReader(new MemoryStream(Encoding.UTF8.GetBytes(_context.InputFile)))) { while (!stream.EndOfStream) { var line = await stream.ReadLineAsync(); if (line == null) { continue; } var commandCheck = lineWithCommand.Match(line); if (commandCheck.Success) { var groupEnumerator = commandCheck.Groups.GetEnumerator(); groupEnumerator.MoveNext(); groupEnumerator.MoveNext(); var group = groupEnumerator.Current as Group; if (group == null) { continue; } var command = group.Value; if (command == null) { continue; } if (!_instructions.TryGetValue(command, out var instruction)) { continue; } var parameters = new List <string>(); while (groupEnumerator.MoveNext()) { var value = (groupEnumerator.Current as Group)?.Value; if (!string.IsNullOrWhiteSpace(value)) { parameters.Add(value ?? throw new InvalidOperationException()); } } if (!_activeInstructions.ContainsKey(instruction.Command)) { _activeInstructions.Add(instruction.Command, instruction); } await instruction.InitializeInstructionAsync(_context, parameters.ToArray()); } else { foreach (var inst in _activeInstructions.Values) { await inst.HandleLineAsync(line); } } } } }