示例#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);
        }
示例#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);
 }
示例#4
0
 public void AddStrategy(StringifierStrategy strategy)
 {
     _strategies.Add(strategy);
 }