मैं अपने ऐप सर्वर पर अपनी सेवाओं का प्रबंधन करने के लिए एकता का उपयोग कर रहा हूं लेकिन किसी कारण से मुझे काम करने के लिए 'GetAllInstances' विधि नहीं मिल सकती है। अजीब चीज यह है कि एक ही प्रकार के लिए 'GetInstance' ठीक काम करने लगता है!यूनिटी 'GetAllInstances' कुछ भी वापस नहीं लौट रहा
यहाँ config है:
<alias alias="IService" type="Atom.Server.Infrastructure.Interface.Service.IService, Atom.Server.Infrastructure.Interface"/>
<alias alias="IAtomCommandService" type="Atom.CommandServer.AtomCommandService.Interface.IAtomCommandService, Atom.CommandServer.AtomCommandService.Interface"/>
<alias alias="AtomCommandService" type="Atom.CommandServer.AtomCommandService.AtomCommandService, Atom.CommandServer.AtomCommandService"/>
<register type="IService" mapTo="AtomCommandService">
<lifetime type="Singleton"/>
</register>
<register type="IAtomCommandService" mapTo="AtomCommandService">
<lifetime type="Singleton"/>
</register>
विचार किया जा रहा है कि जब सर्वर शुरू होता है, मैं उन्हें आरंभ करने के लिए IService के सभी के लिए कॉन्फ़िगर उदाहरणों प्राप्त करने में सक्षम होने की जरूरत है।
IUnityContainer container = ConfigureUnityContainer();
UnityServiceLocator locator = new UnityServiceLocator(container);
var single = locator.GetInstance<IService>();
var all = locator.GetAllInstances<IService>().ToList();
जैसा कि मैंने कहा, एकल काम करता है, लेकिन सभी को कुछ भी नहीं मिलता है। भले ही मैं कॉन्फ़िगरेशन से IAtomCommandService मैपिंग को हटा दूं और केवल IService है, यह अभी भी काम नहीं करता है। इस पर कोई विचार है कि मैं इसके साथ गलत कहां जा रहा हूं?
धन्यवाद मार्क - मैंने प्रश्न पोस्ट करने के बाद ही यह महसूस किया! हमेशा रास्ता! –