示例#1
0
        public Program(string[] args)
        {
            // Load all IDataSourceFactory from plugins.
            IEnumerable <string> pluginLocations =
                new string[] { Assembly.GetExecutingAssembly().Location }.Concat(args);

            using (AggregateCatalog catalog = new AggregateCatalog())
            {
                foreach (string location in pluginLocations)
                {
                    string buffer = Path.GetFullPath(location);
                    if (File.Exists(buffer))
                    {
                        buffer = Directory.GetParent(buffer).FullName;
                    }

                    catalog.Catalogs.Add(new DirectoryCatalog(buffer));
                }

                using (CompositionContainer container = new CompositionContainer(catalog))
                {
                    container.ComposeParts(this);
                }
            }

            // Populate command line argument options.
            int keylessInstances = 0;

            this.options = new Dictionary <string, RunOptionTarget>(StringComparer.OrdinalIgnoreCase);
            foreach (RunOptionTarget target in RunOptionAttribute.GetImplementors(this.GetType()))
            {
                options.Add(
                    target.Attribute.Key ?? (++keylessInstances).ToString(),
                    target);
            }
        }
示例#2
0
 public RunOptionTarget(MethodInfo method, RunOptionAttribute attribute)
 {
     this.Method    = method;
     this.Attribute = attribute;
 }