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
//POST: http://silverlightrush.blogspot.com/2011/11/receita-de-bolo-para-ef-code-first-e.html | |
using System; | |
using System.Collections.Generic; | |
using System.ComponentModel.DataAnnotations; | |
using System.Data.Common; | |
using System.Data.Entity; | |
using System.Data.Entity.Infrastructure; | |
using System.Linq; | |
using Oracle.DataAccess.Client; |
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
CREATE TABLE "PESSOAS" | |
( "ID" NUMBER, | |
"NOME" VARCHAR2(50), | |
CONSTRAINT "PESSOAS_PK" PRIMARY KEY ("ID") ENABLE | |
) | |
/ | |
CREATE TABLE "TELEFONES" | |
( "ID" NUMBER NOT NULL ENABLE, | |
"PESSOA_ID" NUMBER NOT NULL ENABLE, | |
"NUMERO" VARCHAR2(10) NOT NULL ENABLE, |
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
// Created by por Jone Polvora | |
// Twitter: @jpolvora | |
// WebSite: http://silverlightrush.blogspot.com | |
// Based on Dynamic Decorator / CBO Extender Project (http://www.codeproject.com/Articles/275292/Component-Based-Object-Extender) | |
// Depends on Impromptu-Interface (https://code.google.com/p/impromptu-interface/_ | |
// Last Update: 21/05/2012 10:40AM GMT -04:00 | |
// Brazil | |
/* USAGE EXAMPLE |
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
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) |