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