public WhenWeViolateFlagLimit() { x = new EnumerationFlags(StatesSample.One) { AllowMultipleSelections = false }; }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { System.Collections.IEnumerator rator = null; switch (flags) { case EnumerationFlags.Forward: rator = new Enumerator(this); break; case EnumerationFlags.Reverse: rator = new ReverseEnumerator(this); break; case EnumerationFlags.ForwardPosition: rator = new PostionEnumerator(this); break; case EnumerationFlags.ReversePosition: rator = new ReversePostionEnumerator(this); break; default: rator = new Enumerator(this); break; } flags = 0; return(rator); }
public void ItShouldWork() { var x = new EnumerationFlags(StatesSample.One); var json = JsonConvert.SerializeObject(x); var y = JsonConvert.DeserializeObject <EnumerationFlags>(json); Assert.True(y.HasFlag(StatesSample.One)); }
public void ItShouldWork() { var x = new EnumerationFlags(StatesSample.One); x.AddFlag(StatesSample.Three); var json = JsonConvert.SerializeObject(x); var y = JsonConvert.DeserializeObject <EnumerationFlags>(json); Assert.Equal(2, y.SelectedKeys.Count); Assert.Equal(StatesSample.Three, StatesSample.GetInstanceFromKey(y.SelectedKeys.Last())); }
/// <summary> /// Removes a object at a specified index /// </summary> /// <param name="index">the index to remove</param> public virtual void RemoveAt(int index) { if (index * 2 > count) { flags = EnumerationFlags.ReversePosition; index = count - index - 1; } else { flags = EnumerationFlags.ForwardPosition; } foreach (IPosition pos in this as System.Collections.ICollection) { if (index-- == 0) { Remove(pos); return; } } }
/// <summary> /// Inserts an object at a specified index /// </summary> /// <param name="index">the index to insert the object</param> /// <param name="obj">the object to insert</param> public virtual void Insert(int index, T obj) { if (index * 2 > count) { flags = EnumerationFlags.ReversePosition; index = count - index - 1; } else { flags = EnumerationFlags.ForwardPosition; } foreach (Position pos in this as System.Collections.ICollection) { if (index-- == 0) { version++; count++; Position p = new Position(); p.prev = pos; p.next = pos.next; p.prev.next = p; pos.prev = p; p.data = obj; Type t = obj.GetType(); if (keytype == null) { keytype = t; } else if (keytype != t) { Debug.Fail("Invalid condition"); } reversemapping.Add(obj, p); return; } } }
/// <summary> /// Returns an enumerator for the list /// </summary> /// <returns>the enumerator</returns> public virtual IEnumerator <T> GetEnumerator() { IEnumerator <T> rator = null; switch (flags) { case EnumerationFlags.Forward: rator = new Enumerator(this); break; case EnumerationFlags.Reverse: rator = new ReverseEnumerator(this); break; default: rator = new Enumerator(this); break; } flags = 0; return(rator); }
static bool CryptEnumerateContainerNames(ProviderHandle providerHandle, byte[] containerName, ref int containerNameLength_Bytes, EnumerationFlags flags) { return(CryptGetProvParam(providerHandle, CryptGetProvParamParameterTypes.PP_ENUMCONTAINERS, containerName, ref containerNameLength_Bytes, (uint)flags)); }
public WhenWeCreateAFlaggedState() { x = new EnumerationFlags(StatesSample.One); }
public WhenWeAddASecondState() { x = new EnumerationFlags(StatesSample.One); x.AddFlag(StatesSample.Two); }
public WhenWeRemoveAState() { x = new EnumerationFlags(StatesSample.One); x.AddFlag(StatesSample.Two); x.RemoveFlag(StatesSample.One); }
public void ItShouldNotThrowAnError() { var x = new EnumerationFlags(StatesSample.One); x.RemoveFlag(StatesSample.One); }
/// <summary> /// Enumerate the children. /// Do not use this method in performance critical code. Makes garbadge ! /// </summary> /// <param name="enumerationFlags">The enumeration flags.</param> /// <returns></returns> public IEnumerable<MyEntity> EnumChildren(EnumerationFlags enumerationFlags = EnumerationFlags.None) { for (int i = 0; i < this.m_children.Count; i++) { var child = this.m_children[i]; yield return child; if ((enumerationFlags & EnumerationFlags.Hierarchically) != 0) { foreach (var subChild in child.EnumChildren(enumerationFlags)) { yield return subChild; } } } }