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;
            }
        }
 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);
 }
        private bool LoadSampleDataSetFromProjectInfo(SampleDataCollection.SampleDataSetProjectInfo sampleDataInfo)
        {
            if (sampleDataInfo.XsdItem == null || sampleDataInfo.XamlItem == null || (!Microsoft.Expression.Framework.Documents.PathHelper.FileExists(sampleDataInfo.XsdItem.DocumentReference.Path) || !Microsoft.Expression.Framework.Documents.PathHelper.FileExists(sampleDataInfo.XamlItem.DocumentReference.Path)))
            {
                return(false);
            }
            bool          enableAtRuntime = !string.Equals(sampleDataInfo.XamlItem.Properties["BuildAction"], SampleDataSet.DesignTimeBuildType);
            SampleDataSet dataSet         = this.InstantiateSampleDataSet(sampleDataInfo.DataSetContext, sampleDataInfo.Name, enableAtRuntime);

            dataSet.Load();
            if (!dataSet.IsValid)
            {
                dataSet.Close();
                return(false);
            }
            this.dataSets.Add(dataSet);
            this.OnSampleDataAdded(dataSet);
            return(true);
        }