Example #1
0
        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);
        }
Example #2
0
        public override object CreateInstance(ITypeDescriptorContext context, IDictionary propertyValues)
        {
            TreeNodeDataCollection <StringTreeNode> keyFields =
                (TreeNodeDataCollection <StringTreeNode>)propertyValues["KeyFields"];

            TreeNodeDataCollection <StringTreeNode> includedFields =
                (TreeNodeDataCollection <StringTreeNode>)propertyValues["IncludedFields"];

            OrmIndexFields result = new OrmIndexFields();

            result.KeyFields      = keyFields;
            result.IncludedFields = includedFields;
            return(result);
        }
Example #3
0
        public bool EqualsTo(OrmIndexFields other)
        {
            bool isEqual = this.KeyFields.Count == other.KeyFields.Count &&
                           this.IncludedFields.Count == other.IncludedFields.Count;

            if (isEqual)
            {
                isEqual = this.KeyFields.Select(item => string.Format("{0}@{1}", item.DisplayValue, item.IconIndex))
                          .Except(other.KeyFields.Select(item => string.Format("{0}@{1}", item.DisplayValue, item.IconIndex)))
                          .Count() == 0;

                isEqual &= this.IncludedFields.Select(item => string.Format("{0}@{1}", item.DisplayValue, item.IconIndex))
                           .Except(other.IncludedFields.Select(item => string.Format("{0}@{1}", item.DisplayValue, item.IconIndex)))
                           .Count() == 0;
            }

            return(isEqual);
        }