private static void ProcessSampleDataFile(DataSetContext dataSetContext, IProjectItem projectItem, string sampleDataFolder, List <SampleDataCollection.SampleDataSetProjectInfo> collection) { string path = projectItem.DocumentReference.Path; if (!path.StartsWith(sampleDataFolder, StringComparison.OrdinalIgnoreCase)) { return; } string extension = Path.GetExtension(path); if (!extension.Equals(".xsd", StringComparison.OrdinalIgnoreCase) && !extension.Equals(".xaml", StringComparison.OrdinalIgnoreCase)) { return; } string withoutExtension = Path.GetFileNameWithoutExtension(path); if (!string.Format((IFormatProvider)CultureInfo.InvariantCulture, "{0}{1}{2}{1}{3}", (object)sampleDataFolder, (object)withoutExtension, (object)Path.DirectorySeparatorChar, (object)extension).Equals(path, StringComparison.OrdinalIgnoreCase)) { return; } SampleDataCollection.SampleDataSetProjectInfo sampleDataSetInfo = SampleDataCollection.GetOrCreateSampleDataSetInfo(dataSetContext, withoutExtension, collection); if (extension.Equals(".xsd", StringComparison.OrdinalIgnoreCase)) { sampleDataSetInfo.XsdItem = projectItem; } else { sampleDataSetInfo.XamlItem = projectItem; } }
public static string SampleDataSetGuidFromType(Type type) { if (type == (Type)null || type.FullName == null || !DataSetContext.DesignTimeClrNamespacePrefixMatchesDataSetContext(type.FullName)) { return((string)null); } return(((SampleDataSetAttribute)type.GetCustomAttributes(typeof(SampleDataSetAttribute), false)[0]).Guid); }
public static string GetClrNamespacePrefix(DataSetType dataSetType, string rootNamespace) { if (string.IsNullOrEmpty(rootNamespace)) { return(DataSetContext.ClrNamespacePrefixBaseFromDataSetType(dataSetType)); } return(rootNamespace + "." + DataSetContext.ClrNamespacePrefixBaseFromDataSetType(dataSetType)); }
public SampleDataCollection(ProjectContext projectContext, IMSBuildProject msBuildProject, IExpressionInformationService expressionInformationService) { this.projectContext = projectContext; this.msBuildProject = msBuildProject; this.expressionInformationService = expressionInformationService; this.sampleDataClrNamespacePrefix = DataSetContext.GetClrNamespacePrefix(DataSetType.SampleDataSet, this.projectContext.RootNamespace); this.dataStoreClrNamespacePrefix = DataSetContext.GetClrNamespacePrefix(DataSetType.DataStoreSet, this.projectContext.RootNamespace); }
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); }
public SampleDataSet CreateSampleDataSet(DataSetContext dataSetContext, string name, bool enableAtRuntime) { string sampleDataSetName = this.GetUniqueSampleDataSetName(name); if (string.IsNullOrEmpty(sampleDataSetName)) { return((SampleDataSet)null); } SampleDataSet dataSet = this.InstantiateSampleDataSet(dataSetContext, sampleDataSetName, enableAtRuntime); this.dataSets.Add(dataSet); this.OnSampleDataAdded(dataSet); return(dataSet); }
protected SampleDataSet InstantiateSampleDataSet(DataSetContext dataSetContext, string name, bool enableAtRuntime) { return(new SampleDataSet(dataSetContext, name, enableAtRuntime, this.projectContext, this.msBuildProject, this.expressionInformationService)); }
private static SampleDataCollection.SampleDataSetProjectInfo GetOrCreateSampleDataSetInfo(DataSetContext dataSetContext, string name, List <SampleDataCollection.SampleDataSetProjectInfo> collection) { for (int index = 0; index < collection.Count; ++index) { SampleDataCollection.SampleDataSetProjectInfo dataSetProjectInfo = collection[index]; if (dataSetProjectInfo.Name == name) { return(dataSetProjectInfo); } } SampleDataCollection.SampleDataSetProjectInfo dataSetProjectInfo1 = new SampleDataCollection.SampleDataSetProjectInfo(); dataSetProjectInfo1.DataSetContext = dataSetContext; dataSetProjectInfo1.Name = name; collection.Add(dataSetProjectInfo1); return(dataSetProjectInfo1); }
public string GetClrNamespacePrefix(string rootNamespace) { return(DataSetContext.GetClrNamespacePrefix(this.DataSetType, rootNamespace)); }