当前位置: 首页>>代码示例>>C#>>正文


C# TypeMapper类代码示例

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


TypeMapper类属于命名空间,在下文中一共展示了TypeMapper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TransformedType_RequiredProperties_ReturnsRequiredProperties

 public void TransformedType_RequiredProperties_ReturnsRequiredProperties()
 {
     var mapper = new TypeMapper(new CritterPomonaConfiguration());
     var type = mapper.FromType(typeof(Planet));
     var requiredProperties = type.RequiredProperties.ToList();
     Assert.That(requiredProperties.All(x => x.IsRequiredForConstructor), Is.True);
 }
开发者ID:Pomona,项目名称:Pomona,代码行数:7,代码来源:TypeSystemTests.cs

示例2: FromType_QueryResult_ReturnsQueryResultType

 public void FromType_QueryResult_ReturnsQueryResultType()
 {
     this.typeMapper = new TypeMapper(new SimplePomonaConfiguration());
     var type = TypeMapper.FromType(typeof(QueryResult<Critter>));
     Assert.That(type, Is.InstanceOf<QueryResultType>());
     Assert.That(type, Is.InstanceOf<QueryResultType<Critter>>());
 }
开发者ID:Pomona,项目名称:Pomona,代码行数:7,代码来源:TypeMapperTests.cs

示例3: FindProperties

        /// <summary>
        /// 获取指定类型映射器的属性集合。
        /// </summary>
        /// <param name="mapper">类型映射器。</param>
        /// <param name="entity">类型映射器关联的对象实例,并将 <paramref name="entity"/> 转换成映射器的类型 。</param>
        /// <returns>映射属性的集合枚举。</returns>
        protected virtual IEnumerable<PropertyMapper> FindProperties(TypeMapper mapper, ref object entity)
        {
            IEnumerable<PropertyMapper> pms = mapper.Properties;
            var entityType = entity.GetType();
            if(entityType.IsAssignableFrom(mapper.Type)) return pms;

            var mapper2 = TypeMapper.Create(entityType);

            var query = from op in pms
                        join np in mapper2.Properties on op.Property.Name.ToLower() equals np.Name.ToLower()
                        select new { op, np };
            var entity2 = Activator.CreateInstance(mapper.Type, true);

            List<PropertyMapper> pms2 = new List<PropertyMapper>();
            foreach(var item in query)
            {
                pms2.Add(item.op);
                var value = item.np.GetValue(entity);
                if(!item.op.Property.PropertyType.IsAssignableFrom(item.np.Property.PropertyType))
                {
                    value = Convert.ChangeType(value, item.op.Property.PropertyType);
                }

                item.op.SetValue(entity2, value);
            }
            entity = entity2;
            return pms2;
        }
开发者ID:glorylee,项目名称:Aoite,代码行数:34,代码来源:SqlFactory.cs

示例4: MapEntityType_should_not_map_invalid_structural_type

        public void MapEntityType_should_not_map_invalid_structural_type()
        {
            var model = new EdmModel().Initialize();
            var typeMapper = new TypeMapper(new MappingContext(new ModelConfiguration(), new ConventionsConfiguration(), model));

            Assert.Null(typeMapper.MapEntityType(typeof(string)));
        }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:7,代码来源:TypeMapperTests.cs

示例5: Start

 public void Start()
 {
     var bootstrapper = new CritterBootstrapper();
     Repository = bootstrapper.Repository;
     TypeMapper = bootstrapper.TypeMapper;
     Host = new NancyHost(BaseUri, bootstrapper);
     Host.Start();
 }
开发者ID:Pomona,项目名称:Pomona,代码行数:8,代码来源:CritterHost.cs

示例6: Start

 public void Start()
 {
     var bootstrapper = new CritterBootstrapper();
     this.Repository = bootstrapper.Repository;
     this.TypeMapper = bootstrapper.TypeMapper;
     host = new NancyHost(baseUri, bootstrapper);
     host.Start();
 }
开发者ID:BeeWarloc,项目名称:Pomona,代码行数:8,代码来源:CritterHost.cs

示例7: Setup

 public void Setup()
 {
     var fakeRepository = MockRepository.GenerateStub<IMapperRepository>();
     _mapper = new TypeMapper(fakeRepository);
     _dummyA = new DummyA { Name = "dummy A", Family = "family A", Age = 37 };
     _dummyB = new DummyB { Name = "dummy A", Family = "family A", Age = 37 };
     _dummyC = new DummyC { Name = "dummy A", Family = "family A", Address = null };
 }
开发者ID:haimtz,项目名称:Moshavit-Server,代码行数:8,代码来源:MapperGetMapTest.cs

示例8: GetUriFor_WithEntityWithSpaceInPath_EncodesUrlTheRightWay

 public void GetUriFor_WithEntityWithSpaceInPath_EncodesUrlTheRightWay()
 {
     var typeMapper = new TypeMapper(new CritterPomonaConfiguration());
     var uriResolver = new UriResolver(typeMapper,
         new DummyBaseUriProvider() { BaseUri = new Uri("http://whateva/") });
     var galaxy = new Galaxy() { Name = "this is it" };
     var url = uriResolver.GetUriFor(galaxy);
     Assert.That(url, Is.EqualTo("http://whateva/galaxies/this%20is%20it"));
 }
