/// <summary> /// CreateObject /// </summary> /// <param name="type"></param> /// <param name="parameters"></param> /// <returns></returns> public static object CreateObject(Type type, params object[] parameters) { Type[] parameterTypes = GetParameterTypes(parameters); string id = GetIdentity(type, parameterTypes); CreateOjectHandler ctor = null; if (!creatorCache.TryGetValue(id, out ctor)) { ctor = CreateHandler(type, parameterTypes); creatorCache.TryAdd(id, ctor); } return(ctor.Invoke(parameters)); }
/// <summary> /// CreateObject /// </summary> /// <param name="type"></param> /// <param name="parameters"></param> /// <returns></returns> public static object CreateObject(Type type, params object[] parameters) { int token = type.MetadataToken; Type[] parameterTypes = GetParameterTypes(ref token, parameters); lock (creatorCache.SyncRoot) { CreateOjectHandler ctor = creatorCache[token] as CreateOjectHandler; if (ctor == null) { ctor = CreateHandler(type, parameterTypes); creatorCache.Add(token, ctor); } return(ctor.Invoke(parameters)); } }