Example #1
0
        public override string ToString()
        {
            Type          type          = this.GetType();
            SampleDataSet sampleDataSet = SampleDataSet.SampleDataSetFromType(type);

            return(sampleDataSet == null ? type.Name : sampleDataSet.ClrNamespace + "." + type.Name);
        }
Example #2
0
        private void Refresh(SampleDataSet changedSampleData)
        {
            List <DocumentNode> list = (List <DocumentNode>)null;

            foreach (KeyValuePair <DocumentNode, ISchema> keyValuePair in this.schemaCache)
            {
                ClrObjectSchema clrObjectSchema = keyValuePair.Value as ClrObjectSchema;
                if (clrObjectSchema != null)
                {
                    Type typeForDataSource = this.GetTypeForDataSource(keyValuePair.Key);
                    if (typeForDataSource != (Type)null && clrObjectSchema.Root.Type != typeForDataSource)
                    {
                        if (list == null)
                        {
                            list = new List <DocumentNode>();
                        }
                        list.Add(keyValuePair.Key);
                    }
                }
            }
            if (list != null)
            {
                foreach (DocumentNode key in list)
                {
                    this.schemaCache.Remove(key);
                }
            }
            this.designDataManager.Refresh(changedSampleData);
            if (this.ClrObjectSchemasInvalidated == null)
            {
                return;
            }
            this.ClrObjectSchemasInvalidated((object)this, EventArgs.Empty);
        }
Example #3
0
        public void AddCollection()
        {
            if (!this.schemaItem.Schema.DataSource.IsSampleDataSource)
            {
                return;
            }
            SampleDataSet       sampleData    = this.schemaItem.Schema.DataSource.SampleData;
            SampleCompositeType effectiveType = this.DataSchemaNode.EffectiveType;

            if (effectiveType == null)
            {
                return;
            }
            this.model.SelectionContext.Clear();
            string uniquePropertyName           = effectiveType.GetUniquePropertyName("Collection");
            string uniqueTypeName               = sampleData.GetUniqueTypeName(uniquePropertyName + "Item");
            SampleCompositeType  compositeType  = sampleData.CreateCompositeType(uniqueTypeName);
            SampleCollectionType collectionType = sampleData.CreateCollectionType((SampleNonBasicType)compositeType);

            effectiveType.AddProperty(uniquePropertyName, (SampleType)collectionType);
            string schemaNodePath = DataSchemaItem.ProvideNodePathForPendingEdit(this, uniquePropertyName);

            this.model.RenameSampleDataSchemaItemUponRebuild(this.schemaItem.Schema.DataSource, schemaNodePath);
            this.model.ExtendSelectionUponRebuild(this.schemaItem.Schema.DataSource, schemaNodePath);
            this.IsExpanded = true;
            using (TemporaryCursor.SetWaitCursor())
                sampleData.CommitChanges(this.ViewModel.DesignerContext.MessageDisplayService);
        }
Example #4
0
        public void MakeHierarchicalCollection()
        {
            if (!this.schemaItem.Schema.DataSource.IsSampleDataSource)
            {
                return;
            }
            SampleDataSet       sampleData    = this.schemaItem.Schema.DataSource.SampleData;
            SampleCompositeType effectiveType = this.DataSchemaNode.EffectiveType;

            if (effectiveType == null)
            {
                return;
            }
            this.model.SelectionContext.Clear();
            SampleNonBasicType sampleNonBasicType   = (SampleNonBasicType)this.DataSchemaNode.SampleType;
            string             uniquePropertyName1  = effectiveType.GetUniquePropertyName(this.DataSchemaNode.PathName);
            SampleProperty     hierarchicalProperty = effectiveType.AddProperty(uniquePropertyName1, (SampleType)sampleNonBasicType);
            SampleProperty     sampleProperty       = this.DataSchemaNode.EffectiveParentType.GetSampleProperty(this.DataSchemaNode.PathName);
            string             uniquePropertyName2  = DataSchemaItem.GetUniquePropertyName(sampleProperty, hierarchicalProperty, uniquePropertyName1);
            string             schemaNodePath       = DataSchemaItem.ProvideNodePathForPendingEdit(this, uniquePropertyName2, sampleProperty, hierarchicalProperty);

            sampleProperty.Rename(uniquePropertyName2);
            hierarchicalProperty.Rename(uniquePropertyName2);
            this.model.RenameSampleDataSchemaItemUponRebuild(this.schemaItem.Schema.DataSource, schemaNodePath);
            this.model.ExtendSelectionUponRebuild(this.schemaItem.Schema.DataSource, schemaNodePath);
            this.IsExpanded = true;
            using (TemporaryCursor.SetWaitCursor())
                sampleData.CommitChanges(this.ViewModel.DesignerContext.MessageDisplayService);
        }
 public SampleImageConfiguration(SampleDataSet sampleData, string formatParameters)
 {
     this.projectContext         = (IProjectContext)sampleData.ProjectContext;
     this.fallbackImageDirectory = sampleData.FallbackImageFolder;
     this.SetConfigurationValue(ConfigurationPlaceholder.ImageFolderBrowser, (object)formatParameters);
     this.index = -1;
 }
