public void TestMMObjects() { var typeMapper = new TypeMapping(); typeMapper.CreateNewObject = () => new MapTestClass(); typeMapper.GetId = (x) => (x as MapTestClass).Id.ToString(); typeMapper.AddProperty( MapTestClass.IdProperty, (x) => (x as MapTestClass).Id, (x, v) => (x as MapTestClass).Id = v); typeMapper.AddProperty( MapTestClass.NameProperty, (x) => (x as MapTestClass).Name, (x, v) => (x as MapTestClass).Name = v); }
public DynamoDBTestsFixture() { lock (CONFIGURE_MAPPING_LOCK) { if (!AWSConfigsDynamoDB.Context.TableAliases.ContainsKey("FakeTable")) { // .NET Core does not support config files yet, so programmatically configure the settings. See App.45.config AWSConfigsDynamoDB.Context.AddAlias(new TableAlias("FakeTable", "HashRangeTable")); TypeMapping mapping = new TypeMapping(typeof(DynamoDBTests.Employee), "HashRangeTable"); mapping.AddProperty(new PropertyConfig("ManagerName") { Attribute = "Manager" }); mapping.AddProperty(new PropertyConfig("CompanyName") { Attribute = "Company" }); mapping.AddProperty(new PropertyConfig("InternalId") { Ignore = true }); mapping.AddProperty(new PropertyConfig("CurrentStatus") { Attribute = "Status", Converter = typeof(DynamoDBTests.StatusConverter) }); AWSConfigsDynamoDB.Context.AddMapping(mapping); mapping = new TypeMapping(typeof(DynamoDBTests.VersionedEmployee), "FakeTable"); mapping.AddProperty(new PropertyConfig("Version") { Version = true }); AWSConfigsDynamoDB.Context.AddMapping(mapping); AWSConfigsDynamoDB.Context.AddMapping(new TypeMapping(typeof(DynamoDBTests.Employee2), "FakeTable")); AWSConfigsDynamoDB.Context.AddMapping(new TypeMapping(typeof(DynamoDBTests.Employee3), "FakeTable")); } CreateTestTables().Wait(); Client.BeforeRequestEvent += ClientBeforeRequestEvent; // Since tables have a variable prefix, configure the prefix for the process AWSConfigsDynamoDB.Context.TableNamePrefix = TableNamePrefix; // Construct single context object to use for all operations CreateContext(DynamoDBEntryConversion.V1); } }
private static void ConfigureContext() { var currentStatusPropertyConfig = new PropertyConfig("CurrentStatus") { Converter = typeof(StatusConverter) }; var employeeMapping = new TypeMapping(typeof(Employee), "HashRangeTable"); employeeMapping.AddProperty(new PropertyConfig("ManagerName") { Attribute = "Manager" }); employeeMapping.AddProperty(new PropertyConfig("CompanyName") { Attribute = "Company" }); employeeMapping.AddProperty(new PropertyConfig("InternalId") { Ignore = true }); employeeMapping.AddProperty(currentStatusPropertyConfig); var employee2Mapping = new TypeMapping(typeof(Employee2), "HashRangeTable"); employee2Mapping.AddProperty(currentStatusPropertyConfig); var employee3Mapping = new TypeMapping(typeof(Employee3), "HashRangeTable"); employee3Mapping.AddProperty(currentStatusPropertyConfig); var versionedEmployeeMapping = new TypeMapping(typeof(VersionedEmployee), "FakeTable"); versionedEmployeeMapping.AddProperty(new PropertyConfig("Version") { Ignore = true }); var context = AWSConfigsDynamoDB.Context; context.TableAliases["FakeTable"] = "HashRangeTable"; context.AddMapping(versionedEmployeeMapping); context.AddMapping(employeeMapping); context.AddMapping(employee2Mapping); context.AddMapping(employee3Mapping); }