C# Class Castle.ActiveRecord.Framework.Internal.SemanticVerifierVisitor

Traverse the tree checking the semantics of the relation and association. The goal is to raise clear exceptions with tips of how to fix any error. It also tries to infer as much information from the class / attribute model as possible so it can complete the missing information without the user needing to specify it.
Inheritance: AbstractDepthFirstVisitor
Mostra file Open project: nats/castle-1.0.3-mono Class Usage Examples

Public Methods

Method Description
GetIndexTypeFromDictionary ( Type propertyType ) : Type

Gets the index type of a mapped dictionary.

GetMapTypeFromDictionary ( Type propertyType ) : Type

Gets the index type of a mapped dictionary.

SemanticVerifierVisitor ( ActiveRecordModelCollection arCollection ) : System

Initializes a new instance of the SemanticVerifierVisitor class.

VisitAny ( AnyModel model ) : void

Visits any.

VisitBelongsTo ( BelongsToModel model ) : void

Visits the belongs to.

Infer column name and type Verify that the property is virtual if the class was marked lazy.

VisitCompositePrimaryKey ( CompositeKeyModel model ) : void

Visits the composite primary key.

Validate that the composite key type is implementing GetHashCode() and Equals(), is mark serializable. Validate that the compose key is compose of two or more columns

VisitCompositeUserType ( CompositeUserTypeModel model ) : void

Visits the custom composite user type.

Apply any column prefixes specified

VisitField ( FieldModel model ) : void

Visits the field.

Infer column name and nullablity

VisitHasAndBelongsToMany ( HasAndBelongsToManyModel model ) : void

Visits the has and belongs to many.

Verify that a link table was specified Verify that a key was specified and that it is valid Verify that required information was specified

VisitHasMany ( HasManyModel model ) : void

Visits the has many.

Guess the type of the relation, if not specified explicitly Verify that the assoication is valid on [HasMany] Validate that required information is specified Infer the other side of the assoication and grab require data from it

VisitHasManyToAny ( HasManyToAnyModel model ) : void

Visit the has many to any

VisitKey ( KeyModel model ) : void

Visits the key.

Infer column name

VisitModel ( ActiveRecordModel model ) : void

Visits the model.

Check that the model: - Define only a discriminator or a join subclass, not both - Doesn't specify version/timestamp property on a joined subclass / discriminator subclass - Validate that the custom entity persister implements IEntityPersister - Validate the joined subclasses has a [JoinedKey] to map back to the parent table - Validate that the class has a PK

VisitNested ( Castle.ActiveRecord.Framework.Internal.NestedModel model ) : void

Visits the nested model

Infer the column name and applies and column prefixes specified

VisitOneToOne ( Castle.ActiveRecord.Framework.Internal.OneToOneModel model ) : void

Visits the one to one.

Infer the type on the other side

VisitPrimaryKey ( PrimaryKeyModel model ) : void

Visits the primary key.

Infer column name and the reverse property if using [OneToOne]

VisitProperty ( PropertyModel model ) : void

Visits the property.

Infer column name and whatever this propery can be null or not Also catch common mistake of try to use [Property] on an entity, instead of [BelongsTo]

VisitTimestamp ( TimestampModel model ) : void

Visits the timestamp.

Infer column name

VisitVersion ( VersionModel model ) : void

Visits the version.

Infer column name

Private Methods

Method Description
AssertHasValidKey ( ActiveRecordModel model ) : void
GuessRelation ( PropertyInfo property, RelationType type ) : RelationType
ObtainNullableTypeNameForCLRNullable ( Type type ) : String

Method Details

GetIndexTypeFromDictionary() public static method

Gets the index type of a mapped dictionary.
public static GetIndexTypeFromDictionary ( Type propertyType ) : Type
propertyType System.Type Type of the property.
return System.Type

GetMapTypeFromDictionary() public static method

Gets the index type of a mapped dictionary.
public static GetMapTypeFromDictionary ( Type propertyType ) : Type
propertyType System.Type Type of the property.
return System.Type

