Skip to content

Commit

Permalink
To file scoped
Browse files Browse the repository at this point in the history
  • Loading branch information
valentasm committed Jun 13, 2023
1 parent 3a08a1e commit d486c72
Show file tree
Hide file tree
Showing 215 changed files with 9,599 additions and 9,822 deletions.
13 changes: 6 additions & 7 deletions GoogleMapsComponents/DependencyInjectionExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using Microsoft.Extensions.DependencyInjection;

namespace GoogleMapsComponents
namespace GoogleMapsComponents;

public static class DependencyInjectionExtensions
{
public static class DependencyInjectionExtensions
public static IServiceCollection AddBlazorGoogleMaps(this IServiceCollection service)
{
public static IServiceCollection AddBlazorGoogleMaps(this IServiceCollection service)
{
return service;
}
return service;
}
}
}
41 changes: 20 additions & 21 deletions GoogleMapsComponents/EnumMemberConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,36 @@
using System.Text.Json;
using System.Text.Json.Serialization;

namespace GoogleMapsComponents
namespace GoogleMapsComponents;

internal class EnumMemberConverter<T> : JsonConverter<T> where T : IComparable, IFormattable, IConvertible
{
internal class EnumMemberConverter<T> : JsonConverter<T> where T : IComparable, IFormattable, IConvertible
public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
var jsonValue = reader.GetString();

foreach (var fi in typeToConvert.GetFields())
{
var jsonValue = reader.GetString();
var description = (EnumMemberAttribute?)fi.GetCustomAttribute(typeof(EnumMemberAttribute), false);

foreach (var fi in typeToConvert.GetFields())
if (description != null)
{
var description = (EnumMemberAttribute?)fi.GetCustomAttribute(typeof(EnumMemberAttribute), false);

if (description != null)
if (string.Equals(description.Value, jsonValue, StringComparison.OrdinalIgnoreCase))
{
if (string.Equals(description.Value, jsonValue, StringComparison.OrdinalIgnoreCase))
{
return (T)fi.GetValue(null);
}
return (T)fi.GetValue(null);
}
}

throw new JsonException($"string {jsonValue} was not found as a description in the enum {typeToConvert}");
}

public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
{
var fi = value.GetType().GetField(value.ToString());
throw new JsonException($"string {jsonValue} was not found as a description in the enum {typeToConvert}");
}

public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
{
var fi = value.GetType().GetField(value.ToString());

var description = (EnumMemberAttribute)fi.GetCustomAttribute(typeof(EnumMemberAttribute), false);
var description = (EnumMemberAttribute)fi.GetCustomAttribute(typeof(EnumMemberAttribute), false);

writer.WriteStringValue(description.Value);
}
writer.WriteStringValue(description.Value);
}
}
}
19 changes: 9 additions & 10 deletions GoogleMapsComponents/ExampleJsInterop.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
using Microsoft.JSInterop;
using System.Threading.Tasks;

namespace GoogleMapsComponents
namespace GoogleMapsComponents;

public class ExampleJsInterop
{
public class ExampleJsInterop
public static ValueTask<string> Prompt(IJSRuntime jsRuntime, string message)
{
public static ValueTask<string> Prompt(IJSRuntime jsRuntime, string message)
{
// Implemented in exampleJsInterop.js
return jsRuntime.InvokeAsync<string>(
"exampleJsFunctions.showPrompt",
message);
}
// Implemented in exampleJsInterop.js
return jsRuntime.InvokeAsync<string>(
"exampleJsFunctions.showPrompt",
message);
}
}
}
Loading

0 comments on commit d486c72

Please sign in to comment.