Exemplo n.º 1
0
        public ConflictResolutionResult Save(SaveMode saveMode)
        {
            this.CheckDisposed("Save");
            ExTraceGlobals.StorageTracer.Information((long)this.GetHashCode(), "UserConfiguration::Save.");
            if (!this.isOpenMode)
            {
                this.Item[InternalSchema.ItemClass]             = this.configName.FullName;
                this.Item[InternalSchema.UserConfigurationType] = (int)this.configType;
            }
            this.Item.OpenAsReadWrite();
            if (this.configDictionary != null && this.configDictionary.IsDirty)
            {
                using (Stream stream = this.Item.OpenPropertyStream(InternalSchema.UserConfigurationDictionary, PropertyOpenMode.Create))
                {
                    using (XmlWriter xmlWriter = UserConfiguration.InternalGetXmlWriter(stream))
                    {
                        this.configDictionary.WriteXml(xmlWriter);
                    }
                }
            }
            ConflictResolutionResult conflictResolutionResult = this.Item.Save(saveMode);

            if (conflictResolutionResult.SaveStatus == SaveResult.Success || conflictResolutionResult.SaveStatus == SaveResult.SuccessWithConflictResolution)
            {
                if (!this.isOpenMode)
                {
                    this.id = this.Item.StoreObjectId;
                    this.ConflictDetection();
                }
                this.isOpenMode = true;
            }
            return(conflictResolutionResult);
        }