コード例 #1
0
ファイル: Keys.cs プロジェクト: renber/AvisNet
        /// <summary>
        /// Lookup/create a key set for a single key scheme.
        /// </summary>
        /// <param name="scheme"></param>
        /// <returns></returns>
        private DualKeySet NewKeysetFor(DualKeyScheme scheme)
        {
            IKeySet keys;

            if (!keySets.TryGetValue(scheme, out keys))
            {
                keys = new DualKeySet();

                keySets.Add(scheme, keys);
            }

            return (DualKeySet)keys;
        }
コード例 #2
0
ファイル: Keys.cs プロジェクト: renber/AvisNet
        /// <summary>
        /// Remove a key for dual key scheme.
        /// </summary>
        /// <param name="scheme">The key scheme.</param>
        /// <param name="subset">The key subset (PRODUCER or CONSUMER) to remove the key from.</param>
        /// <param name="key">The key to remove.</param>
        public virtual void Remove(DualKeyScheme scheme,
                            DualKeyScheme.Subset subset,
                            Key key)
        {
            IKeySet keySet;

            if (keySets.TryGetValue(scheme, out keySet))
            {
                ((DualKeySet)keySet).KeysFor(subset).Remove(key);

                if (keySet.IsEmpty)
                    keySets.Remove(scheme);
            }
        }
コード例 #3
0
ファイル: Keys.cs プロジェクト: renber/AvisNet
 /// <summary>
 /// Add a key for dual key scheme.
 /// </summary>
 /// <param name="scheme">The key scheme.</param>
 /// <param name="subset">The key subset (PRODUCER or CONSUMER) to add the key to. </param>
 /// <param name="key"> The key to add.</param>
 public virtual void Add(DualKeyScheme scheme,
                  DualKeyScheme.Subset subset, Key key)
 {
     NewKeysetFor(scheme).KeysFor(subset).Add(key);
 }
コード例 #4
0
ファイル: Keys.cs プロジェクト: renber/AvisNet
        /// <summary>
        /// Get the key set for a dual scheme. This set should not be modified.
        /// </summary>
        /// <param name="scheme">The scheme.</param>
        /// <returns>The key set for the scheme. Will be empty if no keys are defined for the scheme.</returns>
        public DualKeySet KeysetFor(DualKeyScheme scheme)
        {
            IKeySet keys;

            if (!keySets.TryGetValue(scheme, out keys))
                return EmptyDualKeyset;
            else
                return (DualKeySet)keys;
        }
コード例 #5
0
ファイル: DualKeySet.cs プロジェクト: renber/AvisNet
 /// <summary>
 /// Get the keys for a producer or consumer.
 /// </summary>
 /// <param name="subset"></param>
 /// <returns></returns>
 public HashSet<Key> KeysFor(DualKeyScheme.Subset subset)
 {
     if (subset == DualKeyScheme.Subset.Producer)
         return ProducerKeys;
     else
         return ConsumerKeys;
 }