public OrmIndexFields MergeChanges(OrmIndexFields other, MergeConflictAction mergeConflictAction) { OrmIndexFields mergedResult = new OrmIndexFields(); var defaultableFields = GetDefaultableFields(); var otherDefaultableFields = other.GetDefaultableFields(); var mergedKeyFields = defaultableFields.Item1.Merge(otherDefaultableFields.Item1, mergeConflictAction); var mergedKeyFieldsItems = mergedKeyFields.Value.Split(','); mergedResult.KeyFields = new TreeNodeDataCollection <StringTreeNode>(); foreach (string mergedKeyFieldsItem in mergedKeyFieldsItems) { mergedResult.KeyFields.Add(new StringTreeNode { DisplayValue = mergedKeyFieldsItem }); } var mergedIncludedFields = defaultableFields.Item2.Merge(otherDefaultableFields.Item2, mergeConflictAction); var mergedIncludedFieldsItems = mergedIncludedFields.Value.Split(','); mergedResult.IncludedFields = new TreeNodeDataCollection <StringTreeNode>(); foreach (string mergedIncludedFieldsItem in mergedIncludedFieldsItems) { mergedResult.IncludedFields.Add(new StringTreeNode { DisplayValue = mergedIncludedFieldsItem }); } return(mergedResult); }
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 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) { 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); }
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); }
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 OrmPropertyConstraints Merge(OrmPropertyConstraints otherConstraints, MergeConflictAction mergeConflictAction) { OrmPropertyConstraints merged = new OrmPropertyConstraints(); foreach (var constraint in this.AllConstraints) { PropertyConstrainType constrainType = constraint.ConstrainType; PropertyConstraint otherConstraint = otherConstraints[constrainType]; PropertyConstraint mergedConstraint = (PropertyConstraint)constraint.MergeChanges(otherConstraint, mergeConflictAction); merged.UpdateConstraint(mergedConstraint); } return(merged); }
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 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); }
protected override void InternalMergeChanges(ref PropertyConstraint mergedConstraint, PropertyConstraint otherConstraint, MergeConflictAction mergeConflictAction) { PropertyRegexConstraint other = (PropertyRegexConstraint)otherConstraint; PropertyRegexConstraint merged = (PropertyRegexConstraint)mergedConstraint; Defaultable <string> mergedPattern = this.GetPatternAsDefaultable().Merge(other.GetPatternAsDefaultable(), mergeConflictAction); merged.Pattern = mergedPattern.IsCustom() ? mergedPattern.Value : string.Empty; Defaultable <RegexOptions> mergedOptions = this.GetOptionsAsDefaultable().Merge(other.GetOptionsAsDefaultable(), mergeConflictAction); merged.Options = mergedOptions.IsCustom() ? mergedOptions.Value : RegexOptions.Compiled; }
public Defaultable Merge(Defaultable other, MergeConflictAction mergeConflictAction) { if (this.GetTypeOfValue() != other.GetTypeOfValue()) { throw new ArgumentException("Type of 'other' is not equal as current type!"); } Defaultable mergedResult = (Defaultable)this.Clone(); object mergedValue; string mergedValueType; if ((this.IsCustom() && other.IsCustom()) || (this.IsDefault() && other.IsDefault())) { if (mergeConflictAction == MergeConflictAction.TakeOther) { mergedValue = other.GetValue(); mergedValueType = other.ValueType; } else { mergedValue = this.GetValue(); mergedValueType = this.ValueType; } } else { if (this.IsCustom()) { mergedValue = this.GetValue(); mergedValueType = this.ValueType; } else // other.IsCustom() { mergedValue = other.GetValue(); mergedValueType = other.ValueType; } } mergedResult.SetValue(mergedValue); mergedResult.ValueType = mergedValueType; return(mergedResult); }
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); }
protected override void InternalMergeChanges(ref PropertyConstraint mergedConstraint, PropertyConstraint otherConstraint, MergeConflictAction mergeConflictAction) { PropertyRangeConstraint other = (PropertyRangeConstraint)otherConstraint; PropertyRangeConstraint merged = (PropertyRangeConstraint)mergedConstraint; Defaultable <ObjectValue> mergedMin = GetMinAsDefaultable().Merge(other.GetMinAsDefaultable(), mergeConflictAction); merged.Min = new ObjectValueInfo(); merged.Min.Enabled = mergedMin.IsCustom(); merged.Min.Value = mergedMin.Value; Defaultable <ObjectValue> mergedMax = GetMaxAsDefaultable().Merge(other.GetMaxAsDefaultable(), mergeConflictAction); merged.Max = new ObjectValueInfo(); merged.Max.Enabled = mergedMax.IsCustom(); merged.Max.Value = mergedMax.Value; }
private void TestDefaultableMerge <T>(T currentValue, T otherValue, MergeConflictAction mergeConflictAction) { Defaultable <T> current = new Defaultable <T>(); current.SetAsCustom(currentValue); Defaultable <T> other = new Defaultable <T>(); other.SetAsCustom(otherValue); Defaultable <T> merged = current.Merge(other, mergeConflictAction); string errorMessage = string.Format("Merging '{0}' values", currentValue.GetType().Name); if (mergeConflictAction == MergeConflictAction.TakeCurrent) { Assert.IsTrue(current.EqualsTo(merged), errorMessage); } else if (mergeConflictAction == MergeConflictAction.TakeOther) { Assert.IsTrue(other.EqualsTo(merged), errorMessage); } }
protected override ContractDescriptorBase InternalMergeChanges(ContractDescriptorBase contractDescriptorBase, MergeConflictAction mergeConflictAction) { return(contractDescriptorBase); }
protected abstract ContractDescriptorBase InternalMergeChanges(ContractDescriptorBase contractDescriptorBase, MergeConflictAction mergeConflictAction);
protected virtual void InternalMergeChanges(ref PropertyConstraint mergedConstraint, PropertyConstraint otherConstraint, MergeConflictAction mergeConflictAction) { }
public abstract IOrmAttribute MergeChanges(IOrmAttribute otherAttribute, MergeConflictAction mergeConflictAction);
public IOrmAttribute MergeChanges(IOrmAttribute otherAttribute, MergeConflictAction mergeConflictAction) { return ((ContractDescriptorBase) InternalMergeChanges(otherAttribute as ContractDescriptorBase, mergeConflictAction)); }