/// <summary>
 /// Write a summary of info to output.
 /// </summary>
 /// <param name="info">Object to format.</param>
 /// <param name="output">Destination for formatted text.</param>
 public static void Write(CompositionInfo info, TextWriter output)
 {
     foreach (var part in info.PartDefinitions)
     {
         PartDefinitionInfoTextFormatter.Write(part, output);
         output.WriteLine();
     }
 }
 /// <summary>
 /// Write a summary of info to output.
 /// </summary>
 /// <param name="info">Object to format.</param>
 /// <param name="output">Destination for formatted text.</param>
 public static void Write(CompositionInfo info, TextWriter output)
 {
     foreach (var part in info.PartDefinitions)
     {
         PartDefinitionInfoTextFormatter.Write(part, output);
         output.WriteLine();
     }
 }
Exemplo n.º 3
0
        public BarcodeForm()
        {
            InitializeComponent();
            try
            {
                string sPath="";
                if (isIntermec)
                    sPath = "MEFdemo1.HAL.Intermec.*Control*.dll";
                else
                    sPath = "MEFdemo1.HAL.ACME.*Control*.dll";

                //I was unable to use the different catalog and let it look in a subfolder
                //so the plugin names are used as a filter
                catalog2 = new DirectoryCatalog(".", sPath);

                foreach (string s in catalog2.LoadedFiles)
                    System.Diagnostics.Debug.WriteLine(s);

                container2 = new CompositionContainer(catalog2);

            #if DEBUG
                //some diagnostics...
                //see http://mef.codeplex.com/wikipage?title=Debugging%20and%20Diagnostics&referringTitle=Guide
                // using Samples\.... as in MEF preview 7 and 8
                CompositionInfo ci = new CompositionInfo(catalog2, container2);
                System.IO.MemoryStream ms = new System.IO.MemoryStream();
                System.IO.TextWriter tw = new System.IO.StreamWriter(ms);
                CompositionInfoTextFormatter.Write(ci, tw);
                System.Diagnostics.Debug.WriteLine(Encoding.UTF8.GetString(ms.GetBuffer(), 0, ms.GetBuffer().Length));
                foreach (PartDefinitionInfo pi in ci.PartDefinitions)
                {
                    System.Diagnostics.Debug.WriteLine("isRejected: " + pi.IsRejected.ToString());
                    System.Diagnostics.Debug.WriteLine("partInfo: " + pi.PartDefinition.ToString());
                }
                tw.Close();
            #endif
                container2.ComposeParts(this);
                initBarcode();
            }
            catch (Exception ex)
            {
                if (ex is ChangeRejectedException)
                    MessageBox.Show("HW-Components not found!");
                else
                    MessageBox.Show("Exception in ComposeParts: " + ex.Message + "\n" + ex.StackTrace);
                this.Close();
            }
        }
Exemplo n.º 4
0
        public MainForm()
        {
            InitializeComponent();
            try
            {
                catalog = new DirectoryCatalog(".", "MEFdemo1.Plugins.*.dll");
                container = new CompositionContainer(catalog);
                container.ComposeParts(this);
            #if DEBUG
                //some diagnostics...
                //see http://mef.codeplex.com/wikipage?title=Debugging%20and%20Diagnostics&referringTitle=Guide
                // using Samples\.... as in MEF preview 7 and 8
                CompositionInfo ci = new CompositionInfo(catalog, container);
                System.IO.MemoryStream ms = new System.IO.MemoryStream();
                System.IO.TextWriter tw = new System.IO.StreamWriter(ms);
                CompositionInfoTextFormatter.Write(ci, tw);
                System.Diagnostics.Debug.WriteLine(Encoding.UTF8.GetString(ms.GetBuffer(), 0, ms.GetBuffer().Length));
                foreach (PartDefinitionInfo pi in ci.PartDefinitions)
                {
                    iPluginCount++;
                    System.Diagnostics.Debug.WriteLine("isRejected: " + pi.IsRejected.ToString());
                    System.Diagnostics.Debug.WriteLine("partInfo: " + pi.PartDefinition.ToString());
                }

                tw.Close();
            #else
                foreach (PartDefinitionInfo pi in ci.PartDefinitions)
                {
                    iPluginCount++;
                }
            #endif
                drawPlugins();
            }
            catch (Exception ex)
            {
                MessageBox.Show("No Plugins loaded: " + ex.Message);
            }
        }