本文整理汇总了C#中ITypeMapper.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# ITypeMapper.GetType方法的具体用法?C# ITypeMapper.GetType怎么用?C# ITypeMapper.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITypeMapper
的用法示例。
在下文中一共展示了ITypeMapper.GetType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TypeInfo
/// <summary>
/// Initialize a new object.
/// </summary>
/// <param name="nativeDbType">Native database type as used in stored procedures.</param>
/// <param name="typeMapper">Mapps native to target data types and renders code items associated with data type.</param>
/// <param name="precision">Native DB type precision - if applicable.</param>
/// <param name="scale">Native DB type scale - if applicable.</param>
public TypeInfo(string nativeDbType, ITypeMapper typeMapper, int precision, int scale)
{
this.typeMapper = typeMapper;
this.precision = precision;
this.scale = scale;
this.NativeDbType = typeMapper.NativeDbType(nativeDbType);
this.IsVariableLengthNativeType = typeMapper.IsVariableLengthNativeType(nativeDbType);
this.Type = typeMapper.Type(nativeDbType, precision, scale);
this.DefaultValue = typeMapper.DefaultValue(nativeDbType, precision, scale);
this.IsValueType = typeMapper.IsValueType(nativeDbType);
this.DbType = typeMapper.DbType(nativeDbType);
this.NullableType = typeMapper.NullableType(nativeDbType, precision, scale);
this.NullValue = typeMapper.NullValue(nativeDbType, precision, scale);
this.DataType = typeMapper.GetType(nativeDbType, precision, scale);
}
示例2: AddTypeMapper
/// <summary>
/// Adds a type mapper to the chain with given priority. If mapper privided as an external MBean, the
/// <paramref name="objectName"/> arguments is the name of this MBean; otherwise it is null.
/// </summary>
/// <param name="mapper">The mapper instance. In case of external mapper this is a reference to proxy of the MBean.</param>
/// <param name="objectName">In case of external mapper, this is its <see cref="ObjectName"/>.</param>
/// <param name="priority">The priority of a mapper. Must be unique.</param>
/// <exception cref="NonUniquePriorityException">Another mapper with privided priority is already registered.</exception>
public void AddTypeMapper(ITypeMapper mapper, ObjectName objectName, int priority)
{
TypeMapperInfo newMapperInfo = new TypeMapperInfo(priority, objectName == null ? mapper.GetType().AssemblyQualifiedName : null, objectName);
if (_mappers.ContainsKey(priority))
{
TypeMapperInfo exisingMapperInfo = _mapperInfos.Find(delegate(TypeMapperInfo info)
{
return info.Priority == priority;
});
throw new NonUniquePriorityException(
newMapperInfo.ObjectName != null ? newMapperInfo.ObjectName.ToString() : newMapperInfo.TypeName,
exisingMapperInfo.ObjectName != null ? exisingMapperInfo.ObjectName.ToString() : exisingMapperInfo.TypeName,
priority
);
}
_mappers.Add(priority, mapper);
_mapperInfos.Add(newMapperInfo);
}
示例3: GenerateType
private static IGeneratedType GenerateType(ModuleBuilder moduleBuilder, ITypeDescription typeDescription, ITypeMapper typeMapper)
{
var typeBuilder = moduleBuilder.DefineType(typeDescription.Name, TypeAttributes.Public | TypeAttributes.Class);
typeBuilder.DefineDefaultConstructor(MethodAttributes.Public);
var types = typeDescription.PropertyDescriptions.Select(x => x.Type).ToArray();
var constructorBuilder = typeBuilder.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, types);
var index = 1;
foreach (var property in typeDescription.PropertyDescriptions)
{
constructorBuilder.DefineParameter(index, ParameterAttributes.None, property.Name.LowercaseFirst());
index++;
}
var ctorIl = constructorBuilder.GetILGenerator();
ctorIl.Emit(OpCodes.Ldarg_0);
ctorIl.Emit(OpCodes.Call, typeBuilder.BaseType.GetConstructor(Type.EmptyTypes));
index = 1;
foreach (var property in typeDescription.PropertyDescriptions)
{
var targetPropertyType = typeMapper.GetType(property.Type);
EmitForPropertyDescription(typeBuilder, property, ctorIl, index, targetPropertyType);
index++;
}
ctorIl.Emit(OpCodes.Ret);
var type = typeBuilder.CreateType();
return new GeneratedType(typeDescription.Name, type, typeDescription);
}