internal void SetExchangeVersion(ExchangeObjectVersion newVersion) { this.CheckWritable(); if (this.propertyBag.ObjectVersionPropertyDefinition == null) { throw new NotSupportedException(DataStrings.ExceptionVersionlessObject); } ExchangeObjectVersion exchangeVersion = this.ExchangeVersion; if (null == newVersion) { newVersion = (ExchangeObjectVersion)this.propertyBag.ObjectVersionPropertyDefinition.DefaultValue; } if (newVersion.IsOlderThan(exchangeVersion)) { List <ProviderPropertyDefinition> list = new List <ProviderPropertyDefinition>(this.propertyBag.Keys.Cast <ProviderPropertyDefinition>()); foreach (ProviderPropertyDefinition providerPropertyDefinition in list) { if (providerPropertyDefinition.VersionAdded.IsNewerThan(newVersion) && !providerPropertyDefinition.VersionAdded.IsNewerThan(exchangeVersion)) { if (this.propertyBag.IsReadOnlyProperty(providerPropertyDefinition) || providerPropertyDefinition.IsCalculated) { this.propertyBag.SetField(providerPropertyDefinition, null); } else { this[providerPropertyDefinition] = null; } } } } this.propertyBag.SetObjectVersion(newVersion); }
internal void ValidateRead(List <ValidationError> errors, IEnumerable <PropertyDefinition> propertiesToValidate) { ExchangeObjectVersion exchangeObjectVersion = (this.propertyBag.ObjectVersionPropertyDefinition == null) ? null : this.ExchangeVersion; if (propertiesToValidate != null) { foreach (PropertyDefinition propertyDefinition in propertiesToValidate) { ProviderPropertyDefinition providerPropertyDefinition = (ProviderPropertyDefinition)propertyDefinition; if (providerPropertyDefinition.IsCalculated) { bool onlyCacheValue = null != exchangeObjectVersion && exchangeObjectVersion.IsOlderThan(providerPropertyDefinition.VersionAdded); this.ValidateCalculatedProperty(providerPropertyDefinition, this.propertyBag, errors, true, onlyCacheValue); } } } List <ValidationError> list = this.instantiationErrors; if (list == null || list.Count == 0) { return; } list.RemoveAll(delegate(ValidationError error) { PropertyValidationError propertyValidationError = error as PropertyValidationError; if (propertyValidationError == null) { return(false); } ProviderPropertyDefinition providerPropertyDefinition2 = propertyValidationError.PropertyDefinition as ProviderPropertyDefinition; if (providerPropertyDefinition2 == null) { return(false); } bool flag = providerPropertyDefinition2.IsMultivalued && ((MultiValuedPropertyBase)this[providerPropertyDefinition2]).Changed; if (flag) { ExTraceGlobals.ValidationTracer.TraceDebug <ValidationError>((long)this.GetHashCode(), "Removing instantiation error '{0}'.", error); } return(flag); }); errors.AddRange(list); }