Skip to content

Commit

Permalink
Change ComponentBase to IComponent (#272)
Browse files Browse the repository at this point in the history
* Use `IComponent` instead of `ComponentBase`
* Change the order of parameter docs to be the same order as parameters themselves
  • Loading branch information
larsk2009 authored Dec 23, 2020
1 parent 4271d94 commit 26d5d86
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
15 changes: 8 additions & 7 deletions src/Blazored.Modal/Services/IModalService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@ public interface IModalService
/// <summary>
/// Shows a modal containing the specified <typeparamref name="TComponent"/>.
/// </summary>
IModalReference Show<TComponent>() where TComponent : ComponentBase;
IModalReference Show<TComponent>() where TComponent : IComponent;

/// <summary>
/// Shows a modal containing a <typeparamref name="TComponent"/> with the specified <paramref name="title"/> .
/// </summary>
/// <param name="title">Modal title</param>
IModalReference Show<TComponent>(string title) where TComponent : ComponentBase;
IModalReference Show<TComponent>(string title) where TComponent : IComponent;

/// <summary>
/// Shows a modal containing a <typeparamref name="TComponent"/> with the specified <paramref name="title"/> and <paramref name="options"/>.
/// </summary>
/// <param name="title">Modal title</param>
/// <param name="options">Options to configure the modal</param>
IModalReference Show<TComponent>(string title, ModalOptions options) where TComponent : ComponentBase;
IModalReference Show<TComponent>(string title, ModalOptions options) where TComponent : IComponent;

/// <summary>
/// Shows a modal containing a <typeparamref name="TComponent"/> with the specified <paramref name="title"/> and <paramref name="parameters"/>.
/// </summary>
/// <param name="title">Modal title</param>
/// <param name="parameters">Key/Value collection of parameters to pass to component being displayed</param>
IModalReference Show<TComponent>(string title, ModalParameters parameters) where TComponent : ComponentBase;
IModalReference Show<TComponent>(string title, ModalParameters parameters) where TComponent : IComponent;

/// <summary>
/// Shows a modal containing a <typeparamref name="TComponent"/> with the specified <paramref name="title"/>,
Expand All @@ -37,7 +37,7 @@ public interface IModalService
/// <param name="title">Modal title.</param>
/// <param name="parameters">Key/Value collection of parameters to pass to component being displayed.</param>
/// <param name="options">Options to configure the modal.</param>
IModalReference Show<TComponent>(string title, ModalParameters parameters = null, ModalOptions options = null) where TComponent : ComponentBase;
IModalReference Show<TComponent>(string title, ModalParameters parameters = null, ModalOptions options = null) where TComponent : IComponent;

/// <summary>
/// Shows a modal containing a <paramref name="component"/>.
Expand All @@ -55,23 +55,24 @@ public interface IModalService
/// <summary>
/// Shows a modal containing a <paramref name="component"/> with the specified <paramref name="title"/> and <paramref name="options"/>.
/// </summary>
/// <param name="title">Modal title.</param>
/// <param name="component">Type of component to display.</param>
/// <param name="title">Modal title.</param>
/// <param name="options">Options to configure the modal.</param>
IModalReference Show(Type component, string title, ModalOptions options);

/// <summary>
/// Shows a modal containing a <paramref name="component"/> with the specified <paramref name="title"/> and <paramref name="parameters"/>.
/// </summary>
/// <param name="title">Modal title.</param>
/// <param name="component">Type of component to display.</param>
/// <param name="title">Modal title.</param>
/// <param name="parameters">Key/Value collection of parameters to pass to component being displayed.</param>
IModalReference Show(Type component, string title, ModalParameters parameters);

/// <summary>
/// Shows a modal containing a <paramref name="component"/> with the specified <paramref name="title"/>, <paramref name="parameters"/>
/// and <paramref name="options"/>.
/// </summary>
/// <param name="component">Type of component to display.</param>
/// <param name="title">Modal title.</param>
/// <param name="parameters">Key/Value collection of parameters to pass to component being displayed.</param>
/// <param name="options">Options to configure the modal.</param>
Expand Down
13 changes: 7 additions & 6 deletions src/Blazored.Modal/Services/ModalService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class ModalService : IModalService
/// <summary>
/// Shows the modal with the component type.
/// </summary>
public IModalReference Show<T>() where T : ComponentBase
public IModalReference Show<T>() where T : IComponent
{
return Show<T>(string.Empty, new ModalParameters(), new ModalOptions());
}
Expand All @@ -20,7 +20,7 @@ public IModalReference Show<T>() where T : ComponentBase
/// Shows the modal with the component type using the specified title.
/// </summary>
/// <param name="title">Modal title.</param>
public IModalReference Show<T>(string title) where T : ComponentBase
public IModalReference Show<T>(string title) where T : IComponent
{
return Show<T>(title, new ModalParameters(), new ModalOptions());
}
Expand All @@ -30,7 +30,7 @@ public IModalReference Show<T>(string title) where T : ComponentBase
/// </summary>
/// <param name="title">Modal title.</param>
/// <param name="options">Options to configure the modal.</param>
public IModalReference Show<T>(string title, ModalOptions options) where T : ComponentBase
public IModalReference Show<T>(string title, ModalOptions options) where T : IComponent
{
return Show<T>(title, new ModalParameters(), options);
}
Expand All @@ -41,7 +41,7 @@ public IModalReference Show<T>(string title, ModalOptions options) where T : Com
/// </summary>
/// <param name="title">Modal title.</param>
/// <param name="parameters">Key/Value collection of parameters to pass to component being displayed.</param>
public IModalReference Show<T>(string title, ModalParameters parameters) where T : ComponentBase
public IModalReference Show<T>(string title, ModalParameters parameters) where T : IComponent
{
return Show<T>(title, parameters, new ModalOptions());
}
Expand All @@ -53,7 +53,7 @@ public IModalReference Show<T>(string title, ModalParameters parameters) where T
/// <param name="title">Modal title.</param>
/// <param name="parameters">Key/Value collection of parameters to pass to component being displayed.</param>
/// <param name="options">Options to configure the modal.</param>
public IModalReference Show<T>(string title, ModalParameters parameters, ModalOptions options) where T : ComponentBase
public IModalReference Show<T>(string title, ModalParameters parameters, ModalOptions options) where T : IComponent
{
return Show(typeof(T), title, parameters, options);
}
Expand Down Expand Up @@ -104,12 +104,13 @@ public IModalReference Show(Type contentComponent, string title, ModalParameters
/// Shows the modal with the component type using the specified <paramref name="title"/>,
/// passing the specified <paramref name="parameters"/> and setting a custom CSS style.
/// </summary>
/// <param name="contentComponent">Type of component to display.</param>
/// <param name="title">Modal title.</param>
/// <param name="parameters">Key/Value collection of parameters to pass to component being displayed.</param>
/// <param name="options">Options to configure the modal.</param>
public IModalReference Show(Type contentComponent, string title, ModalParameters parameters, ModalOptions options)
{
if (!typeof(ComponentBase).IsAssignableFrom(contentComponent))
if (!typeof(IComponent).IsAssignableFrom(contentComponent))
{
throw new ArgumentException($"{contentComponent.FullName} must be a Blazor Component");
}
Expand Down

0 comments on commit 26d5d86

Please sign in to comment.