KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Interfaces (In the assembly named "Interfaces". In project :- Interfaces) namespace Interfaces { public interface IDoSomeWork1 { string DoSomeWork1(); } } namespace Interfaces { public interface IDoSomeWork2 { string DoSomeWork2(); } } Dependencies (In the assembly named "Entities". In project :- Entities) namespace Entities { public class ClassB : IDoSomeWork1 { public string DoSomeWork1() { return this.ToString(); } } } namespace Entities { public class ClassC : IDoSomeWork2 { public string DoSomeWork2() { return this.ToString(); } } } Class (In project :- UsingUnity) public class ClassA { [Dependency] public IDoSomeWork1 DoSomeWork1 { get; set; } [Dependency] public IDoSomeWork2 DoSomeWork2 { get; set; } public void SomeMethodInClassA() { Console.WriteLine(DoSomeWork1.DoSomeWork1()); Console.WriteLine(DoSomeWork2.DoSomeWork2()); } } App.Config (In a console application project :- ConsoleUsingUnity) <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="unity" type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection, Microsoft.Practices.Unity.Configuration" /> </configSections> <unity> <containers> <container> <types> <type type="Interfaces.IDoSomeWork1, Interfaces" mapTo="Entities.ClassB, Entities" /> <type type="Interfaces.IDoSomeWork2, Interfaces" mapTo="Entities
Tags (comma-separated)
Save Edits
Cancel