Sunday, July 19, 2009

Quick overview of WF

Quick overview of WF

WF 4.0 new features (PDC08)


- Activities have in/out Arguments that can be bound to scoped Variables
- persistence points, no-persist zones
- adapting to mid-stream process changes. activities can be updated midstream
- tracking service - 28'
- WF4 vs WF3 - 33'
- Support for Partial Trust Env
- Rehosting improvements (nothing in particular demo'd)

WF 4 custom activities

PDC 2008 cast on custom activities in WF 4

- Base Activity Library supports Interop, Error handling, etc
- Instead of binding properties across activities, Variables are now introduced to box the scope of the outgoing args of an activity.
- No real talk about passivation (Kenny Wolf's talk handles that)
- "custom execution patterns" -- 35'
- WorkflowInvoker class is new - can be used for firing up individual activities for debugging/unit testing
- Scheduling activities explicitly: AEC.ScheduleActivity()
- handling faults - 45.5'
- WorkflowElement class
- AEC.CreateNamedBookmark
- AEC.SetupAsyncOperationBlock - 53'
- Activity designers - 56.5'
- Rehosting designers - 63'


Usage of C# 3.0 features distracts the viewer of this demo a bit

Tuesday, December 9, 2008

Dish #2: A generic AbstractFactory class

#region Copyright
///Copyright 2008 Codesagar.
///DISCLAIMER: Author claims no responsibility for any damages whatsoever
///stemming out either directly or indirectly from the usage of any of the
///source code made available through Codesagar.
#endregion

using
System;

namespace Factories
{
   
/// <summary>
   /// Usage: TConcreteFactory is the concrete factory that implements this base
    /// class and creates instances of type TCreatedType (and its derived classes)
   /// </summary>
   /// <typeparam name="TConcreteFactory">Concrete factory type</typeparam>
   /// <typeparam name="TProduct">Product type to be created by the
    /// concrete factory
   /// </typeparam>
   public class AbstractFactory<TConcreteFactory, TProduct> :
       
SingletonBase<TConcreteFactory>
        
where TConcreteFactory : class, new()
       
where TProduct : class
   {
       
/// <summary>
       /// This is the factory class that must be implemented by your concrete
        /// factory instance.
       /// </summary>
       /// <param name="args">Arguments that your implementation of Create
        /// can accept.
       /// </param>
       /// <returns>Return the instance of your desired type TProduct or its
        /// subtype
       /// </returns>
       public virtual TProduct Create(params object[] args)
       {
           
throw new NotImplementedException();
       }
   }

   
class ExampleProduct { }
   
class ExampleFactory : AbstractFactory<ExampleFactory, ExampleFactory>
   {
       
public override ExampleFactory Create(params object[] args)
       {
           
return new ExampleFactory();
       }
   }

   
class ExampleClient
   {
       
public void Demonstrate()
       {
           
ExampleFactory.Instance.Create();
       }
   }

}


Monday, December 8, 2008

Dish #1: Generic Singleton base class

#region Copyright
///Copyright 2008 Codesagar.
///DISCLAIMER: Author claims no responsibility for any damages whatsoever
///stemming out either directly or indirectly from the usage of any of the
///source code made available through Codesagar.
#endregion

using System;

///Codesagar factory dishes
namespace Factories
{
    ///
    /// This class provides a generic singleton base class that provides a static member
    /// of the derived type tha points to the singleton instance. Ths class also provides
    /// the public singleton getter Instance to access the public interface of the derived 
    /// class.
    ///
    /// The derived class that should be used as a singleton
    public class SingletonBase where T : class, new()
    {
        #region protected static instance
        protected static T s_instance;
        #endregion

        #region protected constructor
        protected SingletonBase()
        {
        }
        #endregion

        #region Singleton interface
        public static T Instance
        {
            get
            {
                if (s_instance == null)
                {
                    T instance = new T();
                    // Insure all writes used to construct new value have been flushed.
                    // For more, see 
                    // http://blogs.msdn.com/brada/archive/2004/05/12/volatile-and-memorybarrier.aspx
                    System.Threading.Thread.MemoryBarrier();
                    s_instance = instance;
                }

                return s_instance;
            }
        }
        #endregion
    }

    ///
    /// A sample singleton class that derives its singleton properties
    /// from the Singleton
    ///
    class MySingleton : SingletonBase
    {
        public void Test()
        {
            Console.WriteLine("MySingleton::Test called!");
        }
    }

    public class Client
    {
        public void TestMySingleton()
        {
            MySingleton.Instance.Test();
        }
    }
}

Sunday, November 30, 2008

Codesagar - Inauguration

Codesagar - thats what i could think of naming this blog dedicated to giving quick programming tips to achieve something worthwhile. A dedication to the gazzillion Bangalore fast food joints around every nook and corner that go by all sortsa names ending with "Sagar" :P 

Some quick reading tips for dish names (every code post is called a dish).
  • # preceding a number means that the dish is in C# . Example: Dish#1 is in C#.
  • ++ preceding a number means that the dish is in C++