1 #region MIT license 2 // 3 // MIT license 4 // 5 // Copyright (c) 2007-2008 Jiri Moudry 6 // 7 // Permission is hereby granted, free of charge, to any person obtaining a copy 8 // of this software and associated documentation files (the "Software"), to deal 9 // in the Software without restriction, including without limitation the rights 10 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 // copies of the Software, and to permit persons to whom the Software is 12 // furnished to do so, subject to the following conditions: 13 // 14 // The above copyright notice and this permission notice shall be included in 15 // all copies or substantial portions of the Software. 16 // 17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 // THE SOFTWARE. 24 // 25 #endregion 26 27 using System; 28 using System.Data.Linq.Mapping; 29 using System.Reflection; 30 using DbLinq.Util; 31 32 namespace DbLinq.Data.Linq.Mapping 33 { 34 internal abstract class AttributedAbstractMetaDataMember : MetaDataMember 35 { AttributedAbstractMetaDataMember(MemberInfo member, MetaType declaringType, DataAttribute attribute)36 protected AttributedAbstractMetaDataMember(MemberInfo member, MetaType declaringType, DataAttribute attribute) 37 { 38 memberInfo = member; 39 memberAccessor = LambdaMetaAccessor.Create(member, declaringType.Type); 40 this.declaringType = declaringType; 41 42 if(attribute.Storage != null) 43 { 44 storageMember = member.DeclaringType.GetSingleMember(attribute.Storage); 45 if (storageMember != null) 46 storageAccessor = LambdaMetaAccessor.Create(storageMember, declaringType.Type); 47 } 48 } 49 50 protected MemberInfo memberInfo; 51 protected MetaType declaringType; 52 protected MetaAccessor memberAccessor; 53 protected MetaAccessor storageAccessor; 54 55 public override MetaType DeclaringType 56 { 57 get { return declaringType; } 58 } 59 60 public override MetaAccessor DeferredSourceAccessor 61 { 62 get { throw new NotImplementedException(); } 63 } 64 65 public override MetaAccessor DeferredValueAccessor 66 { 67 get { throw new NotImplementedException(); } 68 } 69 70 public override bool IsDeferred 71 { 72 get { return false; } 73 } 74 75 public override bool IsPersistent 76 { 77 get { return true; } 78 } 79 80 public override MethodInfo LoadMethod 81 { 82 get { throw new NotImplementedException(); } 83 } 84 85 public override MemberInfo Member 86 { 87 get { return memberInfo; } 88 } 89 90 public override MetaAccessor MemberAccessor 91 { 92 get { return memberAccessor; } 93 } 94 95 public override string Name 96 { 97 get { return memberInfo.Name; } 98 } 99 100 public override int Ordinal 101 { 102 get { throw new NotImplementedException(); } 103 } 104 105 public override MetaAccessor StorageAccessor 106 { 107 get { return storageAccessor; } 108 } 109 110 public override Type Type 111 { 112 get { return memberInfo.GetMemberType(); } 113 } 114 115 public override UpdateCheck UpdateCheck 116 { 117 get { throw new NotImplementedException(); } 118 } 119 IsDeclaredBy(MetaType type)120 public override bool IsDeclaredBy(MetaType type) 121 { 122 return type == declaringType; 123 } 124 125 protected MemberInfo storageMember; 126 public override MemberInfo StorageMember 127 { 128 get { return storageMember; } 129 } 130 131 } 132 }