Example #6
0
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            DataSchemaItem dataSchemaItem = values[0] as DataSchemaItem;
            bool           flag           = values.Length == 2 && (bool)values[1];

            if (dataSchemaItem != null)
            {
                if (dataSchemaItem.IsHierarchicalCollection)
                {
                    return((object)this.hierarchicalCollectionImage);
                }
                if (dataSchemaItem.DataSchemaNode.IsCollection)
                {
                    if (!flag)
                    {
                        return((object)this.detailsCollectionImage);
                    }
                    return((object)this.masterCollectionImage);
                }
                if (dataSchemaItem.HasChildren)
                {
                    return((object)this.compositeImage);
                }
                if (SampleDataSet.SampleDataTypeFromType(dataSchemaItem.DataSchemaNode.Type) is SampleCompositeType)
                {
                    return((object)this.compositeImage);
                }
            }
            return((object)null);
        }
        private IEnumerable <DataStoreReferenceEntry> FindDataStoreReferenceDictionary(SceneDocument document)
        {
            List <DataStoreReferenceEntry>    list = (List <DataStoreReferenceEntry>)null;
            ResourceDictionaryContentProvider dictionaryContentProvider = this.GetResourceDictionaryContentProvider(document);

            if (dictionaryContentProvider != null)
            {
                foreach (DocumentNode documentNode1 in dictionaryContentProvider.Items)
                {
                    DocumentCompositeNode documentCompositeNode = documentNode1 as DocumentCompositeNode;
                    if (documentCompositeNode != null)
                    {
                        DocumentNode documentNode2 = documentCompositeNode.Properties[DictionaryEntryNode.ValueProperty];
                        if (documentNode2 != null)
                        {
                            SampleDataSet sampleDataSet = SampleDataSet.SampleDataSetFromType(documentNode2.Type.RuntimeType);
                            if (sampleDataSet != null && sampleDataSet.Context == DataSetContext.DataStore)
                            {
                                if (list == null)
                                {
                                    list = new List <DataStoreReferenceEntry>();
                                }
                                DataStoreReferenceEntry storeReferenceEntry = new DataStoreReferenceEntry()
                                {
                                    DataStore           = sampleDataSet,
                                    DictionaryEntryNode = documentCompositeNode
                                };
                                list.Add(storeReferenceEntry);
                            }
                        }
                    }
                }
            }
            return((IEnumerable <DataStoreReferenceEntry>)list);
        }
        private void SafelyRemoveSampleDataAndRootFolder(SampleDataSet dataSet, bool forceDeleteFiles)
        {
            dataSet.Close();
            if (forceDeleteFiles)
            {
                SampleDataCollection.DeleteFolder(dataSet.SampleDataFolder, false);
            }
            else
            {
                SampleDataCollection.DeleteFolder(dataSet.AssetFilesFolder, true);
                SampleDataCollection.DeleteFolder(dataSet.SampleDataFolder, true);
            }
            this.OnSampleDataRemoving(dataSet);
            this.dataSets.Remove(dataSet);
            if (Enumerable.FirstOrDefault <SampleDataSet>(Enumerable.Where <SampleDataSet>((IEnumerable <SampleDataSet>) this.dataSets, (Func <SampleDataSet, bool>)(item => item.Context == dataSet.Context))) != null)
            {
                return;
            }
            string       path        = Path.Combine(Path.GetDirectoryName(this.projectContext.ProjectPath), dataSet.Context.DataRootFolder);
            IProject     project     = (IProject)this.projectContext.GetService(typeof(IProject));
            IProjectItem projectItem = project.FindItem(DocumentReference.Create(path));

            if (projectItem == null || Enumerable.FirstOrDefault <IProjectItem>(projectItem.Children) != null)
            {
                return;
            }
            project.RemoveItems(0 != 0, projectItem);
            SampleDataCollection.DeleteFolder(dataSet.Context.DataRootFolder, true);
        }
        public IType GetSampleType(IXmlNamespace xmlNamespace, string typeName)
        {
            if (this.dataSets.Count == 0)
            {
                return((IType)null);
            }
            string clrNamespace;
            string assemblyName;

            if (!XamlParser.TryParseClrNamespaceUri(xmlNamespace.Value, out clrNamespace, out assemblyName))
            {
                return((IType)null);
            }
            if (!clrNamespace.StartsWith(this.sampleDataClrNamespacePrefix, StringComparison.Ordinal) && !clrNamespace.StartsWith(this.dataStoreClrNamespacePrefix, StringComparison.Ordinal))
            {
                return((IType)null);
            }
            SampleDataSet sampleDataSet1 = this.GetSampleDataSet(clrNamespace.Substring(this.sampleDataClrNamespacePrefix.Length), true);

            if (sampleDataSet1 != null)
            {
                return(sampleDataSet1.GetSampleType(xmlNamespace, typeName));
            }
            SampleDataSet sampleDataSet2 = this.GetSampleDataSet(clrNamespace.Substring(this.dataStoreClrNamespacePrefix.Length), true);

            if (sampleDataSet2 != null)
            {
                return(sampleDataSet2.GetSampleType(xmlNamespace, typeName));
            }
            return((IType)null);
        }
 private void OnSampleDataRemoving(SampleDataSet dataSet)
 {
     if (this.SampleDataRemoving == null)
     {
         return;
     }
     this.SampleDataRemoving((object)this, new SampleDataEventArgs(dataSet));
 }
