Exemple #1
0
 /// <summary>
 /// Deserializes instance of this type.
 /// </summary>
 /// <param name="info"></param>
 /// <param name="context"></param>
 protected FlagCollection(SerializationInfo info, StreamingContext context)
     : base(info.GetBoolean("IsLocked"))
 {
     converter = (Biconverter <TFlag, bool>)
                 info.GetValue("AdvancedConverter", typeof(Biconverter <TFlag, bool>));
     keys         = (List <TKey>)info.GetValue("Keys", typeof(List <TKey>));
     readOnlyKeys = new ReadOnlyList <TKey>(keys);
     flags        = new BitVector32(info.GetInt32("Flags"));
 }
Exemple #2
0
 /// <summary>
 /// Initializes a new instance of this type.
 /// </summary>
 /// <param name="converter"><see cref="Converter"/> property value.</param>
 /// <param name="enumerable">Initial content of collection.</param>
 public FlagCollection(Biconverter <TFlag, bool> converter, IEnumerable <KeyValuePair <TKey, TFlag> > enumerable)
     : this()
 {
     this.converter = converter;
     foreach (KeyValuePair <TKey, TFlag> pair in enumerable)
     {
         Add(pair.Key, pair.Value);
     }
 }
        public void ConstructorTest()
        {
            Biconverter <int, bool> bi = new Biconverter <int, bool>(
                delegate(int value) { return(value > 0); },
                delegate(bool value) { return(value ? 1 : -1); });

            Assert.AreEqual(true, bi.ConvertForward(1));
            Assert.AreEqual(false, bi.ConvertForward(0));
            Assert.AreEqual(1, bi.ConvertBackward(true));
            Assert.AreEqual(-1, bi.ConvertBackward(false));
        }
Exemple #4
0
 /// <summary>
 /// Initializes new instance of this type.
 /// </summary>
 /// <param name="maxSize"><see cref="MaxSize"/> property value.</param>
 /// <param name="keyExtractor"><see cref="ICache{TKey, TItem}.KeyExtractor"/> property value.</param>
 /// <param name="cacheConverter"><see cref="CacheConverter"/> property value.</param>
 /// <param name="chainedCache"><see cref="ChainedCache"/> property value.</param>
 public LruCache(long maxSize, Converter <TItem, TKey> keyExtractor,
                 Biconverter <TItem, TCached> cacheConverter, ICache <TKey, TItem> chainedCache)
 {
     if (maxSize <= 0)
     {
         ArgumentValidator.EnsureArgumentIsInRange(maxSize, 1, long.MaxValue, "maxSize");
     }
     ArgumentValidator.EnsureArgumentNotNull(keyExtractor, "keyExtractor");
     this.maxSize        = maxSize;
     this.KeyExtractor   = keyExtractor;
     this.cacheConverter = cacheConverter;
     this.chainedCache   = chainedCache;
     // deque = new TopDeque<TKey, TCached>(1 + (int) maxSize);
     deque = new TopDeque <TKey, TCached>();
 }
Exemple #5
0
 /// <summary>
 /// Initializes a new instance of this type.
 /// </summary>
 /// <param name="maxSize"><see cref="MaxSize"/> property value.</param>
 /// <param name="keyExtractor"><see cref="ICache{TKey, TItem}.KeyExtractor"/> property value.</param>
 /// <param name="cacheConverter"><see cref="CacheConverter"/> property value.</param>
 public LruCache(long maxSize, Converter <TItem, TKey> keyExtractor, Biconverter <TItem, TCached> cacheConverter)
     : this(maxSize, keyExtractor, cacheConverter, null)
 {
 }
Exemple #6
0
        // Constructors

        /// <summary>
        /// Initializes a new instance of this type.
        /// </summary>
        /// <param name="converter"><see cref="Converter"/> property value.</param>
        public FlagCollection(Biconverter <TFlag, bool> converter)
            : this()
        {
            this.converter = converter;
        }