2

I'm having the following classes in my ASP.net MVC project to handle file upload to different cloud db.

public interface IFileUploader<T1, T2>
{
    byte[] GetFileInformation();

    T1 EstablishConnection();

    T2 GetTargetContainerReference(T1 connection);

    Task<string> UploadFile(string filePath);
}


public class BaseMediaUploader : IFileUploader<CloudBlobContainer, CloudBlockBlob>
{
    public string FilePath;
    public IConnectionInfo ConnectionInfo;

    public BaseMediaUploader(IConnectionInfo connectionInfo)
    {
        this.ConnectionInfo = connectionInfo;
    }

    public CloudBlobContainer EstablishConnection()
    {
        //removed code for brevity
    }

    public byte[] GetFileInformation()
    {
        //removed code for brevity
    }

    public CloudBlockBlob GetTargetContainerReference(CloudBlobContainer cbc)
    {
        //removed code for brevity
    }

    public virtual Task<string> UploadFile(string filePath)
    {
        //removed code for brevity
    }
}

If I do not have the T1 and T2 in IFileUploader, its straight forward to use Ninject DI.

The question is having T1, T2 generics, how to make use of Ninject to inject the dependency into MVC controller?

  • Possible duplicate of [NInject with Generic interface](http://stackoverflow.com/questions/2216127/ninject-with-generic-interface) – lorond Jul 10 '16 at 18:28
  • Also http://stackoverflow.com/questions/10243632/how-to-bind-generic-type-interfaces-in-ninject – lorond Jul 10 '16 at 18:29

0 Answers0