Home > Net >  C # under the unified solution of how to realize the mutual reference between different projects?
C # under the unified solution of how to realize the mutual reference between different projects?

Time:01-07

I am now in the project View cited the BLL function, now I have a class file inside the BLL want to invoke the View inside a certain parameter, show can't call, how can I solve this problem?

CodePudding user response:

And to think about why you want to reference in the view the BLL

CodePudding user response:

Independent a public library for the BLL and View call. It'll be ok

CodePudding user response:

Write an interface, back to the parameters

CodePudding user response:

Since the BLL business logic as a separate project, is that you mean the BLL business logic can be used to different interface, the view can refer to the BLL, other mobile terminal app, winform client can use the BLL, that your problem, there is a class file to the BLL call view, what is called the view project right?

If a beginner is not aware of the problem, need not hierarchical, it is a question of the architecture level, by defining interfaces, passing view instance can really realize your ideas, but should not effect you want

CodePudding user response:

The ClassA inherit an interface IClassA,
Then in the ClassB IClassA a=new ClassA ();

CodePudding user response:

To avoid this situation,
The best method is to don't declare a global variable in the class,
But within the method, called which classes, which class is instantiated,

CodePudding user response:

This is typical of dependence, A reference to B, said A relies on B, then B references A, in turn circular dependencies are formed, in the software design should avoid circular dependencies, otherwise more project is to explode,

CodePudding user response:

That's the way to use the parameter passing, instead of using the global variables,
If have to Shared global variables, it is another responsibility of public library,

CodePudding user response:

Architecture did not want to good, incredibly reference each other

CodePudding user response:

Will building blocks, a, b is the
And you come to a, b is next
  •  Tags:  
  • C#
  • Related