public void AddProperty(bool generateTypeForProperty) { 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(); string uniquePropertyName = effectiveType.GetUniquePropertyName(generateTypeForProperty ? "ComplexProperty" : "Property1"); if (generateTypeForProperty) { string uniqueTypeName = sampleData.GetUniqueTypeName(uniquePropertyName + "Type"); SampleCompositeType compositeType = sampleData.CreateCompositeType(uniqueTypeName); effectiveType.AddProperty(uniquePropertyName, (SampleType)compositeType); } else { effectiveType.AddProperty(uniquePropertyName, (SampleType)SampleBasicType.String); } string schemaNodePath = DataSchemaItem.ProvideNodePathForPendingEdit(this, uniquePropertyName); 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); }
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); }