public SampleDataSet CreateDefaultNewSampleDataSource(DataSetContext dataSetContext, string dataSourceName, bool enableAtRuntime) { SampleDataSet dataSet = (SampleDataSet)null; bool flag = false; try { dataSet = this.CreateSampleDataSet(dataSetContext, dataSourceName, enableAtRuntime); if (dataSet != null) { using (dataSet.DisableChangeTracking()) { if (dataSetContext.DataSetType == DataSetType.SampleDataSet) { string uniqueTypeName1 = dataSet.GetUniqueTypeName("Item"); SampleCompositeType compositeType = dataSet.CreateCompositeType(uniqueTypeName1); string uniquePropertyName1 = compositeType.GetUniquePropertyName("Property1"); compositeType.AddProperty(uniquePropertyName1, (SampleType)SampleBasicType.String); string uniquePropertyName2 = compositeType.GetUniquePropertyName("Property2"); compositeType.AddProperty(uniquePropertyName2, (SampleType)SampleBasicType.Boolean); string uniqueTypeName2 = dataSet.GetUniqueTypeName("ItemCollection"); SampleCollectionType collectionType = dataSet.CreateCollectionType(uniqueTypeName2, (SampleType)compositeType); string uniquePropertyName3 = dataSet.RootType.GetUniquePropertyName("Collection"); dataSet.RootType.AddProperty(uniquePropertyName3, (SampleType)collectionType); dataSet.AutoGenerateValues(); } else { string uniquePropertyName = dataSet.RootType.GetUniquePropertyName("Property1"); SampleProperty sampleProperty = dataSet.RootType.AddProperty(uniquePropertyName, (SampleType)SampleBasicType.String); using (SampleDataValueBuilder valueBuilder = dataSet.CreateValueBuilder()) { DocumentCompositeNode rootNode = valueBuilder.RootNode; valueBuilder.RootNode.Properties[(IPropertyId)sampleProperty] = valueBuilder.CreatePropertyValue(rootNode, "Property1", StringTable.DefaultValueDataStore); } dataSet.Save(); } } flag = dataSet.IsSaved; } } finally { if (!flag && dataSet != null) { this.SafelyRemoveSampleDataAndRootFolder(dataSet, true); dataSet = (SampleDataSet)null; } } return(dataSet); }
private DataStoreReferenceEntry CreateNewDataStore(SceneEditTransaction transation) { SampleDataSet sampleDataSet = this.ProjectXamlContext.SampleData.CreateSampleDataSet(DataSetContext.DataStore, "DataStore", true); sampleDataSet.Save(); this.ObjectSet.ViewModel.DataPanelModel.AddDataStoreDataSource(sampleDataSet, true); transation.Update(); IEnumerable <DataStoreReferenceEntry> dataStoreDataSet = this.FindDataStoreDataSet((Predicate <SampleDataSet>)(dataSet => true)); if (dataStoreDataSet != null) { return(Enumerable.FirstOrDefault <DataStoreReferenceEntry>(dataStoreDataSet)); } return((DataStoreReferenceEntry)null); }