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
static void InterceptUsingActionsAndExpressionsToGetMethodNames() | |
{ | |
//pass an array of lambdas to get the names of the methods that will be intercepted | |
var proxyCtx = ObjectProxyFactory | |
.CreateUsingActions<IUnitOfWork>(new MyContext(), | |
pre => System.Console.WriteLine("Entering {0}", pre.CallCtx.MethodName), | |
pos => System.Console.WriteLine("Exiting {0}", pos.CallCtx.MethodName), | |
null, true, | |
//no magic strings | |
m1 => m1.SaveChanges(), |
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
static void InterceptUsingActionsAndStringArrayMethods() | |
{ | |
//helper method that returns the method name - no magic strings | |
var methods = ObjectProxyFactory.GetMethodNames<IUnitOfWork>(c => c.SaveChanges()); | |
//helper method that returns the method names from the properties (getters and setters) - no magic strings | |
var methodsFromProperties = ObjectProxyFactory.GetMethodNamesFromProperties<IMyContext>(c => c.Customers); | |
//union two above arrays | |
var mixedArray = methods.Union(methodsFromProperties).ToArray(); |
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
using System; | |
namespace DynamicProxy.Console.Infra | |
{ | |
public interface IUnitOfWork : IDisposable | |
{ | |
int SaveChanges(); | |
} | |
} |
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
using System; | |
using System.Diagnostics; | |
using System.ComponentModel; | |
using System.Dynamic; | |
using System.Reflection; | |
using System.Linq.Expressions; | |
static void InterceptWithAttributeEntity() | |
{ | |
var myContext = new MyContext(); |
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
public interface INotifyPropertyChangedExtended : INotifyPropertyChanged | |
{ | |
void OnPropertyChanged(string propertyName); | |
} | |
public interface IOrder : INotifyPropertyChangedExtended | |
{ | |
int Id { get; set; } | |
ICustomer Customer { 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
using System; | |
using System.Collections.Generic; | |
using System.ComponentModel; | |
using System.Dynamic; | |
using System.Linq; | |
using System.Reflection; | |
namespace DynamicUtils | |
{ | |
public class NotifyPropertyChangedProxy<T> : DynamicObject, INotifyPropertyChanged |
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
namespace DynamicProxy.Console | |
{ | |
class Program | |
{ | |
static void Main() | |
{ | |
var myContext = new MyContext(); | |
//create entries in DbContext | |
Customer entry = myContext.Customers.FirstOrDefault(); |
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
public static class CaliburnExtensions | |
{ | |
public static IEnumerable<IResult> BeginExecute(this IEnumerable<Func<IResult>> routines) | |
{ | |
return routines.Select(routine => routine()); | |
} | |
public static void AsCoroutine(this IEnumerable<IResult> routine, | |
EventHandler<ResultCompletionEventArgs> callBack = null, | |
ActionExecutionContext ctx = null) |
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
using System.Windows; | |
using System.Windows.Controls; | |
namespace WpfApplication1 | |
{ | |
/// <summary> | |
/// Interaction logic for FilePicker.xaml | |
/// </summary> | |
public partial class FilePicker : UserControl | |
{ |
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 Idea: http://blog.smoothfriction.nl/archive/2012/05/07/silverlight-busyindicator-in-caliburn-micro-pt-2-again.aspx | |
//A simpler solution: | |
public interface IBusy | |
{ | |
bool IsBusy { get; set; } | |
} |