Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reorganize SQLiteLogViewer to support cross-platform development
- Split Models and ViewModels out of the main project - Use EventAggregator to eliminate ViewModels' WPF dependency
- Loading branch information
Russell Johnston
committed
Aug 2, 2016
1 parent
eb2a14f
commit 5677824
Showing
38 changed files
with
445 additions
and
151 deletions.
There are no files selected for viewing
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,6 @@ | ||
namespace SQLiteDebugger | ||
{ | ||
public class ConnectEvent | ||
{ | ||
} | ||
} |
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,90 @@ | ||
// ----------------------------------------------------------------------- | ||
// <copyright file="DelegateWrapper.cs" company="Microsoft"> | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// </copyright> | ||
// ----------------------------------------------------------------------- | ||
|
||
namespace Toolkit | ||
{ | ||
using System; | ||
using System.Reflection; | ||
|
||
internal class DelegateWrapper | ||
{ | ||
private WeakReference target; | ||
private MethodInfo method; | ||
private Type type; | ||
|
||
private ThreadAffinity affinity; | ||
|
||
public DelegateWrapper(Delegate wrappedDelegate, ThreadAffinity affinity) | ||
{ | ||
this.target = new WeakReference(wrappedDelegate.Target); | ||
this.method = wrappedDelegate.GetMethodInfo(); | ||
this.type = wrappedDelegate.GetType(); | ||
|
||
this.affinity = affinity; | ||
} | ||
|
||
public bool IsDead | ||
{ | ||
get { return this.target.Target == null; } | ||
} | ||
|
||
public bool Wraps(Delegate wrappedDelegate) | ||
{ | ||
return wrappedDelegate.Equals(this.TryGetDelegate()); | ||
} | ||
|
||
public Invoker<TMessage> GetInvoker<TMessage>() | ||
{ | ||
var action = this.TryGetDelegate(); | ||
if (action != null) | ||
{ | ||
return new Invoker<TMessage>((Action<TMessage>)action, this.affinity); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public class Invoker<TMessage> | ||
{ | ||
private Action<TMessage> action; | ||
private ThreadAffinity affinity; | ||
|
||
public Invoker(Action<TMessage> action, ThreadAffinity affinity) | ||
{ | ||
this.action = action; | ||
this.affinity = affinity; | ||
} | ||
|
||
public void Invoke(TMessage message, IDispatcher dispatcher) | ||
{ | ||
if (this.affinity == ThreadAffinity.UIThread) | ||
{ | ||
dispatcher.Invoke(() => this.action(message)); | ||
} | ||
else | ||
{ | ||
this.action(message); | ||
} | ||
} | ||
} | ||
|
||
private Delegate TryGetDelegate() | ||
{ | ||
if (this.method.IsStatic) | ||
{ | ||
return this.method.CreateDelegate(this.type, null); | ||
} | ||
|
||
var receiver = this.target.Target; | ||
if (this.target != null) | ||
{ | ||
return this.method.CreateDelegate(this.type, receiver); | ||
} | ||
|
||
return null; | ||
} | ||
} | ||
} |
Oops, something went wrong.