Refactor SelectorNotAvailableException.
This commit is contained in:
@@ -58,7 +58,7 @@ namespace Cryville.Crtr {
|
||||
MatchStatic(r.Value, state, nrctx);
|
||||
}
|
||||
}
|
||||
catch (SelectorNotStaticException) {
|
||||
catch (SelectorNotAvailableException) {
|
||||
dynelems.Add(
|
||||
new DynamicElement { Context = ctx, Selectors = r.Key, Element = r.Value }
|
||||
);
|
||||
|
@@ -61,8 +61,8 @@ namespace Cryville.Crtr {
|
||||
public abstract class SkinSelector {
|
||||
protected SkinSelector() { }
|
||||
public virtual void Optimize(PdtEvaluatorBase etor) { }
|
||||
public virtual IEnumerable<SkinContext> MatchStatic(ContainerState h, SkinContext c) { throw new SelectorNotStaticException(); }
|
||||
public virtual SkinContext MatchDynamic(ContainerState h, SkinContext c) { throw new NotSupportedException(); }
|
||||
public virtual IEnumerable<SkinContext> MatchStatic(ContainerState h, SkinContext c) { throw new SelectorNotAvailableException(); }
|
||||
public virtual SkinContext MatchDynamic(ContainerState h, SkinContext c) { throw new SelectorNotAvailableException(); }
|
||||
public virtual bool IsUpdatable(ContainerState h) {
|
||||
return true;
|
||||
}
|
||||
@@ -121,17 +121,16 @@ namespace Cryville.Crtr {
|
||||
else return Enumerable.Empty<SkinContext>();
|
||||
}
|
||||
public override SkinContext MatchDynamic(ContainerState h, SkinContext c) {
|
||||
return Match(c, true);
|
||||
return Match(c);
|
||||
}
|
||||
public SkinContext Match(SkinContext a, bool dyn = false) {
|
||||
public SkinContext Match(SkinContext a) {
|
||||
ChartPlayer.etor.ContextTransform = a.Transform;
|
||||
try {
|
||||
ChartPlayer.etor.Evaluate(_op, _exp);
|
||||
return _flag ? a : null;
|
||||
}
|
||||
catch (Exception) {
|
||||
if (dyn) throw;
|
||||
else throw new SelectorNotStaticException();
|
||||
catch (Exception ex) {
|
||||
throw new SelectorNotAvailableException("The expression is not evaluatable under the current context", ex);
|
||||
}
|
||||
finally {
|
||||
ChartPlayer.etor.ContextTransform = null;
|
||||
@@ -152,10 +151,10 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
}
|
||||
}
|
||||
public class SelectorNotStaticException : Exception {
|
||||
public SelectorNotStaticException() : base("The selector is not static") { }
|
||||
public SelectorNotStaticException(string message) : base(message) { }
|
||||
public SelectorNotStaticException(string message, Exception innerException) : base(message, innerException) { }
|
||||
protected SelectorNotStaticException(SerializationInfo info, StreamingContext context) : base(info, context) { }
|
||||
public class SelectorNotAvailableException : Exception {
|
||||
public SelectorNotAvailableException() : base("The selector is not available under the current context") { }
|
||||
public SelectorNotAvailableException(string message) : base(message) { }
|
||||
public SelectorNotAvailableException(string message, Exception innerException) : base(message, innerException) { }
|
||||
protected SelectorNotAvailableException(SerializationInfo info, StreamingContext context) : base(info, context) { }
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user