Click here to Skip to main content
15,884,679 members
Articles / Programming Languages / C# 4.0

Propagator in C# - An Alternative to the Observer Design Pattern

Rate me:
Please Sign up or sign in to vote.
4.94/5 (19 votes)
13 Jul 2009CPOL9 min read 55.6K   368   53  
Re-usable implementation of the Propagator Design Pattern in C#, a potentially more powerful alternative to the well-known Observer Design Pattern.
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProductVersion>8.0.50727</ProductVersion>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>{72916EB2-2DB7-49E4-B203-4A111E7EB03D}</ProjectGuid>
    <OutputType>WinExe</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>PropagatorDemo</RootNamespace>
    <AssemblyName>PropagatorDemo</AssemblyName>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="System" />
    <Reference Include="System.Data" />
    <Reference Include="System.Deployment" />
    <Reference Include="System.Drawing" />
    <Reference Include="System.Windows.Forms" />
    <Reference Include="System.Xml" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="ColorChange.cs" />
    <Compile Include="ColorControl.cs">
      <SubType>UserControl</SubType>
    </Compile>
    <Compile Include="ColorControl.Designer.cs">
      <DependentUpon>ColorControl.cs</DependentUpon>
    </Compile>
    <Compile Include="DemoForm.cs">
      <SubType>Form</SubType>
    </Compile>
    <Compile Include="DemoForm.Designer.cs">
      <DependentUpon>DemoForm.cs</DependentUpon>
    </Compile>
    <Compile Include="DemoStateChanges.cs" />
    <Compile Include="Examples.cs" />
    <Compile Include="FontChange.cs" />
    <Compile Include="FontControl.cs">
      <SubType>UserControl</SubType>
    </Compile>
    <Compile Include="FontControl.Designer.cs">
      <DependentUpon>FontControl.cs</DependentUpon>
    </Compile>
    <Compile Include="Program.cs" />
    <Compile Include="Propagators\IPropagator.cs" />
    <Compile Include="Propagators\Propagator.cs" />
    <Compile Include="Propagators\StateChange.cs" />
    <Compile Include="Propagators\StateChangeOptions.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
    <EmbeddedResource Include="ColorControl.resx">
      <SubType>Designer</SubType>
      <DependentUpon>ColorControl.cs</DependentUpon>
    </EmbeddedResource>
    <EmbeddedResource Include="DemoForm.resx">
      <SubType>Designer</SubType>
      <DependentUpon>DemoForm.cs</DependentUpon>
    </EmbeddedResource>
    <EmbeddedResource Include="FontControl.resx">
      <SubType>Designer</SubType>
      <DependentUpon>FontControl.cs</DependentUpon>
    </EmbeddedResource>
    <EmbeddedResource Include="Properties\Resources.resx">
      <Generator>ResXFileCodeGenerator</Generator>
      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
      <SubType>Designer</SubType>
    </EmbeddedResource>
    <Compile Include="Properties\Resources.Designer.cs">
      <AutoGen>True</AutoGen>
      <DependentUpon>Resources.resx</DependentUpon>
    </Compile>
    <None Include="Properties\Settings.settings">
      <Generator>SettingsSingleFileGenerator</Generator>
      <LastGenOutput>Settings.Designer.cs</LastGenOutput>
    </None>
    <Compile Include="Properties\Settings.Designer.cs">
      <AutoGen>True</AutoGen>
      <DependentUpon>Settings.settings</DependentUpon>
      <DesignTimeSharedInput>True</DesignTimeSharedInput>
    </Compile>
  </ItemGroup>
  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
</Project>

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
Software Developer (Senior) Phi International
Canada Canada
Grew up in Amsterdam, now living in downtown Vancouver. There are definitely more mountains here.

My first internship was with the first company in the Netherlands to teach C++ (www.datasim.nl). During this internship I got to know Object Oriented Design, which kept my interest until this day. In the mean time, I have worked for different companies in the Netherlands and Canada. I have done most of my recent work in C#, developing Database/Web/Desktop applications.

I am currently working as a freelance Software Developer for PHI International in Amsterdam.

The CodeProject rocks!

Comments and Discussions