Esempio n. 1
0
        private TypeNaInfo KindReport <T>(IChannel ch, PrimitiveDataViewType type)
        {
            Contracts.AssertValue(ch);
            ch.AssertValue(type);
            ch.Assert(type.IsStandardScalar());

            var             conv = Conversions.Instance;
            InPredicate <T> isNaDel;
            bool            hasNaPred   = conv.TryGetIsNAPredicate(type, out isNaDel);
            bool            defaultIsNa = false;

            if (hasNaPred)
            {
                T def = default(T);
                defaultIsNa = isNaDel(in def);
            }
            return(new TypeNaInfo(hasNaPred, defaultIsNa));
        }
Esempio n. 2
0
            protected ValueWriterBase(PrimitiveDataViewType type, int source, char sep)
                : base(source)
            {
                Contracts.Assert(type.IsStandardScalar() || type is KeyType);
                Contracts.Assert(type.RawType == typeof(T));

                Sep = sep;
                if (type is TextDataViewType)
                {
                    // For text we need to deal with escaping.
                    ValueMapper <ReadOnlyMemory <char>, StringBuilder> c = MapText;
                    Conv = (ValueMapper <T, StringBuilder>)(Delegate) c;
                }
                else if (type is TimeSpanDataViewType)
                {
                    ValueMapper <TimeSpan, StringBuilder> c = MapTimeSpan;
                    Conv = (ValueMapper <T, StringBuilder>)(Delegate) c;
                }
                else if (type is DateTimeDataViewType)
                {
                    ValueMapper <DateTime, StringBuilder> c = MapDateTime;
                    Conv = (ValueMapper <T, StringBuilder>)(Delegate) c;
                }
                else if (type is DateTimeOffsetDataViewType)
                {
                    ValueMapper <DateTimeOffset, StringBuilder> c = MapDateTimeZone;
                    Conv = (ValueMapper <T, StringBuilder>)(Delegate) c;
                }
                else
                {
                    Conv = Conversions.Instance.GetStringConversion <T>(type);
                }

                var d = default(T);

                Conv(in d, ref Sb);
                Default = Sb.ToString();
            }