/// <summary> /// Gets the max range based on the context. /// If not faound <see cref="DEFAULT_MAX"/> is used. /// </summary> /// <param name="ctx">The context.</param> /// <returns>The max value for the range.</returns> private static int GetMaxRange(UserAgentTreeWalkerParser.NumberRangeContext ctx) { var parent = ctx.Parent; var name = ((UserAgentTreeWalkerParser.StepDownContext)parent).name.Text; var maxRange = MaxRange.ContainsKey(name) ? (int?)MaxRange[name] : null; if (maxRange is null) { return(DEFAULT_MAX); } return(maxRange ?? 0); }
/// <summary> /// Initializes a new instance of the <see cref="StepDown"/> class. /// </summary> /// <param name="numberRange">The range<see cref="UserAgentTreeWalkerParser.NumberRangeContext"/> used to get the list of children.</param> /// <param name="name">The name of the node.</param> public StepDown(UserAgentTreeWalkerParser.NumberRangeContext numberRange, string name) : this(NumberRangeVisitor.GetList(numberRange), name) { }
/// <summary> /// Gets the <see cref="NumberRangeList"/> after parsing the user agent. /// </summary> /// <param name="ctx">The ctx<see cref="UserAgentTreeWalkerParser.NumberRangeContext"/>.</param> /// <returns>The <see cref="NumberRangeList"/>.</returns> public static NumberRangeList GetList(UserAgentTreeWalkerParser.NumberRangeContext ctx) { return(Instance.Visit(ctx)); }