public override IOrmAttribute MergeChanges(IOrmAttribute otherAttribute, MergeConflictAction mergeConflictAction) { AssociationInfo other = (AssociationInfo)otherAttribute; AssociationInfo mergedResult = new AssociationInfo(); mergedResult.PairTo = this.PairTo.Merge(other.PairTo, mergeConflictAction); var onOwnerRemove = GetDefaultableOnRemoveAction(true); var mergedOnOwnerRemove = onOwnerRemove.Merge(other.GetDefaultableOnRemoveAction(true), mergeConflictAction); mergedResult.OnOwnerRemove = mergedOnOwnerRemove.IsDefault() ? AssociationOnRemoveAction.Default : mergedOnOwnerRemove.Value; var onTargetRemove = GetDefaultableOnRemoveAction(false); var mergedOnTargetRemove = onTargetRemove.Merge(other.GetDefaultableOnRemoveAction(false), mergeConflictAction); mergedResult.OnTargetRemove = mergedOnTargetRemove.IsDefault() ? AssociationOnRemoveAction.Default : mergedOnTargetRemove.Value; var mergedUseAssociationAttribute = this.GetDefaultableUseAssociationAttribute().Merge(other.GetDefaultableUseAssociationAttribute(), mergeConflictAction); mergedResult.UseAssociationAttribute = mergedUseAssociationAttribute.Value; return(mergedResult); }
private void TestMergeChangesForOrmAttribute <T>(T sourceAttribute, T targetAttribute) where T : IOrmAttribute { var targetGroupItems = targetAttribute.GetAttributeGroupItems(AttributeGroupsListMode.All); foreach (var attributeGroupItem in targetGroupItems) { attributeGroupItem.SetAsDefault(); } bool toXml = false; string xmlSource; string xmlTarget; if (toXml) { xmlSource = sourceAttribute.SerializeToString(); xmlTarget = targetAttribute.SerializeToString(); } IOrmAttribute mergedAttribute = sourceAttribute.MergeChanges(targetAttribute, MergeConflictAction.TakeOther); foreach (var attributeGroupsListMode in EnumType <AttributeGroupsListMode> .Values) { var sourceGroupItems = sourceAttribute.GetAttributeGroupItems(attributeGroupsListMode); var mergedGroupItems = mergedAttribute.GetAttributeGroupItems(attributeGroupsListMode); for (int i = 0; i < mergedGroupItems.Count; i++) { var mergedGroupItem = mergedGroupItems[i]; var sourceGroupItem = sourceGroupItems[i]; Assert.IsTrue(mergedGroupItem.EqualsTo(sourceGroupItem)); } } }
public IOrmAttribute MergeChanges(IOrmAttribute otherAttribute, MergeConflictAction mergeConflictAction) { OrmHierarchyRootAttribute other = (OrmHierarchyRootAttribute)otherAttribute; OrmHierarchyRootAttribute mergedResult = new OrmHierarchyRootAttribute(); bool enabled = this.Enabled; //if (!other.Enabled && mergeConflictAction == MergeConflictAction.TakeOther) if (other.Enabled && !enabled && mergeConflictAction == MergeConflictAction.TakeOther) { enabled = other.Enabled; } mergedResult.Enabled = enabled; var mergedInheritanceSchema = this.GetDefInheritanceSchema().Merge(other.GetDefInheritanceSchema(), mergeConflictAction); mergedResult.InheritanceSchema = mergedInheritanceSchema.Value; mergedResult.IncludeTypeId = this.IncludeTypeId.Merge(other.IncludeTypeId, mergeConflictAction); mergedResult.MappingName = this.MappingName.Merge(other.MappingName, mergeConflictAction); return(mergedResult); }
public IOrmAttribute MergeChanges(IOrmAttribute otherAttribute, MergeConflictAction mergeConflictAction) { OrmKeyGeneratorAttribute other = (OrmKeyGeneratorAttribute)otherAttribute; OrmKeyGeneratorAttribute mergedResult = new OrmKeyGeneratorAttribute(); bool enabled = this.Enabled; //if (!other.Enabled && mergeConflictAction == MergeConflictAction.TakeOther) if (other.Enabled && !enabled && mergeConflictAction == MergeConflictAction.TakeOther) { enabled = other.Enabled; } mergedResult.Enabled = enabled; var defaultableItems = GetDefaultableItems(); var otherDefaultableItems = other.GetDefaultableItems(); var mergedKind = defaultableItems.Item1.Merge(otherDefaultableItems.Item1, mergeConflictAction); mergedResult.Kind = mergedKind.IsDefault() ? KeyGeneratorKind.Default : mergedKind.Value; var mergedName = defaultableItems.Item2.Merge(otherDefaultableItems.Item2, mergeConflictAction); mergedResult.Name = mergedName.Value; var mergedType = defaultableItems.Item3.Merge(otherDefaultableItems.Item3, mergeConflictAction); mergedResult.Type = mergedType.Value; return(mergedResult); }
private void PreparePropertiesTypeAttributes() { mappingPropertiesTypeAttributes.Clear(); foreach (var mapping in mappingProperties) { IPropertyBase sourceProperty = mapping.Key; IPropertyBase inheritedProperty = mapping.Value; IOrmAttribute[] typeAttributes = null; if (sourceProperty == inheritedProperty) { typeAttributes = sourceProperty.TypeAttributes; } else { List <IOrmAttribute> mergedTypeAttributes = new List <IOrmAttribute>(); foreach (var typeAttribute in sourceProperty.TypeAttributes) { Type typeOftypeAttribute = typeAttribute.GetType(); IOrmAttribute inheritedTypeAttribute = inheritedProperty.TypeAttributes.Single(item => item.GetType() == typeOftypeAttribute); IOrmAttribute mergedTypeAttribute = typeAttribute.MergeChanges(inheritedTypeAttribute, MergeConflictAction.TakeCurrent); mergedTypeAttributes.Add(mergedTypeAttribute); } typeAttributes = mergedTypeAttributes.ToArray(); } mappingPropertiesTypeAttributes.Add(sourceProperty, typeAttributes); } }
protected override void Prefilter(IOrmAttribute attribute, Dictionary <string, Defaultable> attributeGroupItems) { switch (propertyOwner.PropertyKind) { case PropertyKind.Scalar: { IScalarProperty scalarProperty = (IScalarProperty)propertyOwner; InternalPrefilter(scalarProperty, attribute, attributeGroupItems); break; } case PropertyKind.Structure: { IStructureProperty structureProperty = (IStructureProperty)propertyOwner; InternalPrefilter(structureProperty, attribute, attributeGroupItems); break; } case PropertyKind.Navigation: { INavigationProperty navigationProperty = (INavigationProperty)propertyOwner; InternalPrefilter(navigationProperty, attribute, attributeGroupItems); break; } } }
public override IOrmAttribute MergeChanges(IOrmAttribute otherAttribute, MergeConflictAction mergeConflictAction) { OrmFieldAttribute other = (OrmFieldAttribute)otherAttribute; OrmFieldAttribute mergedResult = new OrmFieldAttribute(); Defaultable <ObjectValue> defaultValue = this.GetDefaultValueAsDefaultable().Merge(other.GetDefaultValueAsDefaultable(), mergeConflictAction); mergedResult.DefaultValue = new ObjectValueInfo(); mergedResult.DefaultValue.Enabled = defaultValue.IsCustom(); mergedResult.DefaultValue.Value = defaultValue.Value; mergedResult.Indexed = this.Indexed.Merge(other.Indexed, mergeConflictAction); mergedResult.Nullable = this.Nullable.Merge(other.Nullable, mergeConflictAction); mergedResult.Precision = this.Precision.Merge(other.Precision, mergeConflictAction); mergedResult.Scale = this.Scale.Merge(other.Scale, mergeConflictAction); mergedResult.LazyLoad = this.LazyLoad.Merge(other.LazyLoad, mergeConflictAction); mergedResult.Length = this.Length.Merge(other.Length, mergeConflictAction); mergedResult.NullableOnUpgrade = this.NullableOnUpgrade.Merge(other.NullableOnUpgrade, mergeConflictAction); mergedResult.MappingName = this.MappingName.Merge(other.MappingName, mergeConflictAction); mergedResult.Version = this.Version.Merge(other.Version, mergeConflictAction); mergedResult.TypeDiscriminator = this.TypeDiscriminator.Merge(other.TypeDiscriminator, mergeConflictAction); //mergedResult.Constraints = this.Constraints.Merge(other.Constraints, mergeConflictAction); return(mergedResult); }
public IOrmAttribute MergeChanges(IOrmAttribute otherAttribute, MergeConflictAction mergeConflictAction) { OrmTypeDiscriminatorValueAttribute other = (OrmTypeDiscriminatorValueAttribute)otherAttribute; OrmTypeDiscriminatorValueAttribute mergedResult = new OrmTypeDiscriminatorValueAttribute(); bool enabled = this.Enabled; //if (!other.Enabled && mergeConflictAction == MergeConflictAction.TakeOther) if (other.Enabled && !enabled && mergeConflictAction == MergeConflictAction.TakeOther) { enabled = other.Enabled; } mergedResult.Enabled = enabled; Defaultable <bool> mergedDefault = GetDefaultAsDefaultable().Merge(other.GetDefaultAsDefaultable(), mergeConflictAction); mergedResult.Default = mergedDefault.Value; ObjectValue value = this.Value; if (!this.Value.EqualsTo(other.Value) && other.Enabled && mergeConflictAction == MergeConflictAction.TakeOther) { value = other.Value; } mergedResult.Value = value; return(mergedResult); }
public OrmAttributeGroup[] GetAttributeGroups(IOrmAttribute attribute) { if (attributeItems.ContainsKey(attribute)) { return(attributeItems[attribute].AttributeGroups); } return(new OrmAttributeGroup[0]); }
private void InternalPrefilter(INavigationProperty property, IOrmAttribute attribute, Dictionary <string, Defaultable> attributeGroupItems) { OrmFieldAttribute fieldAttribute = attribute as OrmFieldAttribute; if (fieldAttribute != null) { Prefilter(property, fieldAttribute, attributeGroupItems); } }
public IOrmAttribute MergeChanges(IOrmAttribute otherAttribute, MergeConflictAction mergeConflictAction) { PropertyConstraint mergedConstraint = CreateInstance(this.ConstrainType); PropertyConstraint other = (PropertyConstraint)otherAttribute; string mergedValueType; PropertyConstrainMode mergedMode; string mergedErrorMessage; if ((this.Used && other.Used) || (!this.Used && !other.Used)) { if (mergeConflictAction == MergeConflictAction.TakeOther) { mergedValueType = other.ValueType; mergedMode = other.Mode; mergedErrorMessage = other.ErrorMessage; } else { mergedValueType = this.ValueType; mergedMode = this.Mode; mergedErrorMessage = this.ErrorMessage; } } else { if (this.Used) { mergedValueType = this.ValueType; mergedMode = this.Mode; mergedErrorMessage = this.ErrorMessage; } else // other.IsCustom() { mergedValueType = other.ValueType; mergedMode = other.Mode; mergedErrorMessage = other.ErrorMessage; } } mergedConstraint.Mode = mergedMode; mergedConstraint.ErrorMessage = mergedErrorMessage; mergedConstraint.ValueType = mergedValueType; if (mergedConstraint.Used) { InternalMergeChanges(ref mergedConstraint, other, mergeConflictAction); } return(mergedConstraint); }
public Dictionary <string, Defaultable> GetAttributeGroupItems(IOrmAttribute attribute, OrmAttributeGroup attributeGroup) { if (attributeItems.ContainsKey(attribute)) { var attributeGroupItems = attributeItems[attribute].AttributeGroupItems; if (attributeGroupItems.ContainsGroup(attributeGroup)) { return(attributeGroupItems[attributeGroup]); } } return(new Dictionary <string, Defaultable>()); }
public IOrmAttribute MergeChanges(IOrmAttribute otherAttribute, MergeConflictAction mergeConflictAction) { EntityIndex other = (EntityIndex)otherAttribute; EntityIndex mergedResult = new EntityIndex((Store)null); mergedResult.Unique = this.Unique.Merge(other.Unique, mergeConflictAction); mergedResult.FillFactor = this.FillFactor.Merge(other.FillFactor, mergeConflictAction); mergedResult.IndexName = this.IndexName.Merge(other.IndexName, mergeConflictAction); mergedResult.Fields = this.Fields.MergeChanges(other.Fields, mergeConflictAction); return(mergedResult); }
private void InternalPrefilter(IScalarProperty property, IOrmAttribute attribute, Dictionary <string, Defaultable> attributeGroupItems) { OrmFieldAttribute fieldAttribute = attribute as OrmFieldAttribute; if (fieldAttribute != null) { Prefilter(property, fieldAttribute, attributeGroupItems); } IAssociationInfo associationInfo = attribute as IAssociationInfo; if (associationInfo != null) { // No prefiltering at now... } }
protected void Build() { foreach (var pair in attributeItems) { IOrmAttribute attribute = pair.Key; AttrData attributeData = pair.Value; foreach (var attributeGroup in attributeData.AttributeGroups) { Dictionary <string, Defaultable> attributeGroupItems = attribute.GetAttributeGroupItems(attributeGroup); Prefilter(attribute, attributeGroupItems); attributeData.AttributeGroupItems[attributeGroup] = attributeGroupItems; } } }
private void TestMergeChangesForAssociationInfo() { var sourceAttribute = CreateAssociationInfo(TestAttributeValuesType.Values1); var targetAttribute = CreateAssociationInfo(TestAttributeValuesType.Values2); targetAttribute.OnTargetRemove = AssociationOnRemoveAction.Default; IOrmAttribute mergedAttribute = sourceAttribute.MergeChanges(targetAttribute, MergeConflictAction.TakeOther); string expectedMergedXml = "<end multiplicity=\"ZeroOrOne\" onOwnerRemove=\"Deny\" onTargetRemove=\"Deny\"><pairTo valueType=\"Custom\"><value>RevertedItems</value></pairTo></end>"; string mergedAttributeXml = mergedAttribute.SerializeToString(); Action testMergedXml = () => Assert.IsTrue(Util.StringEqual(expectedMergedXml, mergedAttributeXml, true), "Merged xml and expected xml is not equal!"); testMergedXml(); }
public IOrmAttribute MergeChanges(IOrmAttribute otherAttribute, MergeConflictAction mergeConflictAction) { OrmKeyAttribute other = (OrmKeyAttribute)otherAttribute; OrmKeyAttribute mergedResult = new OrmKeyAttribute(); bool enabled = this.Enabled; //if (!other.Enabled && mergeConflictAction == MergeConflictAction.TakeOther) if (other.Enabled && !enabled && mergeConflictAction == MergeConflictAction.TakeOther) { enabled = other.Enabled; } mergedResult.Enabled = enabled; mergedResult.Direction = this.Direction.Merge(other.Direction, mergeConflictAction); mergedResult.Position = this.Position.Merge(other.Position, mergeConflictAction); return(mergedResult); }
public IOrmAttribute MergeChanges(IOrmAttribute otherAttribute, MergeConflictAction mergeConflictAction) { return ((ContractDescriptorBase) InternalMergeChanges(otherAttribute as ContractDescriptorBase, mergeConflictAction)); }
protected PropertyBase(string name) { Name = name; TypeAttributes = new IOrmAttribute[0]; }
protected PersistentType(ModelRoot modelRoot, string name) { modelRoot.AddPersistentType(this); Name = name; TypeAttributes = new IOrmAttribute[0]; }
public string[] CreateTypeAttributesCommon(IOrmAttribute attribute) { return(CreateTypeAttributesCommon(new[] { attribute })); }
public abstract IOrmAttribute MergeChanges(IOrmAttribute otherAttribute, MergeConflictAction mergeConflictAction);
protected virtual void Prefilter(IOrmAttribute attribute, Dictionary <string, Defaultable> attributeGroupItems) { }