本文整理汇总了C#中TypeMap类的典型用法代码示例。如果您正苦于以下问题:C# TypeMap类的具体用法?C# TypeMap怎么用?C# TypeMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypeMap类属于命名空间,在下文中一共展示了TypeMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateModelSQLEmit
public IModelSQLEmit CreateModelSQLEmit(IObjectMapInfoCache cache)
{
ITypeMap tm = new TypeMap();
ISQLTranslator tr = new SQLTranslator();
IModelColumnsBuilder cb = new ModelColumnsBuilder(tr, tm);
return new ModelSQLEmit(cache, tr, tm, cb);
}
示例2: CreateDestinationFunc
private static Expression CreateDestinationFunc(
TypeMap typeMap,
TypeMapRegistry typeMapRegistry,
ParameterExpression srcParam,
ParameterExpression destParam,
ParameterExpression ctxtParam)
{
var newDestFunc = ToType(CreateNewDestinationFunc(typeMap, typeMapRegistry, srcParam, ctxtParam),
typeMap.DestinationTypeToUse);
var getDest = typeMap.DestinationTypeToUse.GetTypeInfo().IsValueType
? newDestFunc
: Coalesce(destParam, newDestFunc);
Expression destinationFunc = Assign(destParam, getDest);
if (typeMap.PreserveReferences)
{
var dest = Variable(typeof (object), "dest");
Expression valueBag = Property(ctxtParam, "InstanceCache");
var set = Assign(Property(valueBag, "Item", srcParam), dest);
var setCache =
IfThen(NotEqual(srcParam, Constant(null)), set);
destinationFunc = Block(new[] {dest}, Assign(dest, destinationFunc), setCache, dest);
}
return destinationFunc;
}
示例3: Establish_context
protected override void Establish_context()
{
_configuration = new Configuration(new TypeMapFactory(), MapperRegistry.AllMappers());
_configuration.CreateMap<Source, Destination>();
_expected = _configuration.FindTypeMapFor(null, typeof(Source), typeof(Destination));
}
示例4: MapByType
public override void MapByType( Type t, TypeMap otm )
{
this.Context = otm;
XmlDocument document = new XmlDocument();
document.Load( this.MappingDocument );
XmlNode node = document.SelectSingleNode( String.Format( "//type-map[@type={0}]", t.Name ) );
otm.Table = node.Attributes["table"].InnerText;
}
示例5: BindCustomProjectionExpression
private static MemberAssignment BindCustomProjectionExpression(PropertyMap propertyMap, TypeMap propertyTypeMap, ExpressionResolutionResult result)
{
var visitor = new ParameterReplacementVisitor(result.ResolutionExpression);
var replaced = visitor.Visit(propertyTypeMap.CustomProjection.Body);
return Expression.Bind(propertyMap.DestinationProperty.MemberInfo, replaced);
}
示例6: First
public void First()
{
var map = new TypeMap();
ushort id;
Assert.IsTrue (map.GetTypeId (typeof (string), out id));
Assert.AreEqual (0, id);
}
示例7: Construct
public static NamedTypeSymbol Construct(this NamedTypeSymbol type, params TypeSymbol[] arguments)
{
Debug.Assert(type != null);
Debug.Assert(arguments != null);
TypeMap map = new TypeMap(ReadOnlyArray<TypeSymbol>.CreateFrom(type.ConstructedFrom.TypeParameters),
arguments.AsReadOnly());
return map.SubstituteNamedType(type.ConstructedFrom);
}
示例8: Configure
public void Configure(TypeMap typeMap)
{
var sourcePropertyConfig = typeMap.FindOrCreateSourceMemberConfigFor(_sourceMember);
foreach (var action in _sourceMemberActions)
{
action(sourcePropertyConfig);
}
}
示例9: SPParameterConfig
public SPParameterConfig(SPParameter parameter, TypeMap map)
{
Definition = parameter;
FriendlyName = NamingHelpers.SplitObjectName(Definition.Name);
IsRequired = Definition.DefaultValue == null;
Type= map.GetCodeType(Definition.TypeInfo.TypeName);
SampleValue = Definition.DefaultValue as String;
Enabled = true;
}
示例10: When_creating_a_new_context_from_an_existing_context_Should_preserve_context_type_map
public void When_creating_a_new_context_from_an_existing_context_Should_preserve_context_type_map()
{
var map = new TypeMap(new TypeInfo(typeof(int)), new TypeInfo(typeof(string)), MemberList.Destination);
var context = new ResolutionContext(map, 5, typeof(int), typeof(string), new MappingOperationOptions());
ResolutionContext newContext = context.CreateValueContext(10);
newContext.GetContextTypeMap().ShouldNotBeNull();
}
示例11: TypeMapPlanBuilder
public TypeMapPlanBuilder(IConfigurationProvider configurationProvider, TypeMapRegistry typeMapRegistry, TypeMap typeMap)
{
_configurationProvider = configurationProvider;
_typeMapRegistry = typeMapRegistry;
_typeMap = typeMap;
_source = Parameter(typeMap.SourceType, "src");
_initialDestination = Parameter(typeMap.DestinationTypeToUse, "dest");
_context = Parameter(typeof(ResolutionContext), "ctxt");
_destination = Variable(_initialDestination.Type, "typeMapDestination");
}
示例12: SPConfig
internal SPConfig(SPInfo definition, ISPLoader loader, TypeMap typeMap)
{
_core = definition;
_loader = loader;
_typeMap = typeMap;
//Defaults:
FriendlyName = NamingHelpers.SplitObjectName(definition.Name);
Enabled = true;
}
示例13: ToString_Always_Succeeds
public void ToString_Always_Succeeds()
{
//Arrange
var typeMap = new TypeMap(typeof(string), typeof(int));
//Act
string actual = typeMap.ToString();
//Assert
Assert.AreEqual<string>(string.Format("{{{0}, {1}}}", typeof(string), typeof(int)), actual);
}
示例14: Add_GoodValues_Succeeds
public void Add_GoodValues_Succeeds()
{
//Arrange
var typeMapCollection = new TypeMapCollection();
var typeMap = new TypeMap(typeof(Type), typeof(Type));
//Act
typeMapCollection.Add(typeMap);
//Assert
Assert.AreEqual<TypeMapBase>(typeMap, typeMapCollection.Get(typeof(Type), typeof(Type)));
}
示例15: CtorTypeMap
public void CtorTypeMap()
{
var map = new TypeMap();
ushort id;
map.GetTypeId (typeof (string), out id);
map.GetTypeId (typeof (int), out id);
var c = new MockClientConnection (new MockConnectionProvider (MockProtocol.Instance));
var context = new SerializationContext (c, MockProtocol.Instance, map);
Assert.AreSame (map, context.TypeMap);
}