示例#1
0
        internal ConflictResolutionResult ResolveConflicts(Dictionary <PropertyDefinition, AcrPropertyProfile.ValuesToResolve> propertyValuesToResolve)
        {
            Dictionary <PropertyDefinition, PropertyConflict> dictionary = new Dictionary <PropertyDefinition, PropertyConflict>(propertyValuesToResolve.Count);

            foreach (KeyValuePair <PropertyDefinition, AcrPropertyProfile.ValuesToResolve> keyValuePair in propertyValuesToResolve)
            {
                AcrPropertyProfile acrPropertyProfile = this[keyValuePair.Key];
                if (!dictionary.ContainsKey(keyValuePair.Key))
                {
                    if (acrPropertyProfile != null)
                    {
                        AcrProfile.ResolveConflicts(dictionary, acrPropertyProfile.Resolver, propertyValuesToResolve, acrPropertyProfile.PropertiesToResolve);
                    }
                    else
                    {
                        AcrProfile.ResolveConflicts(dictionary, this.genericResolver, propertyValuesToResolve, new PropertyDefinition[]
                        {
                            keyValuePair.Key
                        });
                    }
                }
            }
            SaveResult saveResult = SaveResult.Success;

            foreach (PropertyConflict propertyConflict in dictionary.Values)
            {
                if (!propertyConflict.ConflictResolvable)
                {
                    saveResult = SaveResult.IrresolvableConflict;
                    break;
                }
                saveResult = SaveResult.SuccessWithConflictResolution;
            }
            return(new ConflictResolutionResult(saveResult, Util.CollectionToArray <PropertyConflict>(dictionary.Values)));
        }
示例#2
0
        internal IEnumerable <PropertyDefinition> GetPropertiesNeededForResolution(PropertyDefinition propertyDefinition)
        {
            AcrPropertyProfile profile = this[propertyDefinition];

            if (profile != null)
            {
                foreach (PropertyDefinition relatedPropertyDefinition in profile.AllProperties)
                {
                    yield return(relatedPropertyDefinition);
                }
            }
            else
            {
                yield return(propertyDefinition);
            }
            yield break;
        }
示例#3
0
        private void AddPropertyProfile(AcrPropertyResolverChain.ResolutionFunction resolutionFunction, bool requireChangeTracking, params StorePropertyDefinition[] interDependentProperties)
        {
            for (int i = 0; i < interDependentProperties.Length; i++)
            {
                PropertyDefinition propertyDefinition = interDependentProperties[i];
                if (propertyDefinition is SmartPropertyDefinition)
                {
                    throw new ArgumentException("interndependentProperties cannot contain SmartProperties");
                }
                if (this.propertyProfileCollection.ContainsKey(propertyDefinition) || i < Array.LastIndexOf <PropertyDefinition>(interDependentProperties, propertyDefinition))
                {
                    throw new ArgumentException(ServerStrings.ExPropertyDefinitionInMoreThanOnePropertyProfile);
                }
            }
            AcrPropertyProfile value = new AcrPropertyProfile(new AcrPropertyResolverChain(new AcrPropertyResolverChain.ResolutionFunction[]
            {
                resolutionFunction
            }, null, false), requireChangeTracking, interDependentProperties);

            foreach (StorePropertyDefinition key in interDependentProperties)
            {
                this.propertyProfileCollection.Add(key, value);
            }
        }