Example #11
0
 private void SampleDataSet_TypesChanging(SampleDataSet sender, EventArgs e)
 {
     if (this.SampleTypesChanging == null)
     {
         return;
     }
     this.SampleTypesChanging(sender, e);
 }
 private void OnSampleDataAdded(SampleDataSet dataSet)
 {
     if (this.SampleDataAdded == null)
     {
         return;
     }
     this.SampleDataAdded((object)this, new SampleDataEventArgs(dataSet));
 }
Example #13
0
        public SampleCollectionType(string name, SampleType itemType, SampleDataSet declaringDataSet)
            : base(name, declaringDataSet)
        {
            this.itemSampleType = itemType;
            IType type = this.TypeResolver.ResolveType(PlatformTypes.Object);

            this.baseType = this.TypeResolver.GetType(this.TypeResolver.ResolveType(PlatformTypes.ObservableCollection).RuntimeType.MakeGenericType(type.RuntimeType));
            this.DeclaringDataSet.ThrowIfRecursiveRootType(this.ItemSampleType);
        }
        private string CreateNewProperty(SampleDataSet dataSet, string newProperyName)
        {
            string                uniqueTypeName = dataSet.GetUniqueTypeName(newProperyName);
            SampleProperty        sampleProperty = dataSet.RootType.AddProperty(uniqueTypeName, (SampleType)SampleBasicType.String);
            DocumentCompositeNode newRootNode    = (DocumentCompositeNode)dataSet.RootNode.Clone(dataSet.RootNode.Context);

            newRootNode.Properties[(IPropertyId)sampleProperty] = (DocumentNode)newRootNode.Context.CreateNode(StringTable.DefaultValueDataStore);
            dataSet.CommitChanges(newRootNode, this.ObjectSet.ViewModel.DesignerContext.MessageDisplayService);
            return(uniqueTypeName);
        }
        public SampleDataSet GetSampleDataSet(string name, bool onlyIfDataSetValid)
        {
            SampleDataSet sampleDataSet = Enumerable.FirstOrDefault <SampleDataSet>((IEnumerable <SampleDataSet>) this.dataSets, (Func <SampleDataSet, bool>)(ds => ds.Name == name));

            if (sampleDataSet != null && onlyIfDataSetValid && !sampleDataSet.IsValid)
            {
                sampleDataSet = (SampleDataSet)null;
            }
            return(sampleDataSet);
        }
        public override void OnViewNodeInvalidating(IInstanceBuilderContext context, ViewNode target, ViewNode child, ref bool doesInvalidRootsContainTarget, List <ViewNode> invalidRoots)
        {
            base.OnViewNodeInvalidating(context, target, child, ref doesInvalidRootsContainTarget, invalidRoots);
            DocumentCompositeNode fromXamlDocument = SampleDataSet.SampleDataSetFromType(target.DocumentNode.Type.RuntimeType).ValidRootNodeFromXamlDocument;

            if (fromXamlDocument == null || !this.IsSampleDataXamlContext(context, fromXamlDocument.DocumentRoot))
            {
                return;
            }
            InstanceBuilderOperations.SetInvalid(context, target, ref doesInvalidRootsContainTarget, invalidRoots);
        }
