Click here to Skip to main content
15,887,875 members
Articles / Desktop Programming / XAML

A dynamic Rehosted Workflow Designer for WF 4

Rate me:
Please Sign up or sign in to vote.
4.85/5 (26 votes)
29 Jul 2012CPOL10 min read 111.8K   11.8K   78  
This article presents a framework allowing you to integrate the workflow designer more easily in your own applications
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.IO;
using System.Reflection;

namespace Selen.ActivityWorkflowType
{
    public static class ActivityPaths
    {
        private static string fileName;
        private static string destFileName;

        static ActivityPaths()
        {
            fileName = "activities";
            destFileName = "activityModules";

            fileName = ConfigurationManager.AppSettings.AllKeys.Contains("activityFolder") ? ConfigurationManager.AppSettings["activityFolder"] : fileName;
            destFileName = ConfigurationManager.AppSettings.AllKeys.Contains("activityFolder") ? ConfigurationManager.AppSettings["compiledActivityFolder"] : destFileName;

            if (File.Exists(Assembly.GetExecutingAssembly().Location + ".config"))
            {
                var dllConfig = ConfigurationManager.OpenExeConfiguration(Assembly.GetExecutingAssembly().Location);

                AppSettingsSection appSettings = (AppSettingsSection)dllConfig.GetSection("appSettings");
                fileName = appSettings.Settings.AllKeys.Contains("activityFolder") ? appSettings.Settings["activityFolder"].Value : fileName;
                destFileName = appSettings.Settings.AllKeys.Contains("activityFolder") ? appSettings.Settings["compiledActivityFolder"].Value : destFileName;
            }

            fileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName);
            destFileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, destFileName);

            if (!Directory.Exists(fileName)) Directory.CreateDirectory(fileName);
            if (!Directory.Exists(destFileName)) Directory.CreateDirectory(destFileName);
        }

        public static string DestFileName
        {
            get
            {
                return destFileName;
            }
        }

        public static string FileName
        {
            get
            {
                return fileName;
            }
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Student
Germany Germany
I´m a student and hobby programmer from Germany.

Comments and Discussions