Ejemplo n.º 1
0
        /// <summary>
        /// Gets a <see cref="CachedType"/> for the given <see cref="Type"/> instance.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <returns>The <see cref="CachedType"/>.</returns>
        public static ContextualType ToContextualType(this Type type)
        {
            var key = "Type:Context:" + type.FullName;

            lock (Lock)
            {
                if (!Cache.ContainsKey(key))
                {
                    Cache[key] = ContextualType.ForType(type, new Attribute[0]);
                }

                return((ContextualType)Cache[key]);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Gets an uncached <see cref="ContextualType"/> for the given <see cref="Type"/> instance and attributes.
 /// </summary>
 /// <param name="type">The type.</param>
 /// <param name="attributes">The attributes.</param>
 /// <returns>The <see cref="CachedType"/>.</returns>
 public static ContextualType ToContextualType(this Type type, IEnumerable <Attribute> attributes)
 {
     // TODO: Is there a way to cache these contextual types?
     return(ContextualType.ForType(type, attributes));
 }