(+N) Consulting Inc.

Consulting | Software Solutions | Training

C# Generics - Interface declaration

I was challenged recently with a question about generics with constraints. The claim was that it's only a compile flaw that allows your to declare an interface for a generic type with a constraint. Namely that the syntax public interface ISomething <T> where T: SomeClass would pass compilation but would not be useful (runtime) because you can't declare a variable ISomething myVar = new ISomething<SomeClass>(); or something to that extent. I went home feeling a bit uneasy about the discussion, then coded this up the way I see it. While it is completely true that you can't 'new' an interface, using an interface that has a generic type... [More]

Workflow Custom Activity - Designer re-hosting

In developing some workflow stuff, ran across the need to create custom activities that "aggregate" other atomic activities into a larger activity. The idea is that Programmer codes some atomic activities, exposes appropriate Dependency Properties Non programmer Uses these atomics and creates processes using the atomic compiled activities Saves these composite activities as a new custom activity Can expose specific parameters for inner activities, but otherwise the activity is "locked" for the end user. End user Uses the composite activities to define a workflow and run it. Can bind runtime paramet... [More]

Workflow custom Loop Activity

I was doing some workflow work and wanted to create a custom loop activity. The project needs it, and it's a great way to learn what (not) to do. The activity is a container that would loop through a list of discrete items (think foreach(string currentValue in ValueList)) and exposes the current loop variable via a bindable DependencyProperty. The basics of the activity are to keep the container in "Executing" mode until all child activities are done. The tricky part is that the whole ActivityExecutionContext and ExecutionContextManager need to create for a new context each loop iteration. The hookup of the synchronization is done by using Activity.RegisterForStatusChange(.., OnEvent) on each child executed, t... [More]