private void GetRealObject(Type type) { if (this.realObject != null) { return; } Func <object, object> fn; if (!ObjectIdentifierHelper.GetRegistration(type, out fn)) { throw new Exception("The interface is not registred."); } this.realObject = fn(this.identifiers); }
/// <summary> /// Register the interface and the method for get an object that implements the interface. /// </summary> /// <param name="getByIdentifiersMethod">The method who gets the real object.</param> public static void Register <TInterface>(Func <object, TInterface> getByIdentifiersMethod) where TInterface : class { ObjectIdentifierHelper.Register <TInterface>(getByIdentifiersMethod); }