Skip to content

Support for removing Exports from Container #83

Description

@darkcamper

Hi @ipjohnson , I'm looking for some kind of replacement for Ninject's Rebind functionality. It allows to throw away all the previous Exports for a certain type without modifying Exports for the rest of the types.

I'm trying to load a series of IConfigurationModule-like classes (inside a single .Configure call) that add exports to a certain interface, so I can do a Locate<IEnumerable> to retrieve them all. But sometimes I would need that a module could erase all previous exports for IThatCertainInterface before adding its own exports.

Is it currently possible with Grace? Thanks!

Activity

  1. ipjohnson commented on May 12, 2017

    @ipjohnson
    Owner

    Hi @darkcamper Currently it's not possible, that said if it's all within one configuration call I think it would be very possible. I think this would dove tail in with issue #44

    I have one other thing I'm going to try and get working this weekend and then release 6.1.0. This issue and #44 would go into the next release. I probably won't get much time to address this till the following week as we have family in town for our baby shower this weekend.

  2. darkcamper commented on May 12, 2017

    @darkcamper
    Author

    @ipjohnson Family comes first! I'll be looking forward to testing next release.
    Have a nice weekend!

  3. added this to the 6.2.0 milestone on May 20, 2017
  4. ipjohnson commented on May 27, 2017

    @ipjohnson
    Owner

    @darkcamper I'm looking to add these two methods to the registration block interface. Let me know what you think or if you want any changes

            /// <summary>
            /// Test if a type is exported
            /// </summary>
            /// <param name="type"></param>
            /// <param name="key"></param>
            /// <returns></returns>
            bool IsExported(Type type, object key = null);
    
            /// <summary>
            /// Clears exports from registration block
            /// </summary>
            /// <param name="exportFilter"></param>
            /// <returns></returns>
            bool ClearExports(Func<ICompiledExportStrategy, bool> exportFilter = null);
    
  5. darkcamper commented on May 27, 2017

    @darkcamper
    Author

    @ipjohnson I like it. I think the filter delegate solution allows you to remove whatever you want without exposing too much from the internals.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions