本文整理汇总了C#中ITypeMapper类的典型用法代码示例。如果您正苦于以下问题:C# ITypeMapper类的具体用法?C# ITypeMapper怎么用?C# ITypeMapper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ITypeMapper类属于命名空间,在下文中一共展示了ITypeMapper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitializeTypeMapper
public void InitializeTypeMapper(ITypeMapper typeMapper)
{
var thisAssembly = Assembly.GetAssembly(GetType());
foreach (var type in thisAssembly.GetTypes())
{
if (!type.IsConcrete())
continue;
var interfaceName = "I" + type.Name;
var interface_ = type.GetInterface(interfaceName);
if (interface_ == null)
continue;
// This was tricky to figure out, just getting the interface will get
// you the generic type w/o generic parameters, not the generic type
// definition.
var mappedInterface = (interface_.IsGenericType)
? interface_.GetGenericTypeDefinition()
: interface_;
var mappedType = (type.IsGenericType)
? type.GetGenericTypeDefinition()
: type;
typeMapper.Map(mappedInterface, mappedType);
}
}
示例2: DataSourceRootNode
public DataSourceRootNode(ITypeMapper typeMapper, IPomonaDataSource dataSource)
: base(typeMapper, null, "/")
{
if (dataSource == null)
throw new ArgumentNullException("dataSource");
this.dataSource = dataSource;
}
示例3: NewDelegate
public NewDelegate(Type delegateType, Operand target, string methodName, ITypeMapper typeMapper)
{
_delegateType = delegateType;
_target = target;
_typeMapper = typeMapper;
Initialize(target.GetReturnType(typeMapper), methodName);
}
示例4: GetDeleteSql
public string GetDeleteSql(ITypeMapper mapper, string whereSql)
{
if (string.IsNullOrEmpty(whereSql))
return string.Format("Delete From {0}", DecorateName(mapper.TableName));
return string.Format("Delete From {0} Where {1}", DecorateName(mapper.TableName), whereSql);
}
示例5: InitializeTypeMapper
public void InitializeTypeMapper(ITypeMapper typeMapper)
{
typeMapper.Map<IList, ArrayList>();
typeMapper.Map<IDictionary, Hashtable>();
typeMapper.Map(typeof(IList<>), typeof(List<>));
typeMapper.Map(typeof(IDictionary<,>), typeof(Dictionary<,>));
}
示例6: UriResolver
public UriResolver(ITypeMapper typeMapper, IBaseUriProvider baseUriProvider)
{
if (typeMapper == null)
throw new ArgumentNullException("typeMapper");
if (baseUriProvider == null)
throw new ArgumentNullException("baseUriProvider");
this.typeMapper = typeMapper;
this.baseUriProvider = baseUriProvider;
}
示例7: PomonaHttpQueryTransformer
public PomonaHttpQueryTransformer(ITypeMapper typeMapper, QueryExpressionParser parser)
{
if (typeMapper == null)
throw new ArgumentNullException("typeMapper");
if (parser == null)
throw new ArgumentNullException("parser");
this.typeMapper = typeMapper;
this.parser = parser;
}
示例8: Delta
protected Delta(object original, TypeSpec type, ITypeMapper typeMapper, Delta parent = null)
{
if (original == null) throw new ArgumentNullException("original");
if (type == null) throw new ArgumentNullException("type");
if (typeMapper == null) throw new ArgumentNullException("typeMapper");
Original = original;
Type = type;
TypeMapper = typeMapper;
this.parent = parent;
}
示例9: Creator
public static ITypeMapper Creator()
{
if (instance == null)
{
string typeName = ConfigManager.SettingsSection.AppSettings["typeMapper"].Value;
instance = (ITypeMapper)Activator.CreateInstance(Type.GetType(typeName));
}
return instance;
}
示例10: InsertDataCommand
public InsertDataCommand(ICommandPerformer<string> exec, ICache cache, ITypeMapper mapper, EntityData value)
{
this.value = value;
this.cache = cache;
this.executor = exec;
this.schema = cache.Pick<Document>();
this.nameSpace = schema.Settings[Keys.Namespace];
this.mapper = mapper;
this.properties = schema.Entities.Single(x => x.Name == value.EntityName).Properties;
}
示例11: PathNode
protected PathNode(ITypeMapper typeMapper, PathNode parent, string name)
{
if (typeMapper == null)
throw new ArgumentNullException("typeMapper");
if (name == null)
throw new ArgumentNullException("name");
this.typeMapper = typeMapper;
this.parent = parent;
this.name = name;
}
示例12: Initialize
void Initialize(ITypeMapper typeMapper)
{
if (_initialized) return;
_initialized = true;
// TODO: proper checking as in specification
if (_ifTrue.GetReturnType(typeMapper) != _ifFalse.GetReturnType(typeMapper))
throw new ArgumentException(Properties.Messages.ErrInvalidConditionalVariants);
if (_cond.GetReturnType(typeMapper) != typeMapper.MapType(typeof(bool))) _cond = _cond.IsTrue();
}
示例13: CreateContext
public void CreateContext()
{
_typeMapper = new Moq.Mock<ITypeMapper>().Object;
_random = new Moq.Mock<IRandom>().Object;
_idGenerator = new Moq.Mock<IIdGenerator>().Object;
var context = Create();
Assert.That(context.TypeMapper, Is.Not.Null);
Assert.That(context.Random, Is.Not.Null);
Assert.That(context.IdGenerator, Is.Not.Null);
}
示例14: ResourceResolver
public ResourceResolver(ITypeMapper typeMapper, NancyContext context, IRouteResolver routeResolver)
{
if (typeMapper == null)
throw new ArgumentNullException("typeMapper");
if (context == null)
throw new ArgumentNullException("context");
if (routeResolver == null)
throw new ArgumentNullException("routeResolver");
//if (routeResolver == null) throw new ArgumentNullException("routeResolver");
this.typeMapper = typeMapper;
this.context = context;
this.routeResolver = routeResolver;
}
示例15: GenerateTypes
public IEnumerable<IGeneratedType> GenerateTypes(IEnumerable<ITypeDescription> typeDescriptions, ITypeMapper typeMapper)
{
if (typeDescriptions == null)
{
throw new ArgumentNullException("typeDescriptions");
}
if (typeMapper == null)
{
throw new ArgumentNullException("typeMapper");
}
Validate(typeDescriptions);
var name = "PocoAssembly";
var assemblyName = new AssemblyName(name);
var appDomain = Thread.GetDomain();
AssemblyBuilder assemblyBuilder;
ModuleBuilder moduleBuilder;
if (this.getTypeFromDiskAssembly)
{
assemblyBuilder = appDomain.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.RunAndSave);
moduleBuilder = assemblyBuilder.DefineDynamicModule(assemblyName.Name, this.assemblyName);
}
else
{
assemblyBuilder = appDomain.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.Run);
moduleBuilder = assemblyBuilder.DefineDynamicModule(assemblyName.Name);
}
var generatedTypes = new List<IGeneratedType>();
foreach (var typeDescription in typeDescriptions)
{
var result = GenerateType(moduleBuilder, typeDescription, typeMapper);
typeMapper.RegisterNewType(typeDescription, result);
generatedTypes.Add(result);
}
if (this.getTypeFromDiskAssembly)
{
var generatedConvertedTypes = this.LoadFromDisk(assemblyBuilder, generatedTypes);
return generatedConvertedTypes;
}
else
{
return generatedTypes;
}
}