Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5933917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:02:27+00:00 2026-05-22T15:02:27+00:00

Right now we have a dll file that contains all the database calls and

  • 0

Right now we have a dll file that contains all the database calls and i can’t change it. However i need to call i from my Mvc 3 project. The process to call it is simple, i use the following:

ManageProvider.GetProxy<T>(ident);

T is an interface that i want to get the class back from (its like an IoC of its own) and ident is the user identification class. So by calling

var classReturned = ManageProvider.GetProxy<ICommunity>(new UserIden{ Email = "test@test.com" });

I would get a class back with all the community functions.
Now i want to implement Unity in my Mvc 3 project. The question is, can i somehow add these calls to the dll file through unity?

I want to resolve the call by using:

var classReturned = myContainer.Resolve<ICommunity>(new UserIden{ Email = "test@test.com" });

How can i register this in Unity (or is it even possible) ?

Update:

1) Is it better to call the methods with the email/user ident instead of defining a Dependency property? (ex below)

2) There is a bout 20 or so interfaces in the dll file right now. Should i add them all to the same reposatory? (ex below)

    public class ProxyWrapper : IDllRepository
    {
        [Dependency]
        public UserIdent UserIdent { get; set; }

        public ICommunity GetCommunity()
        {
            return ManageProvider.GetProxy<ICommunity>(UserIdent);
        }

        public IDesktop GetDesktop()
        {
            return ManageProvider.GetProxy<IDesktop>(UserIdent);
        }
    }

    public interface IDllRepository
    {
        ICommunity GetCommunity();
        IDesktop GetDesktop();
    }

Whats the best way and how would i call it from my code?
Does the [Dependency] attribute also fall into the Service Locator anti pattern?

Update 23.05.11

1) Yes, something like that. They contain all the logic that is provided to all the projects that includes the dll file.

Regarding the ManagerProvider. It accepts an interface and returns the class that is mapped to this interface. So for the community, the interface looks like this (removed a lot of calls to keep it short, there is also posts, comments, community create/update etc):

List<CommunityThread> GetThreads(int pStartRowIndex, int pMaximumRows, string pOrderBy, string pSearchExpression);
Guid? CreateThread(string pTitle, string pDescription, string pPostContent);
bool DeleteThread(Guid pThreadId);
List<CommunityThread> GetCommunityUserThreads(Guid pCommunityUserId); 

2) What i can’t update is how the ManageProvider.GetProxy works. The GetProxy is a class in the dll file that is hardcoded. Here is the part for the community. The class does the same for all the other interfaces as well, if typeof(interface) … return class.

private static IManageProxy GetProxyForInterface<T>(UserIdent pIdent)
{
....
     if (typeof(T).Equals(typeof(ICommunity)))
          return new PCommunity();
....
}

3) Once registered using this new wrapper class, i can call it through the following code (MvcUnityContainer is a static class that only has a property called Container):

var c = MvcUnityContainer.Container.Resolve<IBackendRepository>(new PropertyOverride("UserIdent",
                                                                           new UserIdent()));

Global.asax

IUnityContainer container = InitContainer();                                 
MvcUnityContainer.Container = container;
DependencyResolver.SetResolver(new UnityMvcResolver(container));

The question is, do i need the static class MvcUnityContainer? Is it possible to configure the DependecyResolver to do that for me? Something like (problem is that it doesn’t accept the override parameter):

var c = DependencyResolver.Current.GetService<IBackendRepository>(new PropertyOverride("UserIdent", new UserIdent()));
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T15:02:28+00:00Added an answer on May 22, 2026 at 3:02 pm

    I think you need to hide the creation behind another abstraction, for instance:

    public interface ICommunityRepository
    {
        ICommunity GetByEmailAddress(string address);
    }
    
    public class ManageProviderCommunityRepository
        : ICommunityRepository
    {
        public ICommunity GetByEmailAddress(string address)
        {
            var id = new UserIden { Email = address };
            return ManageProvider.GetProxy<ICommunity>(id);
        }
    }
    

    This will hide both the ManageProvider and the UserIden behind this abstraction, and allows you to replace it later on with something more useful and makes testing easier.

    Registration now is very easy:

    RegisterType<ICommunityRepository, ManageProviderCommunityRepository>();
    

    Instead of calling myContainer.Resolve (as you do in your example), inject the dependencies in your classes. This prevents you from using the Service Locator anti-pattern.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Right now i have a line of code, in vb, that calls a text
Right now I have something like this in NHibernate: Expression.Like(property, value, MatchMode.Anywhere) and that
Right now we have AD/Exchange to manage all of our users logins/e-mail on-site at
I have been attemptng to create a DLL with C/C++ that can be accessed
I have a method that creates a DLL from a .cs file that is
I have a .hgignore file that works great for hiding all the files and
Good day! I right now have a function the drags an element from a
Right now I have this SQL query which is valid but always times out:
Right now I have def min(array,starting,ending) minimum = starting for i in starting+1 ..ending
Right now I have double numba = 5212.6312 String.Format({0:C}, Convert.ToInt32(numba) ) This will give

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.