Example #17
0
 public DataStorePropertyEntry(SampleDataSet dataStore, IProperty property, IList <DataStorePropertyEntry> properties)
 {
     this.dataStore             = dataStore;
     this.property              = property;
     this.stringValue           = dataStore.RootNode.GetValue <string>((IPropertyId)this.property);
     this.type                  = DataStorePropertyEntry.DataStoreTypeFromSampleProperty(dataStore.RootType.GetSampleProperty(property.Name));
     this.dirtyState            = DataStorePropertyEntryDirtyStates.None;
     this.propertyName          = property.Name;
     this.cacheValue            = new Dictionary <DataStoreType, string>();
     this.cacheValue[this.type] = this.stringValue;
     this.properties            = properties;
 }
Example #18
0
 private SampleCodeGenerator(SampleDataSet dataSet, string sourceCodeFile, string language)
 {
     if (dataSet.Context == DataSetContext.SampleData)
     {
         this.codeSnippets = language == "VB" ? SampleCodeGenerator.SampleCodeSnippetFactory.VB : SampleCodeGenerator.SampleCodeSnippetFactory.CSharp;
     }
     else if (dataSet.Context == DataSetContext.DataStore)
     {
         this.codeSnippets = language == "VB" ? SampleCodeGenerator.SampleCodeSnippetFactory.DataStoreVB : SampleCodeGenerator.SampleCodeSnippetFactory.DataStoreCSharp;
     }
     this.dataSet        = dataSet;
     this.sourceCodeFile = sourceCodeFile;
 }
        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);
        }
Example #20
0
        private static SampleCompositeType CalculateEffectiveType(Type type)
        {
            SampleNonBasicType sampleNonBasicType = SampleDataSet.SampleDataTypeFromType(type);

            if (sampleNonBasicType != null)
            {
                SampleCollectionType sampleCollectionType;
                while ((sampleCollectionType = sampleNonBasicType as SampleCollectionType) != null)
                {
                    sampleNonBasicType = sampleCollectionType.ItemType as SampleNonBasicType;
                }
            }
            return(sampleNonBasicType as SampleCompositeType);
        }
        public void DeleteSampleDataSet(SampleDataSet dataSet)
        {
            TypesChangedEventArgs e = new TypesChangedEventArgs((ICollection <TypeChangedInfo>) new List <TypeChangedInfo>()
            {
                new TypeChangedInfo(dataSet.RootType.RuntimeAssembly, ModificationType.Modified),
                new TypeChangedInfo(RuntimeGeneratedTypesHelper.BlendDefaultAssembly, ModificationType.Modified)
            });

            this.OnSampleDataRemoving(dataSet);
            this.dataSets.Remove(dataSet);
            dataSet.RemoveFromProjectAndClose();
            this.SafelyRemoveSampleDataAndRootFolder(dataSet, false);
            this.projectContext.OnTypesChanged(e);
        }
        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);
        }
        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);
        }
        private void button_Click(object sender, RoutedEventArgs e)
        {
            ReportDocument report = new ReportDocument();
            report.Load("..\\..\\SampleCrystalReport.rpt");
            using (SampleModel db = new SampleModel())
            {

                SampleDataSet dataset = new SampleDataSet();
                System.Data.DataSet dsCopy = dataset.Copy();

                SampleDataSetTableAdapters.batchTableAdapter adapter = new SampleDataSetTableAdapters.batchTableAdapter();
                adapter.Fill(dataset.batch);
                report.SetDataSource(dataset);

            }
            crystalReportsViewer1.ViewerCore.ReportSource = report;
        }
        public IType GetSampleType(Type type)
        {
            if (this.dataSets.Count == 0)
            {
                return((IType)null);
            }
            SampleNonBasicType sampleType = SampleDataSet.SampleDataTypeFromType(type);

            if (sampleType == null)
            {
                return((IType)null);
            }
            if (this.dataSets.Find((Predicate <SampleDataSet>)(s => s == sampleType.DeclaringDataSet)) == null)
            {
                return((IType)null);
            }
            return((IType)sampleType);
        }
        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);
        }
