Esempio n. 1
0
        private void Stuff()
        {
            var pfact = TypeProjector.Create()
                        .SelectFrom <IShip>(t => t.Property(s => s.Fuel, 0.0F),
                                            t => t.Method(s => s.FullStop(), Return <int> .ThisAndArguments(@this => 0)))
                        .Construct(builder => builder.Prototype(
                                       Nonsense: "Lugrgar",
                                       Transform: Return <string> .ThisAndArguments <string>((@this, m) => @this.Xform(m)),
                                       DoStuff: Return <int> .ThisAndArguments <string, Ship>((@this, name, s) => { return(0); }),
                                       DamageIt: ReturnVoid.ThisAndArguments <Ship, Laser, Captain>(
                                           (@this, aShip, laser, captain) =>
            {
                aShip.Captain = captain;
                aShip.HullIntegrity[Sides.Above] -= laser.PowerLevel;
                @this.SplatOnScreen(aShip, laser);
            }),
                                       XFactorIt: Return <bool> .ThisAndArguments(@this => false)))
                        .EmbedInstanceOf <IShip>(MemberNames.MyShip)
                        .EmbedAndExpose <Captain>(MemberNames.MyCaptain,
                                                  t => t.Properties(
                                                      c => c.AggressionLevel,
                                                      c => c.Braveness,
                                                      c => c.DeceptionLevel),
                                                  t => t.Methods(
                                                      c => c.AbandonShip()
                                                      ))
                        .Initializer(
                ReturnVoid.ThisAndArguments(
                    @this =>
            {
                @this.InitialData = Tuple.Create(0, false, MemberNames.MyCaptain, string.Empty,
                                                 new Laser());
            }))
                        .Declare()
                        .CreateFactoryDressedAs <IXFactor>();

            Catalog.Services.Register(_ => pfact());



            var  ixf  = Catalog.Factory.Resolve <IXFactor>();
            bool good = ixf.XFactorIt();
        }
Esempio n. 2
0
 /// <summary>
 /// Creates a new instance of <see cref="ProjectionEntityMapper{TEntity,TModel}"/>
 /// </summary>
 public ProjectionEntityMapper(IProjectionFactory factory = null)
 {
     _projector = TypeProjector.Create <TEntity, TModel>(factory);
 }
Esempio n. 3
0
 /// <summary>
 /// Creates a new instance of <see cref="ProjectionEntityMapper{TEntity,TModel}"/>
 /// </summary>
 public ProjectionEntityMapper(CreateProjectionsCallback callback)
 {
     _projector = TypeProjector.Create <TEntity, TModel>(callback);
 }