-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3244016
commit d6b9629
Showing
14 changed files
with
530 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,63 @@ | ||
namespace Maui.ServerDrivenUI; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Maui.ServerDrivenUI; | ||
|
||
/// <summary> | ||
/// Represents a xaml namespace eg.: xmlns:alias="clr-namespace:namespace;assembly=assembly" | ||
/// </summary> | ||
/// <param name="alias">Define the alias from custom namespaces</param> | ||
Check warning on line 8 in Maui.ServerDrivenUI/Models/CustomNamespace.cs GitHub Actions / Build with dotnet
|
||
/// <param name="namespace">clr-namespace</param> | ||
Check warning on line 9 in Maui.ServerDrivenUI/Models/CustomNamespace.cs GitHub Actions / Build with dotnet
|
||
/// <param name="assembly">Assembly where the custom control is located</param> | ||
public class CustomNamespace(string alias, string @namespace, string? assembly = null) | ||
public class CustomNamespace : IEquatable<CustomNamespace> | ||
{ | ||
public string Alias { get; private set; } = alias; | ||
public string Namespace { get; private set; } = @namespace; | ||
public string? Assembly { get; private set; } = assembly; | ||
public string Alias | ||
{ | ||
get; set; | ||
} | ||
|
||
public string Namespace | ||
{ | ||
get; set; | ||
} | ||
|
||
public string? Assembly | ||
{ | ||
get; set; | ||
} | ||
|
||
[JsonConstructor] | ||
[Obsolete("This constructor should only be used from serializer")] | ||
public CustomNamespace() | ||
{ | ||
Alias = string.Empty; | ||
Namespace = string.Empty; | ||
} | ||
|
||
public CustomNamespace(string alias, string @namespace, string? assembly = null) | ||
{ | ||
Alias = alias; | ||
Namespace = @namespace; | ||
Assembly = assembly; | ||
} | ||
|
||
public bool Equals(CustomNamespace? other) | ||
{ | ||
if (other is null) | ||
return false; | ||
|
||
return Namespace == other?.Namespace | ||
&& Alias == other?.Alias | ||
&& Assembly == other?.Assembly; | ||
} | ||
|
||
public override bool Equals(object? obj) | ||
{ | ||
if(obj is CustomNamespace cn) | ||
return Equals(cn); | ||
|
||
return false; | ||
} | ||
|
||
public override int GetHashCode() => | ||
(Namespace, Alias, Assembly).GetHashCode(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
namespace Maui.ServerDrivenUI.Models; | ||
using Maui.ServerDrivenUI.Services; | ||
|
||
internal sealed class UIElementResolver(Func<string, Task<ServerUIElement>> uiElementGetter) : IUIElementResolver | ||
namespace Maui.ServerDrivenUI.Models; | ||
|
||
internal sealed class UIElementResolver(Func<string, IServiceProvider, Task<ServerUIElement>> uiElementGetter) : IUIElementResolver | ||
{ | ||
private readonly Func<string, Task<ServerUIElement>> _uiElementGetter = uiElementGetter; | ||
private readonly Func<string, IServiceProvider, Task<ServerUIElement>> _uiElementGetter = uiElementGetter; | ||
|
||
public Task<ServerUIElement> GetElementAsync(string elementKey) => | ||
_uiElementGetter(elementKey); | ||
_uiElementGetter(elementKey, ServiceProviderHelper.ServiceProvider!); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.