Beispiel #1
0
        /// <summary>
        /// Create the main form and flow the programs inbound
        /// command line arguments.
        /// </summary>
        /// <param name="args">Command line arguments passed
        /// by the hosting program.</param>
        public MainForm(string[] args)
        {
            InitializeComponent();

            assemblyResolverDialog = new OpenFileDialogAssemblyResolver();

            imageList1.Images.Add(OutOfBoxComponentResources.EmptyNode);

            componentMapping = new Dictionary<Type, List<Type>>();
            imageIndexMapping = new Dictionary<Type, Dictionary<string, int>>();

            WorkflowReflectionUtilitySection section = System.Configuration.ConfigurationManager.GetSection("WorkflowReflectorSettings") as WorkflowReflectionUtilitySection;

            // If no configuration section was found then
            // use the default OOB components.
            if (section == null)
            {
                section = new WorkflowReflectionUtilitySection();
                section.ShowAssemblyResolveExplanation = true;
                section.Components.Add(new ReflectionComponentElement(typeof(AssemblyComponent)));
                section.Components.Add(new ReflectionComponentElement(typeof(WorkflowComponent)));
                section.Components.Add(new ReflectionComponentElement(typeof(RuleComponent)));
                section.Components.Add(new ReflectionComponentElement(typeof(RequiredServiceInterfacesComponent)));
                section.Components.Add(new ReflectionComponentElement(typeof(XamlContextMenuComponent)));
                section.Components.Add(new ReflectionComponentElement(typeof(WorkflowDesignerViewComponent)));
                section.Components.Add(new ReflectionComponentElement(typeof(RuleEvaluatorComponent)));
                section.Components.Add(new ReflectionComponentElement(typeof(WorkflowActivitiesComponent)));
            }

            assemblyResolverDialog.ShowAssemblyResolveExplanation = section.ShowAssemblyResolveExplanation;

            InitializationContext context = new InitializationContext(componentMapping, imageList1, imageIndexMapping);

            // Initialize each component.
            foreach (ReflectionComponentElement element in section.Components)
            {
                Type nodeType = Type.GetType(element.Type);

                if (nodeType == null)
                {
                    MessageBox.Show(string.Format("Could not find type '{0}'.  Application will run without that component.", element.Type));
                    continue;
                }

                WorkflowReflectionComponent node = nodeType.InvokeMember(string.Empty, BindingFlags.CreateInstance, null, null, null, CultureInfo.InvariantCulture) as WorkflowReflectionComponent;
                node.Initialize(context);
            }

            if (args != null && args.Length > 0)
            {
                LoadAssembly(args[0]);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Create the main form and flow the programs inbound
        /// command line arguments.
        /// </summary>
        /// <param name="args">Command line arguments passed
        /// by the hosting program.</param>
        public MainForm(string[] args)
        {
            InitializeComponent();

            assemblyResolverDialog = new OpenFileDialogAssemblyResolver();

            imageList1.Images.Add(OutOfBoxComponentResources.EmptyNode);

            componentMapping  = new Dictionary <Type, List <Type> >();
            imageIndexMapping = new Dictionary <Type, Dictionary <string, int> >();

            WorkflowReflectionUtilitySection section = System.Configuration.ConfigurationManager.GetSection("WorkflowReflectorSettings") as WorkflowReflectionUtilitySection;

            // If no configuration section was found then
            // use the default OOB components.
            if (section == null)
            {
                section = new WorkflowReflectionUtilitySection();
                section.ShowAssemblyResolveExplanation = true;
                section.Components.Add(new ReflectionComponentElement(typeof(AssemblyComponent)));
                section.Components.Add(new ReflectionComponentElement(typeof(WorkflowComponent)));
                section.Components.Add(new ReflectionComponentElement(typeof(RuleComponent)));
                section.Components.Add(new ReflectionComponentElement(typeof(RequiredServiceInterfacesComponent)));
                section.Components.Add(new ReflectionComponentElement(typeof(XamlContextMenuComponent)));
                section.Components.Add(new ReflectionComponentElement(typeof(WorkflowDesignerViewComponent)));
                section.Components.Add(new ReflectionComponentElement(typeof(RuleEvaluatorComponent)));
                section.Components.Add(new ReflectionComponentElement(typeof(WorkflowActivitiesComponent)));
            }

            assemblyResolverDialog.ShowAssemblyResolveExplanation = section.ShowAssemblyResolveExplanation;

            InitializationContext context = new InitializationContext(componentMapping, imageList1, imageIndexMapping);

            // Initialize each component.
            foreach (ReflectionComponentElement element in section.Components)
            {
                Type nodeType = Type.GetType(element.Type);

                if (nodeType == null)
                {
                    MessageBox.Show(string.Format("Could not find type '{0}'.  Application will run without that component.", element.Type));
                    continue;
                }

                WorkflowReflectionComponent node = nodeType.InvokeMember(string.Empty, BindingFlags.CreateInstance, null, null, null, CultureInfo.InvariantCulture) as WorkflowReflectionComponent;
                node.Initialize(context);
            }

            if (args != null && args.Length > 0)
            {
                LoadAssembly(args[0]);
            }
        }