Exemplo n.º 1
0
        public void FindsRootCauseOfRejection()
        {
            var fooInfo = _analysis.GetPartDefinitionInfo(typeof(Foo));

            var rootCause = fooInfo.FindPossibleRootCauses().Single();

            var barInfo = _analysis.GetPartDefinitionInfo(typeof(Bar));

            Assert.AreSame(barInfo, rootCause);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            AssemblyCatalog      catalog   = new AssemblyCatalog(Assembly.GetExecutingAssembly());
            CompositionContainer container = new CompositionContainer(catalog);

            try
            {
                container.GetExportedValue <PluginConsumer>();
            }
            catch
            {
                CompositionInfo ci = new CompositionInfo(catalog, container);
                //we can use the GetPartDefinitionInfo to examine parts for potential issues.We can see if a part was rejected,
                // if its the primary rejection, then we can ask it to return a potential root causes.
                var partDef        = ci.GetPartDefinitionInfo(typeof(PluginConsumer));
                var possibleCauses = partDef.FindPossibleRootCauses();

                //If you want to get a detailed analysis then we can use the Write method provided by the
                // CompositionInforTextFormatter
                CompositionInfoTextFormatter.Write(ci, Console.Out);
            }

            Console.ReadKey();
        }