forked from sgmunn/MonoKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Greg Munn
committed
Oct 7, 2012
1 parent
2b0c0c3
commit 269b32e
Showing
31 changed files
with
237 additions
and
276 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// -------------------------------------------------------------------------------------------------------------------- | ||
// <copyright file="NotificationEventBusExtensions.cs" company="sgmunn"> | ||
// (c) sgmunn 2012 | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated | ||
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation | ||
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and | ||
// to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of | ||
// the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO | ||
// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF | ||
// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||
// IN THE SOFTWARE. | ||
// </copyright> | ||
// -------------------------------------------------------------------------------------------------------------------- | ||
|
||
namespace MonoKit.Domain | ||
{ | ||
using System; | ||
using MonoKit.Reactive.Subjects; | ||
using MonoKit.Data; | ||
using MonoKit.Reactive.Linq; | ||
|
||
public static class NotificationEventBusExtensions | ||
{ | ||
/// <summary> | ||
/// Returns IDataModelEvents that are for the specified identity type. These could be events or read model changes | ||
/// </summary> | ||
// public static IObservable<IEvent> ForIdentity<T>(this IObservable<IDomainEvent> source) | ||
// { | ||
// //return source.Where (x => x != null && typeof(T).IsAssignableFrom(x.Identity.GetType())); | ||
// return source.Where(x => x.DataModelType is T); | ||
// } | ||
// | ||
// /// <summary> | ||
// /// Returns data model changes for the given identity, events or read models | ||
// /// </summary> | ||
// public static IObservable<IDataModelChange> DataModelChangesForIdentity<T>(this IObservable<IDataModelEvent> source) where T : IUniqueIdentity | ||
// { | ||
// return source.ForIdentity<T>() | ||
// .OfType<IDataModelChange>(); | ||
// } | ||
// | ||
// /// <summary> | ||
// /// Returns events for the given identity type | ||
// /// </summary> | ||
// public static IObservable<IAggregateEvent> EventsForIdentity<T>(this IObservable<IDataModelEvent> source) where T : IUniqueIdentity | ||
// { | ||
// return source.ForIdentity<T>() | ||
// .OfType<IAggregateEvent>(); | ||
// } | ||
|
||
/// <summary> | ||
/// Returns data model changes for the specified read model type, excluding deleted read models | ||
/// </summary> | ||
public static IObservable<T> DataModelChangesForType<T>(this IObservable<INotificationEvent> source) | ||
{ | ||
return source.Select(x => x.Event) | ||
.OfType<IDataChangeEvent>() | ||
//.Where (x => x != null && x.Change != DataModelChangeKind.Deleted && typeof(T).IsAssignableFrom(x.DataModel.GetType())) | ||
.Where (x => x != null && x.Change != DataChangeKind.Deleted && x.Data is T) | ||
.Select(x => (T)x.Data); | ||
} | ||
|
||
/// <summary> | ||
/// Returns delete notifications for read models of the specified identity type | ||
/// </summary> | ||
// public static IObservable<IUniqueIdentity> DataModelDeletionsForIdentity<T>(this IObservable<IDataModelEvent> source) where T : IUniqueIdentity | ||
// { | ||
// return source.ForIdentity<T>() | ||
// .OfType<IDataModelChange>() | ||
// .Where(x => x.Deleted) | ||
// .Select(x => x.Identity); | ||
// } | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// -------------------------------------------------------------------------------------------------------------------- | ||
// <copyright file="ObservableNotificationEventBus.cs" company="sgmunn"> | ||
// (c) sgmunn 2012 | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated | ||
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation | ||
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and | ||
// to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of | ||
// the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO | ||
// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF | ||
// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||
// IN THE SOFTWARE. | ||
// </copyright> | ||
// -------------------------------------------------------------------------------------------------------------------- | ||
|
||
namespace MonoKit.Domain | ||
{ | ||
using System; | ||
using MonoKit.Reactive.Subjects; | ||
|
||
public sealed class ObservableNotificationEventBus : INotificationEventBus | ||
{ | ||
private readonly Subject<INotificationEvent> eventPublisher; | ||
|
||
public ObservableNotificationEventBus() | ||
{ | ||
this.eventPublisher = new Subject<INotificationEvent>(); | ||
} | ||
|
||
public void Publish(INotificationEvent evt) | ||
{ | ||
this.eventPublisher.OnNext(evt); | ||
} | ||
|
||
public IDisposable Subscribe(IObserver<INotificationEvent> observer) | ||
{ | ||
return this.eventPublisher.Subscribe(observer); | ||
} | ||
} | ||
} | ||
|
Oops, something went wrong.