Ejemplo n.º 1
0
        private bool WriteItem(NpgsqlNativeTypeInfo TypeInfo, object item, StringBuilder sb, Boolean ForExtendedQuery)
        {
            //item could be:
            //an Ienumerable - in which case we call WriteEnumeration
            //an element - in which case we call the NpgsqlNativeTypeInfo for that type to serialise it.
            //an array - in which case we call WriteArray,

            // Even an string being an IEnumerable, it shouldn't be processed. It will be processed on the last else.
            // See http://pgfoundry.org/tracker/?func=detail&atid=592&aid=1010514&group_id=1000140 for more info.

            if (item == null || NpgsqlTypesHelper.DefinedType(item))
            {
                sb.Append(_elementConverter.ConvertToBackend(item, ForExtendedQuery));
                return(true);
            }
            else if (item is Array)
            {
                return(WriteArray(TypeInfo, item as Array, sb, ForExtendedQuery));
            }
            else if (item is IEnumerable)
            {
                return(WriteEnumeration(TypeInfo, item as IEnumerable, sb, ForExtendedQuery));
            }
            else
            {//This shouldn't really be reachable.
                sb.Append(_elementConverter.ConvertToBackend(item, ForExtendedQuery));
                return(true);
            }
        }
Ejemplo n.º 2
0
        private bool WriteItemText(NpgsqlNativeTypeInfo TypeInfo, object item, MemoryStream array, Boolean forExtendedQuery, NativeToBackendTypeConverterOptions options)
        {
            //item could be:
            //an Ienumerable - in which case we call WriteEnumeration
            //an element - in which case we call the NpgsqlNativeTypeInfo for that type to serialise it.
            //an array - in which case we call WriteArray,

            // Even an string being an IEnumerable, it shouldn't be processed. It will be processed on the last else.
            // See http://pgfoundry.org/tracker/?func=detail&atid=592&aid=1010514&group_id=1000140 for more info.

            if (item == null || NpgsqlTypesHelper.DefinedType(item))
            {
                byte[] element;

                element = _elementConverter.ConvertToBackend(item, forExtendedQuery, options, true);

                array.Write(element, 0, element.Length);

                return(true);
            }
            else if (item is Array)
            {
                return(WriteArrayText(TypeInfo, item as Array, array, forExtendedQuery, options));
            }
            else if (item is IEnumerable)
            {
                return(WriteEnumeration(TypeInfo, item as IEnumerable, array, forExtendedQuery, options));
            }
            else
            {//This shouldn't really be reachable.
                byte[] element;

                element = _elementConverter.ConvertToBackend(item, forExtendedQuery, options, true);

                array.Write(element, 0, element.Length);

                return(true);
            }
        }
Ejemplo n.º 3
0
        private bool WriteItem(NpgsqlNativeTypeInfo TypeInfo, object item, StringBuilder sb)
        {
            //item could be:
            //an Ienumerable - in which case we call WriteEnumeration
            //an element - in which case we call the NpgsqlNativeTypeInfo for that type to serialise it.
            //an array - in which case we call WriteArray,

            if (item is IEnumerable)
            {
                return(WriteEnumeration(TypeInfo, item as IEnumerable, sb));
            }
            else if (item is Array)
            {
                return(WriteArray(TypeInfo, item as Array, sb));
            }
            else
            {
                sb.Append(_elementConverter.ConvertToBackend(item, false));
                return(true);
            }
        }