コード例 #1
0
 /// <summary>
 /// Registers this type
 /// </summary>
 /// <param name="encoding"></param>
 public void Register(IndividualEncodingDefinitionBase encoding)
 {
     lock (m_syncRoot)
     {
         if (encoding.TypeIfNotGeneric is null)
         {
             m_combinedEncoding.Add(encoding.Method, encoding);
         }
         else if (encoding.TypeIfNotGeneric != null)
         {
             m_keyTypedCombinedEncoding.Add(Tuple.Create(encoding.Method, encoding.TypeIfNotGeneric), encoding);
         }
     }
 }
コード例 #2
0
        /// <summary>
        /// Attempts to get the specified encoding method from the dictionary. Will register the types if never registered before.
        /// </summary>
        /// <typeparam name="TTree">The value</typeparam>
        /// <param name="encodingMethod">the encoding method</param>
        /// <param name="encoding">an output if the encoding method exists.</param>
        /// <returns>True if the encoding value was found, false otherwise.</returns>
        public bool TryGetEncodingMethod <TTree>(Guid encodingMethod, out IndividualEncodingDefinitionBase encoding)
            where TTree : SnapTypeBase <TTree>, new()
        {
            Type keyType = typeof(TTree);

            lock (m_syncRoot)
            {
                if (m_keyTypedCombinedEncoding.TryGetValue(Tuple.Create(encodingMethod, keyType), out encoding) ||
                    m_combinedEncoding.TryGetValue(encodingMethod, out encoding))
                {
                    return(true);
                }
            }
            return(false);
        }
コード例 #3
0
 /// <summary>
 /// Registers the provided type in the encoding library.
 /// </summary>
 /// <param name="encoding">the encoding to register</param>
 internal void Register(IndividualEncodingDefinitionBase encoding)
 {
     m_individualEncoding.Register(encoding);
 }