예제 #1
0
 /// <summary>
 /// Gets an instance of ReflectionInfo for the specified type.
 /// </summary>summary>
 /// <param name="type">The type for which to lookup the method cache.</param>
 /// <returns>The properties cache for the type</returns>
 public static ReflectionInfo GetInstance(Type type)
 {
     lock (type)
     {
         ReflectionInfo reflectionInfo = null;
         _reflectionInfoMap.TryGetValue(type, out reflectionInfo);
         if (reflectionInfo == null)
         {
             reflectionInfo = new ReflectionInfo(type);
             _reflectionInfoMap.Add(type, reflectionInfo);
         }
         return(reflectionInfo);
     }
 }
예제 #2
0
        /// <summary>
        ///  Returns the type that the get expects to receive as a parameter when
        ///  setting a member value.
        /// </summary>
        /// <param name="type">The type to check</param>
        /// <param name="memberName">The name of the member</param>
        /// <returns>The type of the member</returns>
        public static Type GetMemberTypeForGetter(Type type, string memberName)
        {
            if (memberName.IndexOf('.') > -1)
            {
                StringTokenizer parser     = new StringTokenizer(memberName, ".");
                IEnumerator     enumerator = parser.GetEnumerator();

                while (enumerator.MoveNext())
                {
                    memberName = (string)enumerator.Current;
                    type       = ReflectionInfo.GetInstance(type).GetGetterType(memberName);
                }
            }
            else
            {
                type = ReflectionInfo.GetInstance(type).GetGetterType(memberName);
            }

            return(type);
        }
예제 #3
0
 /// <summary>
 /// Returns an array of the writeable members name exposed by a object
 /// </summary>
 /// <param name="obj">The object</param>
 /// <returns>The members name</returns>
 public static string[] GetWriteableMemberNames(object obj)
 {
     return(ReflectionInfo.GetInstance(obj.GetType()).GetWriteableMemberNames());
 }
예제 #4
0
 /// <summary>
 /// Returns an array of the readable properties names exposed by an object
 /// </summary>
 /// <param name="obj">The object</param>
 /// <returns>The properties name</returns>
 public static string[] GetReadablePropertyNames(object obj)
 {
     return(ReflectionInfo.GetInstance(obj.GetType()).GetReadableMemberNames());
 }
예제 #5
0
	    /// <summary>
		/// Gets an instance of ReflectionInfo for the specified type.
		/// </summary>summary>
		/// <param name="type">The type for which to lookup the method cache.</param>
		/// <returns>The properties cache for the type</returns>
		public static ReflectionInfo GetInstance(Type type) 
		{
			lock (type) 
			{
                ReflectionInfo reflectionInfo = null;
                _reflectionInfoMap.TryGetValue(type, out reflectionInfo);
                if (reflectionInfo == null) 
				{
                    reflectionInfo = new ReflectionInfo(type);
                    _reflectionInfoMap.Add(type, reflectionInfo);
				}
                return reflectionInfo;
			}
		}