Пример #1
0
		/// <summary>
		/// Describe the given type.
		/// </summary>
		/// <param name="type">Tye type to get information for.</param>
		/// <returns>Returns an instance of <see cref="TypeInfo"/> class describing the
		/// given type.</returns>
		public TypeInfo GetTypeInfo( Type type )
		{
			TypeInfo typeInfo;
			if( !_cache.TryGetValue( type, out typeInfo ))
			{
				lock( _locker )
				{
					if( !_cache.ContainsKey( type ) )
					{
						typeInfo = new TypeInfo( type );
						_cache[type] = typeInfo;
					}
					else
						// If type info were added in other thread
						typeInfo = _cache[type];
				}
			}
			return typeInfo;
		}
Пример #2
0
 /// <summary>
 /// Constructs an empty TypeInfoCache.
 /// </summary>
 private TypeInfoCache()
 {
     _cache  = new Dictionary <Type, TypeInfo>();
     _string = GetTypeInfo(typeof(string));
 }
Пример #3
0
		/// <summary>
		/// Constructs an empty TypeInfoCache.
		/// </summary>
		private TypeInfoCache()
		{
			_cache = new Dictionary<Type, TypeInfo>();
			_string = GetTypeInfo( typeof( string ) );
		}