示例#1
0
        /// <summary>
        /// Gets a read-only set.
        /// </summary>
        /// <param name="value">The set to wrap or return.  This must be non-null.</param>
        /// <returns>If the original <paramref name="value"/> is already read-only, this method
        /// returns it as is.  If it is not read-only, this method returns a read-only wrapper around it.</returns>
        public static ISet <T> AsReadOnly <T>(this ISet <T> value)
        {
            Conditions.RequireReference(value, nameof(value));

            ISet <T> result = value;

            if (result != null && !result.IsReadOnly)
            {
                result = new ReadOnlySet <T>(value);
            }

            return(result !);
        }
示例#2
0
 public ReadOnlySetDebugView(ReadOnlySet <T> set)
 {
     this.set = set ?? throw Exceptions.NewArgumentNullException(nameof(set));
 }