1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle
.ActiveRecord
.Framework
.Internal
18 using System
.Collections
.Generic
;
19 using System
.Reflection
;
21 using Castle
.ActiveRecord
;
24 /// This model represent a <many-to-any/> polymorphic association
27 public class HasManyToAnyModel
: IVisitable
29 private readonly PropertyInfo prop
;
30 private readonly HasManyToAnyAttribute hasManyToAnyAtt
;
31 private IList
<Any
.MetaValueAttribute
> metaValues
;
33 /// Initializes a new instance of the <see cref="HasManyToAnyModel"/> class.
35 /// <param name="prop">The prop.</param>
36 /// <param name="hasManyToAnyAtt">The has many to any att.</param>
37 public HasManyToAnyModel(PropertyInfo prop
, HasManyToAnyAttribute hasManyToAnyAtt
)
40 this.hasManyToAnyAtt
= hasManyToAnyAtt
;
41 metaValues
= new List
<Any
.MetaValueAttribute
>();
45 /// Gets the property.
47 /// <value>The property.</value>
48 public PropertyInfo Property
54 /// Gets the has many to any attribute
56 /// <value>The has many to any att.</value>
57 public HasManyToAnyAttribute HasManyToAnyAtt
59 get { return hasManyToAnyAtt; }
63 /// Gets the configuration.
65 /// <value>The configuration.</value>
66 public Config Configuration
68 get { return new Config(this); }
72 /// Gets or sets the meta values.
74 /// <value>The meta values.</value>
75 public IList
<Any
.MetaValueAttribute
> MetaValues
77 get { return metaValues; }
78 set { metaValues = value; }
81 #region IVisitable Members
84 /// Accepts the specified visitor and call the relevant IVisitor.Visit***() method
86 /// <param name="visitor">The visitor.</param>
87 public void Accept(IVisitor visitor
)
89 visitor
.VisitHasManyToAny(this);
95 /// I need this class to pass special configuration for the many-to-any
97 public class Config
: IVisitable
99 HasManyToAnyModel parent
;
102 /// Gets or sets the parent model
104 /// <value>The parent.</value>
105 public HasManyToAnyModel Parent
107 get { return parent; }
108 set { parent = value; }
112 /// Initializes a new instance of the <see cref="Config"/> class.
114 /// <param name="parent">The parent.</param>
115 internal Config(HasManyToAnyModel parent
)
117 this.parent
= parent
;
120 #region IVisitable Members
123 /// Accepts the specified visitor and call the relevant IVisitor.Visit***() method
125 /// <param name="visitor">The visitor.</param>
126 public void Accept(IVisitor visitor
)
128 visitor
.VisitHasManyToAnyConfig(this);