2
using System.Collections.Generic;
3
using System.Reflection;
5
namespace ServiceStack.Common
7
public static class TypeExtensions
9
private static readonly Dictionary<Type, List<string>> TypePropertyNamesMap = new Dictionary<Type, List<string>>();
11
public static List<string> GetPropertyNames(this Type type)
13
lock (TypePropertyNamesMap)
15
List<string> propertyNames;
16
if (!TypePropertyNamesMap.TryGetValue(type, out propertyNames))
18
propertyNames = Extensions.EnumerableExtensions.ConvertAll(type.GetProperties(), x => x.Name);
19
TypePropertyNamesMap[type] = propertyNames;
25
public static List<T> ToAttributes<T>(this Type type) where T : Attribute
27
return type.GetCustomAttributes(typeof(T), true).SafeConvertAll(x => (T)x);
31
public static string GetAssemblyPath(this Type source)
34
new Uri(source.Assembly.EscapedCodeBase);
36
return assemblyUri.LocalPath;