Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / class / System.Data.Services / System.Data.Services.Providers / ResourceType.cs
1 // 
2 // ResourceType.cs
3 //  
4 // Author:
5 //       Marek Habersack <grendel@twistedcode.net>
6 // 
7 // Copyright (c) 2011 Novell, Inc
8 // 
9 // Permission is hereby granted, free of charge, to any person obtaining a copy
10 // of this software and associated documentation files (the "Software"), to deal
11 // in the Software without restriction, including without limitation the rights
12 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 // copies of the Software, and to permit persons to whom the Software is
14 // furnished to do so, subject to the following conditions:
15 // 
16 // The above copyright notice and this permission notice shall be included in
17 // all copies or substantial portions of the Software.
18 // 
19 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 // THE SOFTWARE.
26
27 using System;
28 using System.Collections.Generic;
29 using System.Collections.ObjectModel;
30 using System.Data.Services.Common;
31 using System.Diagnostics;
32 using System.Linq.Expressions;
33 using System.Reflection;
34 using System.Runtime;
35 using System.Runtime.CompilerServices;
36
37 namespace System.Data.Services.Providers
38 {
39         [DebuggerDisplay ("{Name}: {InstanceType}, {ResourceTypeKind}")]
40         public class ResourceType
41         {
42                 string nameSpace;
43                 
44                 public bool IsMediaLinkEntry {
45                         get { throw new NotImplementedException (); }
46                         set { throw new NotImplementedException (); }
47                 }
48
49                 public Type InstanceType {
50                         get; private set;
51                 }
52
53                 public ResourceType BaseType {
54                         get; private set;
55                 }
56
57                 public ResourceTypeKind ResourceTypeKind {
58                         get; private set;
59                 }
60
61                 public ReadOnlyCollection <ResourceProperty> Properties {
62                         get { throw new NotImplementedException (); }
63                 }
64
65                 public ReadOnlyCollection <ResourceProperty> PropertiesDeclaredOnThisType {
66                         get { throw new NotImplementedException (); }
67                 }
68
69                 public ReadOnlyCollection <ResourceProperty> KeyProperties {
70                         get { throw new NotImplementedException (); }
71                 }
72
73                 public ReadOnlyCollection <ResourceProperty> ETagProperties {
74                         get { throw new NotImplementedException (); }
75                 }
76
77                 public string Name {
78                         get; private set;
79                 }
80
81                 public string FullName {
82                         get; private set;
83                 }
84
85                 public string Namespace {
86                         get {
87                                 if (nameSpace == null)
88                                         return String.Empty;
89                                 return nameSpace;
90                         }
91                 }
92
93                 public bool IsAbstract {
94                         get; private set;
95                 }
96
97                 public bool IsOpenType {
98                         get { throw new NotImplementedException (); }
99                         set { throw new NotImplementedException (); }
100                 }
101
102                 public bool CanReflectOnInstanceType {
103                         get; set;
104                 }
105
106                 public object CustomState {
107                         get { throw new NotImplementedException (); }
108                         set { throw new NotImplementedException (); }
109                 }
110
111                 public bool IsReadOnly {
112                         get; private set;
113                 }
114
115                 public ResourceType (Type instanceType, ResourceTypeKind resourceTypeKind, ResourceType baseType, string namespaceName, string name, bool isAbstract)
116                 {
117                         if (instanceType == null)
118                                 throw new ArgumentNullException ("instanceType");
119                         if (String.IsNullOrEmpty (name))
120                                 throw new ArgumentNullException ("name");
121                         if (resourceTypeKind == ResourceTypeKind.Primitive)
122                                 throw new ArgumentException ("'Primitive' is not a valid value for resourceTypeKind", "resourceTypeKind");
123                         if (instanceType.IsValueType)
124                                 throw new ArgumentException ("Clr type for the resource type cannot be a value type.");
125                         
126                         this.InstanceType = instanceType;
127                         this.ResourceTypeKind = resourceTypeKind;
128                         this.BaseType = baseType;
129                         if (String.IsNullOrEmpty (namespaceName))
130                                 this.FullName = name;
131                         else
132                                 this.FullName = namespaceName + "." + name;
133                         this.Name = name;
134                         this.nameSpace = namespaceName;
135                         this.IsAbstract = isAbstract;
136
137                         // Appears to always be true
138                         this.CanReflectOnInstanceType = true;
139                 }
140
141                 public static ResourceType GetPrimitiveResourceType (Type type)
142                 {
143                         throw new NotImplementedException ();
144                 }
145
146                 public void AddProperty (ResourceProperty property)
147                 {
148                         throw new NotImplementedException ();
149                 }
150
151                 public void AddEntityPropertyMappingAttribute (EntityPropertyMappingAttribute attribute)
152                 {
153                         throw new NotImplementedException ();
154                 }
155
156                 public void SetReadOnly ()
157                 {
158                         // TODO: anything else?
159                         IsReadOnly = true;
160                 }
161
162                 protected virtual IEnumerable <ResourceProperty> LoadPropertiesDeclaredOnThisType ()
163                 {
164                         throw new NotImplementedException ();
165                 }
166         }
167 }