NClass.Core.GeneralizationRelationship.OnAttaching C# (CSharp) Method

OnAttaching() protected method

/// Cannot finalize relationship. ///
protected OnAttaching ( EventArgs e ) : void
e System.EventArgs
return void
		protected override void OnAttaching(EventArgs e)
		{
			base.OnAttaching(e);

			if (!DerivedType.IsAllowedChild)
				throw new RelationshipException(Strings.ErrorNotAllowedChild);
			if (!BaseType.IsAllowedParent)
				throw new RelationshipException(Strings.ErrorNotAllowedParent);
			if (First is SingleInharitanceType && ((SingleInharitanceType) First).HasExplicitBase)
				throw new RelationshipException(Strings.ErrorMultipleBases);
			if (First is SingleInharitanceType ^ Second is SingleInharitanceType ||
				First is InterfaceType ^ Second is InterfaceType)
				throw new RelationshipException(Strings.ErrorInvalidBaseType);

			if (First is SingleInharitanceType && Second is SingleInharitanceType) {
				((SingleInharitanceType) First).Base = (SingleInharitanceType) Second;
			}
			else if (First is InterfaceType && Second is InterfaceType) {
				((InterfaceType) First).AddBase((InterfaceType) Second);
			}
		}