private static void RenamePropertyAndType(SampleProperty property, string propertyName, string typeName) { if (propertyName == property.Name) { return; } property.Rename(propertyName); SampleNonBasicType sampleNonBasicType1 = property.PropertySampleType as SampleNonBasicType; if (sampleNonBasicType1 == null) { return; } string uniqueTypeName1 = sampleNonBasicType1.DeclaringDataSet.GetUniqueTypeName(typeName, sampleNonBasicType1.Name); if (string.IsNullOrEmpty(uniqueTypeName1)) { return; } sampleNonBasicType1.Rename(uniqueTypeName1); SampleCollectionType sampleCollectionType = sampleNonBasicType1 as SampleCollectionType; SampleNonBasicType sampleNonBasicType2 = sampleCollectionType != null ? sampleCollectionType.ItemSampleType as SampleNonBasicType : (SampleNonBasicType)null; if (sampleNonBasicType2 == null || sampleNonBasicType2 == sampleNonBasicType1) { return; } string uniqueTypeName2 = sampleNonBasicType2.DeclaringDataSet.GetUniqueTypeName(typeName + "Item", sampleNonBasicType2.Name); if (string.IsNullOrEmpty(uniqueTypeName2)) { return; } sampleNonBasicType2.Rename(uniqueTypeName2); }
public void AddCollection() { 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("Collection"); string uniqueTypeName = sampleData.GetUniqueTypeName(uniquePropertyName + "Item"); SampleCompositeType compositeType = sampleData.CreateCompositeType(uniqueTypeName); SampleCollectionType collectionType = sampleData.CreateCollectionType((SampleNonBasicType)compositeType); effectiveType.AddProperty(uniquePropertyName, (SampleType)collectionType); 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); }
private static SampleProperty GetHierarchicalPropertyToRename(SampleProperty sampleProperty) { SampleCollectionType collectionType = sampleProperty.PropertySampleType as SampleCollectionType; if (collectionType == null) { return((SampleProperty)null); } SampleCompositeType sampleCompositeType = collectionType.ItemSampleType as SampleCompositeType; if (sampleCompositeType == null) { return((SampleProperty)null); } SampleProperty hierarchicalProperty = Enumerable.FirstOrDefault <SampleProperty>((IEnumerable <SampleProperty>)sampleCompositeType.SampleProperties, (Func <SampleProperty, bool>)(p => p.PropertySampleType == collectionType)); if (hierarchicalProperty == null) { return((SampleProperty)null); } if (Enumerable.FirstOrDefault <SampleProperty>((IEnumerable <SampleProperty>)sampleCompositeType.SampleProperties, (Func <SampleProperty, bool>)(p => { if (p != hierarchicalProperty) { return(p.PropertySampleType == collectionType); } return(false); })) != null) { return((SampleProperty)null); } return(hierarchicalProperty); }
public void ProcessChildren(DataSchemaItem dataSchemaItem) { DataSchemaNodePath dataSchemaNodePath = dataSchemaItem.DataSchemaNodePath; DataSchemaNode dataSchemaNode = dataSchemaNodePath.Node; bool flag = true; while (dataSchemaNode.IsCollection && dataSchemaNode.CollectionItem != null && dataSchemaNode.CollectionItem.Type != typeof(object)) { dataSchemaNode = dataSchemaNode.CollectionItem; } if (dataSchemaNode.Type == typeof(string) && !(dataSchemaItem.DataSchemaNodePath.Schema is XmlSchema)) { flag = false; } else if (dataSchemaItem.SampleType is SampleBasicType) { flag = false; } else if (dataSchemaNode != dataSchemaNodePath.Node) { SampleCollectionType sampleCollectionType = dataSchemaNodePath.Node.SampleType as SampleCollectionType; if (sampleCollectionType != null && sampleCollectionType.ItemSampleType is SampleBasicType) { flag = false; } } if (flag) { foreach (DataSchemaNode node in dataSchemaNode.Children) { DataSchemaItem dataSchemaItem1 = new DataSchemaItem(dataSchemaNodePath.GetExtendedPath(node), this, this.model, this.itemSelectionContext); dataSchemaItem.AddChild((DataModelItemBase)dataSchemaItem1); } } if (this.lastFilter == null) { return; } dataSchemaItem.SetFilter(this.lastFilter); }
public SampleCollectionItemTypeChanged(SampleCollectionType sampleType, SampleType oldType) : base((SampleNonBasicType)sampleType) { this.OldItemType = oldType; this.NewItemType = sampleType.ItemSampleType; }