private Tuple <Defaultable <KeyGeneratorKind>, Defaultable <string>, Defaultable <string> > GetDefaultableItems()
        {
            Defaultable <KeyGeneratorKind> defKind = new Defaultable <KeyGeneratorKind>();

            if (this.Kind != KeyGeneratorKind.Default)
            {
                defKind.SetAsCustom(this.Kind);
            }

            Defaultable <string> defName = new Defaultable <string>();

            if (!string.IsNullOrEmpty(this.Name))
            {
                defName.SetAsCustom(this.Name);
            }

            Defaultable <string> defType = new Defaultable <string>();

            if (!string.IsNullOrEmpty(this.Type))
            {
                defType.SetAsCustom(this.Type);
            }

            return(new Tuple <Defaultable <KeyGeneratorKind>, Defaultable <string>, Defaultable <string> >(defKind, defName,
                                                                                                           defType));
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        public object CloneFromPropertyValues(IDictionary propertyValues)
        {
            Defaultable cloned = (Defaultable)this.Clone();

            cloned.AssignFromPropertyValues(propertyValues);
            return(cloned);
        }
Beispiel #5
0
        private Defaultable <bool> GetDefaultableUseAssociationAttribute()
        {
            Defaultable <bool> defaultable = new Defaultable <bool>();

            defaultable.SetAsCustom(this.UseAssociationAttribute);
            return(defaultable);
        }
Beispiel #6
0
        public void DeserializeFromXml(XmlReader reader, string propertyName)
        {
            XmlProxy xmlRoot = XmlProxySerializer.Instance.Deserialize(reader);

            if (xmlRoot.ElementName == propertyName)
            {
                string           strMultiplicity = xmlRoot.GetAttr("multiplicity");
                MultiplicityKind multiplicityKind;
                if (Enum.TryParse(strMultiplicity, true, out multiplicityKind))
                {
                    this.multiplicity = multiplicityKind;
                }

                string strOnOwnerRemove = xmlRoot.GetAttr("onOwnerRemove");
                AssociationOnRemoveAction onOwnerRemove;
                if (Enum.TryParse(strOnOwnerRemove, true, out onOwnerRemove))
                {
                    this.OnOwnerRemove = onOwnerRemove;
                }

                string strOnTargetRemove = xmlRoot.GetAttr("onTargetRemove");
                AssociationOnRemoveAction onTargetRemove;
                if (Enum.TryParse(strOnTargetRemove, true, out onTargetRemove))
                {
                    this.OnTargetRemove = onTargetRemove;
                }

                this.UseAssociationAttribute = xmlRoot.GetAttr("useAssociationAttribute", true);

                XmlProxy xmlPairTo = xmlRoot["pairTo"];
                this.PairTo = new Defaultable <string>();
                this.PairTo.DeserializeFromXml(xmlPairTo);
            }
        }
Beispiel #7
0
 protected override void InternalAssignFromPropertyValues(IDictionary propertyValues)
 {
     base.InternalAssignFromPropertyValues(propertyValues);
     this.EmitDefaultValue = (Defaultable <bool>)propertyValues["EmitDefaultValue"];
     this.IsRequired       = (Defaultable <bool>)propertyValues["IsRequired"];
     this.Order            = (Defaultable <int>)propertyValues["Order"];
 }
Beispiel #8
0
        public void FillAttributeGroupItems(/*OrmAttributeGroup @group,*/ Dictionary <string, Defaultable> result)
        {
            string keyFields = string.Join(",",
                                           KeyFields.Select(
                                               node =>
                                               string.Format("{0}{1}", node.DisplayValue,
                                                             node.IconIndex == TreeNodeProxy.ICON_INDEX_SORT_DESC ? ":DESC" : string.Empty)));

            Defaultable <string[]> defKeyFields = new Defaultable <string[]>();

            defKeyFields.SetAsCustom(keyFields.Split(','));
            result.Add(ATTRIBUTE_GROUP_ITEM_KEY_FIELDS, defKeyFields);

            string includedFields = string.Join(",", IncludedFields.Select(node => node.DisplayValue));
            Defaultable <string[]> defIncludedFields = new Defaultable <string[]>();

            if (string.IsNullOrEmpty(includedFields))
            {
                defIncludedFields.SetAsDefault();
            }
            else
            {
                defIncludedFields.SetAsCustom(includedFields.Split(','));
            }
            result.Add(ATTRIBUTE_GROUP_ITEM_INCLUDED_FIELDS, defIncludedFields);
        }
Beispiel #9
0
 public OrmAssociationEnd()
 {
     this.OnOwnerRemove           = AssociationOnRemoveAction.Default;
     this.OnTargetRemove          = AssociationOnRemoveAction.Default;
     this.UseAssociationAttribute = true;
     this.pairTo = new Defaultable <string>();
     this.pairTo.IsDefault();
 }
Beispiel #10
0
 public DataMemberDescriptor()
 {
     this.EmitDefaultValue = new Defaultable <bool>();
     this.EmitDefaultValue.SetAsDefault();
     this.IsRequired = new Defaultable <bool>();
     this.IsRequired.SetAsDefault();
     this.Order = new Defaultable <int>();
     this.Order.SetAsDefault();
 }
Beispiel #11
0
        private Defaultable <ObjectValue> GetDefaultValueAsDefaultable()
        {
            Defaultable <ObjectValue> defValue = new Defaultable <ObjectValue>();

            if (this.DefaultValue.Enabled)
            {
                defValue.SetAsCustom(this.DefaultValue.Value);
            }
            return(defValue);
        }
Beispiel #12
0
        private Tuple <Defaultable <string>, Defaultable <string> > GetDefaultableFields()
        {
            Dictionary <string, Defaultable> fields = new Dictionary <string, Defaultable>();

            FillAttributeGroupItems(/*OrmAttributeGroup.Empty, */ fields);
            Defaultable <string> keyFields      = (Defaultable <string>)fields["KeyFields"];
            Defaultable <string> includedFields = (Defaultable <string>)fields["IncludedFields"];

            return(new Tuple <Defaultable <string>, Defaultable <string> >(keyFields, includedFields));
        }
Beispiel #13
0
        private Defaultable <bool> GetDefaultAsDefaultable()
        {
            Defaultable <bool> defaultable = new Defaultable <bool>();

            if (this.Enabled)
            {
                defaultable.SetAsCustom(this.Default);
            }
            return(defaultable);
        }
Beispiel #14
0
        protected override void InternalAssignFromPropertyValues(IDictionary propertyValues)
        {
            Defaultable <int> propertyValue = (Defaultable <int>)propertyValues[ATTRIBUTE_GROUP_ITEM_POSITION];

            this.Position = (Defaultable <int>)propertyValue.Clone();

            Defaultable <KeyDirection> keyDirection = (Defaultable <KeyDirection>)propertyValues[ATTRIBUTE_GROUP_ITEM_DIRECTION];

            this.Direction = (Defaultable <KeyDirection>)keyDirection.Clone();
        }
Beispiel #15
0
        internal Defaultable <RegexOptions> GetOptionsAsDefaultable()
        {
            Defaultable <RegexOptions> defValue = new Defaultable <RegexOptions>();

            if (Options != RegexOptions.Compiled)
            {
                defValue.SetAsCustom(Options);
            }
            return(defValue);
        }
Beispiel #16
0
        internal Defaultable <ObjectValue> GetMaxAsDefaultable()
        {
            Defaultable <ObjectValue> defValue = new Defaultable <ObjectValue>();

            if (this.Max.Enabled)
            {
                defValue.SetAsCustom(this.Max.Value);
            }
            return(defValue);
        }
Beispiel #17
0
        internal Defaultable <string> GetPatternAsDefaultable()
        {
            Defaultable <string> defValue = new Defaultable <string>();

            if (!string.IsNullOrEmpty(Pattern))
            {
                defValue.SetAsCustom(Pattern);
            }
            return(defValue);
        }
        private Defaultable <HierarchyRootInheritanceSchema> GetDefInheritanceSchema()
        {
            var defInheritanceSchema = new Defaultable <HierarchyRootInheritanceSchema>();

            if (this.Enabled && this.InheritanceSchema != HierarchyRootInheritanceSchema.Default)
            {
                defInheritanceSchema.SetAsCustom(this.InheritanceSchema);
            }
            return(defInheritanceSchema);
        }
Beispiel #19
0
        private Defaultable <string> GetErrorMessageAsDefaultable()
        {
            Defaultable <string> result = new Defaultable <string>();

            if (!string.IsNullOrEmpty(this.ErrorMessage))
            {
                result.SetAsCustom(this.ErrorMessage);
            }

            return(result);
        }
Beispiel #20
0
        private Defaultable <PropertyConstrainMode> GetModeAsDefaultable()
        {
            Defaultable <PropertyConstrainMode> result = new Defaultable <PropertyConstrainMode>();

            if (this.Mode != PropertyConstrainMode.Default)
            {
                result.SetAsCustom(this.Mode);
            }

            return(result);
        }
Beispiel #21
0
        protected override void InternalAssignFrom(DefaultableMulti other)
        {
            base.InternalAssignFrom(other);
            DataMemberDescriptor otherDescriptor = other as DataMemberDescriptor;

            if (otherDescriptor != null)
            {
                this.EmitDefaultValue = otherDescriptor.EmitDefaultValue;
                this.IsRequired       = otherDescriptor.IsRequired;
                this.Order            = otherDescriptor.Order;
            }
        }
        protected override void InternalAssignFromPropertyValues(IDictionary propertyValues)
        {
            Defaultable <bool> propertyValue = (Defaultable <bool>)propertyValues["IncludeTypeId"];

            this.IncludeTypeId = (Defaultable <bool>)propertyValue.Clone();

            this.InheritanceSchema = (HierarchyRootInheritanceSchema)propertyValues["InheritanceSchema"];

            Defaultable <string> mappingName = (Defaultable <string>)propertyValues["MappingName"];

            this.MappingName = (Defaultable <string>)mappingName.Clone();
        }
Beispiel #23
0
        protected override void InternalGetAttributeGroupItems(OrmAttributeGroup @group, Dictionary <string, Defaultable> groupItems)
        {
            if (group == AttributeGroup)
            {
                groupItems.Add("IsReference", IsReference);

                Defaultable <string> namespaceDefaultable = new Defaultable <string>();
                if (!string.IsNullOrEmpty(this.Namespace))
                {
                    namespaceDefaultable.Value = this.Namespace;
                }
                groupItems.Add("Namespace", namespaceDefaultable);
            }
        }
Beispiel #24
0
        public virtual Dictionary <string, Defaultable> GetAttributeGroupItems(OrmAttributeGroup @group)
        {
            Dictionary <string, Defaultable> result          = new Dictionary <string, Defaultable>();
            Defaultable <string>             nameDefaultable = new Defaultable <string>();

            if (!string.IsNullOrEmpty(this.Name))
            {
                nameDefaultable.Value = this.Name;
            }
            result.Add("Name", nameDefaultable);
            InternalGetAttributeGroupItems(group, result);

            return(result);
        }
Beispiel #25
0
        private Defaultable <AssociationOnRemoveAction> GetDefaultableOnRemoveAction(bool onOwnerRemove)
        {
            var defaultable = new Defaultable <AssociationOnRemoveAction>();
            AssociationOnRemoveAction associationOnRemoveAction = onOwnerRemove ? this.OnOwnerRemove : this.OnTargetRemove;

            if (associationOnRemoveAction != AssociationOnRemoveAction.Default)
            {
                defaultable.SetAsCustom(associationOnRemoveAction);
            }
            else
            {
                defaultable.SetAsDefault();
            }
            return(defaultable);
        }
Beispiel #26
0
        //public PropertyConstraints Constraints { get; set; }

        public OrmFieldAttribute()
        {
            this.MappingName       = new Defaultable <string>();
            this.Indexed           = new Defaultable <bool>();
            this.LazyLoad          = new Defaultable <bool>();
            this.Length            = new Defaultable <int>();
            this.Nullable          = new Defaultable <bool>();
            this.NullableOnUpgrade = new Defaultable <bool>();
            this.Precision         = new Defaultable <int>();
            this.Scale             = new Defaultable <int>();
            this.TypeDiscriminator = new Defaultable <bool>();
            this.Version           = new Defaultable <VersionMode>();

            this.DefaultValue = new ObjectValueInfo();
            //this.Constraints = new PropertyConstraints();
        }
Beispiel #27
0
        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;
        }
