static void Main(string[] args) { int x = 10; double y = 0; float z = 0; long xx = 0; char yy = '1'; Dictionary <int, Type> d = new Dictionary <int, Type>(); d[1] = x.GetType(); d[2] = y.GetType(); d[3] = z.GetType(); d[4] = xx.GetType(); d[5] = yy.GetType(); Parallel.ForEach(d.Keys, (i) => { try { TypeCacher.GetPropertiesAndFields(d[i]); TypeCacher.GetPropertiesAndFields(d[i]); } catch (Exception) { } }); }
public void SameTags_ActivatesObjects_OfSameType() { Type TypeResolver() => typeof(SameTags_ActivatesObjects_OfSameType_TestData); var tc1 = new TypeCacher <SameTags_ActivatesObjects_OfSameType_TestData>(); var tc2 = new TypeCacher <SameTags_ActivatesObjects_OfSameType_TestData>(); var o1 = tc1.Activate(TypeResolver); var o2 = tc2.Activate(TypeResolver); Assert.Equal(o1.GetType(), o2.GetType()); }
public void DifferentTags_ActivatesDifferentObjects() { Type TypeResolver1() => typeof(DifferentTags_ActivatesDifferentObjects_TestData1); Type TypeResolver2() => typeof(DifferentTags_ActivatesDifferentObjects_TestData2); var tc1 = new TypeCacher <DifferentTags_ActivatesDifferentObjects_TestData1>(); var tc2 = new TypeCacher <DifferentTags_ActivatesDifferentObjects_TestData2>(); var o1 = tc1.Activate(TypeResolver1); var o2 = tc2.Activate(TypeResolver2); Assert.NotEqual(o1.GetType(), o2.GetType()); }
public void SameTags_InvokesResover_Once() { int invoked = 0; Type TypeResolver() { invoked++; return(typeof(SameTags_InvokesResover_Once_TestData)); } var tc1 = new TypeCacher <SameTags_InvokesResover_Once_TestData>(); var tc2 = new TypeCacher <SameTags_InvokesResover_Once_TestData>(); var o1 = tc1.Activate(TypeResolver); var o2 = tc2.Activate(TypeResolver); Assert.Equal(1, invoked); }