Пример #1
0
 public override HashSet <T> ConvertFromSurrogate(ref HashSetSurrogate <T> surrogate)
 {
     if (surrogate.Values is null)
     {
         return(null);
     }
     else
     {
         if (surrogate.Comparer is object)
         {
             return(new HashSet <T>(surrogate.Values, surrogate.Comparer));
         }
         else
         {
             return(new HashSet <T>(surrogate.Values));
         }
     }
 }
Пример #2
0
        public override void ConvertToSurrogate(HashSet <T> value, ref HashSetSurrogate <T> surrogate)
        {
            if (value is null)
            {
                surrogate = default;
                return;
            }
            else
            {
                surrogate = new HashSetSurrogate <T>
                {
                    Values = new List <T>(value)
                };

                if (!ReferenceEquals(value.Comparer, EqualityComparer <T> .Default))
                {
                    surrogate.Comparer = value.Comparer;
                }
            }
        }