A 1-post collection

Redux for C#.NET 2.0

Refer to :

I made this piece of code because those redux libraries just don't support .NET 2.0. If you are in the same situation as I was, this piece of code might shed some light on your project.

If you don't know what Redux is ? Educate yourself with, Yes! originally it was designed for javascript web development. Many people found this too good to be kept only in the js world, including me.

I don't intend for this to be a full-fledged redux library, I developed this just for a proof of concept that redux is really compatible with .NET 2.0. Feel free tailor the code to suit your need :D

What's included

  1. Libs
    1. class Act, every action should extend this class
    2. class State, every state should extend this class
    3. class Store, every store should extend this class
    4. class Reducer, every reducer should extend this class
      • each methods in classes extending this class, should be Reducer functions in the form of public <StateClass> Reduce(<StateClass> s, <ActClass> act) {..}
    5. class ReduceRunner, create an instance of this class and use it to run reduce functions (keeping the program responsive while reducing).
  2. Examples
    1. Calculator program
    2. GUI Calculator program



This should be an oversimplified calculator application supporting only a plus operation, and have no UI, just for demonstration purposes.

All the actions for this application are defined in the file calculator/act.cs

public class ActPlus : Act { public int a; public int b; }  
public class ActClear : Act { }  

And now our state calculator/state.cs

public class CalculatorState : State<CalculatorState>  
    public bool has_result = false;
    public int result;

Reducer functions should be defined in calculator/reducer.cs

public class CalculatorReducer : Reducer<CalculatorState, CalculatorStore&
อ่านต่อ »