Add IResourceMeta
constraint on resource action.
This commit is contained in:
@@ -28,7 +28,7 @@ namespace Cryville.Crtr.Browsing.Actions {
|
|||||||
public void Register(IResourceAction action) {
|
public void Register(IResourceAction action) {
|
||||||
Register(typeof(object), action);
|
Register(typeof(object), action);
|
||||||
}
|
}
|
||||||
public void Register<T>(IResourceAction<T> action) {
|
public void Register<T>(IResourceAction<T> action) where T : IResourceMeta {
|
||||||
Register(typeof(T), action);
|
Register(typeof(T), action);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@ namespace Cryville.Crtr.Browsing.Actions {
|
|||||||
public void Unregister(IResourceAction action) {
|
public void Unregister(IResourceAction action) {
|
||||||
Unregister(typeof(object), action);
|
Unregister(typeof(object), action);
|
||||||
}
|
}
|
||||||
public void Unregister<T>(IResourceAction<T> action) {
|
public void Unregister<T>(IResourceAction<T> action) where T : IResourceMeta {
|
||||||
Unregister(typeof(T), action);
|
Unregister(typeof(T), action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -4,9 +4,9 @@ namespace Cryville.Crtr.Browsing.Actions {
|
|||||||
public interface IResourceAction {
|
public interface IResourceAction {
|
||||||
string Name { get; }
|
string Name { get; }
|
||||||
int Priority { get; }
|
int Priority { get; }
|
||||||
void Invoke(Uri uri, object resource);
|
void Invoke(Uri uri, IResourceMeta resource);
|
||||||
}
|
}
|
||||||
public interface IResourceAction<T> : IResourceAction {
|
public interface IResourceAction<T> : IResourceAction where T : IResourceMeta {
|
||||||
void Invoke(Uri uri, T resource);
|
void Invoke(Uri uri, T resource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -11,7 +11,7 @@ namespace Cryville.Crtr.Browsing.Actions {
|
|||||||
public string Name { get { return "Import"; } }
|
public string Name { get { return "Import"; } }
|
||||||
public int Priority { get { return 0; } }
|
public int Priority { get { return 0; } }
|
||||||
|
|
||||||
public void Invoke(Uri uri, object resource) {
|
public void Invoke(Uri uri, IResourceMeta resource) {
|
||||||
if (_destination.ImportFrom(uri))
|
if (_destination.ImportFrom(uri))
|
||||||
Popup.Create("Import succeeded");
|
Popup.Create("Import succeeded");
|
||||||
else
|
else
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Cryville.Crtr.Browsing.Actions {
|
namespace Cryville.Crtr.Browsing.Actions {
|
||||||
public abstract class ResourceAction<T> : IResourceAction<T> {
|
public abstract class ResourceAction<T> : IResourceAction<T> where T : IResourceMeta {
|
||||||
public abstract string Name { get; }
|
public abstract string Name { get; }
|
||||||
public abstract int Priority { get; }
|
public abstract int Priority { get; }
|
||||||
public abstract void Invoke(Uri uri, T resource);
|
public abstract void Invoke(Uri uri, T resource);
|
||||||
public void Invoke(Uri uri, object resource) {
|
public void Invoke(Uri uri, IResourceMeta resource) {
|
||||||
if (resource == null) throw new ArgumentNullException("resource");
|
if (resource == null) throw new ArgumentNullException("resource");
|
||||||
if (!(resource is T)) throw new ArgumentException("Mismatched resource type.");
|
if (!(resource is T)) throw new ArgumentException("Mismatched resource type.");
|
||||||
Invoke(uri, (T)resource);
|
Invoke(uri, (T)resource);
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Cryville.Crtr.Browsing {
|
namespace Cryville.Crtr.Browsing {
|
||||||
internal interface IChartDetail {
|
internal interface IChartDetail : IResourceMeta {
|
||||||
string RulesetId { get; }
|
string RulesetId { get; }
|
||||||
string Name { get; }
|
string Name { get; }
|
||||||
string SongName { get; }
|
string SongName { get; }
|
||||||
|
@@ -5,7 +5,7 @@ using System.Collections.Generic;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Cryville.Crtr.Browsing.Legacy {
|
namespace Cryville.Crtr.Browsing.Legacy {
|
||||||
internal class LegacyChartDetail : IChartDetail, IResourceMeta {
|
internal class LegacyChartDetail : IChartDetail {
|
||||||
public AsyncDelivery<Texture2D> Cover { get; set; }
|
public AsyncDelivery<Texture2D> Cover { get; set; }
|
||||||
public ChartMeta Meta { get; set; }
|
public ChartMeta Meta { get; set; }
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user