public int Compare(IBaseSpec a, IBaseSpec b) { IPathElement ape = a.GetPathElement(); IPathElement bpe = b.GetPathElement(); int aa = _orderMap[ape.GetType()]; int bb = _orderMap[bpe.GetType()]; int elementsEqual = aa < bb ? -1 : aa == bb ? 0 : 1; if (elementsEqual != 0) { return(elementsEqual); } // At this point we have two PathElements of the same type. string acf = ape.GetCanonicalForm(); string bcf = bpe.GetCanonicalForm(); int alen = acf.Length; int blen = bcf.Length; // Sort them by.Length, with the longest (most specific) being first // aka "rating-range-*" needs to be evaluated before "rating-*", or else "rating-*" will catch too much // If the.Lengths are equal, sort alphabetically as the last ditch deterministic behavior return(alen > blen ? -1 : alen == blen?acf.CompareTo(bcf) : 1); }
/** * Create a path element and ensures it is a Matchable Path Element */ public static IMatchablePathElement BuildMatchablePathElement(string rawJsonKey) { IPathElement pe = PathElementBuilder.ParseSingleKeyLHS(rawJsonKey); if (!(pe is IMatchablePathElement mpe)) { throw new SpecException("Spec LHS key=" + rawJsonKey + " is not a valid LHS key."); } return((IMatchablePathElement)mpe); }
public SelfLookupArg(PathEvaluatingTraversal traversal) { IPathElement pathElement = traversal.Get(traversal.Size() - 1); if (pathElement is TransposePathElement tpe) { _pathElement = tpe; } else { throw new SpecException("Expected @ path element here"); } }
private IPathElement createPathElement(string path, out string newPath) { //get the first applicable path element type var pathElementFactory = PathElementFactories.Where(f => f.IsApplicable(path)).FirstOrDefault(); if (pathElementFactory == null) { throw new InvalidOperationException($"There is no applicable path element factory for {path}"); } IPathElement result = pathElementFactory.Create(path, out newPath); return(result); }
/** * @param refDotNotation the original dotNotation string used for error messages * @return List of PathElements based on the provided List<string> keys */ public static List <IPathElement> ParseList(List <string> keys, string refDotNotation) { var paths = new List <IPathElement>(); foreach (string key in keys) { IPathElement path = ParseSingleKeyLHS(key); if (path is AtPathElement) { throw new SpecException("'.@.' is not valid on the RHS: " + refDotNotation); } paths.Add(path); } return(paths); }
public CardinalitySpec(string rawJsonKey) { var pathElements = Parse(rawJsonKey); if (pathElements.Count != 1) { throw new SpecException("CardinalityTransform invalid LHS:" + rawJsonKey + " can not contain '.'"); } IPathElement pe = pathElements[0]; if (!(pe is IMatchablePathElement mpe)) { throw new SpecException("Spec LHS key=" + rawJsonKey + " is not a valid LHS key."); } _pathElement = mpe; }
internal static string PathInTreeNamespace(this IPathElement element) => DatabaseSchema.TreeNamespace + element.Path;
public ValueTask <bool> HasReadAccessAsync(string accessId, IPathElement item) => ValueTask.FromResult(true);
public ValueCondition(IPathElement attributePath, object value, OperatorType operatorType) { this.attributePath = attributePath; this.value = value; this.operatorType = operatorType; }
public GraphicsPath CreateGraphicsPath(bool close) { var path = new GraphicsPath(_fillMode); path.StartFigure(); IPathElement elem = null; for (int i = 0; i < _pathElements.Count; ++i) { elem = _pathElements[i]; switch (elem.Kind) { case PathElementKind.Arc: { var arc = elem as ArcPathElement; path.AddArc(arc.Rect, arc.StartAngle, arc.SweepAngle); break; } case PathElementKind.Bezier: { var bezier = elem as BezierPathElement; path.AddBezier(bezier.Point1, bezier.Point2, bezier.Point3, bezier.Point4); break; } case PathElementKind.Curve: { var curve = elem as CurvePathElement; if (curve.Tension.HasValue) { path.AddCurve(curve.Points, curve.Tension.Value); } else { path.AddCurve(curve.Points); } break; } case PathElementKind.Ellipse: { var ellipse = elem as EllipsePathElement; path.AddEllipse(ellipse.Rect); break; } case PathElementKind.Line: { var line = elem as LinePathElement; path.AddLine(line.Point1, line.Point2); break; } case PathElementKind.Pie: { var pie = elem as PiePathElement; path.AddPie(pie.Rect, pie.StartAngle, pie.SweepAngle); break; } case PathElementKind.Polygon: { var polygon = elem as PolygonPathElement; path.AddPolygon(polygon.Points); break; } case PathElementKind.Rectangle: { var rectangle = elem as RectanglePathElement; path.AddRectangle(rectangle.Rect); break; } default: { throw new InvalidOperationException("Invalid kind of path element"); } } } if (close) { path.CloseAllFigures(); } return(path); }