public int Compare(object x, object y) { DataStorePropertyEntry storePropertyEntry1 = (DataStorePropertyEntry)x; DataStorePropertyEntry storePropertyEntry2 = (DataStorePropertyEntry)y; if (storePropertyEntry1.IsCreateNewPropertyEntry && storePropertyEntry2.IsCreateNewPropertyEntry) { return(0); } if (storePropertyEntry1.IsCreateNewPropertyEntry) { return(-1); } if (storePropertyEntry2.IsCreateNewPropertyEntry) { return(1); } int num = string.Compare(storePropertyEntry1.DataSetName, storePropertyEntry2.DataSetName, StringComparison.CurrentCulture); if (num != 0) { return(num); } return(string.Compare(storePropertyEntry1.Name, storePropertyEntry2.Name, StringComparison.CurrentCulture)); }
public void Rebuild() { if (this.SceneNodeProperty == null) { return; } ProjectXamlContext projectXamlContext = this.ProjectXamlContext; if (this.ProjectXamlContext != null) { SampleDataCollection sampleData = projectXamlContext.SampleData; IEnumerable <DataStoreReferenceEntry> dataStoreDataSet = this.FindDataStoreDataSet((Predicate <SampleDataSet>)(dataSet => true)); HashSet <string> hashSet = new HashSet <string>(); List <DataStorePropertyEntry> list = new List <DataStorePropertyEntry>(); list.Add(new DataStorePropertyEntry((SampleDataSet)null, StringTable.CreateNewPropertyItem, true)); this.properties = list; if (dataStoreDataSet != null) { foreach (DataStoreReferenceEntry storeReferenceEntry in dataStoreDataSet) { SampleDataSet dataStore = storeReferenceEntry.DataStore; if (!hashSet.Contains(dataStore.Name)) { hashSet.Add(dataStore.Name); for (int index = 0; index < storeReferenceEntry.DataStore.RootType.Properties.Count; ++index) { list.Add(new DataStorePropertyEntry(storeReferenceEntry.DataStore, storeReferenceEntry.DataStore.RootType.Properties[index].Name, false)); } } } if (this.editingProperty != null) { this.editingProperty = Enumerable.FirstOrDefault <DataStorePropertyEntry>(Enumerable.Where <DataStorePropertyEntry>((IEnumerable <DataStorePropertyEntry>) this.properties, (Func <DataStorePropertyEntry, bool>)(entry => entry.Name == this.SelectedProperty.Name))); } } } if (this.Rebuilt == null) { return; } this.Rebuilt((object)this, (EventArgs)null); }
private void CreateBinding(DataStorePropertyEntry propertyEntry) { string path = (string)null; bool flag = false; DataStoreReferenceEntry storeReferenceEntry = (DataStoreReferenceEntry)null; using (SceneEditTransaction editTransaction = this.ObjectSet.ViewModel.CreateEditTransaction(StringTable.ConditionChangeUndo)) { if (propertyEntry.Renamed || propertyEntry.IsCreateNewPropertyEntry) { IEnumerable <DataStoreReferenceEntry> dataStoreDataSet = this.FindDataStoreDataSet((Predicate <SampleDataSet>)(dataSet => true)); if (dataStoreDataSet != null) { IEnumerable <DataStoreReferenceEntry> source = (IEnumerable <DataStoreReferenceEntry>)null; if (propertyEntry.Renamed) { source = Enumerable.Where <DataStoreReferenceEntry>(dataStoreDataSet, (Func <DataStoreReferenceEntry, bool>)(entry => Enumerable.Count <SampleProperty>(Enumerable.Where <SampleProperty>((IEnumerable <SampleProperty>)entry.DataStore.RootType.SampleProperties, (Func <SampleProperty, bool>)(property => property.Name == propertyEntry.Name))) > 0)); } if (source != null && Enumerable.FirstOrDefault <DataStoreReferenceEntry>(source) != null) { storeReferenceEntry = Enumerable.FirstOrDefault <DataStoreReferenceEntry>(source); path = propertyEntry.Name; } else { storeReferenceEntry = Enumerable.FirstOrDefault <DataStoreReferenceEntry>(dataStoreDataSet); if (propertyEntry.IsCreateNewPropertyEntry) { AddDataStorePropertyDialogModel model = new AddDataStorePropertyDialogModel(dataStoreDataSet); bool?nullable = new GenericDialog("Resources\\DataPane\\AddDataStorePropertyDialog.xaml", StringTable.AddDataStorePropertyDialogTitle, (IGenericDialogModel)model).ShowDialog(); if ((!nullable.GetValueOrDefault() ? 0 : (nullable.HasValue ? 1 : 0)) != 0) { propertyEntry.Name = model.PropertyName; storeReferenceEntry = Enumerable.FirstOrDefault <DataStoreReferenceEntry>(Enumerable.Where <DataStoreReferenceEntry>(dataStoreDataSet, (Func <DataStoreReferenceEntry, bool>)(entry => entry.DataStore.Name == model.SelectedDataStore))); } else { this.editingProperty = this.lastEditingProperty; editTransaction.Cancel(); this.Rebuild(); return; } } path = this.CreateNewProperty(storeReferenceEntry.DataStore, propertyEntry.Name); flag = true; } } if (storeReferenceEntry == null) { storeReferenceEntry = this.CreateNewDataStore(editTransaction); if (storeReferenceEntry != null) { if (propertyEntry.IsCreateNewPropertyEntry) { IList <DataStoreReferenceEntry> list = (IList <DataStoreReferenceEntry>) new List <DataStoreReferenceEntry>(); list.Add(storeReferenceEntry); AddDataStorePropertyDialogModel propertyDialogModel = new AddDataStorePropertyDialogModel((IEnumerable <DataStoreReferenceEntry>)list); bool?nullable = new GenericDialog("Resources\\DataPane\\AddDataStorePropertyDialog.xaml", StringTable.AddDataStorePropertyDialogTitle, (IGenericDialogModel)propertyDialogModel).ShowDialog(); if ((!nullable.GetValueOrDefault() ? 0 : (nullable.HasValue ? 1 : 0)) != 0) { propertyEntry.Name = propertyDialogModel.PropertyName; } else { this.editingProperty = this.lastEditingProperty; editTransaction.Cancel(); this.Rebuild(); return; } } path = this.CreateNewProperty(storeReferenceEntry.DataStore, propertyEntry.Name); } flag = true; } } else { storeReferenceEntry = Enumerable.FirstOrDefault <DataStoreReferenceEntry>(this.FindDataStoreDataSet((Predicate <SampleDataSet>)(dataSet => { if (dataSet.Name != propertyEntry.DataSetName) { return(false); } return(Enumerable.Count <SampleProperty>(Enumerable.Where <SampleProperty>((IEnumerable <SampleProperty>)dataSet.RootType.SampleProperties, (Func <SampleProperty, bool>)(property => property.Name == propertyEntry.Name))) > 0); }))); path = propertyEntry.Name; } if (storeReferenceEntry != null && path != null) { ISchema schemaForDataSource = SchemaManager.GetSchemaForDataSource(storeReferenceEntry.DictionaryEntryNode.Properties[DictionaryEntryNode.ValueProperty]); this.ObjectSet.ViewModel.BindingEditor.CreateAndSetBindingOrData(this.OwnerObject, (IPropertyId)this.SceneNodeProperty.Reference.LastStep, this.PropertyNameEntry != null ? schemaForDataSource.CreateNodePath() : schemaForDataSource.GetNodePathFromPath(path), false); if (this.PropertyNameEntry != null) { IType type = this.ObjectSet.RepresentativeSceneNode.Type; IProperty property; for (property = (IProperty)null; property == null && type != null; type = type.BaseType) { property = type.GetMember(MemberType.LocalProperty, this.PropertyNameEntry, MemberAccessTypes.All) as IProperty; } if (property != null) { this.ObjectSet.RepresentativeSceneNode.SetValue((IPropertyId)property, (object)path); } } propertyEntry.Name = path; } editTransaction.Commit(); if (!flag) { return; } DataStorePropertiesValueProvider.FireRebuildForAllProviders(); } }