コード例 #1
0
ファイル: MapperFactory.cs プロジェクト: peterzhao/aft
        public IMapper GetMapper(string objectType)
        {
            Logger.Trace("Get mapper for " + objectType);
            if (!mappers.Keys.Contains(objectType))
            {
                using (var db = new AftDbContext())
                {
                    mappers[objectType] = new Mapper(objectType, db.FieldMappings.Where(map => map.ObjectType == objectType).ToList());
                }
            }

            return mappers[objectType];
        }
コード例 #2
0
ファイル: MapperTests.cs プロジェクト: peterzhao/aft
 public void SetUp()
 {
     _mappings = new List<FieldMapping>
     {
         new FieldMapping{AftField = "Email", SalsaField = "email", DataType = "string", MappingRule = MappingRules.primaryKey},
         new FieldMapping{AftField = "Address", SalsaField = "address", DataType = "string", MappingRule = MappingRules.onlyIfBlank},
         new FieldMapping{AftField = "State", SalsaField = "state", DataType = "string", MappingRule = MappingRules.onlyIfBlank},
         new FieldMapping{AftField = "NickName", SalsaField = "nick_name", DataType = "string", MappingRule = MappingRules.salsaWins},
         new FieldMapping{AftField = "SalsaLastModified", SalsaField = "LastModified", DataType = "datetime", MappingRule = MappingRules.readOnly},
         new FieldMapping{AftField = "CustomDate1", SalsaField = "custom_date1", DataType = "dateTime", MappingRule = MappingRules.aftWins},
         new FieldMapping{AftField = "ChapterKey", SalsaField = "chapter_KEY", DataType = "int", MappingRule = MappingRules.writeOnlyNewMembership},
         new FieldMapping{AftField = "GroupKey", SalsaField = "group_KEY", DataType = "int", MappingRule = MappingRules.writeOnly},
     };
     _mapper = new Mapper("SomeObject", _mappings);
 }