public void MakeHierarchicalCollection() { if (!this.schemaItem.Schema.DataSource.IsSampleDataSource) { return; } SampleDataSet sampleData = this.schemaItem.Schema.DataSource.SampleData; SampleCompositeType effectiveType = this.DataSchemaNode.EffectiveType; if (effectiveType == null) { return; } this.model.SelectionContext.Clear(); SampleNonBasicType sampleNonBasicType = (SampleNonBasicType)this.DataSchemaNode.SampleType; string uniquePropertyName1 = effectiveType.GetUniquePropertyName(this.DataSchemaNode.PathName); SampleProperty hierarchicalProperty = effectiveType.AddProperty(uniquePropertyName1, (SampleType)sampleNonBasicType); SampleProperty sampleProperty = this.DataSchemaNode.EffectiveParentType.GetSampleProperty(this.DataSchemaNode.PathName); string uniquePropertyName2 = DataSchemaItem.GetUniquePropertyName(sampleProperty, hierarchicalProperty, uniquePropertyName1); string schemaNodePath = DataSchemaItem.ProvideNodePathForPendingEdit(this, uniquePropertyName2, sampleProperty, hierarchicalProperty); sampleProperty.Rename(uniquePropertyName2); hierarchicalProperty.Rename(uniquePropertyName2); this.model.RenameSampleDataSchemaItemUponRebuild(this.schemaItem.Schema.DataSource, schemaNodePath); this.model.ExtendSelectionUponRebuild(this.schemaItem.Schema.DataSource, schemaNodePath); this.IsExpanded = true; using (TemporaryCursor.SetWaitCursor()) sampleData.CommitChanges(this.ViewModel.DesignerContext.MessageDisplayService); }
private bool RenamePropertyInternal(SampleProperty sampleProperty, SampleProperty hierarchicalProperty, string rawName) { string uniquePropertyName = DataSchemaItem.GetUniquePropertyName(sampleProperty, hierarchicalProperty, rawName); if (string.IsNullOrEmpty(uniquePropertyName) || uniquePropertyName == sampleProperty.Name && (hierarchicalProperty == null || hierarchicalProperty.Name == uniquePropertyName)) { return(false); } this.pendingName = uniquePropertyName; Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, (Delegate)(() => this.ChangeEffectivePropertyIfValid((DataSchemaItem.ModifySamplePropertyOperation)((parentType, property) => { string schemaNodePath = (string)null; if (this.IsSelected) { this.model.SelectionContext.Remove((DataModelItemBase)this); schemaNodePath = DataSchemaItem.ProvideNodePathForPendingEdit(this.Parent as DataSchemaItem, this.pendingName, sampleProperty, hierarchicalProperty); } string typeName = rawName.Trim(); DataSchemaItem.RenamePropertyAndType(sampleProperty, this.pendingName, typeName); if (hierarchicalProperty != null) { DataSchemaItem.RenamePropertyAndType(hierarchicalProperty, this.pendingName, typeName); } if (schemaNodePath != null) { this.model.ExtendSelectionUponRebuild(this.DataSourceNode, schemaNodePath); } this.pendingName = (string)null; })))); return(true); }