/// <summary> /// Set first level navigation value /// </summary> /// <param name="namespace"></param> /// <param name="value"></param> /// <exception cref="ArgumentNullException"></exception> public void SetFirstLevelNavValue(string @namespace, EndValueNamespaceNavigationNode value) { if (string.IsNullOrWhiteSpace(@namespace)) { throw new ArgumentNullException(nameof(@namespace)); } if (value == null) { throw new ArgumentNullException(nameof(value)); } value = FixedValue(value); var firstMatched = _namespaceNavigators.FirstOrDefault(x => string.CompareOrdinal(x.NamespaceFragment, @namespace) == 0); if (firstMatched == null) { var nav = new NamespaceNavigator(@namespace); nav.AppendValue(value); _namespaceNavigators.Add(nav); } else { firstMatched.AppendValue(value); } }
/// <summary> /// Set to all navigation node /// </summary> /// <param name="value"></param> /// <exception cref="ArgumentNullException"></exception> public void SetAllNavValue(EndValueNamespaceNavigationNode value) { if (value == null) { throw new ArgumentNullException(nameof(value)); } if (!HasAllValue()) { ForAllNavNode = new NamespaceNavigator("*"); } ForAllNavNode.AppendValue(value); }
/// <summary> /// Set default navigation node value /// </summary> /// <param name="value"></param> /// <exception cref="ArgumentNullException"></exception> public void SetDefaultNavValue(EndValueNamespaceNavigationNode value) { if (value == null) { throw new ArgumentNullException(nameof(value)); } if (!HasDefaultValue()) { DefaultNavNode = new NamespaceNavigator("Default"); } DefaultNavNode.AppendValue(value); }
private EndValueNamespaceNavigationNode FixedValue(EndValueNamespaceNavigationNode value) { if (_registeredEndValueNodeDict.ContainsKey(value.GetHashCode())) { value = _registeredEndValueNodeDict[value.GetHashCode()]; } else { _registeredEndValueNodeDict.Add(value.GetHashCode(), value); } return(value); }
public virtual void AppendValue(EndValueNamespaceNavigationNode value) { if (value == null) { throw new ArgumentNullException(nameof(value)); } var hashcode = value.GetHashCode(); if (!_valueDict.ContainsKey(hashcode)) { _valueDict.Add(hashcode, value); } }
/// <inheritdoc /> public void Parse(string basePath, OutputOptions options, out EndValueNamespaceNavigationNode endValueNode) { if (options == null) { throw new ArgumentNullException(nameof(options)); } var root = RootNamespaceNavigation.GetInstance(); var strategy = StrategyFactory.Create(basePath, options); Console.WriteLine(strategy.Path); endValueNode = new EndValueNamespaceNavigationNode(strategy); if (IsDefault(options)) { root.SetDefaultNavValue(endValueNode); return; } if (IncludeStar(options)) { root.SetAllNavValue(endValueNode); return; } var validNamespaceList = GetValidNamespaceList(options); foreach (var @namespace in validNamespaceList) { if (@namespace.IndexOf(".", StringComparison.Ordinal) < 0) { root.SetFirstLevelNavValue(@namespace, endValueNode); } else { root.SetFluentLinkedNavValue(@namespace, endValueNode); } } }
/// <summary> /// Set fluent linked navigation value /// </summary> /// <param name="namespace"></param> /// <param name="value"></param> /// <exception cref="ArgumentNullException"></exception> public void SetFluentLinkedNavValue(string @namespace, EndValueNamespaceNavigationNode value) { if (string.IsNullOrWhiteSpace(@namespace)) { throw new ArgumentNullException(nameof(@namespace)); } if (value == null) { throw new ArgumentNullException(nameof(value)); } value = FixedValue(value); var nss = @namespace.Split('.'); var root = TouchRootNode(nss[0], out var createdMode); var currentNav = root; for (var i = 1; i < nss.Length; i++) { var _ = _namespaceNavigators.FirstOrDefault(x => x.NamespaceFragment == nss[i]); if (_ == null) { _ = new NamespaceNavigator(nss[i]); currentNav.AddChild(_); } currentNav = _; if (nss[i] == "*") { break; } } currentNav.AppendValue(value); if (createdMode) { _namespaceNavigators.Add(root); } }
/// <inheritdoc /> public override void AppendValue(EndValueNamespaceNavigationNode nav) { }
/// <inheritdoc /> public void Parse(string basePath, OutputOptions options, out EndValueNamespaceNavigationNode endValueNode) { _namespaceNavigationParser.Parse(basePath, options, out endValueNode); }