public void RegisterAsType(object locator, Type type) { if (locator == null) { throw new NullReferenceException("Locator cannot be null"); } if (type == null) { throw new NullReferenceException("Type cannot be null"); } Func <object, object> factory = (_) => { try { return(TypeReflector.CreateInstanceByType(type)); } catch { return(null); } }; _registrations.Add(new Registration(locator, factory)); }