/// <summary> /// Creates a builder for a custom ParameterConverter. /// Call builder.With(...) to define field conversions, then builder.Compile(). /// </summary> /// <param name="withDefaultConversions">If true, field conversions will fall back to default conversion when no custom conversion can be used.</param> public Builder(bool withDefaultConversions = true) { _withDefaults = withDefaultConversions; _binderBuilders = typeof(TParams) .FieldsOrderedByDeclaration() .Where(CanGetValue) .Select(m => ValueBinder.Build <TParams>(m)) .ToList(); }
private ValueBinder.IBuilder <TParams> GetOrAdd(MemberInfo member) { var builder = _binderBuilders.Find(cm => cm.Member == member); if (builder == null) { builder = ValueBinder.Build <TParams>(member); _binderBuilders.Add(builder); } return(builder); }
/// <summary> /// Creates a builder for a custom ParameterConverter. /// Call builder.With(...) to define conversions, then builder.Compile(). /// </summary> /// <param name="withDefaultConversions">If true, conversion will fall back to default conversions when no custom conversion can be used.</param> public ScalarBuilder(bool withDefaultConversions = true) { _withDefaults = withDefaultConversions; _builder = ValueBinder.Build <TParams>(); }