예제 #1
0
 /// <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();
 }
예제 #2
0
            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);
            }
예제 #3
0
 /// <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>();
 }
예제 #4
0
 internal ParameterConverter(ValueBinder <TParams, TParams> scalarBinder)
 {
     _scalarBinder = scalarBinder;
     FieldCount    = 1;
 }