/// <summary> /// Gets a field hash table for quick lookup for any object. /// </summary> /// <param name="any">Any object to get a field table for.</param> /// <returns>A field table or null if unable to obtain a table.</returns> public static FieldTable GetFields(object any) { FieldTable match = null; lock(_proptable.SyncRoot) { // attempt to get a match match = _fieldtable[any.GetType()] as FieldTable; // return it if we have one if (match != null) return match; // reflect the object into a new field table match = new FieldTable(any); // cache it for future usage _fieldtable[any.GetType()] = match; } // return the match return match; }
/// <summary> /// Gets a field hash table for quick lookup for any object. /// </summary> /// <param name="any">Any object to get a field table for.</param> /// <returns>A field table or null if unable to obtain a table.</returns> public static FieldTable GetFields(object any) { FieldTable match = null; lock (_proptable.SyncRoot) { // attempt to get a match match = _fieldtable[any.GetType()] as FieldTable; // return it if we have one if (match != null) { return(match); } // reflect the object into a new field table match = new FieldTable(any); // cache it for future usage _fieldtable[any.GetType()] = match; } // return the match return(match); }
/// <summary> /// Gets the field table for any object. /// </summary> /// <param name="any">Any object to obtain a field table for.</param> /// <returns>A reference to a field table.</returns> /// <remarks>It will cache the field table in a hash for quick lookup at a later time.</remarks> public static FieldTable GetFieldTable(ref object any) { if (any == null) return null; string typefullname = any.GetType().FullName; FieldTable ft = _fieldtablehash[typefullname] as FieldTable; if (ft == null) { ft = new FieldTable(any); _fieldtablehash[typefullname] = ft; } return ft; }