public void Map(ITypeMappingConfigurator<Planemo> map) { map.AsUriBaseType(); map.AsChildResourceOf(x => x.PlanetarySystem, x => x.Planets); map.PostAllowed(); map.DeleteAllowed(); }
public void Map(ITypeMappingConfigurator <Critter> map) { map.AsUriBaseType() .Include(x => x.CrazyValue) .Include(x => x.CreatedOn) .Include(x => x.Subscriptions, o => o.Expand().Writable()) .Include(x => x.HandledGeneratedProperty, o => o.OnQuery(x => x.Id % 6)) .Include(x => x.Password, o => o.WithAccessMode(HttpMethod.Post | HttpMethod.Put)) .Include(x => x.PublicAndReadOnlyThroughApi, o => o.ReadOnly()) .Include(x => x.PropertyWithAttributeAddedFluently, o => o.HasAttribute(new ObsoleteAttribute())) .IncludeAs <string>(x => x.IntExposedAsString, o => o.OnGet(x => x.IntExposedAsString.ToString()).OnQuery(x => x.IntExposedAsString.ToString()) .OnSet((c, v) => c.IntExposedAsString = int.Parse(v))) .Include(x => x.Weapons, o => o.Writable()) .Include(x => x.RelativeImageUrl, o => o.Named("AbsoluteImageUrl") .OnGet <NancyContext>((critter, ctx) => { var absUrl = ctx.Request.Url.Clone(); absUrl.Path = critter.RelativeImageUrl; absUrl.Query = null; return(absUrl.ToString()); }) .OnSet <NancyContext>( (critter, value, ctx) => { critter.RelativeImageUrl = new Uri(value).AbsolutePath.Substring((ctx.Request.Url.BasePath ?? "").Length); })) .Include(x => x.Enemies, o => o.ExpandShallow()) .HandledBy <CritterHandler>() .OnDeserialized(c => c.FixParentReferences()); }
public void Map(ITypeMappingConfigurator <Planemo> map) { map.AsUriBaseType(); map.AsChildResourceOf(x => x.PlanetarySystem, x => x.Planets); map.PostAllowed(); map.DeleteAllowed(); }
public void Map(ITypeMappingConfigurator <StringToObjectDictionaryContainer> map) { // SAMPLE: map-property-as-attributes map.Include(x => x.Map, o => o.AsAttributes()); // ENDSAMPLE map.Include(x => x.ETag, o => o.AsEtag()); }
public void Map(ITypeMappingConfigurator <PlanetarySystem> map) { map.AsUriBaseType() .Include(x => x.Planets, o => o.ExposedAsRepository().Allow(HttpMethod.Post).ItemsAllow(HttpMethod.Delete)) .HasChild(x => x.Star, x => x.PlanetarySystem) .AsChildResourceOf(x => x.Galaxy, x => x.PlanetarySystems); }
public void Map(ITypeMappingConfigurator<PlanetarySystem> map) { map.AsUriBaseType() .Include(x => x.Planets, o => o.ExposedAsRepository().Allow(HttpMethod.Post).ItemsAllow(HttpMethod.Delete)) .HasChild(x => x.Star, x => x.PlanetarySystem) .AsChildResourceOf(x => x.Galaxy, x => x.PlanetarySystems); }
// ENDSAMPLE #endregion #region sample // SAMPLE: misc-include-property-onget-onset-onquery public void IncludePropertyWithCustomAccessors(ITypeMappingConfigurator <Customer> customer) { customer .Include(x => x.Name, x => x .OnGet(y => y.Name.ToUpper()) .OnSet((c, v) => c.Name = v.ToLower()) .OnQuery(y => y.Name.ToUpper())); }
public void Map(ITypeMappingConfigurator <Loner> map) { map.ConstructedUsing( (c) => new Loner(c.Requires().Name, c.Requires().Strength, c.Optional().OptionalInfo, c.Optional().OptionalDate)); }
public void Map(ITypeMappingConfigurator<Planet> map) { map.HasChildren(x => x.Moons, x => x.Planet, x => x.AsUriBaseType() .ConstructedUsing(y => new Moon(y.Requires().Name, y.Parent<Planet>())), x => x.Writable()); map.ConstructedUsing(x => new Planet(x.Requires().Name, x.Parent<PlanetarySystem>())); }
public void Map(ITypeMappingConfigurator <Planet> map) { map.HasChildren(x => x.Moons, x => x.Planet, x => x.AsUriBaseType() .ConstructedUsing(y => new Moon(y.Requires().Name, y.Parent <Planet>())), x => x.Writable()); map.ConstructedUsing(x => new Planet(x.Requires().Name, x.Parent <PlanetarySystem>())); }
public void Map(ITypeMappingConfigurator <IExposedInterface> map) { map .Named("ExposedInterface") .AsUriBaseType() .WithPluralName("ExposedInterfaces") .Include(x => x.PropertyFromInheritedInterface) .AsConcrete() .ConstructedUsing(c => new ExposedInterfaceInternalImplementation()); }
public void Map(ITypeMappingConfigurator<IExposedInterface> map) { map .Named("ExposedInterface") .AsUriBaseType() .WithPluralName("ExposedInterfaces") .Include(x => x.PropertyFromInheritedInterface) .AsConcrete() .ConstructedUsing(c => new ExposedInterfaceInternalImplementation()); }
public void Map(ITypeMappingConfigurator<Planet> map) { map.AsUriBaseType(); map.HasChildren(x => x.Moons, x => x.Planet, x => x.AsUriBaseType() .AsChildResourceOf(y => y.Planet, y => y.Moons) .ConstructedUsing(y => new Moon(y.Requires().Name, y.Parent<Planet>())), x => x); map.AsChildResourceOf(x => x.PlanetarySystem, x => x.Planets) .ConstructedUsing(x => new Planet(x.Requires().Name, x.Parent<PlanetarySystem>())) .Include(x => x.Moons, o => o.Writable()); }
public void Map(ITypeMappingConfigurator <VirtualPropertyThing> map) { map .Include <string>("Rocky", o => o.OnGetAndQuery(x => x.Items.SafeGet("Rocky") ?? "BALOBA") .OnSet((x, v) => x.Items["Rocky"] = v) .Writable()) .Include <double>("NumberSquareRoot", o => o.OnGetAndQuery(x => Math.Sqrt(x.Number)) .OnSet((x, v) => x.Number = v * v) .Writable()); }
public void Map(ITypeMappingConfigurator<HandledThing> map) { map .HasChildren(x => x.Children, x => x.Parent, t => { return t.ConstructedUsing(c => new HandledChild(c.Parent<HandledThing>())) .HandledBy<HandledThingsHandler>(); }, o => o.ExposedAsRepository()) .Include(x => x.ETag, o => o.AsEtag()) .AsUriBaseType() .DeleteAllowed().HandledBy<HandledThingsHandler>(); }
public void Map(ITypeMappingConfigurator <HandledThing> map) { map .HasChildren(x => x.Children, x => x.Parent, t => { return (t.ConstructedUsing(c => new HandledChild(c.Parent <HandledThing>())) .HandledBy <HandledThingsHandler>()); }, o => o.ExposedAsRepository()) .Include(x => x.ETag, o => o.AsEtag()) .AsUriBaseType() .DeleteAllowed().HandledBy <HandledThingsHandler>(); }
public void Map(ITypeMappingConfigurator <TestEntityBase> map) { map.Include(x => x.Id); map.Include(x => x.ToBeOverridden); switch (this.defaultPropertyInclusionMode) { case null: break; case DefaultPropertyInclusionMode.AllPropertiesRequiresExplicitMapping: map.AllPropertiesRequiresExplicitMapping(); break; case DefaultPropertyInclusionMode.AllPropertiesAreIncludedByDefault: map.AllPropertiesAreIncludedByDefault(); break; case DefaultPropertyInclusionMode.AllPropertiesAreExcludedByDefault: map.AllPropertiesAreExcludedByDefault(); break; } }
// ENDSAMPLE #endregion #region sample // SAMPLE: misc-exclude-property-fluent-rule public void ExcludeRule(ITypeMappingConfigurator<Customer> customer) { customer.Exclude(x => x.Password); }
// ENDSAMPLE #endregion #region sample // SAMPLE: misc-plural-name-fluent-rule public void PluralNameRule(ITypeMappingConfigurator<Mouse> mouse) { mouse.WithPluralName("Mice"); }
public void Map(ITypeMappingConfigurator <ThingIndependentFromBase> map) { map.AsIndependentTypeRoot(); }
// SAMPLE: misc-constructed-using-fluent-rule public void ConstructedUsingRule(ITypeMappingConfigurator<Customer> customer) { customer.ConstructedUsing(c => new Customer(c.Requires().Name, c.Optional().Password)); }
public void Map(ITypeMappingConfigurator <UnpatchableThing> map) { map.PatchDenied(); }
public void Map(ITypeMappingConfigurator <MusicalCritter> map) { map.ConstructedUsing((c) => new MusicalCritter(c.Optional().OnlyWritableByInheritedResource)); }
public void Map(ITypeMappingConfigurator<UnpostableThingOnServer> map) { map.WithPluralName("UnpostableThingsOnServer"); map.PostDenied(); }
public void Map(ITypeMappingConfigurator<GuidThing> map) { map.HandledBy<GuidThingHandler>().ConstructedUsing(c => new GuidThing(null)); }
public void Map(ITypeMappingConfigurator<MusicalCritter> map) { map.ConstructedUsing((c) => new MusicalCritter(c.Optional().OnlyWritableByInheritedResource)); }
public void Map(ITypeMappingConfigurator<UnpatchableThing> map) { map.PatchDenied(); }
public void Map(ITypeMappingConfigurator <Subscription> map) { map.AsValueObject(); map.Exclude(x => x.Critter); }
public void Map(ITypeMappingConfigurator <ErrorStatus> map) { map.AsValueObject(); }
public void Map(ITypeMappingConfigurator<NoPrimaryKeyThing> map) { }
// ENDSAMPLE #endregion #region sample // SAMPLE: misc-include-property-named public void IncludePropertyNamed(ITypeMappingConfigurator<Customer> customer) { customer.Include(x => x.Identifier, x => x.Named("Id")); }
public void Map(ITypeMappingConfigurator <HasReadOnlyDictionaryProperty> map) { map.Include(x => x.Map, o => o.AsAttributes().WithAccessMode(HttpMethod.Get | HttpMethod.Patch | HttpMethod.Post)); }
public void Map(ITypeMappingConfigurator<UnpostableThing> map) { map.PostDenied(); }
// SAMPLE: etag-fluent-rule public void Map(ITypeMappingConfigurator <EtaggedEntity> map) { map.Include(x => x.ETag, o => o.AsEtag()); }
public void Map(ITypeMappingConfigurator <OrderResponse> map) { map.AsValueObject(); }
// ENDSAMPLE #endregion public void Map(ITypeMappingConfigurator <CritterCaptureCommand> map) { map.AsValueObject(); }
public void Map(ITypeMappingConfigurator <NoPrimaryKeyThing> map) { }
public void Map(ITypeMappingConfigurator <Gun> map) { map.ConstructedUsing(x => new Gun(x.Requires().Model)) .Include(x => x.ExplosionFactor); }
public void Map(ITypeMappingConfigurator <JunkWithRenamedProperty> map) { map.Include(x => x.ReallyUglyPropertyName, o => o.Named("BeautifulAndExposed")); }
public void Map(ITypeMappingConfigurator<UnpostableThingOnServer> map) { map.PostAllowed(); }
// ENDSAMPLE #endregion #region sample // SAMPLE: misc-expand-property public void ExpandProperty(ITypeMappingConfigurator<Customer> customer) { customer .Include(x => x.Address, x => x.Expand(ExpandMode.Full)); }
public void Map(ITypeMappingConfigurator<AbstractAnimal> map) { map.Include(x => x.PublicAndReadOnlyThroughApi, o => o.ReadOnly()); }
// ENDSAMPLE #endregion #region sample // SAMPLE: misc-contextful-construction-fluent-rule public void ContextfulConstructionRule(ITypeMappingConfigurator<Customer> customer) { customer.ConstructedUsing( c => c.Context<ICustomerFactory>() .CreateCustomer(c.Requires().Name, c.Optional().Password)); }
public void Map(ITypeMappingConfigurator <RenamedThing> map) { map.Named("GotNewName").WithPluralName("ThingsWithNewName").ExposedAt("renamings"); }
// ENDSAMPLE #endregion #region sample // SAMPLE: misc-handled-by-fluent-rule public void HandlerRule(ITypeMappingConfigurator<Customer> customer) { customer.HandledBy<CustomerHandler>(); }
public void Map(ITypeMappingConfigurator <UnhandledThing> map) { // HandledThingsHandler got not matching methods for unhandled thing. Which means request should be passed to the DataSource instead. map.HandledBy <HandledThingsHandler>(); }
// ENDSAMPLE #endregion #region sample // SAMPLE: misc-value-object-fluent-rule public void ValueObjectRule(ITypeMappingConfigurator<Customer> customer) { customer.AsValueObject(); }
public void Map(ITypeMappingConfigurator<CelestialObject> map) { map.AsIndependentTypeRoot() .Include(x => x.Name, o => o.AsPrimaryKey()) .Include(x => x.ETag, o => o.AsEtag().ReadOnly()); }
// ENDSAMPLE #endregion #region sample // SAMPLE: misc-include-property-onget-onset-onquery public void IncludePropertyWithCustomAccessors(ITypeMappingConfigurator<Customer> customer) { customer .Include(x => x.Name, x => x .OnGet(y => y.Name.ToUpper()) .OnSet((c, v) => c.Name = v.ToLower()) .OnQuery(y => y.Name.ToUpper())); }
public void Map(ITypeMappingConfigurator<Galaxy> map) { map.AsUriBaseType() .Include(x => x.PlanetarySystems, o => o.ExposedAsRepository()); }
public void Map(ITypeMappingConfigurator<Star> map) { map.AsChildResourceOf(x => x.PlanetarySystem, x => x.Star); }
public void Map(ITypeMappingConfigurator<Customer> map) { map.Exclude(x => x.Password); map.Include(x => x.Name); map.Include(x => x.Identifier, o => o.AsPrimaryKey()); }
public void Map(ITypeMappingConfigurator <UnpostableThing> map) { map.PostDenied(); }
public void Map(ITypeMappingConfigurator <ArgNullThrowingThing> map) { // This should throw ArgumentNullException on creation if Incoming property is null, // for testing that this turns into a ValidationException. map.ConstructedUsing(x => new ArgNullThrowingThing(x.Optional().Incoming)); }
public void Map(ITypeMappingConfigurator<PlanetarySystem> map) { map.AsUriBaseType() .Include(x => x.Planets, o => o.ExposedAsRepository()) .AsChildResourceOf(x => x.Galaxy, x => x.PlanetarySystems); }
public void Map(ITypeMappingConfigurator <AbstractAnimal> map) { map.Include(x => x.PublicAndReadOnlyThroughApi, o => o.ReadOnly()); }
public void Map(ITypeMappingConfigurator <UnpostableThingOnServer> map) { map.WithPluralName("UnpostableThingsOnServer"); map.PostDenied(); }
public void Map(ITypeMappingConfigurator<Dummy> map) { map.HandledBy<DummyHandler>(); }
public void Map(ITypeMappingConfigurator<Critter> map) { map.Include(x => x.PublicAndReadOnlyThroughApi, o => o.ReadOnly()); }
public void Map(ITypeMappingConfigurator <HandledSingleChild> map) { map.AsChildResourceOf(x => x.HandledThing, x => x.SingleChild); }