1 //------------------------------------------------------------------------------
2 // <copyright file="SqlUserDefinedTypeAttribute.cs" company="Microsoft Corporation">
3 // Copyright (c) Microsoft Corporation. All Rights Reserved.
4 // Information Contained Herein is Proprietary and Confidential.
6 // <owner current="true" primary="true">Microsoft</owner>
7 // <owner current="true" primary="true">Microsoft</owner>
8 // <owner current="true" primary="true">daltudov</owner>
9 // <owner current="true" primary="true">Microsoft</owner>
10 // <owner current="true" primary="false">beysims</owner>
11 // <owner current="true" primary="false">Microsoft</owner>
12 // <owner current="true" primary="false">vadimt</owner>
13 // <owner current="false" primary="false">venkar</owner>
14 // <owner current="false" primary="false">Microsoft</owner>
15 //------------------------------------------------------------------------------
17 namespace Microsoft.SqlServer.Server {
20 using System.Data.Common;
22 public enum Format { //: byte
28 // This custom attribute indicates that the given type is
29 // a SqlServer udt. The properties on the attribute reflect the
30 // physical attributes that will be used when the type is registered
32 [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple=false, Inherited=true)]
33 public sealed class SqlUserDefinedTypeAttribute: Attribute {
34 private int m_MaxByteSize;
35 private bool m_IsFixedLength;
36 private bool m_IsByteOrdered;
37 private Format m_format;
38 private string m_fName;
40 // The maximum value for the maxbytesize field, in bytes.
41 internal const int YukonMaxByteSizeValue = 8000;
42 private String m_ValidationMethodName = null;
45 // A required attribute on all udts, used to indicate that the
46 // given type is a udt, and its storage format.
47 public SqlUserDefinedTypeAttribute(Format format) {
50 throw ADP.NotSupportedUserDefinedTypeSerializationFormat((Microsoft.SqlServer.Server.Format)format, "format");
52 case Format.UserDefined:
53 this.m_format = format;
56 throw ADP.InvalidUserDefinedTypeSerializationFormat((Microsoft.SqlServer.Server.Format)format);
60 // The maximum size of this instance, in bytes. Does not have to be
61 // specified for Native serialization. The maximum value
62 // for this property is specified by MaxByteSizeValue.
63 public int MaxByteSize {
65 return this.m_MaxByteSize;
69 throw ADP.ArgumentOutOfRange("MaxByteSize");
71 this.m_MaxByteSize = value;
75 // Are all instances of this udt the same size on disk?
76 public bool IsFixedLength {
78 return this.m_IsFixedLength;
81 this.m_IsFixedLength = value;
85 // Is this type byte ordered, i.e. is the on disk representation
86 // consistent with the ordering semantics for this type?
87 // If true, the binary representation of the type will be used
88 // in comparison by SqlServer. This property enables indexing on the
89 // udt and faster comparisons.
90 public bool IsByteOrdered {
92 return this.m_IsByteOrdered;
95 this.m_IsByteOrdered = value;
99 // The on-disk format for this type.
100 public Format Format {
102 return this.m_format;
106 // An Optional method used to validate this UDT
107 // Signature: bool <ValidationMethodName>();
108 public String ValidationMethodName {
111 return this.m_ValidationMethodName;
115 this.m_ValidationMethodName = value;