MongoServices 0.2.0
A Service/Repository Framework for mongoDB
|
00001 using System; 00002 using System.Collections.Generic; 00003 using System.Linq; 00004 using System.Text; 00005 using System.Reflection; 00006 00007 namespace MongoServices 00008 { 00012 public static class ReflectionsExtensions 00013 { 00014 #region Public Static Methods 00015 00016 00017 00018 00019 00020 00021 00022 public static T GetCustomAttribute<T>(this MemberInfo member, bool inherit = false) 00023 where T : Attribute 00024 { 00025 var attrs = member.GetCustomAttributes(typeof(T), inherit); 00026 00027 if (attrs.Length > 0) 00028 return (T)attrs.First(); 00029 00030 return null; 00031 } 00032 #endregion 00033 } 00034 }