public override void SetUp() { base.SetUp(); objectRepository = new Dictionary <string, object>(); codingStyle = BuildRoutine.CodingStyle().FromBasic() .AddTypes(GetType().Assembly, t => t.IsPublic && t.Namespace != null && t.Namespace.StartsWith(RootNamespace)) .Initializers.Add(c => c.Constructors().When(t => t.IsValueType && t.Namespace?.StartsWith(RootNamespace) == true)) .Datas.Add(c => c.PublicProperties(m => !m.IsInherited()).When(t => t.Namespace?.StartsWith(RootNamespace) == true)) .Operations.Add(c => c.PublicMethods(m => !m.IsInherited()).When(t => t.Namespace?.StartsWith(RootNamespace) == true)) .IdExtractor.Set(c => c.IdByProperty(p => p.Returns <string>("Id")).When(t => t.Namespace != null && t.Namespace.StartsWith(RootNamespace))) .Locator.Set(c => c.Locator(l => l.SingleBy(id => objectRepository[id])).When(t => t.Namespace != null && t.Namespace.StartsWith(RootNamespace) && t.Properties.Any(m => m.Returns <string>("Id")))) .NextLayer() ; var cache = new DictionaryCache(); ctx = new DefaultCoreContext(codingStyle, cache); testing = new ObjectService(ctx, cache); }
public void Configure(ConventionBasedCodingStyle codingStyle, IKernel kernel) { codingStyle .AddTypes( v => v.WebService("Unity", s => s .Methods.Add(o => o.Proxy <IAccountManagerService>("CreateAccount").TargetBySingleton(kernel)) ) ); }
public static ConventionBasedCodingStyle AddCommonSystemTypes(this ConventionBasedCodingStyle source) => source.AddTypes( typeof(void), typeof(bool), typeof(byte), typeof(short), typeof(ushort), typeof(int), typeof(uint), typeof(long), typeof(ulong), typeof(float), typeof(double), typeof(decimal), typeof(TimeSpan), typeof(DateTime), typeof(Guid), typeof(string) );
public static ConventionBasedCodingStyle AddTypes(this ConventionBasedCodingStyle source, params Func <VirtualTypeBuilder, VirtualType>[] typeBuilders ) => source.AddTypes(typeBuilders.Select(builder => builder(BuildRoutine.VirtualType())));
public static ConventionBasedCodingStyle Use(this ConventionBasedCodingStyle source, Func <PatternBuilder <ConventionBasedCodingStyle>, ConventionBasedCodingStyle> pattern ) => source.Merge(pattern(BuildRoutine.CodingStylePattern()));