Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I use this code to make a toolbar in my Designer but it does not retrieve all the elements of state machine like final state. What is the correct namespace to load all the elements of state machine?
C#
private static ToolboxControl CreateToolboxControlshahram() {
    const string @namespace = "System.Activities.Statements";
    var toolbox = new ToolboxControl();
    var cat = new ToolboxCategory(@namespace);
    ToolboxItemWrappers(typeof(Flowchart).Assembly, @namespace).ToList().ForEach(cat.Add);
    if (cat.Tools.Count > 0)
        toolbox.Categories.Add(cat);

    return toolbox;
}

private static IEnumerable<ToolboxItemWrapper> ToolboxItemWrappers(Assembly assembly, string @namespace) {
    if (assembly == null) {
        throw new ArgumentNullException("assembly");
    }
    if (string.IsNullOrEmpty(@namespace)) {
        return Enumerable.Empty<ToolboxItemWrapper>();
    }

    var q = from type in assembly.GetTypes()
            where string.Equals(type.Namespace, @namespace)
            && type.IsPublic && !type.IsNested && !type.IsAbstract
            && type.GetConstructor(Type.EmptyTypes) != null
            orderby type.Name
            select new ToolboxItemWrapper(type);
    return q;
}
Posted

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900