Note that there are some explanatory texts on larger screens.

plurals
  1. POType inference question: Generic Method Argument to non-Generic Method
    primarykey
    data
    text
    <p>First of all I know that the title is not so good but the thing is I dont even know how to explain my question; I'll just show an example below on what I'm trying to do:</p> <p><strong>EDIT:</strong> I should have given a better example to begin with; let's try again:</p> <pre><code>// MyAppComponentModel.dll namespace MyAppComponentModel { using System.Collections; interface IResource { } interface IStringResource : IResource { } interface IIconResource : IResource { } interface IDialogResource : IResource { } interface IResourceProvider { void GetResource&lt;T&gt;(out T result, IDictionary criteria = null) where T : IResource; } } // ThirdPartyLib.dll namespace ResourceProviderLibA { using System.Collections; using System.ComponentModel.Composition; using MyAppComponentModel. public sealed class StringResource : IStringResource { ... } public sealed class IconResource : IIconResource { ... } [Export(typeof(IResourceProvider))] public sealed class StringAndIconResourceProvider : IResourceProvider { void IResourceProvider.Get&lt;T&gt;(out T result, IDictionary criteria) { if (typeof(T) == typeof(IDialogResource)) throw new NotSupportedException(); this.InternalGet(out result, criteria); } void InternalGet(out IStringResource result, IDictionary criteria) { result = new StringResource(); ... } void InternalGet(out IIconResource result, IDictionary criteria) { result = new IconResource(); ... } } } // MyMefTestApp.exe namespace MyMefTestApp { using System.Collections.Generic; using System.ComponentModel.Composition.Hosting; using MyAppComponentModel. static class Program { [ImportMany(typeof(IResourceProvider))] private IEnumerable&lt;IResourceProvider&gt; mProviders; static void Main(String[] args) { foreach (var provider in this.mProviders) { ... } } } } </code></pre> <p>I know it's somehow possible and I strongly believe I did something like this once just dont remember how. Anyone?</p> <p>I already know that this can be done via Reflection so please skip those solutions - thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload