/// <summary> /// Create an instance of <seealso cref="MappingSchema"/>. /// </summary> /// <param name="configuration">Configuration name.</param> /// <param name="schemas">Base schemas.</param> public MappingSchema(string?configuration, params MappingSchema[]?schemas) { var schemaInfo = new MappingSchemaInfo(configuration); #pragma warning disable CA1508 // Avoid dead conditional code if (schemas == null || schemas.Length == 0) #pragma warning restore CA1508 // Avoid dead conditional code { Schemas = new[] { schemaInfo, Default.Schemas[0] }; } else if (schemas.Length == 1) { Schemas = new MappingSchemaInfo[1 + schemas[0].Schemas.Length]; Schemas[0] = schemaInfo; Array.Copy(schemas[0].Schemas, 0, Schemas, 1, schemas[0].Schemas.Length); } else { var schemaList = new List <MappingSchemaInfo>(10) { schemaInfo }; foreach (var schema in schemas) { foreach (var sc in schema.Schemas) { if (schemaList.Contains(sc)) { schemaList.Remove(sc); } schemaList.Add(sc); } } Schemas = schemaList.ToArray(); } }
/// <summary> /// Create an instance of <seealso cref="MappingSchema"/>. /// </summary> /// <param name="configuration">Configuration name.</param> /// <param name="schemas">Base schemas.</param> public MappingSchema(string configuration, params MappingSchema[] schemas) { var schemaInfo = new MappingSchemaInfo(configuration); if (schemas == null || schemas.Length == 0) { Schemas = new[] { schemaInfo, Default.Schemas[0] }; } else if (schemas.Length == 1) { Schemas = new MappingSchemaInfo[1 + schemas[0].Schemas.Length]; Schemas[0] = schemaInfo; Array.Copy(schemas[0].Schemas, 0, Schemas, 1, schemas[0].Schemas.Length); } else { var schemaList = new List <MappingSchemaInfo>(10) { schemaInfo }; foreach (var schema in schemas) { foreach (var sc in schema.Schemas) { if (schemaList.Contains(sc)) { schemaList.Remove(sc); } schemaList.Add(sc); } } Schemas = schemaList.ToArray(); } }
internal MappingSchema(MappingSchemaInfo mappingSchemaInfo) { Schemas = new[] { mappingSchemaInfo }; }