23 lines
836 B
C#
23 lines
836 B
C#
using System;
|
|
|
|
namespace Cryville.Crtr.Browsing.Actions {
|
|
public abstract class ResourceAction<T> : IResourceAction<T> where T : IResourceMeta {
|
|
public abstract string Name { get; }
|
|
public abstract int Priority { get; }
|
|
|
|
public abstract bool CanInvoke(Uri uri, T resource);
|
|
public bool CanInvoke(Uri uri, IResourceMeta resource) {
|
|
if (resource == null) throw new ArgumentNullException("resource");
|
|
if (!(resource is T)) throw new ArgumentException("Mismatched resource type.");
|
|
return CanInvoke(uri, (T)resource);
|
|
}
|
|
|
|
public abstract void Invoke(Uri uri, T resource);
|
|
public void Invoke(Uri uri, IResourceMeta resource) {
|
|
if (resource == null) throw new ArgumentNullException("resource");
|
|
if (!(resource is T)) throw new ArgumentException("Mismatched resource type.");
|
|
Invoke(uri, (T)resource);
|
|
}
|
|
}
|
|
}
|