public PointerDeviceState(IPointerDevice pointerDevice) { this.SourceDevice = pointerDevice; PressedPointers = new ReadOnlySet <PointerPoint>(pressedPointers); ReleasedPointers = new ReadOnlySet <PointerPoint>(releasedPointers); DownPointers = new ReadOnlySet <PointerPoint>(downPointers); }
/// <summary> /// Gets the type hierarchy for the specified type. /// </summary> /// <param name="typeId">The type identifier.</param> /// <param name="cache">The cache to use.</param> /// <param name="descendants">if set to <c>true</c> then get descendants, else get ancestors.</param> /// <param name="sorted">if set to <c>true</c> [sorted].</param> /// <returns> /// The requested type hierarchy. /// </returns> private ICollection <long> GetTypeHierarchy(long typeId, ICache <long, ICollection <long> > cache, bool descendants, bool sorted) { ICollection <long> types; // Hit the cache first if (cache.TryGetValue(typeId, out types)) { return(types); } lock (_syncRoot) { // Try the cache again if (cache.TryGetValue(typeId, out types)) { return(types); } // Get from the database and update the cache types = GetTypeHierarchyFromDatabase(typeId, descendants, sorted); if (!sorted) { // Make the set readonly types = new ReadOnlySet <long>(types as ISet <long>); } cache[typeId] = types; } return(types); }
/// <summary> /// /// </summary> /// <param name="domain"></param> /// <returns></returns> private IEnumerable <double> GetModifiedWeights(ReadOnlySet <int> domain) { for (int i = 0; i < _weights.Length; i++) { yield return(domain.Contains(i) ? _weights[i] : 0.0); } }
/// <summary> /// Updates the tag instance's state from a block of tag data. /// </summary> /// <param name="data">The tag data.</param> /// <param name="dataOffset">The offset of the tag data relative to the tag instance's header.</param> internal void Update(CachedTagData data, uint dataOffset) { Group = data.Group; DefinitionOffset = data.MainStructOffset + dataOffset; Dependencies = new ReadOnlySet <int>(new HashSet <int>(data.Dependencies)); _pointerOffsets = data.PointerFixups.Select(fixup => fixup.WriteOffset + dataOffset).ToList(); _resourceOffsets = data.ResourcePointerOffsets.Select(offset => offset + dataOffset).ToList(); }
public static void AddInterests <TKey, TInterest>( this IInterestMap <TKey, TInterest> map, TInterest interest, IReadOnlySet <TKey> addTo) { Contracts.Requires.That(map != null); Contracts.Requires.That(addTo.AllAndSelfNotNull()); map.UpdateInterests(interest, addTo, ReadOnlySet.Empty <TKey>()); }
public static void RemoveInterests <TKey, TInterest>( this IInterestMap <TKey, TInterest> map, TInterest interest, IReadOnlySet <TKey> removeFrom) { Contracts.Requires.That(map != null); Contracts.Requires.That(removeFrom.AllAndSelfNotNull()); map.UpdateInterests(interest, ReadOnlySet.Empty <TKey>(), removeFrom); }
public void CountTest() { var s = new ReadOnlySet <int>(new HashSet <int> { 10, 42 }); Assert.AreEqual(2, s.Count); }
public void GetEnumeratorTest() { var roSet = new ReadOnlySet <long>(new HashSet <long>()); Assert.DoesNotThrow(() => roSet.GetEnumerator()); Assert.DoesNotThrow(() => ((IEnumerable)roSet).GetEnumerator()); }
internal IrcChannel(string name) { Name = name; type = IrcChannelType.Unspecified; modes = new HashSet<char>(); Modes = new ReadOnlySet<char>(modes); users = new Collection<IrcChannelUser>(); Users = new IrcChannelUserCollection(this, users); }
private void TestMethod(SortedSet <int>[] sets, Action <ReadOnlySet <int>, ISet <int> > testAction) { foreach (ISet <int> set in sets) { ReadOnlySet <int> readOnlySet = new ReadOnlySet <int>(set); testAction(readOnlySet, set); } }
internal IrcLocalUser(string nickName, string distribution, string description) : base(true, nickName, null, null) { IsService = true; modes = new HashSet <char>(); Modes = new ReadOnlySet <char>(modes); ServiceDistribution = distribution; ServiceDescription = description; }
internal IrcLocalUser(string nickName, string distribution, string description) : base(true, nickName, null, null) { IsService = true; modes = new HashSet<char>(); Modes = new ReadOnlySet<char>(modes); ServiceDistribution = distribution; ServiceDescription = description; }
internal IrcChannel(string name) { this.name = name; this.type = IrcChannelType.Unspecified; this.modes = new HashSet<char>(); this.modesReadOnly = new ReadOnlySet<char>(this.modes); this.users = new Collection<IrcChannelUser>(); this.usersReadOnly = new IrcChannelUserCollection(this, this.users); }
internal IrcChannel(string name) { this.name = name; this.type = IrcChannelType.Unspecified; this.modes = new HashSet <char>(); this.modesReadOnly = new ReadOnlySet <char>(this.modes); this.users = new Collection <IrcChannelUser>(); this.usersReadOnly = new IrcChannelUserCollection(this, this.users); }
internal IrcChannelUser(IrcUser user, IEnumerable<char> modes = null) { this.user = user; this.modes = new HashSet<char>(); this.modesReadOnly = new ReadOnlySet<char>(this.modes); if (modes != null) this.modes.AddRange(modes); }
public DataNamesAttribute([NotNull] params string[] valueNames) { foreach (string valueName in valueNames.SkipNullOrEmptyTrim()) { ValueNamesInternal.Add(valueName); } ValueNames = new ReadOnlySet <string>(ValueNamesInternal); }
internal IrcLocalUser(string nickName, string distribution, string description) : base(true, nickName, null, null) { this.isService = true; this.modes = new HashSet<char>(); this.modesReadOnly = new ReadOnlySet<char>(this.modes); this.distribution = distribution; this.description = description; }
internal IrcLocalUser(string nickName, string userName, string realName, IEnumerable<char> modes = null) : base(true, nickName, userName, realName) { this.isService = false; this.modes = new HashSet<char>(); this.modesReadOnly = new ReadOnlySet<char>(this.modes); if (modes != null) this.modes.AddRange(modes); }
public void ContainsTest() { var s = new ReadOnlySet <string>(new HashSet <string> { "ABC", "pqr" }); Assert.IsTrue(s.Contains("ABC")); Assert.IsTrue(s.Contains("pqr")); }
public MouseDeviceState(PointerDeviceState pointerState, IMouseDevice mouseDevice) { this.PointerState = pointerState; this.MouseDevice = mouseDevice; DownButtons = new ReadOnlySet <MouseButton>(downButtons); PressedButtons = new ReadOnlySet <MouseButton>(pressedButtons); ReleasedButtons = new ReadOnlySet <MouseButton>(releasedButtons); }
internal IrcLocalUser(string nickName, string distribution, string description) : base(true, nickName, null, null) { this.isService = true; this.modes = new HashSet <char>(); this.modesReadOnly = new ReadOnlySet <char>(this.modes); this.distribution = distribution; this.description = description; }
internal IrcChannel(string name) { Name = name; type = IrcChannelType.Unspecified; modes = new HashSet <char>(); Modes = new ReadOnlySet <char>(modes); users = new Collection <IrcChannelUser>(); Users = new IrcChannelUserCollection(this, users); }
public void ContainsTest() { var hs = new HashSet <long> { 5, 6, 7 }; var roSet = new ReadOnlySet <long>(hs); Assert.DoesNotThrow(() => roSet.Contains(5)); }
public void TestIsSupersetOf_IsNotSupersetOf_ReturnsFalse() { ReadOnlySet <int> set = new ReadOnlySet <int>(new HashSet <int>() { 1, 2, 3 }); bool result = set.IsSupersetOf(new int[] { 1, 2, 3, 4 }); Assert.IsFalse(result, "The set should not have been a superset."); }
public void CopyToTest() { var hs = new HashSet <long> { 5, 6, 7 }; var roSet = new ReadOnlySet <long>(hs); var array = new long[3]; Assert.DoesNotThrow(() => roSet.CopyTo(array, 0)); }
public void TestIsSubsetOf_IsSubset_ReturnsTrue() { ReadOnlySet <int> set = new ReadOnlySet <int>(new HashSet <int>() { 1, 2, 3, 4 }); bool result = set.IsSubsetOf(new int[] { 1, 2, 3, 4, 5 }); Assert.IsTrue(result, "The set should have been a subset."); }
public void TestContains_ItemMissing_ReturnsFalse() { ReadOnlySet <int> set = new ReadOnlySet <int>(new HashSet <int>() { 1, 2, 3 }); bool result = set.Contains(0); Assert.IsFalse(result, "The item should not have been found."); }
public void TestOverlaps_NoSharedItems_ReturnsFalse() { ReadOnlySet <int> set = new ReadOnlySet <int>(new HashSet <int>() { 1, 2, 3, 4, 5 }); bool result = set.Overlaps(new int[] { 7, 8 }); Assert.IsFalse(result, "The set should not have overlapped with the collection."); }
public void AddTest() { var roSet = new ReadOnlySet <long>(new HashSet <long>()); Assert.Throws <InvalidOperationException>(() => roSet.Add(5)); var iCollection = roSet as ICollection <long>; Assert.Throws <InvalidOperationException>(() => iCollection.Add(5)); }
public void TestGetEnumerator_Explicit_EnumeratesAllItems() { IEnumerable set = new ReadOnlySet <int>(new HashSet <int>() { 1, 2 }); Assert.IsTrue(enumerate(set).Cast <int>().Contains(1), "The first item was not present."); Assert.IsTrue(enumerate(set).Cast <int>().Contains(2), "The second item was not present."); }
public void TestContains_ItemExists_ReturnsTrue() { ReadOnlySet <int> set = new ReadOnlySet <int>(new HashSet <int>() { 1, 2, 3 }); bool result = set.Contains(2); Assert.IsTrue(result, "The item should have been found."); }
public void TestSetEquals_DifferentItems_ReturnsFalse() { ReadOnlySet <int> set = new ReadOnlySet <int>(new HashSet <int>() { 1, 2, 3, 4, 5 }); bool result = set.SetEquals(new int[] { 1, 2, 3, 4 }); Assert.IsFalse(result, "The sets should not have been equal."); }
public void TestSetEquals_SameItems_ReturnsTrue() { ReadOnlySet <int> set = new ReadOnlySet <int>(new HashSet <int>() { 1, 2, 3, 4, 5 }); bool result = set.SetEquals(new int[] { 1, 2, 3, 4, 5 }); Assert.IsTrue(result, "The sets should have been equal."); }
public UpdateParameterData UpdateParameterAction() { if (IsValid() != null) { throw new InvalidOperationException("Current enum selection is invalid"); } ReadOnlySet <Guid> selection = new ReadOnlySet <Guid>(m_comboBoxes.TakeWhile((c, i) => i < m_comboBoxes.Count - 1).Select(c => c.SelectedItem.Contents)); return(m_parameter.SetValueAction(selection)); }
internal IrcLocalUser(string nickName, string userName, string realName, IEnumerable <char> modes = null) : base(true, nickName, userName, realName) { this.isService = false; this.modes = new HashSet <char>(); this.modesReadOnly = new ReadOnlySet <char>(this.modes); if (modes != null) { this.modes.AddRange(modes); } }
internal IrcChannelUser(IrcUser user, IEnumerable <char> modes = null) { this.user = user; this.modes = new HashSet <char>(); this.modesReadOnly = new ReadOnlySet <char>(this.modes); if (modes != null) { this.modes.AddRange(modes); } }
public void Freeze() { _frozen = true; DirectlyUsedVariables = new ReadOnlySet<IVariable>(DirectlyUsedVariables); DirectlyDeclaredVariables = new ReadOnlySet<IVariable>(DirectlyDeclaredVariables); NestedFunctions = NestedFunctions.AsReadOnly(); }
private void _loadModel(string profileName, IEnumerable<string> moduleNames) { LoadingPopup.IsOpen = true; LeadingVersion = new Version(); LeadingTimestamp = DateTime.MinValue; var profile = new BplProfile(profileName); profile.Add(typeof(BplObject).Assembly); foreach (var name in moduleNames) { var assembly = AppDomain.CurrentDomain.Load(Path.GetFileNameWithoutExtension(name)); profile.Add(assembly); var date = File.GetLastWriteTime(Path.Combine(AssembliesFolder, name)); if (date > LeadingTimestamp) LeadingTimestamp = date; var version = assembly.GetName().Version; if (version > LeadingVersion) LeadingVersion = version; } profile.Seal(); ViewName = null; BplLanguage.Load(profile); BplLanguage.LoadTaxonomies(TaxonomiesFolder); LoadedClasses = new ReadOnlySet<BplClass>(BplLanguage.Classes); _selectedClasses = new HashSet<BplClass>(); SelectedClasses = new ReadOnlySet<BplClass>(_selectedClasses); _hiddenClasses = new HashSet<BplClass>(); HiddenClasses = new ReadOnlySet<BplClass>(_hiddenClasses); _applyClassFilter(); _onModelLoaded(); GuiTimer.StartAfterRender(t => { try { if (File.Exists(SettingsFile)) { var snapshot = DiagramSnapshot.Load(SettingsFile); snapshot.Restore(DiagramViewer); } } catch { } }); GuiTimer.StartAfterRender(t => _loadDocumentation()); }
/// <summary>Creates a new <see cref="DiagramBlock"/> instance.</summary> public DiagramBlock(DiagramCanvas canvas, long id, BplNamespace bplNamespace) : base(canvas, id) { Namespace = bplNamespace; _nodes = new HashSet<DiagramNode>(); Nodes = new ReadOnlySet<DiagramNode>(_nodes); }
public void ReadOnlyHashSet_is_readonly_and_throws_for_mutating_methods() { var set = new ReadOnlySet<string>(new HashSet<string>()); Assert.True(set.IsReadOnly); Assert.Equal( Strings.DbPropertyValues_PropertyValueNamesAreReadonly, Assert.Throws<NotSupportedException>(() => ((ICollection<string>)set).Add("")).Message); Assert.Equal( Strings.DbPropertyValues_PropertyValueNamesAreReadonly, Assert.Throws<NotSupportedException>(() => set.Add("")).Message); Assert.Equal( Strings.DbPropertyValues_PropertyValueNamesAreReadonly, Assert.Throws<NotSupportedException>(() => set.Clear()).Message); Assert.Equal( Strings.DbPropertyValues_PropertyValueNamesAreReadonly, Assert.Throws<NotSupportedException>(() => set.Remove("")).Message); }
/// <summary> /// Updates the tag instance's state from a block of tag data. /// </summary> /// <param name="data">The tag data.</param> /// <param name="dataOffset">The offset of the tag data relative to the tag instance's header.</param> internal void Update(TagData data, uint dataOffset) { Group = data.Group; MainStructOffset = data.MainStructOffset + dataOffset; Dependencies = new ReadOnlySet<int>(new HashSet<int>(data.Dependencies)); _pointerOffsets = data.PointerFixups.Select(fixup => fixup.WriteOffset + dataOffset).ToList(); _resourceOffsets = data.ResourcePointerOffsets.Select(offset => offset + dataOffset).ToList(); }
public void ReadOnlyHashSet_calls_underlying_Set_methods() { var mockSet = new Mock<ISet<string>>(); var mockIEnumerable = mockSet.As<IEnumerable>(); var set = new ReadOnlySet<string>(mockSet.Object); var other = new HashSet<string>(); var array = new string[0]; set.CopyTo(array, 0); mockSet.Verify(s => s.CopyTo(array, 0), Times.Once()); set.ExceptWith(other); mockSet.Verify(s => s.ExceptWith(other), Times.Once()); set.IntersectWith(other); mockSet.Verify(s => s.IntersectWith(other), Times.Once()); set.IsProperSubsetOf(other); mockSet.Verify(s => s.IsProperSubsetOf(other), Times.Once()); set.IsProperSupersetOf(other); mockSet.Verify(s => s.IsProperSupersetOf(other), Times.Once()); set.IsSubsetOf(other); mockSet.Verify(s => s.IsSubsetOf(other), Times.Once()); set.IsSupersetOf(other); mockSet.Verify(s => s.IsSupersetOf(other), Times.Once()); set.Overlaps(other); mockSet.Verify(s => s.Overlaps(other), Times.Once()); set.SetEquals(other); mockSet.Verify(s => s.SetEquals(other), Times.Once()); set.SymmetricExceptWith(other); mockSet.Verify(s => s.SymmetricExceptWith(other), Times.Once()); set.UnionWith(other); mockSet.Verify(s => s.UnionWith(other), Times.Once()); set.Contains("Foo"); mockSet.Verify(s => s.Contains("Foo"), Times.Once()); var _ = set.Count; mockSet.Verify(s => s.Count, Times.Exactly(2)); mockSet.Setup(s => s.GetEnumerator()).Returns(Enumerable.Empty<string>().GetEnumerator()); set.GetEnumerator(); mockSet.Verify(s => s.GetEnumerator(), Times.Once()); mockIEnumerable.Setup(s => s.GetEnumerator()).Returns(Enumerable.Empty<string>().GetEnumerator()); ((IEnumerable)set).GetEnumerator(); mockIEnumerable.Verify(s => s.GetEnumerator(), Times.Once()); }
/// <summary> /// Reads the header for the tag instance from a stream. /// </summary> /// <param name="reader">The stream to read from.</param> internal void ReadHeader(BinaryReader reader) { Checksum = reader.ReadUInt32(); // 0x00 uint32 checksum TotalSize = reader.ReadUInt32(); // 0x04 uint32 total size var numDependencies = reader.ReadInt16(); // 0x08 int16 dependencies count var numDataFixups = reader.ReadInt16(); // 0x0A int16 data fixup count var numResourceFixups = reader.ReadInt16(); // 0x0C int16 resource fixup count reader.BaseStream.Position += 2; // 0x0E int16 (padding) MainStructOffset = reader.ReadUInt32(); // 0x10 uint32 main struct offset var groupTag = new Tag(reader.ReadInt32()); // 0x14 int32 group tag var parentGroupTag = new Tag(reader.ReadInt32()); // 0x18 int32 parent group tag var grandparentGroupTag = new Tag(reader.ReadInt32()); // 0x1C int32 grandparent group tag var groupName = new StringId(reader.ReadUInt32()); // 0x20 uint32 group name stringid Group = new TagGroup(groupTag, parentGroupTag, grandparentGroupTag, groupName); // Read dependencies var dependencies = new HashSet<int>(); for (var j = 0; j < numDependencies; j++) dependencies.Add(reader.ReadInt32()); Dependencies = new ReadOnlySet<int>(dependencies); // Read offsets _pointerOffsets = new List<uint>(numDataFixups); for (var j = 0; j < numDataFixups; j++) _pointerOffsets.Add(PointerToOffset(reader.ReadUInt32())); _resourceOffsets = new List<uint>(numResourceFixups); for (var j = 0; j < numResourceFixups; j++) _resourceOffsets.Add(PointerToOffset(reader.ReadUInt32())); }
public TypeOOPEmulationPhase(IEnumerable<ITypeDefinition> dependentOnTypes, IEnumerable<JsStatement> statements) { DependentOnTypes = new ReadOnlySet<ITypeDefinition>(dependentOnTypes != null ? new HashSet<ITypeDefinition>(dependentOnTypes) : new HashSet<ITypeDefinition>()); Statements = statements.AsReadOnly(); }
internal static void TestCorrectness() { ISet<int> set = new HashSet<int>() { 1, 2, 3, 4, 5 }; ReadOnlySet<int> roset = new ReadOnlySet<int>(set); //roset.Add(6); // should be error Console.WriteLine(roset.Contains(1)); // should be correct Console.WriteLine(roset.Count); }