public void Seal(IConfigurationProvider configurationProvider) { if (_sealed) { return; } _sealed = true; _inheritedTypeMaps.ForAll(tm => _includedMembersTypeMaps.UnionWith(tm._includedMembersTypeMaps)); foreach (var includedMemberTypeMap in _includedMembersTypeMaps) { includedMemberTypeMap.TypeMap.Seal(configurationProvider); ApplyIncludedMemberTypeMap(includedMemberTypeMap); } _inheritedTypeMaps.ForAll(ApplyInheritedTypeMap); _orderedPropertyMaps = PropertyMaps.OrderBy(map => map.MappingOrder).ToArray(); _propertyMaps.Clear(); MapExpression = CreateMapperLambda(configurationProvider, null); Features.Seal(configurationProvider); }
public void WatchDirectories(IEnumerable<FullPath> directories) { lock (_watchersLock) { var oldSet = new HashSet<FullPath>(_watchers.Keys); var newSet = new HashSet<FullPath>(directories); var removed = new HashSet<FullPath>(oldSet); removed.ExceptWith(newSet); var added = new HashSet<FullPath>(newSet); added.ExceptWith(oldSet); removed.ForAll(RemoveDirectory); added.ForAll(AddDirectory); } }
public void WatchDirectories(IEnumerable <DirectoryName> directories) { lock (_watchersLock) { var oldSet = new HashSet <DirectoryName>(_watchers.Keys); var newSet = new HashSet <DirectoryName>(directories); var removed = new HashSet <DirectoryName>(oldSet); removed.ExceptWith(newSet); var added = new HashSet <DirectoryName>(newSet); added.ExceptWith(oldSet); removed.ForAll(x => RemoveDirectory(x)); added.ForAll(x => AddDirectory(x)); } }
public void WatchDirectories(IEnumerable <FullPath> directories) { lock (_watchersLock) { var oldSet = new HashSet <FullPath>(_watchers.Keys); var newSet = new HashSet <FullPath>(directories); var removed = new HashSet <FullPath>(oldSet); removed.ExceptWith(newSet); var added = new HashSet <FullPath>(newSet); added.ExceptWith(oldSet); removed.ForAll(RemoveDirectory); added.ForAll(AddDirectory); } }
protected void WatchDirectoriesImpl(IEnumerable <FullPath> directories) { var oldSet = new HashSet <FullPath>(StateHost.WatcherDictionary.Keys); var newSet = new HashSet <FullPath>(directories); var removed = new HashSet <FullPath>(oldSet); removed.ExceptWith(newSet); var added = new HashSet <FullPath>(newSet); added.ExceptWith(oldSet); removed.ForAll(RemoveDirectory); added.ForAll(AddDirectory); }
public void WatchDirectories(IEnumerable<DirectoryName> directories) { lock (_watchersLock) { var oldSet = new HashSet<DirectoryName>(_watchers.Keys); var newSet = new HashSet<DirectoryName>(directories); var removed = new HashSet<DirectoryName>(oldSet); removed.ExceptWith(newSet); var added = new HashSet<DirectoryName>(newSet); added.ExceptWith(oldSet); removed.ForAll(x => RemoveDirectory(x)); added.ForAll(x => AddDirectory(x)); } }
/// <summary> /// Assigns all player's initial relationships returning a lookup table of initial relationships of all AIPlayers with the User. /// </summary> /// <param name="existingDebugUnitCreators">The existing debug unit creators.</param> /// <returns></returns> private IDictionary<DiplomaticRelationship, IList<Player>> AssignAllPlayerInitialRelationships(ADebugUnitCreator[] existingDebugUnitCreators) { Player userPlayer = _gameMgr.UserPlayer; IList<Player> aiPlayers = _gameMgr.AIPlayers; int aiPlayerQty = aiPlayers.Count; var aiOwnedDebugUnitCreators = existingDebugUnitCreators.Where(uc => !uc.EditorSettings.IsOwnerUser); var desiredAiUserRelationships = aiOwnedDebugUnitCreators.Select(uc => uc.EditorSettings.DesiredRelationshipWithUser.Convert()); HashSet<DiplomaticRelationship> uniqueDesiredAiUserRelationships = new HashSet<DiplomaticRelationship>(desiredAiUserRelationships, DiplomaticRelationshipEqualityComparer.Default); //D.Log(ShowDebugLog, "{0}: Unique desired AI/User Relationships = {1}.", DebugName, uniqueDesiredAiUserRelationships.Select(r => r.GetValueName()).Concatenate()); // Setup initial AIPlayer <-> User relationships derived from editorCreators.. Dictionary<DiplomaticRelationship, IList<Player>> aiPlayerInitialUserRelationsLookup = new Dictionary<DiplomaticRelationship, IList<Player>>(aiPlayerQty, DiplomaticRelationshipEqualityComparer.Default); Stack<Player> unassignedAIPlayers = new Stack<Player>(aiPlayers); uniqueDesiredAiUserRelationships.ForAll(aiUserRelationship => { if (unassignedAIPlayers.Count > Constants.Zero) { var aiPlayer = unassignedAIPlayers.Pop(); //D.Log(ShowDebugLog, "{0} about to set {1}'s user relationship to {2}.", DebugName, aiPlayer, aiUserRelationship.GetValueName()); userPlayer.SetInitialRelationship(aiPlayer, aiUserRelationship); // will auto handle both assignments aiPlayerInitialUserRelationsLookup.Add(aiUserRelationship, new List<Player>() { aiPlayer }); } }); // ..then assign any aiPlayers that have not been assigned an initial user relationship to Neutral if (unassignedAIPlayers.Count > Constants.Zero) { IList<Player> neutralAiPlayers; if (!aiPlayerInitialUserRelationsLookup.TryGetValue(DiplomaticRelationship.Neutral, out neutralAiPlayers)) { neutralAiPlayers = new List<Player>(unassignedAIPlayers.Count); aiPlayerInitialUserRelationsLookup.Add(DiplomaticRelationship.Neutral, neutralAiPlayers); } unassignedAIPlayers.ForAll(aiPlayer => { //D.Log(ShowDebugLog, "{0} about to set {1}'s user relationship to {2}.", DebugName, aiPlayer, DiplomaticRelationship.Neutral.GetValueName()); userPlayer.SetInitialRelationship(aiPlayer); // Neutral, will auto handle both assignments neutralAiPlayers.Add(aiPlayer); }); } // Set initial AIPlayer <-> AIPlayer relationships to Neutral for (int j = 0; j < aiPlayerQty; j++) { for (int k = j + 1; k < aiPlayerQty; k++) { Player jAiPlayer = aiPlayers[j]; Player kAiPlayer = aiPlayers[k]; jAiPlayer.SetInitialRelationship(kAiPlayer); // Neutral, will auto handle both assignments } } return aiPlayerInitialUserRelationsLookup; }