static void Main(string[] args) { //实例化接口实现类 var repo = new Repository(); //动态生成代理 var repoProxy = EmitGenerator <IRepository> .GenerateProxy(repo); //使用代理调用方法 repoProxy.Add("Hello"); repoProxy.Add("World"); repoProxy.Remove("World"); repoProxy.Update("A,ning", p => p == "World"); //将会抛出列表中不存在项异常 //var repoGeneric = new RepositoryGeneric<string>(); //var repoGenProxy = EmitGenerator<IRepositoryGeneric<string>>.GenerateProxy(repoGeneric); ////使用代理调用方法 //repoGenProxy.Add("Hello"); //repoGenProxy.Add("World"); //repoGenProxy.Remove("World"); //repoGenProxy.Update("A,ning", p => p == "World"); //将会抛出列表中不存在项异常 Console.WriteLine("End..."); Console.ReadKey(); }
/// <returns>The instance variable</returns> private static void ComputeReader(ILGenerator il, Type type, BoisComplexTypeInfo typeInfo) { switch (typeInfo.ComplexKnownType) { case EnComplexKnownType.Collection: EmitGenerator.ReadRootCollection(type, typeInfo, il); break; case EnComplexKnownType.Dictionary: EmitGenerator.ReadRootDictionary(type, typeInfo, il); break; case EnComplexKnownType.UnknownArray: EmitGenerator.ReadRootUnknownArray(type, typeInfo, il); break; case EnComplexKnownType.NameValueColl: EmitGenerator.ReadRootNameValueColl(type, typeInfo, il); break; case EnComplexKnownType.ISet: EmitGenerator.ReadRootISet(type, typeInfo, il); break; case EnComplexKnownType.Unknown: default: ReadRootObject(il, type, typeInfo); break; } }
private static void ReadRootObjectComplexMember(Type memberType, BoisComplexTypeInfo complexTypeInfo, PropertyInfo prop, FieldInfo field, Type containerType, ILGenerator il, SharedVariables variableCache) { switch (complexTypeInfo.ComplexKnownType) { case EnComplexKnownType.Collection: case EnComplexKnownType.ISet: EmitGenerator.ReadGenericCollection(prop, field, null, containerType, il, complexTypeInfo.IsNullable, variableCache); break; case EnComplexKnownType.Dictionary: EmitGenerator.ReadDictionary(prop, field, null, containerType, il, complexTypeInfo.IsNullable, variableCache); break; case EnComplexKnownType.UnknownArray: EmitGenerator.ReadUnknownArray(prop, field, null, containerType, il, complexTypeInfo.IsNullable, variableCache); break; case EnComplexKnownType.NameValueColl: EmitGenerator.ReadNameValueColl(prop, field, null, containerType, il, complexTypeInfo.IsNullable, variableCache); break; case EnComplexKnownType.Unknown: default: EmitGenerator.ReadUnknownComplexTypeCall(memberType, prop, field, containerType, il, complexTypeInfo); return; } }
private static void WriteRootObjectComplexMember(Type memberType, BoisComplexTypeInfo complexTypeInfo, PropertyInfo prop, FieldInfo field, Type containerType, ILGenerator il) { switch (complexTypeInfo.ComplexKnownType) { case EnComplexKnownType.Collection: EmitGenerator.WriteCollection(prop, field, null, containerType, il, complexTypeInfo.IsNullable); break; case EnComplexKnownType.Dictionary: EmitGenerator.WriteDictionary(prop, field, null, containerType, il, complexTypeInfo.IsNullable); break; case EnComplexKnownType.UnknownArray: EmitGenerator.WriteUnknownArray(prop, field, null, containerType, il, complexTypeInfo.IsNullable); break; case EnComplexKnownType.NameValueColl: EmitGenerator.WriteNameValueColl(prop, field, null, il, complexTypeInfo.IsNullable); break; case EnComplexKnownType.ISet: EmitGenerator.WriteISet(prop, field, null, containerType, il, complexTypeInfo.IsNullable); break; case EnComplexKnownType.Unknown: default: EmitGenerator.WriteUnknownComplexTypeCall(memberType, prop, field, il, containerType, complexTypeInfo); return; } }
internal static void ComputeWriter(ILGenerator il, Type type, BoisComplexTypeInfo typeInfo) { switch (typeInfo.ComplexKnownType) { case EnComplexKnownType.Collection: EmitGenerator.WriteRootList(type, typeInfo, il); break; case EnComplexKnownType.Dictionary: EmitGenerator.WriteRootDictionary(type, typeInfo, il); break; case EnComplexKnownType.NameValueColl: EmitGenerator.WriteRootNameValueCol(type, typeInfo, il); return; case EnComplexKnownType.UnknownArray: EmitGenerator.WriteRootUnknownArray(type, typeInfo, il); break; case EnComplexKnownType.ISet: EmitGenerator.WriteRootISet(type, typeInfo, il); break; case EnComplexKnownType.Unknown: default: WriteRootObject(il, type, typeInfo); break; } }
public void EmitConstructorBody(TypeBuilder typeBuilder, EmitGenerator gen) { var mergerType = DefineParameterMergerField(typeBuilder); var mergerCtor = GetParameterMergerConstructor(mergerType); gen.LoadThis(); gen.LoadArgument(1); gen.New(mergerCtor); gen.StoreField(_paramMergerField); }
public void EmitConstructorBody(TypeBuilder typeBuilder, EmitGenerator gen, int ctorArgumentIndex, ref int memberParameterIndex) { if (_paramEmitBodySet == null) { return; } for (int i = 0; i < _paramEmitBodySet.Length; i++) { _paramEmitBodySet[i].EmitConstructorBody(typeBuilder, gen, ctorArgumentIndex, ref memberParameterIndex); } }
public void EmitConstructorBody(TypeBuilder typeBuilder, EmitGenerator gen, int ctorArgumentIndex, ref int memberParameterIndex) { var fieldType = DefineParameterField(typeBuilder, memberParameterIndex); gen.LoadThis(); gen.LoadArgument(ctorArgumentIndex); gen.LoadArrayElement(memberParameterIndex); gen.CastAny(fieldType); gen.StoreField(_paramField); memberParameterIndex += 1; }
public void EmitExecuteMethodBody(EmitGenerator gen, LocalBuilder instance) { // Use MakeByRefType(), because this is an out (ref) parameter in the method signature. var paramType = _dependencyProvider.TargetType.MakeByRefType(); var paramTypes = new Type[] { typeof(InjectionContext), paramType }; var createObjectMethod = _paramField.FieldType.GetMethod("CreateObject", paramTypes); if (createObjectMethod == null) { throw new ImpossibleException(); } _paramValue = gen.DeclareLocal(_dependencyProvider.TargetType); gen.LoadThis(); gen.LoadField(_paramField); gen.LoadArgument(1); gen.LoadLocalAddress(_paramValue); gen.CallMethod(createObjectMethod); }
public void EmitExecuteMethodBody(EmitGenerator gen, LocalBuilder instance) { if (_paramEmitBodySet == null) { gen.LoadLocal(instance); gen.CallMethod(_injectedMethod); } else { for (int i = 0; i < _paramEmitBodySet.Length; i++) { _paramEmitBodySet[i].EmitExecuteMethodBody(gen, instance); } gen.LoadLocal(instance); for (int i = 0; i < _paramEmitBodySet.Length; i++) { gen.LoadLocal(_paramEmitBodySet[i].ParameterValue); } gen.CallMethod(_injectedMethod); } }
public void EmitExecuteMethodBody(EmitGenerator gen, LocalBuilder instance) { if (_dependencyProviders == null || _dependencyProviders.Length == 0) { //var dummyClass = new DummyClass(); gen.New(_injectedCtor); gen.StoreLocal(instance); } else { //IObjectRegistration p1; //IConfigurationModule p2; //ILifetimeScope p3; //_parameterMerger.Merge(context, out p1, out p2, out p3); //instance = new DummyClass(p1, p2, p3); var mergeMethod = _paramMergerField.FieldType.GetMethod("Merge"); if (mergeMethod == null) { throw new ImpossibleException(); } #region Define Locals //IObjectRegistration p1; //IConfigurationModule p2; //ILifetimeScope p3; var ctorParamBuilders = new LocalBuilder[_dependencyProviders.Length]; for (int i = 0; i < _dependencyProviders.Length; i++) { ctorParamBuilders[i] = gen.DeclareLocal(_dependencyProviders[i].TargetType); } #endregion #region _parameterMerger.Merge(context, out p1, out p2, out p3); gen.LoadThis(); gen.LoadField(_paramMergerField); gen.LoadArgument(1); for (int i = 0; i < ctorParamBuilders.Length; i++) { gen.LoadLocalAddress(ctorParamBuilders[i]); } gen.CallMethod(mergeMethod); #endregion #region instance = new DummyClass(p1, p2, p3); for (int i = 0; i < ctorParamBuilders.Length; i++) { gen.LoadLocal(ctorParamBuilders[i]); } gen.New(_injectedCtor); gen.StoreLocal(instance); #endregion } }
static void EmitMergeMethodBody(EmitGenerator gen, GenericTypeParameterBuilder[] genParamBuilders, FieldBuilder[] depProviderFields) { // var myParams = context.Parameters; var myParams = gen.DeclareLocal(ParameterSetType); gen.LoadArgument(1); gen.CallMethod(GetInjectionContextParameters); gen.StoreLocal(myParams); #region If (myParams == null || myParams.Length == 0) condition // if (myParams == null || myParams.Length == 0) Goto myParamsIsNullLabel Else Goto myParamsIsNotNullAndLengthNotEqualTo0Label var myParamsIsNullLabel = gen.DefineLabel(); var myParamsIsNotNullAndLengthNotEqualTo0Label = gen.DefineLabel(); gen.LoadLocal(myParams); gen.IfFalseGoto(myParamsIsNullLabel); gen.LoadLocal(myParams); gen.CallMethod(GetParameterLength); gen.IfTrueGoto(myParamsIsNotNullAndLengthNotEqualTo0Label); #endregion var createObjectMethods = new MethodInfo[depProviderFields.Length]; #region if (myParams == null || myParams.Length == 0) block gen.MarkLabel(myParamsIsNullLabel); for (int i = 0; i < depProviderFields.Length; i++) { // _dependency0.CreateObject(context, out param0); // _dependency1.CreateObject(context, out param1); // ... var depProviderField = depProviderFields[i]; gen.LoadThis(); gen.LoadField(depProviderField); gen.LoadArgument(1); // load parameter [context] gen.LoadArgument(i + 2); // load parameter [param0], [param1], [param2]... var createObjectMethod = GetCreateObjectOfDependencyProviderMethod(depProviderField.FieldType); createObjectMethods[i] = createObjectMethod; gen.CallMethod(createObjectMethod); } gen.Return(); #endregion #region if (myParams != null && myParams.Length != 0) block gen.MarkLabel(myParamsIsNotNullAndLengthNotEqualTo0Label); // var paramKind = myParams.ParameterKind; var paramKind = gen.DeclareLocal(typeof(ParameterKind)); gen.LoadLocal(myParams); gen.CallMethod(GetParameterKind); gen.StoreLocal(paramKind); // (Ok)===================================================== var paramKindDefaultCase = gen.DefineLabel(); var paramKindTable = new Label[] { gen.DefineLabel(), gen.DefineLabel() }; gen.LoadLocal(paramKind); gen.Switch(paramKindTable); // switch (paramKind) // case default Goto paramKindDefaultCase gen.Goto(paramKindDefaultCase); // (Ok)===================================================== #region case paramKind = ParameterKind.Positional (Ok) gen.MarkLabel(paramKindTable[0]); // var myParamLength = myParams.Length; var myParamLength = gen.DeclareLocal(typeof(int)); gen.LoadLocal(myParams); gen.CallMethod(GetParameterLength); gen.StoreLocal(myParamLength); // switch (myParamLength) gen.LoadLocal(myParamLength); gen.LoadInt32(1); gen.Substrate(); // myParamLength - 1, this is because the switch branch is starting from 1, instead of 0 var paramLengthDefaultCase = gen.DefineLabel(); var paramLengthTable = new Label[depProviderFields.Length]; for (int i = 0; i < depProviderFields.Length; i++) { paramLengthTable[i] = gen.DefineLabel(); } gen.Switch(paramLengthTable); // case default Goto paramLengthDefaultCase gen.Goto(paramLengthDefaultCase); #region case i for myParamLength for (int i = 0; i < depProviderFields.Length; i++) { gen.MarkLabel(paramLengthTable[i]); for (int j = 0; j < depProviderFields.Length; j++) { if (j <= i) { // something like: param0 = GetPositionalDependencyObject(_depProvider0, myParams[0], context); // load _depProvider0 gen.LoadThis(); gen.LoadField(depProviderFields[j]); // load myParams[0] gen.LoadLocal(myParams); gen.LoadInt32(j); gen.CallMethod(GetItem); // load context gen.LoadArgument(1); var genParamType = genParamBuilders[j]; gen.CallMethod(OpenGetPositionalDependencyObjectMethod.MakeGenericMethod(genParamType)); //gen.StoreObject(genParamType); gen.StoreArgument(j + 2); } else { // something like: _depProvider1.CreateObject(context, out param1); // load _depProvider1 gen.LoadThis(); gen.LoadField(depProviderFields[j]); // load context gen.LoadArgument(1); // load param1, its index is j + 2 gen.LoadArgument(j + 2); gen.CallMethod(createObjectMethods[j]); } } gen.Return(); } #endregion #region default case for myParamLength gen.MarkLabel(paramLengthDefaultCase); gen.LoadArgument(1); gen.LoadInt32(depProviderFields.Length); gen.LoadLocal(myParams); gen.CallMethod(GetParameterLength); gen.CallMethod(ParameterNumberExceedsMethod); gen.Throw(); #endregion gen.Return(); #endregion #region case paramKind = ParameterKind.Named (Ok) gen.MarkLabel(paramKindTable[1]); for (int i = 0; i < depProviderFields.Length; i++) { // something like: param0 = GetNamedDependencyObject(_depProvider0, myParams, context); // load _depProvider0 gen.LoadThis(); //gen.LoadThis(); // why do we need this? gen.LoadField(depProviderFields[i]); // load myParams gen.LoadLocal(myParams); // load context gen.LoadArgument(1); var genParamType = genParamBuilders[i]; gen.CallMethod(OpenGetNamedDependencyObjectMethod.MakeGenericMethod(genParamType)); // store to param0, its parameter index is [i + 2] gen.StoreArgument(i + 2); } gen.Return(); #endregion #region default case for ParameterKind (Ok) gen.MarkLabel(paramKindDefaultCase); gen.Throw(ImpossibleExceptionConstructor); #endregion gen.Return(); #endregion }
private static void ReadRootObjectBasicMember(Type memberType, BoisBasicTypeInfo basicInfo, PropertyInfo prop, FieldInfo field, Type containerType, ILGenerator il, SharedVariables variableCache) { switch (basicInfo.KnownType) { case EnBasicKnownType.String: EmitGenerator.ReadString(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.Bool: EmitGenerator.ReadBool(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.Int16: EmitGenerator.ReadInt16(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.Int32: EmitGenerator.ReadInt32(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.Int64: EmitGenerator.ReadInt64(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.UInt16: EmitGenerator.ReadUInt16(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.UInt32: EmitGenerator.ReadUInt32(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.UInt64: EmitGenerator.ReadUInt64(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.Double: EmitGenerator.ReadDouble(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.Decimal: EmitGenerator.ReadDecimal(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.Single: EmitGenerator.ReadFloat(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.Byte: EmitGenerator.ReadByte(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.SByte: EmitGenerator.ReadSByte(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.DateTime: EmitGenerator.ReadDateTime(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.DateTimeOffset: EmitGenerator.ReadDateTimeOffset(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.KnownTypeArray: EmitGenerator.ReadUnknownArray(prop, field, null, containerType, il, basicInfo.IsNullable, variableCache); break; case EnBasicKnownType.ByteArray: EmitGenerator.ReadByteArray(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.Enum: EmitGenerator.ReadEnum(prop, field, null, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.TimeSpan: EmitGenerator.ReadTimeSpan(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.Char: EmitGenerator.ReadChar(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.Guid: EmitGenerator.ReadGuid(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.Color: EmitGenerator.ReadColor(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.DbNull: EmitGenerator.ReadDbNull(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.Uri: EmitGenerator.ReadUri(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.Version: EmitGenerator.ReadVersion(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.DataTable: EmitGenerator.ReadDataTable(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.DataSet: EmitGenerator.ReadDataSet(prop, field, null, containerType, il, basicInfo.IsNullable); break; default: case EnBasicKnownType.Unknown: return; } }
internal static void WriteBasicTypeDirectly(Type containerType, ILGenerator il, BoisBasicTypeInfo keyTypeBasicInfo, Func <Type> valueLoader) { switch (keyTypeBasicInfo.KnownType) { case EnBasicKnownType.String: EmitGenerator.WriteString(null, null, valueLoader, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.Bool: EmitGenerator.WriteBool(null, null, valueLoader, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.Int16: EmitGenerator.WriteInt16(null, null, valueLoader, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.Int32: EmitGenerator.WriteInt32(null, null, valueLoader, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.Int64: EmitGenerator.WriteInt64(null, null, valueLoader, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.UInt16: EmitGenerator.WriteUInt16(null, null, valueLoader, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.UInt32: EmitGenerator.WriteUInt32(null, null, valueLoader, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.UInt64: EmitGenerator.WriteUInt64(null, null, valueLoader, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.Double: EmitGenerator.WriteDouble(null, null, valueLoader, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.Decimal: EmitGenerator.WriteDecimal(null, null, valueLoader, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.Single: EmitGenerator.WriteFloat(null, null, valueLoader, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.Byte: EmitGenerator.WriteByte(null, null, valueLoader, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.SByte: EmitGenerator.WriteSByte(null, null, valueLoader, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.DateTime: EmitGenerator.WriteDateTime(null, null, valueLoader, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.DateTimeOffset: EmitGenerator.WriteDateTimeOffset(null, null, valueLoader, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.KnownTypeArray: EmitGenerator.WriteKnownTypeArray(null, null, valueLoader, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.ByteArray: EmitGenerator.WriteByteArray(null, null, valueLoader, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.Enum: EmitGenerator.WriteEnum(null, null, valueLoader, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.TimeSpan: EmitGenerator.WriteTimeSpan(null, null, valueLoader, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.Char: EmitGenerator.WriteChar(null, null, valueLoader, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.Guid: EmitGenerator.WriteGuid(null, null, valueLoader, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.Color: EmitGenerator.WriteColor(null, null, valueLoader, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.DbNull: EmitGenerator.WriteDbNull(null, null, valueLoader, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.Uri: EmitGenerator.WriteUri(null, null, valueLoader, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.Version: EmitGenerator.WriteVersion(null, null, valueLoader, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.DataTable: EmitGenerator.WriteDataTable(null, null, valueLoader, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.DataSet: EmitGenerator.WriteDataSet(null, null, valueLoader, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.Unknown: default: throw new ArgumentOutOfRangeException("keyTypeBasicInfo.KnownType"); } }
private static void WriteRootObjectBasicMember(Type memberType, BoisBasicTypeInfo basicInfo, PropertyInfo prop, FieldInfo field, Type containerType, ILGenerator il) { switch (basicInfo.KnownType) { case EnBasicKnownType.String: EmitGenerator.WriteString(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.Bool: EmitGenerator.WriteBool(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.Int16: EmitGenerator.WriteInt16(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.Int32: EmitGenerator.WriteInt32(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.Int64: EmitGenerator.WriteInt64(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.UInt16: EmitGenerator.WriteUInt16(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.UInt32: EmitGenerator.WriteUInt32(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.UInt64: EmitGenerator.WriteUInt64(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.Double: EmitGenerator.WriteDouble(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.Decimal: EmitGenerator.WriteDecimal(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.Single: EmitGenerator.WriteFloat(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.Byte: EmitGenerator.WriteByte(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.SByte: EmitGenerator.WriteSByte(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.DateTime: EmitGenerator.WriteDateTime(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.DateTimeOffset: EmitGenerator.WriteDateTimeOffset(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.ByteArray: EmitGenerator.WriteByteArray(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.KnownTypeArray: EmitGenerator.WriteKnownTypeArray(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.Enum: EmitGenerator.WriteEnum(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.TimeSpan: EmitGenerator.WriteTimeSpan(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.Char: EmitGenerator.WriteChar(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.Guid: EmitGenerator.WriteGuid(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.Color: EmitGenerator.WriteColor(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.DbNull: EmitGenerator.WriteDbNull(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.Uri: EmitGenerator.WriteUri(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.Version: EmitGenerator.WriteVersion(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.DataTable: EmitGenerator.WriteDataTable(prop, field, null, containerType, il, basicInfo.IsNullable); break; case EnBasicKnownType.DataSet: EmitGenerator.WriteDataSet(prop, field, null, containerType, il, basicInfo.IsNullable); break; default: case EnBasicKnownType.Unknown: return; } }
internal static void ReadBasicTypeDirectly(ILGenerator il, Type containerType, BoisBasicTypeInfo keyTypeBasicInfo, Action valueSetter) { switch (keyTypeBasicInfo.KnownType) { case EnBasicKnownType.String: EmitGenerator.ReadString(null, null, valueSetter, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.Bool: EmitGenerator.ReadBool(null, null, valueSetter, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.Int16: EmitGenerator.ReadInt16(null, null, valueSetter, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.Int32: EmitGenerator.ReadInt32(null, null, valueSetter, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.Int64: EmitGenerator.ReadInt64(null, null, valueSetter, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.UInt16: EmitGenerator.ReadUInt16(null, null, valueSetter, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.UInt32: EmitGenerator.ReadUInt32(null, null, valueSetter, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.UInt64: EmitGenerator.ReadUInt64(null, null, valueSetter, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.Double: EmitGenerator.ReadDouble(null, null, valueSetter, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.Decimal: EmitGenerator.ReadDecimal(null, null, valueSetter, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.Single: EmitGenerator.ReadFloat(null, null, valueSetter, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.Byte: EmitGenerator.ReadByte(null, null, valueSetter, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.SByte: EmitGenerator.ReadSByte(null, null, valueSetter, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.DateTime: EmitGenerator.ReadDateTime(null, null, valueSetter, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.DateTimeOffset: EmitGenerator.ReadDateTimeOffset(null, null, valueSetter, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.KnownTypeArray: //EmitGenerator.ReadKnownTypeArray(null, null, valueSetter, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.ByteArray: EmitGenerator.ReadByteArray(null, null, valueSetter, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.Enum: EmitGenerator.ReadEnum(null, null, valueSetter, containerType, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.TimeSpan: EmitGenerator.ReadTimeSpan(null, null, valueSetter, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.Char: EmitGenerator.ReadChar(null, null, valueSetter, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.Guid: EmitGenerator.ReadGuid(null, null, valueSetter, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.Color: EmitGenerator.ReadColor(null, null, valueSetter, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.DbNull: EmitGenerator.ReadDbNull(null, null, valueSetter, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.Uri: EmitGenerator.ReadUri(null, null, valueSetter, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.Version: EmitGenerator.ReadVersion(null, null, valueSetter, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.DataTable: EmitGenerator.ReadDataTable(null, null, valueSetter, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.DataSet: EmitGenerator.ReadDataSet(null, null, valueSetter, containerType, il, keyTypeBasicInfo.IsNullable); break; case EnBasicKnownType.Unknown: default: throw new ArgumentOutOfRangeException("keyTypeBasicInfo.KnownType"); } }