示例#1
0
        //---------------------------------------------------------------------

        /// <summary>
        /// Saves the dataset to a file, and associates that file with the
        /// dataset.
        /// </summary>
        public void SaveAs(string path)
        {
            if (path == null)
            {
                throw new ArgumentNullException();
            }
            if (path.Trim(null) == "")
            {
                throw new ArgumentException();
            }

            PersistentDataset persistentDataset = new PersistentDataset();

            foreach (ExtensionInfo extensionInfo in plugIns)
            {
                persistentDataset.PlugIns.Add(extensionInfo.PersistentInfo);
            }
            persistentDataset.Save(path);

            this.path = path;

            if (SavedEvent != null)
            {
                SavedEvent(this);
            }
        }
 //---------------------------------------------------------------------
 private void AssertAreEqual(PersistentDataset.PlugInInfo expected,
     PersistentDataset.PlugInInfo actual)
 {
     Assert.IsNotNull(actual);
     Assert.AreEqual(expected.Name, actual.Name);
     Assert.AreEqual(expected.Version, actual.Version);
     Assert.AreEqual(expected.TypeName, actual.TypeName);
     Assert.AreEqual(expected.AssemblyName, actual.AssemblyName);
     Assert.AreEqual(expected.ClassName, actual.ClassName);
     Assert.AreEqual(expected.UserGuidePath, actual.UserGuidePath);
 }
        //---------------------------------------------------------------------

        private void CreateSaveLoadAndCompareDataset(string                                filename,
                                                     params PersistentDataset.PlugInInfo[] plugIns)
        {
            PersistentDataset dataset = new PersistentDataset();
            foreach (PersistentDataset.PlugInInfo plugIn in plugIns)
            	dataset.PlugIns.Add(plugIn);

            string path = Data.MakeOutputPath(filename);
            dataset.Save(path);

            PersistentDataset dataset2;
            dataset2 = PersistentDataset.Load(path);

            AssertAreEqual(dataset, dataset2);
        }
示例#4
0
        //---------------------------------------------------------------------

        /// <summary>
        /// Initializes a new instance by loading the dataset from a file.
        /// </summary>
        /// <param name="path">
        /// Path to the file where the dataset is stored
        /// </param>
        public Dataset(string path)
        {
            if (path == null)
            {
                throw new ArgumentNullException();
            }
            if (path.Trim(null) == "")
            {
                throw new ArgumentException("path is empty or just whitespace.");
            }

            this.path = path;
            PersistentDataset dataset = PersistentDataset.Load(path);

            plugIns = new List <ExtensionInfo>();
            foreach (PersistentDataset.PlugInInfo info in dataset.PlugIns)
            {
                plugIns.Add(new ExtensionInfo(info));
            }
        }
 //---------------------------------------------------------------------
 private void AssertAreEqual(PersistentDataset expected,
     PersistentDataset actual)
 {
     Assert.IsNotNull(actual);
     AssertAreEqual(expected.PlugIns, actual.PlugIns);
 }
示例#6
0
        //---------------------------------------------------------------------

        /// <summary>
        /// Saves the dataset to a file, and associates that file with the
        /// dataset.
        /// </summary>
        public void SaveAs(string path)
        {
        	if (path == null)
        		throw new ArgumentNullException();
        	if (path.Trim(null) == "")
        		throw new ArgumentException();

        	PersistentDataset persistentDataset = new PersistentDataset();
        	foreach (ExtensionInfo extensionInfo in plugIns)
        		persistentDataset.PlugIns.Add(extensionInfo.PersistentInfo);
        	persistentDataset.Save(path);
        	
        	this.path = path;

        	if (SavedEvent != null)
        	    SavedEvent(this);
        }