public SerializedComponent(SerializedComponent other) { component = other.component; typeFullName = other.component.GetType().AssemblyQualifiedName; zuid = other.zuid; persistenceType = other.persistenceType; }
public SerializedComponent(Component component, string zuid, PersistentType persistenceType) { this.component = component; typeFullName = component.GetType().AssemblyQualifiedName; this.zuid = zuid; this.persistenceType = persistenceType; }
internal static ValidationResult Validate(NavigationPropertyHasTypedEntitySet link, bool workWithTransaction) { ValidationResult result = new ValidationResult(); if (link != null && (!workWithTransaction || !link.CurrentTransactionIsSerializing())) { TypedEntitySet targetTypedEntitySet = link.TypedEntitySet; Interface targetItemTypeOfEntitySet = targetTypedEntitySet.ItemType; result.IsValid = targetItemTypeOfEntitySet != null; if (!result.IsValid) { result.ErrorMessage = string.Format(ERROR_MISSING_ITEM_TYPE, targetTypedEntitySet.Name); result.ErrorCode = CODE_TYPED_ENTITYSET_ITEM_TYPE; result.ValidationElements = new[] { targetTypedEntitySet }; } if (result.IsValid) { NavigationProperty sourceNavigationProperty = link.OwnerNavigationProperty; PersistentType targetPersistentType = sourceNavigationProperty.PersistentTypeHasAssociations.TargetPersistentType; result.IsValid = targetItemTypeOfEntitySet == targetPersistentType; if (!result.IsValid && targetItemTypeOfEntitySet.TypeKind == PersistentTypeKind.Interface && targetPersistentType is Interface) { Interface targetInterface = (Interface)targetPersistentType; result.IsValid = targetInterface.InheritInterface(targetItemTypeOfEntitySet); } if (!result.IsValid) { result.ValidationElements = new[] { targetItemTypeOfEntitySet }; result.ErrorCode = CODE_TYPED_ENTITYSET_ITEM_TYPE; result.ErrorMessage = string.Format(ERROR_INCOMPATIBLE_ITEM_TYPE, targetTypedEntitySet.Name, targetItemTypeOfEntitySet.Name, targetPersistentType.Name); } } if (!result.IsValid && workWithTransaction) { link.RollbackCurrentTransaction(result.ErrorMessage); } } return(result); }
public void UpdateOwner(PersistentType owner) { this.Owner = owner; }
internal static ValidationResult Validate(EntityBaseHasBaseType link, bool workWithTransaction) { ValidationResult result = new ValidationResult(); if (link != null && (!workWithTransaction || !link.CurrentTransactionIsSerializing())) { EntityBase sourcePersistentType = link.SourceEntityBase; PersistentType targetPersistentType = link.TargetEntityBase; result.IsValid = !sourcePersistentType.Id.Equals(targetPersistentType.Id); if (result.IsValid) { if (targetPersistentType is EntityBase) { EntityBase targetEntityBase = (EntityBase)targetPersistentType; result.IsValid = targetEntityBase.BaseType == null || !targetEntityBase.BaseType.Id.Equals(sourcePersistentType.Id); if (!result.IsValid) { result.ErrorMessage = string.Format(ERROR_CIRCULAR_REFERENCE, targetPersistentType.Name, sourcePersistentType.Name); result.ErrorCode = CODE_BASE_TYPE; result.ValidationElements = new[] { targetEntityBase }; } else { result.IsValid = targetEntityBase.InheritanceModifier != InheritanceModifiers.Sealed; if (!result.IsValid) { result.ErrorMessage = string.Format(ERROR_BASE_TYPE_IS_SEALED, targetPersistentType.Name, sourcePersistentType.Name); result.ErrorCode = CODE_BASE_TYPE; result.ValidationElements = new[] { targetEntityBase }; } else { if (sourcePersistentType.Access == AccessModifier.Public && targetPersistentType.Access == AccessModifier.Internal) { result.IsValid = false; result.ErrorCode = CODE_INVALID_INHERITANCE; result.ValidationElements = new[] { targetPersistentType }; result.ErrorMessage = string.Format(ERROR_INCOMPATIBLE_ACCESS_MODIFIERS, sourcePersistentType.Name, targetPersistentType.Name); } else { IEnumerable <EntityBase> ancestors; if (sourcePersistentType.GetAncestors(out ancestors)) { result.IsValid = false; result.ErrorCode = CODE_INVALID_INHERITANCE; result.ValidationElements = ancestors.ToArray(); result.ErrorMessage = string.Format(ERROR_LOOP_IN_INHERITANCE, sourcePersistentType.Name); } else { if (sourcePersistentType is Entity) { result.IsValid = targetPersistentType.TypeKind != PersistentTypeKind.Structure; if (!result.IsValid) { result.ErrorMessage = ERROR_BASE_TYPE_CANNOT_BE_STRUCTURE; result.ErrorCode = CODE_BASE_TYPE; result.ValidationElements = new[] { targetEntityBase }; } } else // sourcePersistentType is Structure { result.IsValid = (targetPersistentType is Structure); if (!result.IsValid) { result.ErrorMessage = ERROR_BASE_TYPE_CANNOT_BE_ENTITY_OR_INTERFACE; result.ErrorCode = CODE_BASE_TYPE; result.ValidationElements = new[] { targetEntityBase }; } } } } } } } } else { result.ErrorMessage = ERROR_BASE_TYPE_CANNOT_BE_ITSELF; result.ErrorCode = CODE_BASE_TYPE; result.ValidationElements = new[] { sourcePersistentType }; } if (!result.IsValid && workWithTransaction) { link.RollbackCurrentTransaction(result.ErrorMessage); } } return(result); }