开发者ID:BeeWarloc,项目名称:Pomona,代码行数:9,代码来源:UriResolverTests.cs

示例9: CanMapSimpleNullableTypes

        public void CanMapSimpleNullableTypes(Type type, string expectedParamType, string expectedFormat = "")
        {
            var mapper = new TypeMapper();
            var inputParam = new InputParameter { Type = type };
            var param = mapper.Map(inputParam);

            Assert.AreEqual(expectedParamType, param.type);
            Assert.AreEqual(expectedFormat, param.format);

            Assert.IsEmpty(mapper.Models);
        }
开发者ID:huoxudong125,项目名称:OpenRastaSwagger,代码行数:11,代码来源:TypeMapperFixture.cs

示例10: CanMapEnumerableIntegerTypes

        public void CanMapEnumerableIntegerTypes(Type collectionType)
        {
            var mapper = new TypeMapper();

            var param = mapper.Register(collectionType);

            Assert.AreEqual("array", param.Type);
            Assert.AreEqual("integer", param.Items.Type);

            Assert.IsEmpty(mapper.Models);
        }
开发者ID:huoxudong125,项目名称:OpenRastaSwagger,代码行数:11,代码来源:TypeMapperFixture.cs

示例11: MapComplexType_should_not_map_ignored_type

        public void MapComplexType_should_not_map_ignored_type()
        {
            var model = new EdmModel(DataSpace.CSpace);
            var mockModelConfiguration = new Mock<ModelConfiguration>();
            var typeMapper = new TypeMapper(new MappingContext(mockModelConfiguration.Object, new ConventionsConfiguration(), model));
            mockModelConfiguration.Setup(m => m.IsIgnoredType(typeof(AType1))).Returns(true);

            var complexType = typeMapper.MapComplexType(typeof(AType1));

            Assert.Null(complexType);
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:11,代码来源:TypeMapperTests.cs

示例12: ClientLibGenerator

 public ClientLibGenerator(TypeMapper typeMapper)
 {
     if (typeMapper == null)
         throw new ArgumentNullException("typeMapper");
     this.typeMapper = typeMapper;
     this.allowedReferencedAssemblies = new[]
     {
         /*mscorlib*/typeof(string).Assembly, typeof(IPomonaClient).Assembly, /*System.Core*/
         typeof(Func<>).Assembly, /*System*/ typeof(Uri).Assembly
     };
     PomonaClientEmbeddingEnabled = true;
 }
开发者ID:BeeWarloc,项目名称:Pomona,代码行数:12,代码来源:ClientLibGenerator.cs

示例13: MapEntityType_should_not_map_ignored_type

        public void MapEntityType_should_not_map_ignored_type()
        {
            var model = new EdmModel().Initialize();
            var mockModelConfiguration = new Mock<ModelConfiguration>();
            var typeMapper = new TypeMapper(new MappingContext(mockModelConfiguration.Object, new ConventionsConfiguration(), model));
            var mockType = new MockType("Foo");
            mockModelConfiguration.Setup(m => m.IsIgnoredType(mockType)).Returns(true);

            var entityType = typeMapper.MapEntityType(mockType);

            Assert.Null(entityType);
        }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:12,代码来源:TypeMapperTests.cs

示例14: ToFactory

 public Factory ToFactory(IEnumerable<Column> columns, TypeMapper typeMapper)
 {
   if (columns.Count() != _attributes.Count())
   {
     throw new InvalidOperationException("Did not get equal number of Columns and Attributes");
   }
   var readers = columns.Zip<Column, Attribute, Func<object[], object>>(_attributes, (column, attribute) => {
     var mapper = typeMapper.MappingFor(column, attribute);
     return (row) => mapper(column.Read(row));
   });
   return new Factory(_info, readers.ToArray());
 }
开发者ID:machine,项目名称:machine.sqlmap,代码行数:12,代码来源:TypeConstructor.cs

示例15: HandlerMethod

 public HandlerMethod(MethodInfo methodInfo, TypeMapper typeMapper)
 {
     if (methodInfo == null)
         throw new ArgumentNullException(nameof(methodInfo));
     if (typeMapper == null)
         throw new ArgumentNullException(nameof(typeMapper));
     MethodInfo = methodInfo;
     TypeMapper = typeMapper;
     this.parameters =
         new Lazy<IList<HandlerParameter>>(
             () => methodInfo.GetParameters().Select(x => new HandlerParameter(x, this)).ToList());
     this.parameterTypes = new Lazy<IList<Type>>(() => Parameters.MapList(x => x.Type));
 }
开发者ID:Pomona,项目名称:Pomona,代码行数:13,代码来源:HandlerMethod.cs


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