/// <summary> /// Create an instance using the Agent configuration file. /// </summary> /// <param name="agentConfig">Configuration file for the SIF Agent.</param> /// <exception cref="System.ArgumentException">agentConfig parameter is null.</exception> /// <exception cref="Systemic.Sif.Framework.Publisher.IteratorException">Error parsing student details from the Agent configuration file.</exception> public StudentPersonalIterator(AgentConfig agentConfig) { if (agentConfig == null) { throw new ArgumentException("agentConfig parameter is null."); } Mappings mappings = agentConfig.Mappings.GetMappings("Default"); if (mappings == null) { throw new IteratorException("<mappings id=\"Default\"> has not been specified for Agent " + agentConfig.SourceId + "."); } objectMapping = mappings.GetObjectMapping(typeof(StudentPersonal).Name, true); if (objectMapping == null) { throw new IteratorException("An object mapping for StudentPersonal has not been specified for Agent " + agentConfig.SourceId + "."); } string xml = objectMapping.XmlElement.InnerXml; IElementDef elementDef = Adk.Dtd.LookupElementDef(objectMapping.ObjectType); try { studentPersonal = (StudentPersonal)sifParser.Parse(xml); } catch (AdkParsingException e) { throw new IteratorException("The following event message from StudentPersonalIterator has parsing errors: " + xml + ".", e); } }
public void Apply <T>(SerializationRegistry registry, ObjectMapping <T> mapping) { // Java field naming convention. mapping.SetNamingConvention(new CamelCaseNamingConvention()); // Do not serialize properties, only fields. Include both public and private fields. CollectFields(mapping, mapping.ObjectType); }
public AccountHandler() { TryLoadFromStorage = false; LastErrorMessage = ""; m_oObjectMapping = new ObjectMapping(); m_oSearchObjects = new ObjectTextSearch(); m_oAccounts = new ObservableRangeCollection <IAccountInterface>(); }
public void Apply <T>(JsonSerializerOptions options, ObjectMapping <T> objectMapping) { _defaultConvention.Apply(options, objectMapping); // restrict to members holding JsonPropertyNameAttribute objectMapping.SetMemberMappings(objectMapping.MemberMappings .Where(m => m.MemberInfo != null && m.MemberInfo.IsDefined(typeof(JsonPropertyNameAttribute))) .ToList()); }
public void Apply <T>(SerializationRegistry registry, ObjectMapping <T> objectMapping) { _defaultConvention.Apply(registry, objectMapping); // restrict to members holding CborPropertyAttribute objectMapping.SetMemberMappings(objectMapping.MemberMappings .Where(m => m.MemberInfo != null && m.MemberInfo.IsDefined(typeof(CborPropertyAttribute))) .ToList()); }
protected void Application_Start() { ObjectMapping.Init(); if (!ZooKeeperHelper.Exists(ZooKeeperHelper.ZooKeeperRootNode)) { ZooKeeperHelper.Create(ZooKeeperHelper.ZooKeeperRootNode, null); } new AppHost().Init(); }
public GameObject CreateMesh(CityModel cityModel, Vector3RD origin) { GameObject container = new GameObject(); //Terraindata terrainData = container.AddComponent<Terraindata>(); verts = GetVerts(cityModel, origin); List <Vector3> newVerts = new List <Vector3>(); triangleLists = GetTriangleLists(cityModel); Vector2Int textureSize = ObjectIDMapping.GetTextureSize(triangleLists.Count); Debug.Log(textureSize); Mesh mesh = new Mesh(); List <int> triangles = new List <int>(); List <string> objectIDs = new List <string>(); List <Vector2> uvs = new List <Vector2>(); List <int> vectorIDs = new List <int>(); List <int> triangleCount = new List <int>(); int objectIDNumber = 0; int vertexCounter = 0; foreach (var item in triangleLists) { vertexCounter = 0; Vector2 uv = ObjectIDMapping.GetUV(objectIDNumber, textureSize); foreach (int vertexIndex in item.Value) { newVerts.Add(verts[vertexIndex]); uvs.Add(uv); vectorIDs.Add(objectIDNumber); triangles.Add(newVerts.Count - 1); vertexCounter++; } triangleCount.Add(vertexCounter); objectIDs.Add(item.Key); objectIDNumber++; } mesh.indexFormat = UnityEngine.Rendering.IndexFormat.UInt32; mesh.vertices = newVerts.ToArray(); mesh.triangles = triangles.ToArray(); mesh.uv = uvs.ToArray(); //mesh.RecalculateNormals(); //mesh.Optimize(); container.AddComponent <MeshFilter>().mesh = mesh; ObjectMapping objectMapping = container.AddComponent <ObjectMapping>(); objectMapping.vectorIDs = vectorIDs; objectMapping.BagID = objectIDs; objectMapping.TriangleCount = triangleCount; return(container); }
public void Apply <T>(JsonSerializerOptions options, ObjectMapping <T> objectMapping) where T : class { defaultObjectMappingConvention.Apply <T>(options, objectMapping); // use Autofac to create types that have been registered with it if (_container.IsRegistered(objectType)) { objectMapping.MapCreator(o => _container.Resolve <T>()); } }
public void Apply <T>(JsonSerializerOptions options, ObjectMapping <T> objectMapping) { defaultObjectMappingConvention.Apply <T>(options, objectMapping); foreach (IMemberMapping memberMapping in objectMapping.MemberMappings) { if (memberMapping is MemberMapping <T> member) { member.SetShouldSerializeMethod(o => fields.Contains(member.MemberName.ToLower())); } } }
public void Apply <T>(JsonSerializerOptions options, ObjectMapping <T> objectMapping) { _defaultConvention.Apply(options, objectMapping); foreach (IMemberMapping memberMapping in objectMapping.MemberMappings) { if (_fieldNameChanges.Count > 0 && _fieldNameChanges.TryGetValue(memberMapping.MemberInfo.Name, out string newName)) { memberMapping.MemberName = newName; } } }
public void Apply <T>(SerializationRegistry registry, ObjectMapping <T> mapping) { // Java field naming convention. mapping.SetNamingConvention(new CamelCaseNamingConvention()); // Do not serialize properties, only fields. Include both public and private fields. CollectFields(mapping, mapping.ObjectType); // Allow serialization of objects without default constructor. We don't need deserialization. var constructors = mapping.ObjectType.GetConstructors(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); if (!constructors.Any(c => c.GetParameters().Length == 0)) { mapping.SetCreatorMapping(new NoDefaultConstructor()); } }
public void Reindex() { _client.DeleteIndex(IndexType); _client.CreateIndex(IndexType); var indexDefinition = new RootObjectMapping { Properties = new Dictionary <PropertyNameMarker, IElasticType>() }; var paramsProperty = new ObjectMapping { Properties = new Dictionary <PropertyNameMarker, IElasticType>() }; var numberMapping = new NumberMapping(); var boolMapping = new BooleanMapping(); var stringMapping = new StringMapping { Index = FieldIndexOption.NotAnalyzed }; IEnumerable <object> properties = GetAllProperties(); foreach (var property in properties) { //switch (property.DataType) //{ // case DataType.Logic: // paramsProperty.Properties.Add(property.Id, boolMapping); // break; // case DataType.Numeric: // paramsProperty.Properties.Add(property.Id, numberMapping); // break; // case DataType.Text: // paramsProperty.Properties.Add(property.Id, stringMapping); // break; //} } indexDefinition.Properties.Add(Property.Name <ProductIndex>(p => p.Params), paramsProperty); indexDefinition.Properties.Add(Property.Name <ProductIndex>(p => p.Id), stringMapping); indexDefinition.Properties.Add(Property.Name <ProductIndex>(p => p.CategoryId), stringMapping); _client.Map <ProductIndex>(x => x.InitializeUsing(indexDefinition)); IEnumerable <Product> products = GetAllProducts(); _client.IndexMany(products); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { ObjectMapping.Init(); services.AddSession(options => { // Set a short timeout for easy testing. options.IdleTimeout = TimeSpan.FromHours(2); options.Cookie.HttpOnly = true; // Make the session cookie essential options.Cookie.IsEssential = true; }); services.AddCustomeHttpContextAccessor(); services.AddControllersWithViews(); }
public void testFieldMapping010() { StudentPersonal sp = new StudentPersonal(); Mappings mappings = fCfg.Mappings.GetMappings("Default"); IDictionary map = buildIDictionaryForStudentPersonalTest(); // Add a "default" to the middle name rule and assert that it gets // created ObjectMapping om = mappings.GetObjectMapping("StudentPersonal", false); FieldMapping middleNameRule = om.GetRule(3); middleNameRule.DefaultValue = "Jerry"; map.Remove("MIDDLE_NAME"); StringMapAdaptor adaptor = new StringMapAdaptor(map); mappings.MapOutbound(adaptor, sp); SifWriter writer = new SifWriter(Console.Out); writer.Write(sp); writer.Flush(); // For the purposes of this test, all we care about is the Ethnicity // mapping. // It should have the default outbound value we specified, which is "7" Assertion.AssertEquals("Middle Name should be Jerry", "Jerry", sp .Name.MiddleName); // Now, remap the student back into application fields IDictionary restoredData = new Hashtable(); adaptor.Dictionary = restoredData; mappings.MapInbound(sp, adaptor); Assertion.AssertEquals("Middle Name should be Jerry", "Jerry", restoredData["MIDDLE_NAME"]); sp.Name.LastName = null; // Now, remap the student back into application fields restoredData = new Hashtable(); adaptor.Dictionary = restoredData; mappings.MapInbound(sp, adaptor); Object lastName = restoredData["LAST_NAME"]; Console.WriteLine(sp.ToXml()); Assertion.AssertNull("Last Name should be null", lastName); }
/// <summary> /// Constructor. Takes the path to the xml map file. /// </summary> /// <param name="mapFile"></param> public ObjectMapper(string mapFile) { mapList = new Dictionary <string, string>(); StreamReader str = new StreamReader(mapFile); XmlSerializer xSerializer = new XmlSerializer(typeof(ObjectMapping)); ObjectMapping deserialized = (ObjectMapping)xSerializer.Deserialize(str); foreach (var mapping in deserialized.Mapping) { mapList.Add(mapping.src.FirstOrDefault().Value, mapping.dest.FirstOrDefault().Value); } str.Close(); }
static void CollectFields <T>(ObjectMapping <T> mapping, Type type) { // Reflection will not give us private fields of base classes, so walk base classes explicitly. var parent = type.BaseType; if (parent != null) { CollectFields(mapping, parent); } foreach (var field in type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly)) { if (field.GetCustomAttribute <CompilerGeneratedAttribute>() == null) { mapping.MapMember(field, field.FieldType); } } }
private Mappings buildMappings1() { // root Mappings root = new Mappings(); // root.Default Mappings defaults = new Mappings(root, "Default", null, null, null); root.AddChild(defaults); // root.Default.StudentPersonal ObjectMapping studentMappings = new ObjectMapping("StudentPersonal"); defaults.AddRules(studentMappings); studentMappings.AddRule(new FieldMapping("REFID", "@RefId")); // root.Default.MA Mappings massachusetts = new Mappings(defaults, "MA", null, null, null); defaults.AddChild(massachusetts); // root.Default.MA.StudentPersonal studentMappings = new ObjectMapping("StudentPersonal"); massachusetts.AddRules(studentMappings); studentMappings.AddRule(new FieldMapping("LOCALID", "LocalId")); studentMappings.AddRule(new FieldMapping("FIRSTNAME", "Name[@Type='01']/FirstName")); studentMappings.AddRule(new FieldMapping("LASTNAME", "Name[@Type='01']/LastName")); // root.Default.MA.Boston Mappings boston = new Mappings(massachusetts, "Boston", null, "Boston", null); massachusetts.AddChild(boston); // root.Default.MA.Boston.StudentPersonal studentMappings = new ObjectMapping("StudentPersonal"); boston.AddRules(studentMappings); studentMappings.AddRule(new FieldMapping("BIRTHDAY", "Demographics/BirthDate")); return(root); }
public void testCreateMappings() { // Create the root instance Mappings root = new Mappings(); // Create the default set of universal mappings Mappings defaults = new Mappings(root, "Default"); root.AddChild(defaults); // Create an ObjectMapping for StudentPersonal ObjectMapping studentMappings = new ObjectMapping("StudentPersonal"); defaults.AddRules(studentMappings); // Add field rules studentMappings.AddRule(new FieldMapping("FIRSTNAME", "Name[@Type='04']/FirstName")); studentMappings.AddRule(new FieldMapping("LASTNAME", "Name[@Type='04']/LastName")); // Create a set of mappings for the state of Wisconsin Mappings wisconsin = new Mappings(defaults, "Wisconsin"); defaults.AddChild(wisconsin); // Create a set of mappings for the Neillsville School District Mappings neillsville = new Mappings(wisconsin, "Neillsville"); wisconsin.AddChild(neillsville); XmlDocument doc = new XmlDocument( ); doc.LoadXml("<agent/>"); XmlElement n = root.ToDom(doc); debug(doc); }
protected void Application_Start() { ObjectMapping.Init(); AreaRegistration.RegisterAllAreas(); RouteConfig.RegisterRoutes(RouteTable.Routes); }
public void Visit(ObjectMapping mapping) { this.PrettyPrint(mapping); }
public void Apply <T>(JsonSerializerOptions options, ObjectMapping <T> objectMapping) { _defaultConvention.Apply(options, objectMapping); objectMapping.SetDiscriminator(typeof(T).Name); }
/** * Asserts that the provided set of Mappings matches the one that was * created in createMappings(); */ private void assertMappings(Mappings m) { Mappings test = m.GetMappings("Test"); Assertion.AssertNotNull("Test mappings is not present", test); Assertion.AssertEquals("Should have a single Object Mapping", 1, test.GetObjectMappings().Length); // TODO: Test the version and sourceId filters more carefully /* * Assertion.AssertEquals( "SifVersion attr should be empty", 0, * test.SifVersionFilter().Length ); Assertion.AssertEquals( "SourceId attr * should be empty", 0, test.SourceIdFilter().Length ); Assertion.AssertEquals( * "Zone attr should be empty", 0, test.ZoneIdFilter().Length ); */ // assert the object mapping ObjectMapping om = test.GetObjectMapping("StudentPersonal", false); Assertion.AssertNotNull("StudentPersonal mappings", om); Assertion.AssertEquals("There should be five rules", 5, om.RuleCount); IList <FieldMapping> rules = om.GetRulesList(false); // Field 1 Assertion.AssertEquals("FIELD1 name", "FIELD1", rules[0].FieldName); Assertion.AssertEquals("FIELD1 rule", "Name/FirstName", rules[0].GetRule().ToString()); Assertion.AssertEquals("FIELD1 ifNull", MappingBehavior.IfNullUnspecified, rules[0].NullBehavior); // Field 2 Assertion.AssertEquals("FIELD2 name", "FIELD2", rules[1].FieldName); Assertion.AssertEquals("FIELD2 rule", "Name/LastName", rules[1].GetRule().ToString()); Assertion.AssertEquals("FIELD2 valueset", "VS1", rules[1].ValueSetID); Assertion.AssertEquals("FIELD2 alias", "ALIAS1", rules[1].Alias); Assertion.AssertEquals("FIELD2 default", "DEFAULT1", rules[1].DefaultValue); MappingsFilter filter = rules[1].Filter; Assertion.AssertNotNull("FIELD2 filter is null", filter); Assertion.AssertEquals("filter direction", MappingDirection.Inbound, filter .Direction); Assertion.AssertEquals("filter sif version", "=" + SifVersion.SIF11.ToString(), filter.SifVersion); // Field 3 Assertion.AssertEquals("FIELD3 name", "FIELD3", rules[2].FieldName); Assertion.AssertEquals("FIELD3 rule", "Name/MiddleName", rules[2].GetRule().ToString()); Assertion.AssertEquals("FIELD3 valueset", "VS2", rules[2].ValueSetID); Assertion.AssertEquals("FIELD3 alias", "ALIAS2", rules[2].Alias); Assertion.AssertEquals("FIELD3 default", "DEFAULT2", rules[2].DefaultValue); Assertion.AssertEquals("FIELD3 ifNull", MappingBehavior.IfNullDefault, rules[2].NullBehavior); MappingsFilter filter2 = rules[2].Filter; Assertion.AssertNotNull("FIELD3 filter is null", filter2); Assertion.AssertEquals("filter2 direction", MappingDirection.Outbound, filter2.Direction); Assertion.AssertEquals("filter2 sif version", "=" + SifVersion.SIF15r1.ToString(), filter2.SifVersion); // Field 4 Assertion.AssertEquals("FIELD4 name", "FIELD4", rules[3].FieldName); Assertion.AssertNull("FIELD4 valueset", rules[3].ValueSetID); Assertion.AssertNull("FIELD4 alias", rules[3].Alias); Assertion.AssertNull("FIELD4 default", rules[3].DefaultValue); Assertion.AssertEquals("FIELD4 ifNull", MappingBehavior.IfNullSuppress, rules[3].NullBehavior); Rule r = rules[3].GetRule(); Assertion.Assert("Rule should be OtherIdRule", r is OtherIdRule); Assertion.AssertEquals("FIELD5 name", "FIELD5", rules[4].FieldName); Assertion.AssertEquals("FIELD5 datatype", SifDataType.Date, rules[4] .DataType); // TODO: The OtherIdRule doesn't have an API to get at the // OtherIdMapping. For now, just // convert it to a string and assert the results String ruleStr = r.ToString(); Assertion.Assert("prefix should be BUSROUTE", ruleStr .IndexOf("prefix='BUSROUTE'") > 1); Assertion.Assert("type should be ZZ", ruleStr.IndexOf("type='ZZ'") > 1); ValueSet vs = test.GetValueSet("VS1", false); Assertion.AssertNotNull("ValueSet VS1 should not be null", vs); Assertion.AssertEquals("VS1 should have 12 entries", 12, vs.Entries.Length); for (int a = 0; a < 10; a++) { Assertion.AssertEquals("Mapping by appvalue", "SifValue" + a, vs.Translate("Value" + a)); Assertion.AssertEquals("Mapping by sifvalue", "Value" + a, vs.TranslateReverse("SifValue" + a)); } // Test the default value entries Assertion.AssertEquals("Expecting app default value", "AppDefault", vs.TranslateReverse("abcdefg")); Assertion.AssertEquals("Expecting app default value", "AppDefault", vs.TranslateReverse(null)); Assertion.AssertEquals("Expecting sif default value", "SifDefault", vs.Translate("abcdefg")); Assertion.AssertNull("Expecting NULL value", vs.Translate(null)); vs = test.GetValueSet("VS2", false); Assertion.AssertNotNull("ValueSet VS2 should not be null", vs); Assertion.AssertEquals("VS2 should have 4 entries", 4, vs.Entries.Length); for (int a = 0; a < 3; a++) { Assertion.AssertEquals("Mapping by appvalue", "w" + a, vs.Translate("q" + a)); Assertion.AssertEquals("Mapping by sifvalue", "q" + a, vs .TranslateReverse("w" + a)); } // Test the default value entries Assertion.AssertEquals("Expecting app default value", "AppDefault", vs .TranslateReverse("abcdefg")); Assertion.AssertEquals("Expecting app default value", "AppDefault", vs .TranslateReverse(null)); Assertion.AssertEquals("Expecting sif default value", "0000", vs .Translate("abcdefg")); Assertion.AssertEquals("Expecting sif default value", "0000", vs.Translate(null)); }
/** * Creates a set of mappings that operations can be applied to, such as * saving to a DOM or Agent.cfg. The results can be asserted by calling * {@see #assertMappings(Mappings)}. * * NOTE: This method returns an AgentConfig instance instead of a mappings * instance because there is no way set the Mappings instance on * AgentConfig. This might change in the future * * @return */ private AgentConfig createMappings() { Mappings root = fCfg.Mappings; // Remove the mappings being used root.RemoveChild(root.GetMappings("Default")); root.RemoveChild(root.GetMappings("TestID")); Mappings newMappings = root.CreateChild("Test"); // Add an object mapping ObjectMapping objMap = new ObjectMapping("StudentPersonal"); // Currently, the Adk code requires that an Object Mapping be added // to it's parent before fields are added. // We should re-examine this and perhaps fix it, if possible newMappings.AddRules(objMap); objMap.AddRule(new FieldMapping("FIELD1", "Name/FirstName")); // Field 2 FieldMapping field2 = new FieldMapping("FIELD2", "Name/LastName"); field2.ValueSetID = "VS1"; field2.Alias = "ALIAS1"; field2.DefaultValue = "DEFAULT1"; MappingsFilter mf = new MappingsFilter(); mf.Direction = MappingDirection.Inbound; mf.SifVersion = SifVersion.SIF11.ToString(); field2.Filter = mf; objMap.AddRule(field2); // Field 3 test setting the XML values after it's been added to the // parent object (the code paths are different) FieldMapping field3 = new FieldMapping("FIELD3", "Name/MiddleName"); objMap.AddRule(field3); field3.ValueSetID = "VS2"; field3.Alias = "ALIAS2"; field3.DefaultValue = "DEFAULT2"; MappingsFilter mf2 = new MappingsFilter(); mf2.Direction = MappingDirection.Outbound; mf2.SifVersion = SifVersion.SIF15r1.ToString(); field3.Filter = mf2; field3.NullBehavior = MappingBehavior.IfNullDefault; OtherIdMapping oim = new OtherIdMapping("ZZ", "BUSROUTE"); FieldMapping field4 = new FieldMapping("FIELD4", oim); objMap.AddRule(field4); field4.DefaultValue = "Default"; field4.ValueSetID = "vs"; field4.Alias = "alias"; field4.DefaultValue = null; field4.ValueSetID = null; field4.Alias = null; field4.NullBehavior = MappingBehavior.IfNullSuppress; // Field4 tests the new datatype attribute FieldMapping field5 = new FieldMapping("FIELD5", "Demographics/BirthDate"); objMap.AddRule(field5); field5.DataType = SifDataType.Date; // Add a valueset translation ValueSet vs = new ValueSet("VS1"); newMappings.AddValueSet(vs); // Add a few definitions for (int a = 0; a < 10; a++) { vs.Define("Value" + a, "SifValue" + a, "Title" + a); } vs.Define("AppDefault", "0000", "Default App Value"); vs.SetAppDefault("AppDefault", true); vs.Define("0000", "SifDefault", "Default Sif Value"); vs.SetSifDefault("SifDefault", false); // Add a valueset translation vs = new ValueSet("VS2"); newMappings.AddValueSet(vs); // Add a few definitions for (int a = 0; a < 3; a++) { vs.Define("q" + a, "w" + a, "t" + a); } vs.Define("AppDefault", "0000", "Default Value"); vs.SetAppDefault("AppDefault", true); vs.SetSifDefault("0000", true); return(fCfg); }
/// <summary> /// Deletes the documents for objects of the given type matching the given selection. /// </summary> /// <param name="writer"> /// The IndexWriter to delete the documents from. /// </param> /// <param name="type"> /// The type of the object to delete documents for. /// </param> /// <param name="selection"> /// The Query which selects the documents to delete. /// </param> public static void DeleteDocuments(this IndexWriter writer, Type type, Query selection) { Query deleteQuery = new FilteredQuery(selection, ObjectMapping.GetTypeFilter(type)); writer.DeleteDocuments(deleteQuery); }
/// <summary> /// Deletes the documents for objects of the given type matching the given selection. /// </summary> /// <typeparam name="TObject"> /// The type of the object to delete documents for. /// </typeparam> /// <param name="writer"> /// The IndexWriter to delete the documents from. /// </param> /// <param name="kind"> /// The kind of type to restrict the search to. /// </param> /// <param name="selection"> /// The Query which selects the documents to delete. /// </param> public static void DeleteDocuments <TObject>(this IndexWriter writer, DocumentObjectTypeKind kind, Query selection) { Query deleteQuery = new FilteredQuery(selection, ObjectMapping.GetTypeFilter <TObject>(kind)); writer.DeleteDocuments(deleteQuery); }
public void Apply <T>(SerializationRegistry registry, ObjectMapping <T> objectMapping) { defaultObjectMappingConvention.Apply <T>(registry, objectMapping); objectMapping.SetNamingConvention(lowerCaseNamingConvention); }
public void testFieldMapping020() { Mappings mappings = fCfg.Mappings.GetMappings("Default"); IDictionary map = buildIDictionaryForStudentPersonalTest(); // Find the Ethnicity rule ObjectMapping om = mappings.GetObjectMapping("StudentPersonal", false); FieldMapping inboundEthnicityRule = null; FieldMapping outboundEthnicityRule = null; for (int a = 0; a < om.RuleCount; a++) { FieldMapping fm = om.GetRule(a); if (fm.FieldName.Equals("ETHNICITY")) { if (fm.Filter.Direction == MappingDirection.Inbound) { inboundEthnicityRule = fm; } else { outboundEthnicityRule = fm; } } } // Put a value into the map that won't match the valueset map["ETHNICITY"] = "abcdefg"; StudentPersonal sp = new StudentPersonal(); MapOutbound(sp, mappings, map); // There's no default value defined, so we expect that what get's put in // is what we get out Assertion.AssertEquals("Outbound Ethnicity", "abcdefg", sp.Demographics.RaceList.ItemAt(0).Code); // Now, remap the student back into application fields IDictionary restoredData = new Hashtable(); StringMapAdaptor adaptor = new StringMapAdaptor(restoredData); mappings.MapInbound(sp, adaptor); // The value "abcdefg" does not have a match in the value set // It should be passed back through Assertion.AssertEquals("Inbound Ethnicity", "abcdefg", restoredData["ETHNICITY"]); inboundEthnicityRule.DefaultValue = "11111"; outboundEthnicityRule.DefaultValue = "99999"; sp = new StudentPersonal(); MapOutbound(sp, mappings, map); // It should have the default value we specified, which is "99999" Assertion.AssertEquals("Outbound Ethnicity", "99999", sp.Demographics.RaceList.ItemAt(0).Code); // Now, remap the student back into application fields restoredData = new Hashtable(); adaptor.Dictionary = restoredData; mappings.MapInbound(sp, adaptor); // The value "9999" does not have a match in the value set // we want it to take on the default value, which is "111111" Assertion.AssertEquals("Inbound Ethnicity", "11111", restoredData["ETHNICITY"]); // Now, do the mapping again, this time with the Ethnicity value // completely missing sp = new StudentPersonal(); map.Remove("ETHNICITY"); MapOutbound(sp, mappings, map); // Ethnicity should be set to "99999" in this case because we didn't set // the "ifNull" behavior and the // default behavior is "NULL_DEFAULT" Assertion.AssertEquals("Outbound Ethnicity", "99999", sp.Demographics .RaceList.ItemAt(0).Code); // Now, do the mapping again, this time with the NULL_DEFALT behavior. // The result should be the same outboundEthnicityRule.NullBehavior = MappingBehavior.IfNullDefault; sp = new StudentPersonal(); MapOutbound(sp, mappings, map); // Ethnicity should be set to "99999" in this case because we set the // ifnull behavior to "NULL_DEFAULT" Assertion.AssertEquals("Outbound Ethnicity", "99999", sp.Demographics.RaceList.ItemAt(0).Code); outboundEthnicityRule.NullBehavior = MappingBehavior.IfNullSuppress; sp = new StudentPersonal(); MapOutbound(sp, mappings, map); // Ethnicity should be null in this case because we told it to suppress // set the "ifNull" behavior Assertion.AssertNull("Ethnicity should not be set", sp.Demographics.RaceList); }
public Startup(IConfiguration configuration) { ObjectMapping.Init(); ConfigurationManager.Configuration = configuration; Configuration = configuration; }
public void Apply <T>(SerializationRegistry registry, ObjectMapping <T> objectMapping) { _defaultObjectMappingConvention.Apply <T>(registry, objectMapping); objectMapping.SetOrderBy(m => m.MemberName); }
public GameObject CreateMeshesByIdentifier(List <Building> buildings, string identifiername, Vector3RD origin) { offset = CoordConvert.RDtoUnity(new Vector2((float)origin.x, (float)origin.y)); GameObject container = new GameObject(); ObjectMapping objMap = container.AddComponent <ObjectMapping>(); List <string> identifiers = new List <string>(); List <List <SurfaceData> > surfdata = new List <List <SurfaceData> >(); int buildingnumber = 0; foreach (Building building in buildings) { string buildingname = ""; foreach (Semantics item in building.semantics) { if (item.name == "name") { buildingname = item.value; } } objMap.Objectmap.Add(buildingnumber, buildingname); objMap.BagID.Add(buildingname); buildingnumber++; List <SurfaceData> surfaces = SortSurfacesBySemantics(building, identifiername, buildingnumber); foreach (SurfaceData surf in surfaces) { bool found = false; for (int i = 0; i < identifiers.Count; i++) { if (identifiers[i] == surf.identifierValue) { found = true; surfdata[i].Add(surf); } } if (found == false) { identifiers.Add(surf.identifierValue); surfdata.Add(new List <SurfaceData>()); surfdata[surfdata.Count - 1].Add(surf); } } } int vertexcount = 0; int counter = 0; for (int i = 0; i < identifiers.Count; i++) { List <CombineInstance> cis = new List <CombineInstance>(); foreach (SurfaceData surf in surfdata[i]) { if (vertexcount + surf.texturedMesh.mesh.vertexCount > 65535) { AddSubobject(container, cis, identifiers[i], counter); counter += 1; cis = new List <CombineInstance>(); vertexcount = 0; } CombineInstance ci = new CombineInstance(); ci.mesh = surf.texturedMesh.mesh; cis.Add(ci); surf.texturedMesh.mesh = null; vertexcount += ci.mesh.vertexCount; } surfdata[i] = null; AddSubobject(container, cis, identifiers[i], counter); } return(container); }