Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Program
- {
- static void Main()
- {
- var f = new IFoo {
- Foo = "foo",
- Print = () => Console.WriteLine(Foo)
- };
- }
- }
- interface IFoo
- {
- String Foo { get; set; }
- void Print();
- }
- internal sealed class <>f__AnonymousType0<<Foo>j__TPar> : IFoo
- {
- readonly <Foo>j__TPar <Foo>i__Field;
- public <>f__AnonymousType0(<Foo>j__TPar Foo)
- {
- this.<Foo>i__Field = Foo;
- }
- public <Foo>j__TPar Foo
- {
- get { return this.<Foo>i__Field; }
- }
- public void Print()
- {
- Console.WriteLine(this.Foo);
- }
- }
- Create<IFoo>
- (
- new
- {
- Foo = "foo",
- Print = (Action)(() => Console.WriteLine(Foo))
- }
- );
- T Create<T> (object o)
- {
- //...
- }
- Create
- {
- new Members<IFoo>
- {
- {"Print", ((IFoo @this)=>Console.WriteLine(Foo))},
- {"Foo", "foo"}
- }
- }
- using ImpromptuInterface.Dynamic;
- var f = ImpromptuGet.Create<IFoo>(new{
- Foo = "foo",
- Print = ReturnVoid.Arguments(() => Console.WriteLine(Foo))
- });
- void Main() {
- var foo = new Foo();
- foo.Bar = "bar";
- foo.Print = () => Console.WriteLine(foo.Bar);
- foo.Print();
- }
- class Foo : IFoo {
- public String Bar { get; set; }
- public Action Print {get;set;}
- }
- using System;
- class Program {
- static void Main() {
- var f = new IFoo() {
- public String Foo { get { return "foo"; } }
- public void Print() { Console.WriteLine(Foo); }
- };
- }
- }
- interface IFoo {
- String Foo { get; set; }
- void Print();
- }
Add Comment
Please, Sign In to add comment