Beispiel #1
0
        private Func <GetStringRequest, string> findConverter(GetStringRequest request)
        {
            if (request.PropertyType.IsNullable())
            {
                if (request.RawValue == null)
                {
                    return(r => string.Empty);
                }

                return(findConverter(request.GetRequestForNullableType()));
            }

            if (request.PropertyType.IsArray)
            {
                if (request.RawValue == null)
                {
                    return(r => string.Empty);
                }

                return(r =>
                {
                    if (r.RawValue == null)
                    {
                        return string.Empty;
                    }

                    return r.RawValue.As <Array>().OfType <object>().Select(GetString).Join(", ");
                });
            }

            StringifierStrategy strategy = _strategies.FirstOrDefault(x => x.Matches(request));

            return(strategy == null ? toString : strategy.StringFunction);
        }
Beispiel #2
0
        private Func <GetStringRequest, string> findConverter(GetStringRequest request)
        {
            if (request.PropertyType.IsNullable())
            {
                if (request.RawValue == null)
                {
                    return(r => string.Empty);
                }

                return(findConverter(request.GetRequestForNullableType()));
            }

            StringifierStrategy strategy = _strategies.FirstOrDefault(x => x.Matches(request));

            return(strategy == null ? toString : strategy.StringFunction);
        }
 public void AddStrategy(StringifierStrategy strategy)
 {
     _strategies.Add(strategy);
 }
Beispiel #4
0
 public void AddStrategy(StringifierStrategy strategy)
 {
     _strategies.Add(strategy);
 }