using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Reflection; using Bowin.Common.Utility; namespace Bowin.Common { [AttributeUsage( AttributeTargets.Property, AllowMultiple = false)] public class DataPropertyAttribute: Attribute { private static Dictionary dataProperties = new Dictionary(); public static PropertyInfo[] GetDataProperties(Type entityType) { Guard.ArgumentNotNullOrEmpty(entityType, "entityType"); if (dataProperties.ContainsKey(entityType)) { return dataProperties[entityType]; } lock (typeof(DataPropertyAttribute)) { if (dataProperties.ContainsKey(entityType)) { return dataProperties[entityType]; } var properties = (from property in entityType.GetProperties() where property.GetCustomAttributes(typeof(DataPropertyAttribute), true).Any() select property).ToArray(); dataProperties[entityType] = properties; return properties; } } } }