-
Notifications
You must be signed in to change notification settings - Fork 8
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
1 parent
8f4378b
commit fded0ae
Showing
8 changed files
with
119 additions
and
139 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
|
||
namespace Terminal.Core.Collections | ||
{ | ||
public interface IGroup | ||
{ | ||
/// <summary> | ||
/// Group index | ||
/// </summary> | ||
/// <returns></returns> | ||
long GetIndex(); | ||
|
||
/// <summary> | ||
/// Grouping implementation | ||
/// </summary> | ||
/// <param name="previous"></param> | ||
/// <returns></returns> | ||
IGroup Update(IGroup previous); | ||
} | ||
|
||
public class ObservableGroupCollection<T> : ObservableCollection<T> where T : IGroup | ||
{ | ||
/// <summary> | ||
/// Groups | ||
/// </summary> | ||
protected virtual IDictionary<long, int> Groups { get; set; } | ||
|
||
/// <summary> | ||
/// Constructor | ||
/// </summary> | ||
public ObservableGroupCollection() | ||
{ | ||
Groups = new Dictionary<long, int>(); | ||
} | ||
|
||
/// <summary> | ||
/// Grouping implementation | ||
/// </summary> | ||
/// <param name="item"></param> | ||
/// <param name="span"></param> | ||
public virtual void Add(IGroup item, TimeSpan? span) | ||
{ | ||
var index = item.GetIndex(); | ||
|
||
if (Groups.TryGetValue(index, out var position)) | ||
{ | ||
this[position] = (T)item.Update(this[position]); | ||
return; | ||
} | ||
|
||
Groups[index] = Count; | ||
|
||
Add((T)item.Update(null)); | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using System; | ||
|
||
namespace Terminal.Core.Services | ||
{ | ||
public class NotificationService | ||
{ | ||
public virtual Action<string> OnMessage { get; set; } | ||
} | ||
} |
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