• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# TypeMap类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中TypeMap的典型用法代码示例。如果您正苦于以下问题:C# TypeMap类的具体用法?C# TypeMap怎么用?C# TypeMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TypeMap类属于命名空间,在下文中一共展示了TypeMap类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
 }
开发者ID:rexzh,项目名称:RexToy,代码行数:7,代码来源:DialectProvider.cs


示例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;
        }
开发者ID:284247028,项目名称:AutoMapper,代码行数:29,代码来源:TypeMapPlanBuilder.cs


示例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));
            }
开发者ID:DeanMilojevic,项目名称:AutoMapper,代码行数:7,代码来源:ConfigurationSpecs.cs


示例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;
 }
开发者ID:ikariiwarrior,项目名称:Alpaca,代码行数:8,代码来源:XmlMappingProvider.cs


示例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);
        }
开发者ID:gonzalogilrepositorio,项目名称:Proyecto-ComIT,代码行数:8,代码来源:CustomProjectionExpressionBinder.cs


示例6: First

        public void First()
        {
            var map = new TypeMap();

            ushort id;
            Assert.IsTrue (map.GetTypeId (typeof (string), out id));
            Assert.AreEqual (0, id);
        }
开发者ID:strager,项目名称:Tempest,代码行数:8,代码来源:TypeMapTests.cs


示例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);
        }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:9,代码来源:NamedTypeSymbolExtensions.cs


示例8: Configure

        public void Configure(TypeMap typeMap)
        {
            var sourcePropertyConfig = typeMap.FindOrCreateSourceMemberConfigFor(_sourceMember);

            foreach (var action in _sourceMemberActions)
            {
                action(sourcePropertyConfig);
            }
        }
开发者ID:284247028,项目名称:AutoMapper,代码行数:9,代码来源:SourceMappingExpression.cs


示例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;
 }
开发者ID:404htm,项目名称:FlightORM_Original,代码行数:9,代码来源:SPParameterConfig.cs


示例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();
        }
开发者ID:nates1973,项目名称:AutoMapper,代码行数:10,代码来源:ResolutionContextTester.cs


示例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");
 }
开发者ID:tlycken,项目名称:AutoMapper,代码行数:10,代码来源:TypeMapPlanBuilder.cs


示例12: SPConfig

        internal SPConfig(SPInfo definition, ISPLoader loader, TypeMap typeMap)
        {
            _core = definition;
            _loader = loader;
            _typeMap = typeMap;

            //Defaults:
            FriendlyName = NamingHelpers.SplitObjectName(definition.Name);
            Enabled = true;
        }
开发者ID:404htm,项目名称:FlightORM_Original,代码行数:10,代码来源:SPConfig.cs


示例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);
        }
开发者ID:hennadiilu,项目名称:Nmap,代码行数:11,代码来源:TypeMapTesting.cs


示例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)));
        }
开发者ID:hennadiilu,项目名称:Nmap,代码行数:12,代码来源:TypeMapCollectionTesting.cs


示例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);
        }
开发者ID:strager,项目名称:Tempest,代码行数:13,代码来源:SerializationContextTests.cs


示例16: HaveSameParameterTypes

        internal static bool HaveSameParameterTypes(ReadOnlyArray<ParameterSymbol> params1, TypeMap typeMap1, ReadOnlyArray<ParameterSymbol> params2, TypeMap typeMap2, bool considerRefOutDifference, bool considerCustomModifiers)
        {
            Contract.ThrowIfNotEquals(params1.Count, params2.Count);

            var numParams = params1.Count;

            for (int i = 0; i < numParams; i++)
            {
                var param1 = params1[i];
                var param2 = params2[i];

                var type1 = SubstituteType(typeMap1, param1.Type);
                var type2 = SubstituteType(typeMap2, param2.Type);

                //the runtime compares custom modifiers using (effectively) SequenceEqual
                if (considerCustomModifiers)
                {
                    if (!type1.IsSameType(type2, ignoreDynamic: true) || !param1.CustomModifiers.SequenceEqual(param2.CustomModifiers))
                    {
                        return false;
                    }
                }
                else if (!type1.IsSameType(type2, ignoreCustomModifiers: true, ignoreDynamic: true))
                {
                    return false;
                }

                var refKind1 = param1.RefKind;
                var refKind2 = param2.RefKind;

                // Metadata signatures don't distinguish ref/out, but C# does - even when comparing metadata method signatures.
                if (considerRefOutDifference)
                {
                    if (refKind1 != refKind2)
                    {
                        return false;
                    }
                }
                else
                {
                    if ((refKind1 == RefKind.None) != (refKind2 == RefKind.None))
                    {
                        return false;
                    }
                }
            }

            return true;
        }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:49,代码来源:SignatureComparisonHelper.cs


