- castleextensionsdemo.zip
- App.Configuration
- App.Core
- App.Data
- Castle.ExtensibleDynamicProxy
- Castle.Facilities.PresentationModelIntegration
- CastleExtensionsDemo.sln
- libs
- AttachedCommandBehavior.dll
- Castle.Core.dll
- Castle.DynamicProxy2.dll
- Castle.MicroKernel.dll
- Castle.Windsor.dll
- PresentationModelBase
- WPFUI
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Castle.Core;
using Castle.Windsor;
using Castle.MicroKernel;
using Castle.MicroKernel.Registration;
using App.Core;
using App.Data;
using System.Collections.ObjectModel;
using PresentationModelBase;
using Castle.DynamicProxy;
using System.Reflection;
using System.Collections.Specialized;
using Castle.MicroKernel.ModelBuilder.Inspectors;
using Castle.Facilities.PresentationModelIntegration;
namespace App.Configuration
{
public class ConfigurationManager
{
internal static DefaultKernel _microkernel = new DefaultKernel();
public static void Configure()
{
AppDomain.CurrentDomain.SetData("servicelocator", _microkernel);
_microkernel.AddFacility<PresentationModelWpfFacility>();
_microkernel.Register
(
Component.For<MainViewPresentationModel, IMainViewPresentationModel>().LifeStyle.Is(LifestyleType.Singleton),
Component.For<ProductsViewPresentationModel, IEntityCollectionViewPresentationModel<Product>>().LifeStyle.Is(LifestyleType.Singleton),
Component.For(typeof(DummyDao<>), typeof(IDao<>)).LifeStyle.Is(LifestyleType.Singleton),
Component.For(typeof(List<>), typeof(IList<>)).LifeStyle.Is(LifestyleType.Transient),
Component.For<ProductEditViewPresentationModel, IEntityViewPresentationModel<Product>>().LifeStyle.Is(LifestyleType.Transient)
);
InsertStubData();
}
private static void InsertStubData()
{
IDao<Product> dao = _microkernel.Resolve<IDao<Product>>();
Random r = new Random();
for (int i = 0; i < 10; i++)
{
Product p = new Product();
p.Name = string.Format("Product {0}", i + 1);
p.Price = r.Next(2, 523);
dao.SaveOrUpdate(p);
}
}
}
}
|
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.