SemanticVerifierVisitor() public method

Initializes a new instance of the SemanticVerifierVisitor class.
public SemanticVerifierVisitor ( ActiveRecordModelCollection arCollection ) : System
arCollection ActiveRecordModelCollection The ar collection.
return System

VisitAny() public method

Visits any.
public VisitAny ( AnyModel model ) : void
model AnyModel The model.
return void

VisitBelongsTo() public method

Visits the belongs to.
Infer column name and type Verify that the property is virtual if the class was marked lazy.
public VisitBelongsTo ( BelongsToModel model ) : void
model BelongsToModel The model.
return void

VisitCompositePrimaryKey() public method

Visits the composite primary key.
Validate that the composite key type is implementing GetHashCode() and Equals(), is mark serializable. Validate that the compose key is compose of two or more columns
public VisitCompositePrimaryKey ( CompositeKeyModel model ) : void
model CompositeKeyModel The model.
return void

VisitCompositeUserType() public method

Visits the custom composite user type.
Apply any column prefixes specified
public VisitCompositeUserType ( CompositeUserTypeModel model ) : void
model CompositeUserTypeModel The model.
return void

VisitField() public method

Visits the field.
Infer column name and nullablity
public VisitField ( FieldModel model ) : void
model FieldModel The model.
return void

VisitHasAndBelongsToMany() public method

Visits the has and belongs to many.
Verify that a link table was specified Verify that a key was specified and that it is valid Verify that required information was specified
public VisitHasAndBelongsToMany ( HasAndBelongsToManyModel model ) : void
model HasAndBelongsToManyModel The model.
return void

VisitHasMany() public method

Visits the has many.
Guess the type of the relation, if not specified explicitly Verify that the assoication is valid on [HasMany] Validate that required information is specified Infer the other side of the assoication and grab require data from it
public VisitHasMany ( HasManyModel model ) : void
model HasManyModel The model.
return void

VisitHasManyToAny() public method

Visit the has many to any
public VisitHasManyToAny ( HasManyToAnyModel model ) : void
model HasManyToAnyModel The model.
return void

VisitKey() public method

Visits the key.
Infer column name
public VisitKey ( KeyModel model ) : void
model KeyModel The model.
return void

VisitModel() public method

Visits the model.
Check that the model: - Define only a discriminator or a join subclass, not both - Doesn't specify version/timestamp property on a joined subclass / discriminator subclass - Validate that the custom entity persister implements IEntityPersister - Validate the joined subclasses has a [JoinedKey] to map back to the parent table - Validate that the class has a PK
public VisitModel ( ActiveRecordModel model ) : void
model ActiveRecordModel The model.
return void

VisitNested() public method

Visits the nested model
Infer the column name and applies and column prefixes specified
public VisitNested ( Castle.ActiveRecord.Framework.Internal.NestedModel model ) : void
model Castle.ActiveRecord.Framework.Internal.NestedModel The model.
return void

VisitOneToOne() public method

Visits the one to one.
Infer the type on the other side
public VisitOneToOne ( Castle.ActiveRecord.Framework.Internal.OneToOneModel model ) : void
model Castle.ActiveRecord.Framework.Internal.OneToOneModel The model.
return void

VisitPrimaryKey() public method

Visits the primary key.
Infer column name and the reverse property if using [OneToOne]
public VisitPrimaryKey ( PrimaryKeyModel model ) : void
model PrimaryKeyModel The model.
return void

VisitProperty() public method

Visits the property.
Infer column name and whatever this propery can be null or not Also catch common mistake of try to use [Property] on an entity, instead of [BelongsTo]
public VisitProperty ( PropertyModel model ) : void
model PropertyModel The model.
return void

VisitTimestamp() public method

Visits the timestamp.
Infer column name
public VisitTimestamp ( TimestampModel model ) : void
model TimestampModel The model.
return void

VisitVersion() public method

Visits the version.
Infer column name
public VisitVersion ( VersionModel model ) : void
model VersionModel The model.
return void