Make System.Web.Script.Serialization.JavaScriptSerializer.ConvertToType(Type, object...
[mono.git] / mcs / class / Npgsql / Npgsql / NpgsqlCopyFormat.cs
1 // Npgsql.NpgsqlCopyFormat.cs
2 //
3 // Author:
4 //      Kalle Hallivuori <kato@iki.fi>
5 //
6 //      Copyright (C) 2007 The Npgsql Development Team
7 //      npgsql-general@gborg.postgresql.org
8 //      http://gborg.postgresql.org/project/npgsql/projdisplay.php
9 //
10 //  Copyright (c) 2002-2007, The Npgsql Development Team
11 //
12 // Permission to use, copy, modify, and distribute this software and its
13 // documentation for any purpose, without fee, and without a written
14 // agreement is hereby granted, provided that the above copyright notice
15 // and this paragraph and the following two paragraphs appear in all copies.
16 //
17 // IN NO EVENT SHALL THE NPGSQL DEVELOPMENT TEAM BE LIABLE TO ANY PARTY
18 // FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
19 // INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
20 // DOCUMENTATION, EVEN IF THE NPGSQL DEVELOPMENT TEAM HAS BEEN ADVISED OF
21 // THE POSSIBILITY OF SUCH DAMAGE.
22 //
23 // THE NPGSQL DEVELOPMENT TEAM SPECIFICALLY DISCLAIMS ANY WARRANTIES,
24 // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
25 // AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
26 // ON AN "AS IS" BASIS, AND THE NPGSQL DEVELOPMENT TEAM HAS NO OBLIGATIONS
27 // TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
28
29
30 using System;
31
32 namespace Npgsql
33 {
34         /// <summary>
35         /// Represents information about COPY operation data transfer format as returned by server.
36         /// </summary>
37         public sealed class NpgsqlCopyFormat
38         {
39                 private readonly byte _copyFormat;
40                 private readonly Int16[] _copyFieldFormats;
41
42                 /// <summary>
43                 /// Only created when a CopyInResponse or CopyOutResponse is received by NpgsqlState.ProcessBackendResponses()
44                 /// </summary>
45                 internal NpgsqlCopyFormat(byte copyFormat, Int16[] fieldFormats)
46                 {
47                         _copyFormat = copyFormat;
48                         _copyFieldFormats = fieldFormats;
49                 }
50
51                 /// <summary>
52                 /// Returns true if this operation is currently active and in binary format.
53                 /// </summary>
54                 public bool IsBinary
55                 {
56                         get { return _copyFormat != 0; }
57                 }
58
59                 /// <summary>
60                 /// Returns true if this operation is currently active and field at given location is in binary format.
61                 /// </summary>
62                 public bool FieldIsBinary(int fieldNumber)
63                 {
64                         return _copyFieldFormats[fieldNumber] != 0;
65                 }
66
67                 /// <summary>
68                 /// Returns number of fields if this operation is currently active, otherwise -1
69                 /// </summary>
70                 public int FieldCount
71                 {
72                         get { return _copyFieldFormats.Length; }
73                 }
74         }
75 }