Example #27
0
        private void ChangeEffectivePropertyIfValid(DataSchemaItem.ModifySamplePropertyOperation operation)
        {
            SampleCompositeType effectiveParentType = this.DataSchemaNode.EffectiveParentType;

            if (effectiveParentType == null)
            {
                return;
            }
            SampleDataSet  declaringDataSet = effectiveParentType.DeclaringDataSet;
            SampleProperty sampleProperty   = effectiveParentType.GetSampleProperty(this.DataSchemaNode.PathName);

            if (sampleProperty == null)
            {
                return;
            }
            operation(effectiveParentType, sampleProperty);
            using (TemporaryCursor.SetWaitCursor())
                declaringDataSet.CommitChanges(this.ViewModel.DesignerContext.MessageDisplayService);
        }
        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 static void PerformTestByTesterAndSample(Type testerType, SampleDataSet <Orders> sampleDataset, ResultGroup resultGroup, int testsToPerform)
        {
            for (var i = 1; i <= testsToPerform; i++)
            {
                // Create the new tester
                var ctor   = testerType.GetConstructor(new[] { typeof(SampleDataSet <Orders>) });
                var tester = (Tester <Orders>)ctor.Invoke(new object[] { sampleDataset });

                // Run test
                Console.WriteLine(String.Format("Testing {0} [Sample Size: {1}]...", tester.Name, tester.SampleDataSet.Size));
                tester.Test();

                // Collect results
                resultGroup.Results.Add(tester.GetResult());

                // Clean up any unused/unreferenced resources.
                tester.Dispose();
                GC.Collect();
            }
        }
Example #30
0
 public static ISampleTypeConfiguration CreateConfiguration(SampleDataSet sampleData, SampleBasicType type, string format, string formatParameters)
 {
     if (type == SampleBasicType.Boolean)
     {
         return((ISampleTypeConfiguration) new SampleBooleanConfiguration());
     }
     if (type == SampleBasicType.Image)
     {
         return((ISampleTypeConfiguration) new SampleImageConfiguration(sampleData, formatParameters));
     }
     if (type == SampleBasicType.Number)
     {
         return((ISampleTypeConfiguration) new SampleNumberConfiguration(formatParameters));
     }
     if (type == SampleBasicType.String)
     {
         return((ISampleTypeConfiguration) new SampleStringConfiguration(format, formatParameters));
     }
     return((ISampleTypeConfiguration)null);
 }
        public override bool Instantiate(IInstanceBuilderContext context, ViewNode viewNode)
        {
            bool flag = viewNode.Instance != null;

            base.Instantiate(context, viewNode);
            if (flag)
            {
                return(false);
            }
            SampleDataSet sampleDataSet = SampleDataSet.SampleDataSetFromType(viewNode.DocumentNode.Type.RuntimeType);

            if (sampleDataSet == null)
            {
                return(!flag);
            }
            DocumentCompositeNode documentCompositeNode = sampleDataSet != null ? sampleDataSet.ValidRootNodeFromXamlDocument : (DocumentCompositeNode)null;

            if (documentCompositeNode == null || !PlatformTypes.PlatformsCompatible((IPlatformMetadata)context.Platform.Metadata, documentCompositeNode.PlatformMetadata) || (this.IsSampleDataXamlContext(context, documentCompositeNode.DocumentRoot) || DesignDataHelper.GetDesignDataFile(viewNode.DocumentNode) != null))
            {
                return(!flag);
            }
            using (StandaloneInstanceBuilderContext instanceBuilderContext = new StandaloneInstanceBuilderContext(context.DocumentContext, context))
            {
                using (instanceBuilderContext.ChangeSerializationContext(context.SerializationContext))
                {
                    ViewNode viewNode1 = this.GetViewNode((IInstanceBuilderContext)instanceBuilderContext, (DocumentNode)documentCompositeNode);
                    viewNode1.Instance = viewNode.Instance;
                    this.Initialize((IInstanceBuilderContext)instanceBuilderContext, viewNode1, true);
                    viewNode1.Instance     = (object)null;
                    viewNode.InstanceState = InstanceState.Valid;
                }
            }
            context.DocumentRootResolver.GetDocumentRoot(documentCompositeNode.DocumentRoot.DocumentContext.DocumentUrl);
            IProperty index           = context.DocumentContext.TypeResolver.ResolveProperty(DesignTimeProperties.SampleDataTagProperty);
            ViewNode  referenceSource = new ViewNode(context.ViewNodeManager, (DocumentNode)documentCompositeNode);

            viewNode.Properties[index] = referenceSource;
            context.ViewNodeManager.AddRelatedDocumentRoot(referenceSource, documentCompositeNode.DocumentRoot);
            return(!flag);
        }