/// <summary> /// Append <see cref="LineParameter"/>. /// </summary> /// <param name="appender"></param> /// <param name="previous"></param> /// <param name="parameterName"></param> /// <param name="parameterValue"></param> /// <param name="result"></param> /// <returns></returns> public virtual bool TryCreate(ILineFactory appender, ILine previous, string parameterName, string parameterValue, out ILineParameter result) { // Try resolve ILineArgument args; ILine resolved; if (Resolver.TryResolveParameter(previous, parameterName, parameterValue, out args) && this.TryCreate(previous, args, out resolved) && resolved is ILineParameter castedResolved) { // Return as parameter and as resolved instance result = castedResolved; return(true); } IParameterInfo pi; if (ParameterInfos.TryGetValue(parameterName, out pi)) { if (pi.InterfaceType == typeof(ILineHint)) { result = new LineHint(appender, previous, parameterName, parameterValue); return(true); } if (pi.InterfaceType == typeof(ILineCanonicalKey)) { result = new LineCanonicalKey(appender, previous, parameterName, parameterValue); return(true); } if (pi.InterfaceType == typeof(ILineNonCanonicalKey)) { result = new LineNonCanonicalKey(appender, previous, parameterName, parameterValue); return(true); } } // Return as parameter result = new LineParameter(appender, previous, parameterName, parameterValue); return(true); }
/// <summary> /// Append key. /// </summary> /// <param name="appender"></param> /// <param name="previous"></param> /// <param name="parameterName"></param> /// <param name="parameterValue"></param> /// <param name="result"></param> /// <returns></returns> public virtual bool TryCreate(ILineFactory appender, ILine previous, string parameterName, string parameterValue, out ILineCanonicalKey result) { // Try resolve ILineArgument args; ILine resolved; if (Resolver.TryResolveParameter(previous, parameterName, parameterValue, out args) && this.TryCreate(previous, args, out resolved) && resolved is ILineCanonicalKey castedResolved) { // Return as parameter and as resolved instance result = castedResolved; return(true); } result = new LineCanonicalKey(this, previous, parameterName, parameterValue); return(true); }