예제 #1
0
 /// <summary>Initializes a new instance of the Family class.</summary>
 protected Family(
     System.Collections.Immutable.ImmutableSortedSet <Person> members)
     : base()
 {
     this.members = members;
     this.Validate();
 }
예제 #2
0
        /// <summary>Returns a new instance with the Children property set to the specified value.</summary>
        public FileSystemDirectory WithChildren(System.Collections.Immutable.ImmutableSortedSet <FileSystemEntry> value)
        {
            if (value == this.Children)
            {
                return(this);
            }

            return(this.With(children: value));
        }
예제 #3
0
 /// <summary>Initializes a new instance of the FileSystemDirectory class.</summary>
 protected FileSystemDirectory(
     System.String pathSegment,
     System.Collections.Immutable.ImmutableSortedSet <FileSystemEntry> children)
     : base(
         pathSegment: pathSegment)
 {
     this.children = children;
     this.Validate();
 }
예제 #4
0
        /// <summary>Returns a new instance with the Members property set to the specified value.</summary>
        public Family WithMembers(System.Collections.Immutable.ImmutableSortedSet <Person> value)
        {
            if (value == this.Members)
            {
                return(this);
            }

            return(this.With(members: value));
        }
예제 #5
0
 /// <summary>Initializes a new instance of the Family class.</summary>
 protected Family(
     System.UInt32 identity,
     System.Collections.Immutable.ImmutableSortedSet <Person> members,
     ImmutableObjectGraph.Optional <bool> skipValidation = default(ImmutableObjectGraph.Optional <bool>))
 {
     this.identity = identity;
     this.members  = members;
     if (!skipValidation.Value)
     {
         this.Validate();
     }
 }
        protected static IComparer <T>?GetComparer <T>(System.Collections.Immutable.IImmutableSet <T> set)
        {
            return(set switch
            {
                // Unordered collections
                ImmutableSegmentedHashSet <T> => null,
                System.Collections.Immutable.ImmutableHashSet <T> => null,

                // Ordered collections
                System.Collections.Immutable.ImmutableSortedSet <T> s => s.KeyComparer,

                // Unknown
                _ => throw ExceptionUtilities.UnexpectedValue(set),
            });
예제 #7
0
            public static System.Collections.Immutable.ImmutableSortedSet <T> Replace <T>(System.Collections.Immutable.ImmutableSortedSet <T> set, T oldValue, T newValue)
            {
                var alteredSet = set.Remove(oldValue);

                return(alteredSet != set?alteredSet.Add(newValue) : set);
            }
예제 #8
0
 public static System.Collections.Immutable.ImmutableSortedSet <T> RemoveRange <T>(System.Collections.Immutable.ImmutableSortedSet <T> set, System.Collections.Generic.IEnumerable <T> values)
 {
     return(set.Except(values));
 }
예제 #9
0
 public static System.Collections.Immutable.ImmutableSortedSet <T> AddRange <T>(System.Collections.Immutable.ImmutableSortedSet <T> set, System.Collections.Generic.IEnumerable <T> values)
 {
     return(set.Union(values));
 }
예제 #10
0
 public static System.Collections.Immutable.ImmutableSortedSet <T> ResetContents <T>(System.Collections.Immutable.ImmutableSortedSet <T> set, System.Collections.Generic.IEnumerable <T> values)
 {
     return(set.SetEquals(values) ? set : set.Clear().Union(values));
 }