Skip to content

Commit

Permalink
Modernize EventSourcing quickstart
Browse files Browse the repository at this point in the history
  • Loading branch information
Hawxy committed Jun 14, 2024
1 parent f175add commit 854005e
Show file tree
Hide file tree
Showing 26 changed files with 1,001 additions and 979 deletions.
4 changes: 2 additions & 2 deletions docs/configuration/hostbuilder.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public interface IConfigureMarten
void Configure(IServiceProvider services, StoreOptions options);
}
```
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/Marten/MartenServiceCollectionExtensions.cs#L902-L913' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_iconfiguremarten' title='Start of snippet'>anchor</a></sup>
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/Marten/MartenServiceCollectionExtensions.cs#L1028-L1039' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_iconfiguremarten' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

You could alternatively implement a custom `IConfigureMarten` (or `IConfigureMarten<T> where T : IDocumentStore` if you're [working with multiple databases](#working-with-multiple-marten-databases)) class like so:
Expand Down Expand Up @@ -308,7 +308,7 @@ public interface IAsyncConfigureMarten
ValueTask Configure(StoreOptions options, CancellationToken cancellationToken);
}
```
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/Marten/MartenServiceCollectionExtensions.cs#L915-L927' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_iasyncconfiguremarten' title='Start of snippet'>anchor</a></sup>
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/Marten/MartenServiceCollectionExtensions.cs#L1041-L1053' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_iasyncconfiguremarten' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

As an example from the tests, here's a custom version that uses the Feature Management service:
Expand Down
11 changes: 10 additions & 1 deletion docs/configuration/storeoptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,18 @@ public abstract class MartenAttribute: Attribute
/// <param name="mapping"></param>
/// <param name="member"></param>
public virtual void Modify(DocumentMapping mapping, MemberInfo member) { }

/// <summary>
/// When used with the automatic type discovery (assembly scanning), this will be called
/// to make registrations to the Marten configuration with the type that this attribute
/// decorates
/// </summary>
/// <param name="discoveredType"></param>
/// <param name="options"></param>
public virtual void Register(Type discoveredType, StoreOptions options){}
}
```
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/Marten/Schema/MartenAttribute.cs#L12-L30' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_martenattribute' title='Start of snippet'>anchor</a></sup>
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/Marten/Schema/MartenAttribute.cs#L12-L39' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_martenattribute' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

And decorate either classes or individual field or properties on a document type, your custom attribute will be
Expand Down
Loading

0 comments on commit 854005e

Please sign in to comment.