public void Conditionals() { EasyType typebuilder = new EasyType(module, "mytype"); FieldReference cachefield = typebuilder.CreateField("cache", typeof(IDictionary)); ArgumentReference arg = new ArgumentReference(typeof(bool)); EasyConstructor constructor = typebuilder.CreateConstructor(arg); constructor.CodeBuilder.InvokeBaseConstructor(); ConditionExpression exp = new ConditionExpression(OpCodes.Brtrue_S, arg.ToExpression()); exp.AddTrueStatement(new AssignStatement(cachefield, new NewInstanceExpression(typeof(HybridDictionary), new Type[0]))); exp.AddFalseStatement(new AssignStatement(cachefield, new NewInstanceExpression(typeof(Hashtable), new Type[0]))); constructor.CodeBuilder.AddStatement(new ExpressionStatement(exp)); constructor.CodeBuilder.AddStatement(new ReturnStatement()); ReturnReferenceExpression ret = new ReturnReferenceExpression(typeof(IDictionary)); EasyMethod getCache = typebuilder.CreateMethod("GetCache", ret); getCache.CodeBuilder.AddStatement(new ReturnStatement(cachefield)); Type newType = typebuilder.BuildType(); object instance = Activator.CreateInstance(newType, new object[] { true }); MethodInfo method = instance.GetType().GetMethod("GetCache"); object dic = method.Invoke(instance, new object[0]); Assert.IsTrue(dic is HybridDictionary); instance = Activator.CreateInstance(newType, new object[] { false }); dic = method.Invoke(instance, new object[0]); Assert.IsTrue(dic is Hashtable); RunPEVerify(); }