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();
            }
        }