示例17: TestSerializationAndDeserialization

        public void TestSerializationAndDeserialization()
        {
            var map = new TypeMap();
            map.Entries.Add(new TypeInfo());
            map.Entries.Add(new TypeInfo());
            map.Source = "Test Source";

            var f = Path.GetTempFileName();
            map.Save(f);
            var map2 = TypeMap.Load(f);

            Assert.IsNotNull(map2);
            Assert.IsTrue(map.Source == map2.Source);
            Assert.IsTrue(map.Entries.Count == map2.Entries.Count());
        }
开发者ID:404htm,项目名称:FlightORM_Original,代码行数:15,代码来源:TypeMapTests.cs


示例18: Get_GoodValues_ReturnsTypeMap

        public void Get_GoodValues_ReturnsTypeMap()
        {
            //Arrange
            var typeMapCollection = new TypeMapCollection();
            var typeMap = new TypeMap(typeof(Type), typeof(Type));
            typeMapCollection.Add(typeMap);

            //Act
            var actual = typeMapCollection.Get(typeof(Type), typeof(Type));
            var value = typeMapCollection.Get(typeof(Type), typeof(string));

            //Assert
            Assert.AreEqual<TypeMapBase>(typeMap, actual);
            Assert.IsNull(value);
        }
开发者ID:hennadiilu,项目名称:Nmap,代码行数:15,代码来源:TypeMapCollectionTesting.cs


示例19: Multiple

        public void Multiple()
        {
            var map = new TypeMap();

            ushort id, id2;
            Assert.IsTrue (map.GetTypeId (typeof (string), out id));
            Assert.AreEqual (0, id);

            Assert.IsFalse (map.GetTypeId (typeof (string), out id2));
            Assert.AreEqual (id, id2);

            Assert.IsTrue (map.GetTypeId (typeof (int), out id));
            Assert.AreNotEqual (id2, id);

            Assert.IsFalse (map.GetTypeId (typeof (int), out id2));
            Assert.AreEqual (id, id2);
        }
开发者ID:strager,项目名称:Tempest,代码行数:17,代码来源:TypeMapTests.cs


示例20: Ctor

        public void Ctor()
        {
            var dict = new Dictionary<Type, ushort> { { typeof (string), 0 }, { typeof (int), 1 } };
            TypeMap map = null;
            Assert.DoesNotThrow (() => map = new TypeMap (dict));

            Type type;
            Assert.IsTrue (map.TryGetType (0, out type));
            Assert.AreEqual (typeof (string), type);
            Assert.IsTrue (map.TryGetType (1, out type));
            Assert.AreEqual (typeof (int), type);

            ushort id;
            Assert.IsFalse (map.GetTypeId (typeof (string), out id));
            Assert.AreEqual (0, id);
            Assert.IsFalse (map.GetTypeId (typeof (int), out id));
            Assert.AreEqual (1, id);
        }
开发者ID:strager,项目名称:Tempest,代码行数:18,代码来源:TypeMapTests.cs



注:本文中的TypeMap类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# TypeMapper类代码示例发布时间:2022-05-24
下一篇:
C# TypeKind类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap