Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
archanox committed Jan 1, 2024
1 parent 7a1421a commit e138e5b
Show file tree
Hide file tree
Showing 63 changed files with 242 additions and 241 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

namespace KartaViewSharp.Common.Converters;

public class JsonStringAsArrayJsonConverter<T> : JsonConverter<T[]>
internal class JsonStringAsArrayJsonConverter<T> : JsonConverter<T[]>
{
public override T[] Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
public override T[] Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
switch (reader.TokenType)
{
Expand All @@ -18,13 +18,11 @@ public override T[] Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSeri
case JsonTokenType.String when !string.IsNullOrWhiteSpace(reader.GetString()):
return JsonSerializer.Deserialize<T[]>(reader.GetString(), options) ?? throw new JsonException();
default:
{
throw new JsonException($"Unexpected token type {reader.TokenType}");
}
throw new JsonException($"Unexpected token type {reader.TokenType}");
}
}

public override void Write(Utf8JsonWriter writer, T[] value, JsonSerializerOptions options)
public override void Write(Utf8JsonWriter writer, T[] value, JsonSerializerOptions options)
{
writer.WriteRawValue(JsonSerializer.Serialize(value, options));
}
Expand Down
48 changes: 24 additions & 24 deletions KartaViewSharp/Common/Converters/JsonStringAsObjectJsonConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,30 @@

namespace KartaViewSharp.Common.Converters;

public class JsonStringAsObjectJsonConverter<T> : JsonConverter<T>
internal class JsonStringAsObjectJsonConverter<T> : JsonConverter<T>
{
public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
switch (reader.TokenType)
{
case JsonTokenType.Null:
return default;
case JsonTokenType.StartObject:
{
return JsonSerializer.Deserialize<T>(ref reader, options) ?? throw new JsonException();
}
case JsonTokenType.String when string.IsNullOrWhiteSpace(reader.GetString()):
return default;
case JsonTokenType.String when !string.IsNullOrWhiteSpace(reader.GetString()):
var input = reader.GetString();
return JsonSerializer.Deserialize<T>(input, options) ?? throw new JsonException();
default:
throw new JsonException();
}
}
public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
switch (reader.TokenType)
{
case JsonTokenType.Null:
return default;
case JsonTokenType.StartObject:
{
return JsonSerializer.Deserialize<T>(ref reader, options) ?? throw new JsonException();
}
case JsonTokenType.String when string.IsNullOrWhiteSpace(reader.GetString()):
return default;
case JsonTokenType.String when !string.IsNullOrWhiteSpace(reader.GetString()):
var input = reader.GetString();
return JsonSerializer.Deserialize<T>(input, options) ?? throw new JsonException();
default:
throw new JsonException();
}
}

public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
{
writer.WriteRawValue(JsonSerializer.Serialize(value, options));
}
public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
{
writer.WriteRawValue(JsonSerializer.Serialize(value, options));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace KartaViewSharp.Common.Converters;

public class ObjectAsArrayJsonConverter<T, T2> : JsonConverter<T[]> where T2 : JsonSerializerContext, new()
internal class ObjectAsArrayJsonConverter<T, T2> : JsonConverter<T[]> where T2 : JsonSerializerContext, new()
{
public override T[] Read(
ref Utf8JsonReader reader,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace KartaViewSharp.Common.Converters;

public class StringAsAutoImgProcessingResultJsonConverter : JsonConverter<AutoImgProcessingResult>
internal class StringAsAutoImgProcessingResultJsonConverter : JsonConverter<AutoImgProcessingResult>
{
public override AutoImgProcessingResult Read(
ref Utf8JsonReader reader,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace KartaViewSharp.Common.Converters;

public class StringAsBoolJsonConverter : JsonConverter<bool>
internal class StringAsBoolJsonConverter : JsonConverter<bool>
{
public override bool Read(
ref Utf8JsonReader reader,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace KartaViewSharp.Common.Converters;

public class StringAsDateTimeJsonConverter : JsonConverter<DateTime>
internal class StringAsDateTimeJsonConverter : JsonConverter<DateTime>
{
public override DateTime Read(
ref Utf8JsonReader reader,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace KartaViewSharp.Common.Converters;

public class StringAsDateTimeV1JsonConverter : JsonConverter<DateTime>
internal class StringAsDateTimeV1JsonConverter : JsonConverter<DateTime>
{
public override DateTime Read(
ref Utf8JsonReader reader,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace KartaViewSharp.Common.Converters;

public class StringAsDoubleJsonConverter : JsonConverter<double>
internal class StringAsDoubleJsonConverter : JsonConverter<double>
{
public override double Read(
ref Utf8JsonReader reader,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace KartaViewSharp.Common.Converters;

public class StringAsDriverTypeJsonConverter : JsonConverter<DriverType>
internal class StringAsDriverTypeJsonConverter : JsonConverter<DriverType>
{
public override DriverType Read(
ref Utf8JsonReader reader,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace KartaViewSharp.Common.Converters;

public class StringAsImagePartProjectionJsonConverter : JsonConverter<ImagePartProjection>
internal class StringAsImagePartProjectionJsonConverter : JsonConverter<ImagePartProjection>
{
public override ImagePartProjection Read(
ref Utf8JsonReader reader,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace KartaViewSharp.Common.Converters;

public class StringAsIntJsonConverter : JsonConverter<int>
internal class StringAsIntJsonConverter : JsonConverter<int>
{
public override int Read(
ref Utf8JsonReader reader,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace KartaViewSharp.Common.Converters;

public class StringAsNullableBoolJsonConverter : JsonConverter<bool?>
internal class StringAsNullableBoolJsonConverter : JsonConverter<bool?>
{
public override bool? Read(
ref Utf8JsonReader reader,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace KartaViewSharp.Common.Converters;

public class StringAsNullableCountryJsonConverter : JsonConverter<Country?>
internal class StringAsNullableCountryJsonConverter : JsonConverter<Country?>
{
public override Country? Read(
ref Utf8JsonReader reader,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace KartaViewSharp.Common.Converters;

public class StringAsNullableDateTimeJsonConverter : JsonConverter<DateTime?>
internal class StringAsNullableDateTimeJsonConverter : JsonConverter<DateTime?>
{
public override DateTime? Read(
ref Utf8JsonReader reader,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace KartaViewSharp.Common.Converters;

public class StringAsNullableDoubleJsonConverter : JsonConverter<double?>
internal class StringAsNullableDoubleJsonConverter : JsonConverter<double?>
{
public override double? Read(
ref Utf8JsonReader reader,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace KartaViewSharp.Common.Converters;

public class StringAsNullableIntJsonConverter : JsonConverter<int?>
internal class StringAsNullableIntJsonConverter : JsonConverter<int?>
{
public override int? Read(
ref Utf8JsonReader reader,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace KartaViewSharp.Common.Converters;

public class StringAsNullableLongJsonConverter : JsonConverter<long?>
internal class StringAsNullableLongJsonConverter : JsonConverter<long?>
{
public override long? Read(
ref Utf8JsonReader reader,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace KartaViewSharp.Common.Converters;

public class StringAsNullableSequenceTypeJsonConverter : JsonConverter<SequenceType?>
internal class StringAsNullableSequenceTypeJsonConverter : JsonConverter<SequenceType?>
{
public override SequenceType? Read(
ref Utf8JsonReader reader,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace KartaViewSharp.Common.Converters;

public class StringAsProjectionJsonConverter : JsonConverter<Projection>
internal class StringAsProjectionJsonConverter : JsonConverter<Projection>
{
public override Projection Read(
ref Utf8JsonReader reader,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace KartaViewSharp.Common.Converters;

public class StringAsSequenceStatusJsonConverter : JsonConverter<SequenceStatus>
internal class StringAsSequenceStatusJsonConverter : JsonConverter<SequenceStatus>
{
public override SequenceStatus Read(
ref Utf8JsonReader reader,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace KartaViewSharp.Common.Converters;

public class StringAsStatusJsonConverter : JsonConverter<Status>
internal class StringAsStatusJsonConverter : JsonConverter<Status>
{
public override Status Read(
ref Utf8JsonReader reader,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace KartaViewSharp.Common.Converters;

public class StringAsUserCategoryJsonConverter : JsonConverter<UserCategory>
internal class StringAsUserCategoryJsonConverter : JsonConverter<UserCategory>
{
public override UserCategory Read(
ref Utf8JsonReader reader,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace KartaViewSharp.Common.Converters;

public class StringAsVisibilityJsonConverter : JsonConverter<Visibility>
internal class StringAsVisibilityJsonConverter : JsonConverter<Visibility>
{
public override Visibility Read(
ref Utf8JsonReader reader,
Expand Down
2 changes: 1 addition & 1 deletion KartaViewSharp/Common/Response/ResponseStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace KartaViewSharp.Common.Response;

public class ResponseStatus
public sealed class ResponseStatus
{
/// <summary>
/// API Code
Expand Down
2 changes: 1 addition & 1 deletion KartaViewSharp/Common/RestClientUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace KartaViewSharp.Common;

public abstract class RestClientUtil
internal abstract class RestClientUtil
{
internal static RestClient CreateRestClient<T>(string baseUrl) where T : JsonSerializerContext, new()
{
Expand Down
5 changes: 5 additions & 0 deletions KartaViewSharp/V1/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ public async Task<object> UploadPhoto(int sequenceId, int sequenceIndex, string
throw new NotImplementedException();
}

public Task<object> UploadPhoto(int sequenceId, int sequenceIndex, Coordinate coordinate, byte[] photo, string accessToken)
{
throw new NotImplementedException();
}

public async Task<object> RemovePhoto(int photoId, string accessToken)
{
throw new NotImplementedException();
Expand Down
2 changes: 1 addition & 1 deletion KartaViewSharp/V1/Interfaces/IAuthentication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace KartaViewSharp.V1.Interfaces;
/// For each secured method you have to use the access_token parameter.
/// In order to get the access_token, you have to get the request_token and secret token returned after OAuth authentification on OSM.
/// </summary>
public interface IAuthentication
internal interface IAuthentication
{
/// <summary>
/// OpenStreetCam authentication uses request_token and secret_token obtained after OAuth authentication on OSM.
Expand Down
2 changes: 1 addition & 1 deletion KartaViewSharp/V1/Interfaces/IMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace KartaViewSharp.V1.Interfaces;
/// All the uploaded sequences are maped to the map's segments.
/// So each map's segement belongs to one or multiple sequences.
/// </summary>
public interface IMap
internal interface IMap
{
/// <summary>
/// Get list of nearby sequences, in radius of specified distance and location.
Expand Down
10 changes: 6 additions & 4 deletions KartaViewSharp/V1/Interfaces/IPhoto.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace KartaViewSharp.V1.Interfaces;
using NetTopologySuite.Geometries;

namespace KartaViewSharp.V1.Interfaces;

/// <summary>
/// Photo methods provide access to information and operations relating to the photos.
Expand All @@ -10,18 +12,18 @@
/// PROCESSING: Photo is processing.
/// FINISHED: photo processing is running.
/// </summary>
public interface IPhoto
internal interface IPhoto
{
/// <summary>
/// Upload the sequence's photo.
/// </summary>
/// <param name="sequenceId"></param>
/// <param name="sequenceIndex"></param>
/// <param name="coordinate">Coordinates where the photo was taken. Valid format: ('lat,long')</param>
/// <param name="coordinate">Coordinates where the photo was taken.</param>
/// <param name="photo"></param>
/// <param name="accessToken"></param>
/// <returns></returns>
Task<object> UploadPhoto(int sequenceId, int sequenceIndex, string coordinate, byte[] photo, string accessToken);
Task<object> UploadPhoto(int sequenceId, int sequenceIndex, Coordinate coordinate, byte[] photo, string accessToken);

/// <summary>
/// Remove a photo by specifying photo ID.
Expand Down
2 changes: 1 addition & 1 deletion KartaViewSharp/V1/Interfaces/ISequence.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace KartaViewSharp.V1.Interfaces;
/// PROCESSING_FINISHED: data processing is finished.
/// PROCESSING_FAILED: data processing failed.
/// </summary>
public interface ISequence
internal interface ISequence
{
/// <summary>
/// Get Sequence details.
Expand Down
2 changes: 1 addition & 1 deletion KartaViewSharp/V1/Interfaces/IUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace KartaViewSharp.V1.Interfaces;

public interface IUser
internal interface IUser
{
/// <summary>
/// The user details represent statuses and activity information of the user, like overall rank, the covered total distance, total number of photos etc.
Expand Down
2 changes: 1 addition & 1 deletion KartaViewSharp/V1/Interfaces/IVideo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/// NEW: video isn't processed yet.
/// SPLIT_FINISH: video split is finished.
/// </summary>
public interface IVideo
internal interface IVideo
{
/// <summary>
/// The video contains all the recorded sequences'photos.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace KartaViewSharp.V1.Response.Resources.Authentication;

public class AuthenticationData
public sealed class AuthenticationData
{
[JsonPropertyName("access_token")]
public string AccessToken { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace KartaViewSharp.V1.Response.Resources.Authentication;

public class AuthenticationResponse
public sealed class AuthenticationResponse
{
[JsonPropertyName("status")]
public ResponseStatus Status { get; set; }
Expand Down
Loading

0 comments on commit e138e5b

Please sign in to comment.