Created
January 13, 2010 23:05
-
-
Save tunatoksoz/276657 to your computer and use it in GitHub Desktop.
This file contains hidden or 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.Linq; | |
using System.Text; | |
namespace ConsoleApplication2 | |
{ | |
using System.Runtime.Serialization; | |
class Thing1 | |
{ | |
private readonly Thing2 thing2; | |
public Thing1(Thing2 thing2) | |
{ | |
this.thing2 = thing2; | |
} | |
public Thing2 Thing2 | |
{ | |
get { return thing2; } | |
} | |
} | |
class Thing2 | |
{ | |
private readonly Thing1 thing1; | |
public Thing2(Thing1 thing1) | |
{ | |
this.thing1 = thing1; | |
} | |
public Thing1 Thing1 | |
{ | |
get { return thing1; } | |
} | |
} | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var t1 = (Thing1)FormatterServices.GetUninitializedObject(typeof(Thing1)); | |
var t2 = (Thing2)FormatterServices.GetUninitializedObject(typeof(Thing2)); | |
typeof(Thing1).GetConstructor(new[] { typeof(Thing2) }).Invoke(t1, new object[] { t2 }); | |
typeof(Thing2).GetConstructor(new[] { typeof(Thing1) }).Invoke(t2, new object[] { t1 }); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment