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 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); }
private bool RenameProperty(string rawName) { SampleCompositeType effectiveParentType1 = this.DataSchemaNode.EffectiveParentType; SampleProperty sampleProperty1 = effectiveParentType1.GetSampleProperty(this.DataSchemaNode.PathName); SampleProperty propertyToRename1 = DataSchemaItem.GetHierarchicalPropertyToRename(sampleProperty1); if (propertyToRename1 == null || propertyToRename1 != sampleProperty1) { return(this.RenamePropertyInternal(sampleProperty1, propertyToRename1, rawName)); } for (DataSchemaItem dataSchemaItem = this.Parent as DataSchemaItem; dataSchemaItem != null; dataSchemaItem = dataSchemaItem.Parent as DataSchemaItem) { SampleCompositeType effectiveParentType2 = dataSchemaItem.DataSchemaNode.EffectiveParentType; if (effectiveParentType2 != effectiveParentType1) { SampleProperty sampleProperty2 = effectiveParentType2 != null?effectiveParentType2.GetSampleProperty(dataSchemaItem.DataSchemaNode.PathName) : (SampleProperty)null; if (sampleProperty2 == null) { return(this.RenamePropertyInternal(sampleProperty1, (SampleProperty)null, rawName)); } SampleProperty propertyToRename2 = DataSchemaItem.GetHierarchicalPropertyToRename(sampleProperty2); if (propertyToRename2 != sampleProperty1) { return(this.RenamePropertyInternal(sampleProperty1, (SampleProperty)null, rawName)); } return(dataSchemaItem.RenamePropertyInternal(sampleProperty2, propertyToRename2, rawName)); } } return(this.RenamePropertyInternal(sampleProperty1, (SampleProperty)null, rawName)); }
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); }
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); }
public DataPaneCallback(DataSchemaItem dataSchemaItem) { DataSchemaNode node = dataSchemaItem.DataSchemaNodePath.Node; this.property = ((SampleCompositeType)node.Parent.SampleType).GetSampleProperty(node.PathName); this.configuration = new SampleDataPropertyConfiguration(this.property); this.messageService = dataSchemaItem.ViewModel.DesignerContext.MessageDisplayService; }
public SamplePropertyTypeOrFormatChanged(SampleProperty sampleProperty, SampleType oldType, string oldFormat, string oldFormatParameters) : base(sampleProperty) { this.OldType = oldType; this.OldFormat = oldFormat; this.OldFormatParameters = oldFormatParameters; this.NewFormat = sampleProperty.Format; this.NewFormatParameters = sampleProperty.FormatParameters; this.NewType = sampleProperty.PropertySampleType; }
private string CreateNewProperty(SampleDataSet dataSet, string newProperyName) { string uniqueTypeName = dataSet.GetUniqueTypeName(newProperyName); SampleProperty sampleProperty = dataSet.RootType.AddProperty(uniqueTypeName, (SampleType)SampleBasicType.String); DocumentCompositeNode newRootNode = (DocumentCompositeNode)dataSet.RootNode.Clone(dataSet.RootNode.Context); newRootNode.Properties[(IPropertyId)sampleProperty] = (DocumentNode)newRootNode.Context.CreateNode(StringTable.DefaultValueDataStore); dataSet.CommitChanges(newRootNode, this.ObjectSet.ViewModel.DesignerContext.MessageDisplayService); return(uniqueTypeName); }
private string ValidatePropertyName(string propertyName) { SampleProperty dataSetProperty = this.DataSetProperty; propertyName = this.dataStore.GetUniqueTypeName(propertyName, this.PropertyName); if (string.IsNullOrEmpty(propertyName)) { return(string.Empty); } return(propertyName); }
private void ChangePropertyName(DataStorePropertyEntry entry) { SampleProperty dataSetProperty = entry.DataSetProperty; entry.ValidatePropertyName(); if (string.IsNullOrEmpty(entry.PropertyName)) { return; } dataSetProperty.Rename(entry.PropertyName); }
public SampleDataPropertyConfiguration(SampleProperty sampleProperty) { this.activeType = (SampleBasicType)sampleProperty.PropertySampleType; this.valueGenerators = new Dictionary <SampleBasicType, ISampleTypeConfiguration>(); foreach (SampleBasicType sampleBasicType in SampleBasicType.SampleBasicTypes) { string format = sampleBasicType == sampleProperty.PropertySampleType ? sampleProperty.Format : (string)null; string formatParameters = sampleBasicType == sampleProperty.PropertySampleType ? sampleProperty.FormatParameters : (string)null; ISampleTypeConfiguration configuration = SampleDataPropertyConfiguration.CreateConfiguration(sampleProperty.DeclaringDataSet, sampleBasicType, format, formatParameters); this.valueGenerators.Add(sampleBasicType, configuration); } }
public static DataStoreType DataStoreTypeFromSampleProperty(SampleProperty sampleProperty) { if (sampleProperty.PropertySampleType == SampleBasicType.String) { return(DataStoreType.String); } if (sampleProperty.PropertySampleType == SampleBasicType.Boolean) { return(DataStoreType.Boolean); } return(sampleProperty.PropertySampleType == SampleBasicType.Number ? DataStoreType.Number : DataStoreType.String); }
private DocumentCompositeNode GetCollectionNode(DocumentCompositeNode rootSampleDataNode, bool createMissingNodes) { DataSchemaNode node = this.editingSchemaPath.Node; List <DataSchemaNode> list = new List <DataSchemaNode>(); for (DataSchemaNode dataSchemaNode = node; dataSchemaNode.Parent != null; dataSchemaNode = dataSchemaNode.Parent) { list.Insert(0, dataSchemaNode); } DocumentCompositeNode documentNode1 = rootSampleDataNode; for (int index = 0; index < list.Count; ++index) { DataSchemaNode dataSchemaNode = list[index]; SampleNonBasicType sampleNonBasicType = (SampleNonBasicType)documentNode1.Type; DocumentNode documentNode2; if (sampleNonBasicType.IsCollection) { if (documentNode1.Children.Count > 0) { documentNode2 = documentNode1.Children[0]; } else { if (!createMissingNodes) { return((DocumentCompositeNode)null); } documentNode2 = this.ValueBuilder.CreateNode(((SampleCollectionType)sampleNonBasicType).ItemSampleType); documentNode1.Children.Add(documentNode2); } } else { SampleProperty sampleProperty = ((SampleCompositeType)sampleNonBasicType).GetSampleProperty(dataSchemaNode.PathName); documentNode2 = documentNode1.Properties[(IPropertyId)sampleProperty]; if (documentNode2 == null) { if (!createMissingNodes) { return((DocumentCompositeNode)null); } documentNode2 = this.ValueBuilder.CreatePropertyValue(documentNode1, sampleProperty); documentNode1.Properties[(IPropertyId)sampleProperty] = documentNode2; } } documentNode1 = (DocumentCompositeNode)documentNode2; } return(documentNode1); }
public void UpdateSampleProperty() { SampleDataPropertyConfiguration typeConfiguration = this.SampleTypeConfiguration; SampleProperty sampleProperty = this.SampleProperty; if (typeConfiguration.SampleType == sampleProperty.PropertySampleType && typeConfiguration.Format == sampleProperty.Format && typeConfiguration.FormatParameters == sampleProperty.FormatParameters) { return; } this.Model.SetModified(); this.SampleProperty.ChangeTypeAndFormat((Microsoft.Expression.DesignSurface.SampleData.SampleType)typeConfiguration.SampleType, typeConfiguration.Format, typeConfiguration.FormatParameters); if (sampleProperty.PropertySampleType == SampleBasicType.Image) { this.SampleDataSet.EnsureSampleImages(); } this.Model.UpdateEditingCollection(); }
private void ChangeEffectivePropertyIfValid(DataSchemaItem.ModifySamplePropertyOperation operation) { SampleCompositeType effectiveParentType = this.DataSchemaNode.EffectiveParentType; if (effectiveParentType == null) { return; } SampleDataSet declaringDataSet = effectiveParentType.DeclaringDataSet; SampleProperty sampleProperty = effectiveParentType.GetSampleProperty(this.DataSchemaNode.PathName); if (sampleProperty == null) { return; } operation(effectiveParentType, sampleProperty); using (TemporaryCursor.SetWaitCursor()) declaringDataSet.CommitChanges(this.ViewModel.DesignerContext.MessageDisplayService); }
private static string GetUniquePropertyName(SampleProperty sampleProperty, SampleProperty hierarchicalProperty, string rawName) { string uniqueNameForRename1 = sampleProperty.GetUniqueNameForRename(rawName); if (string.IsNullOrEmpty(uniqueNameForRename1) || hierarchicalProperty == null || hierarchicalProperty.GetUniqueNameForRename(uniqueNameForRename1) == uniqueNameForRename1) { return(uniqueNameForRename1); } NumberedName numberedName = new NumberedName(uniqueNameForRename1); while (numberedName.Increment()) { if (!(sampleProperty.GetUniqueNameForRename(numberedName.CurrentName) != numberedName.CurrentName)) { string uniqueNameForRename2 = hierarchicalProperty.GetUniqueNameForRename(numberedName.CurrentName); if (!(uniqueNameForRename2 != numberedName.CurrentName)) { return(uniqueNameForRename2); } } } return((string)null); }
public SamplePropertyCreated(SampleProperty sampleProperty) : base(sampleProperty) { }
public SamplePropertyDeleted(SampleProperty sampleProperty) : base(sampleProperty) { }
public override void Undo() { SampleProperty sampleProperty = this.SampleProperty; this.SampleProperty.DeclaringSampleType.AddProperty(sampleProperty.Name, sampleProperty.PropertySampleType); }
public SamplePropertyRenamed(SampleProperty sampleProperty, string oldName) : base(sampleProperty) { this.OldName = oldName; this.NewName = sampleProperty.Name; }
public SampleDataProperty(SampleProperty sampleProperty, SampleDataEditorModel model) { this.SampleProperty = sampleProperty; this.Model = model; this.SampleTypeConfiguration = new SampleDataPropertyConfiguration(sampleProperty); }
set => SetValue(SampleProperty, value);
protected SamplePropertyChange(SampleProperty sampleProperty) : base((object)sampleProperty) { }
private static string ProvideNodePathForPendingEdit(DataSchemaItem parentItem, string newPropertyName, params SampleProperty[] renamedProperties) { DataSchemaNodePath dataSchemaNodePath = parentItem.DataSchemaNodePath; DataSchemaNode endNode = (DataSchemaNode)null; if (dataSchemaNodePath.IsCollection) { endNode = dataSchemaNodePath.EffectiveCollectionItemNode; } if (endNode == null) { endNode = dataSchemaNodePath.Node; } if (endNode == null) { return(newPropertyName); } string inheritedPath = (string)null; if (renamedProperties.Length == 0) { if (endNode != dataSchemaNodePath.Node) { dataSchemaNodePath = new DataSchemaNodePath(dataSchemaNodePath.Schema, endNode); } return(ClrObjectSchema.CombinePaths(dataSchemaNodePath.Path, newPropertyName)); } List <string> list = new List <string>() { newPropertyName }; string pathName = endNode.PathName; for (DataSchemaNode parent = endNode.Parent; parent != null; parent = parent.Parent) { SampleCompositeType sampleCompositeType = parent.SampleType as SampleCompositeType; if (sampleCompositeType == null) { list.Add(pathName); } else { string name = pathName; SampleProperty sampleProperty = sampleCompositeType.GetSampleProperty(name); if (Enumerable.FirstOrDefault <SampleProperty>((IEnumerable <SampleProperty>)renamedProperties, (Func <SampleProperty, bool>)(p => p == sampleProperty)) != null) { name = newPropertyName; } list.Add(name); } if (parent != dataSchemaNodePath.Schema.Root) { pathName = parent.PathName; } else { break; } } for (int index = list.Count - 1; index >= 0; --index) { inheritedPath = ClrObjectSchema.CombinePaths(inheritedPath, list[index]); } return(inheritedPath); }