The Bitter Coder Tutorials, Binsor Style
Simple Configuration
So, before we get to the code, in order to get Binsor to work, you'll need the following references: From Rhino Tools (http://sourceforge.net/projects/rhino-tools/)- Boo.Lang
- Boo.Lang.Compiler
- Boo.Lang.Extensions
- Boo.Lang.Parser
- Rhino.Commons.Binsor
- Rhino.Commons.Clr
- Rhino.DSL
- Castle.Core
- Castle.DynamicProxy2
- Castle.MicroKernal
- Castle.Windsor
namespace BitterCoder.Tutorials.Binsor.Core
{
public class TaxCalculator
{
private decimal _rate = 0.125m;
public decimal Rate
{
set { _rate = value; }
get { return _rate; }
}
public decimal CalculateTax(decimal gross)
{
return Math.Round(_rate * gross, 2);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Castle.Core;
using Castle.Windsor;
using Rhino.Commons.Binsor;
using BitterCoder.Tutorials.Binsor.Core;
namespace BitterCoder.Tutorials.Binsor.ConsoleTester
{
class Program
{
static void Main(string[] args)
{
IWindsorContainer container = new WindsorContainer().Install(BinsorScript.FromFile("windsor.boo"));
TaxCalculator calculator = container.Resolve<TaxCalculator>();
decimal gross = 100;
decimal tax = calculator.CalculateTax(gross);
Console.WriteLine("Gross: {0}, Tax: {1}", gross, tax);
Console.Read();
}
}
}
import System
import System.Reflection
import BitterCoder.Tutorials.Binsor.Core
component "tax.calculator", TaxCalculator:
Rate=Convert.ToDecimal(0.25)