public static IDynamicConstructor GetDynamicConstructor(Type objectType, IDictionary <string, object> namedArgValues) { IDictionary <string, object> namedParamValues = namedArgValues == null ? new Dictionary <string, object>() : namedArgValues; DynamicConstructorCacheKey key = new DynamicConstructorCacheKey(objectType, namedParamValues); IDynamicConstructor dynamicConstructor = null; if (!_namedArgumentDynamicConstructors.TryGetValue(key, out dynamicConstructor)) { lock (_syncObj) { if (!_namedArgumentDynamicConstructors.TryGetValue(key, out dynamicConstructor)) { ConstructorInfo constructorInfo = ReflectionHelper.GetConstructorByNamedArgumentValues(objectType, namedArgValues); dynamicConstructor = DynamicConstructor.Create(constructorInfo); if (dynamicConstructor != null) { _namedArgumentDynamicConstructors.Add(key, dynamicConstructor); } } } } return(dynamicConstructor); }
public override bool Equals(object obj) { DynamicConstructorCacheKey key = obj as DynamicConstructorCacheKey; if (key != null && key.Type == this.Type && ParametersEquals(key.NamedArgumentValues, this.NamedArgumentValues)) { return(true); } return(false); }