public void ImportTypes(VoxTypes voxTypes) { foreach (var kvp in voxTypes.EnumerateTypes()) { var typeId = kvp.Key; var typeContext = kvp.Value; var typeContextAndTypeId = new TypeContextAndTypeId(typeId, typeContext); ImportType(typeContextAndTypeId); } }
private void ImportType(TypeContextAndTypeId typeContextAndTypeId) { var resultTypeContextAndTypeId = typeContextAndTypeIdByType.GetOrAdd(typeContextAndTypeId.Type, add => typeContextAndTypeId); if (typeContextAndTypeId.TypeId != resultTypeContextAndTypeId.TypeId) { throw new InvalidStateException($"Type {typeContextAndTypeId.Type.FullName} assigned two typeIds: {resultTypeContextAndTypeId.TypeId} and {typeContextAndTypeId.TypeId}."); } resultTypeContextAndTypeId = typeContextAndTypeIdByTypeId.GetOrAdd(typeContextAndTypeId.TypeId, add => typeContextAndTypeId); if (resultTypeContextAndTypeId.Type != typeContextAndTypeId.Type) { throw new InvalidStateException($"Type {typeContextAndTypeId.Type.FullName} and {resultTypeContextAndTypeId.Type.FullName} assigned to typeId {typeContextAndTypeId.TypeId}."); } }