예제 #1
0
				/// <summary>
				/// Enumerate instances that pass the requested file
				/// </summary>
				/// <param name="filter">One or more state flags. Any set flag satisfies the filter</param>
				public IEnumerable<KeyValuePair<ObjectType, ObjectTypeStates>> EnumerateStates(ObjectTypeStates filter)
				{
					foreach (KeyValuePair<ObjectType, ObjectTypeStates> pair in myStates)
					{
						if (0 != (CalculateState(pair.Value) & filter))
						{
							yield return pair;
						}
					}
				}
예제 #2
0
				/// <summary>
				/// Set the specific state flag(s) for this object type and permutation
				/// </summary>
				/// <returns><see langword="true"/> if the state changes</returns>
				private bool SetState(ObjectType objectType, ObjectTypeStates state, uint permutationIdentifier)
				{
					Dictionary<ObjectType, ObjectTypeStates> dictionary = myStates;
					ObjectTypeStates existingState;
					if (dictionary.TryGetValue(objectType, out existingState))
					{
						uint existingPermutationIdentifier = (uint)existingState >> PermutationIdentifierShift; // Note that shift is sufficient without mask, C# 0 fills uint right shift
						if (existingPermutationIdentifier != permutationIdentifier)
						{
							existingState = (ObjectTypeStates)(((uint)existingState & ~(PermutationIdentifierBeforeShiftMask | (uint)ObjectTypeStates.PermutationState)) | (permutationIdentifier << PermutationIdentifierShift) | (uint)(existingState & ObjectTypeStates.PredecidedState));
						}
						else if ((existingState & state) == state)
						{
							return false;
						}
						state |= existingState;
					}
					else
					{
						state |= (ObjectTypeStates)(permutationIdentifier << PermutationIdentifierShift);
					}
					dictionary[objectType] = state;
					return true;
				}
예제 #3
0
				private ObjectTypeStates CalculateState(ObjectTypeStates storedState)
				{
					if (((uint)storedState >> PermutationIdentifierShift) == myPermutationIdentifier)
					{
						return storedState & (ObjectTypeStates.PredecidedState | ObjectTypeStates.PermutationState);
					}
					return storedState & ObjectTypeStates.PredecidedState;
				}
예제 #4
0
				/// <summary>
				/// Set the specific state flag(s) for this object type
				/// </summary>
				private void SetState(ObjectType objectType, ObjectTypeStates state)
				{
					Dictionary<ObjectType, ObjectTypeStates> dictionary = myStates;
					ObjectTypeStates existingState;
					if (dictionary.TryGetValue(objectType, out existingState))
					{
						if ((existingState & state) == state)
						{
							return;
						}
						state |= existingState;
					}
					dictionary[objectType] = state;
				}