private static BindingRegistry GetRegistry(Binding binding) { BindingRegistry retVal = null; if (!registryMap.TryGetValue(binding, out retVal)) { lock (registryMap) { if (!registryMap.TryGetValue(binding, out retVal)) { retVal = new BindingRegistry(binding); registryMap.Add(binding, retVal); } } } return retVal; }
public CustomFactoryMethodMap(MethodInfo methodInfo, BindingRegistry registry) { string methodName = methodInfo.Name; if (!methodName.ToLower().StartsWith(prefix) || methodInfo.GetParameters().Length > 0) throw new ArgumentException("Methods on custom types must start with get and must not have any parameters."); // TODO: Complete member initialization string name = methodName.Length <= prefixLength ? (methodInfo.ReturnType.IsInterface && methodInfo.ReturnType.Name.StartsWith("I") ? methodInfo.ReturnType.Name.Substring(1) : methodInfo.ReturnType.Name) : methodInfo.Name.Substring(prefixLength); this.Map = registry.GetMapForType(methodInfo.ReturnType, name, false, null); this.MethodInfo = methodInfo; this.ReturnType = this.MethodInfo.ReturnType; }