Beispiel #28
0
        public bool EqualsTo(OrmFieldAttribute other)
        {
            List <Defaultable> currentDefaultableItems = GetAttributeGroupItems(AttributeGroupsListMode.All);
            List <Defaultable> otherDefaultableItems   = other.GetAttributeGroupItems(AttributeGroupsListMode.All);

            for (int i = 0; i < currentDefaultableItems.Count; i++)
            {
                Defaultable currentItem = currentDefaultableItems[i];
                Defaultable otherItem   = otherDefaultableItems[i];
                if (!currentItem.EqualsTo(otherItem))
                {
                    return(false);
                }
            }

            return(true);
        }
        protected override void DeserializeValueFromXml(XmlProxy parent)
        {
            XmlProxy elementValue = parent["value"];

            string schema = elementValue.GetAttr("inheritanceSchema");

            this.InheritanceSchema =
                (HierarchyRootInheritanceSchema)Enum.Parse(typeof(HierarchyRootInheritanceSchema), schema, true);

            XmlProxy elementIncludeTypeId = elementValue["includeTypeId"];

            IncludeTypeId = new Defaultable <bool>();
            IncludeTypeId.DeserializeFromXml(elementIncludeTypeId);

            XmlProxy xmlMappingName = elementValue["mappingName"];

            this.MappingName = new Defaultable <string>();
            this.MappingName.DeserializeFromXml(xmlMappingName);
        }
Beispiel #30
0
        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);
        }