コード例 #1
0
 /// <summary>
 /// Saves the <see cref="DbConnectionSettings"/> to file.
 /// </summary>
 public void Save()
 {
     using (var writer = GenericValueWriter.Create(FilePath, _rootNodeName, EncodingFormat))
     {
         ((IPersistable)this).WriteState(writer);
     }
 }
コード例 #2
0
 /// <summary>
 /// Writes the stats to a file.
 /// </summary>
 /// <param name="filePath">The file path to write to.</param>
 public void Write(string filePath)
 {
     using (var writer = GenericValueWriter.Create(filePath, _rootNodeName, EncodingFormat))
     {
         Write(writer);
     }
 }
コード例 #3
0
ファイル: AudioManager.cs プロジェクト: pashcovich/netgore
        /// <summary>
        /// Writes the audio values to file.
        /// </summary>
        /// <param name="fileName">The name of the file.</param>
        /// <param name="rootNode">The name of the root node.</param>
        /// <param name="values">The values to write.</param>
        internal static void WriteValues(string fileName, string rootNode, IEnumerable <KeyValuePair <string, int> > values)
        {
            // Save to Dev
            var devPath = ContentPaths.Dev.Data.Join(fileName + EngineSettings.DataFileSuffix);

            using (var w = GenericValueWriter.Create(devPath, rootNode))
            {
                w.WriteManyNodes("Items", values, WriteValue);
            }

            // Copy from Dev to Build
            var buildPath = ContentPaths.Build.Data.Join(fileName + EngineSettings.DataFileSuffix);

            try
            {
                File.Copy(devPath, buildPath, true);
            }
            catch (Exception ex)
            {
                const string errmsg = "Failed to copy file to ContentPaths.Build (`{0}` to `{1}`). Exception: {2}";
                if (log.IsErrorEnabled)
                {
                    log.ErrorFormat(errmsg, devPath, buildPath, ex);
                }
                Debug.Fail(string.Format(errmsg, devPath, buildPath, ex));
            }
        }
コード例 #4
0
        public void XmlTest()
        {
            var filePath = Path.GetTempFileName();

            try
            {
                using (
                    var writer = GenericValueWriter.Create(format: GenericValueIOFormat.Xml, filePath: filePath,
                                                           rootNodeName: "Root"))
                {
                    writer.Write("Test", "asdf");
                }

                var reader = GenericValueReader.CreateFromFile(filePath, "Root");
                var s      = reader.ReadString("Test");
                Assert.AreEqual("asdf", s);
            }
            finally
            {
                if (File.Exists(filePath))
                {
                    File.Delete(filePath);
                }
            }
        }
コード例 #5
0
ファイル: SchemaReader.cs プロジェクト: thepirateclub/netgore
        /// <summary>
        /// Saves the values to the specified file path.
        /// </summary>
        /// <param name="filePath">The file path.</param>
        public void Save(string filePath)
        {
            var tables = _tableSchemas.ToArray();

            using (var writer = GenericValueWriter.Create(filePath, _rootNodeName, EncodingFormat))
            {
                writer.WriteManyNodes(_tablesNodeName, tables, (w, table) => table.Write(w));
            }
        }
コード例 #6
0
        /// <summary>
        /// Saves the <see cref="ParticleEffectManager"/> to file.
        /// </summary>
        /// <param name="contentPath">The <see cref="ContentPaths"/> to save to.</param>
        public void Save(ContentPaths contentPath)
        {
            var filePath = GetFilePath(contentPath);

            using (var writer = GenericValueWriter.Create(filePath, _rootNodeName, EncodingFormat))
            {
                writer.WriteManyNodes(_particleEffectsNodeName, _effects.Values, (w, v) => v.WriteState(w));
            }
        }
コード例 #7
0
        /// <summary>
        /// Saves the <see cref="NPCChatDialogBase"/>s in this <see cref="NPCChatManagerBase"/> to file.
        /// </summary>
        /// <param name="contentPath">The content path.</param>
        public void Save(ContentPaths contentPath)
        {
            var dialogs = _npcChatDialogs.Where(x => x != null);

            // Write
            var filePath = GetFilePath(contentPath);

            using (var writer = GenericValueWriter.Create(filePath, _rootNodeName, EncodingFormat))
            {
                writer.WriteManyNodes(_chatDialogsNodeName, dialogs, ((w, item) => item.Write(w)));
            }
        }
コード例 #8
0
        /// <summary>
        /// Saves the settings to file.
        /// </summary>
        /// <param name="filePath">The file path to save to.</param>
        public void Save(string filePath)
        {
            var kvps     = _tools.ToArray();
            var toolBars = ToolBar.ToolBars;

            lock (_saveSync)
            {
                using (var writer = GenericValueWriter.Create(filePath, _rootNodeName, EncodingFormat))
                {
                    writer.WriteManyNodes(_toolSettingsNodeName, kvps, WriteKVP);
                    writer.WriteManyNodes(_toolBarItemsNodeName, toolBars, WriteToolBarItems);
                }
            }
        }
コード例 #9
0
ファイル: ScriptAssemblyCache.cs プロジェクト: wtfcolt/game
        /// <summary>
        /// Saves the cache data.
        /// </summary>
        void Save()
        {
            lock (_cacheSync)
            {
                if (!_isDirty)
                {
                    return;
                }

                var items = _cache.Values.ToImmutable();
                using (var w = GenericValueWriter.Create(CacheDataFilePath, _rootNodeName, EncodingFormat))
                {
                    w.WriteManyNodes(_cacheItemNodeName, items, (x, y) => y.Write(x));
                }
            }
        }
コード例 #10
0
ファイル: GrhInfo.cs プロジェクト: wtfcolt/game
        /// <summary>
        /// Saves all of the GrhData information to the specified file.
        /// </summary>
        /// <param name="contentPath">ContentPath to save the GrhData to.</param>
        public static void Save(ContentPaths contentPath)
        {
            // Grab the GrhDatas by their type
            var gds = GrhDatas.Where(x => x != null).OrderBy(x => x.Categorization.ToString(), StringComparer.OrdinalIgnoreCase);
            var stationaryGrhDatas   = gds.OfType <StationaryGrhData>().ToImmutable();
            var animatedGrhDatas     = gds.OfType <AnimatedGrhData>().ToImmutable();
            var autoAnimatedGrhDatas = gds.OfType <AutomaticAnimatedGrhData>().ToImmutable();

            // Write
            var path = GetGrhDataFilePath(contentPath);

            using (IValueWriter writer = GenericValueWriter.Create(path, _rootNodeName, EncodingFormat))
            {
                writer.WriteManyNodes(_nonAnimatedGrhDatasNodeName, stationaryGrhDatas, ((w, item) => item.Write(w)));
                writer.WriteManyNodes(_animatedGrhDatasNodeName, animatedGrhDatas, ((w, item) => item.Write(w)));
                writer.WriteManyNodes(_autoAnimatedGrhDatasNodeName, autoAnimatedGrhDatas, ((w, item) => item.Write(w)));
            }
        }
コード例 #11
0
ファイル: Skeleton.cs プロジェクト: thepirateclub/netgore
        public void Write(string filePath)
        {
            if (filePath == null)
            {
                throw new ArgumentNullException("filePath");
            }

            // Validate the skeleton
            if (!IsValid())
            {
                throw new InvalidOperationException("Skeleton returned false for IsValid().");
            }

            // Write the file
            using (var writer = GenericValueWriter.Create(filePath, _rootNodeName, EncodingFormat))
            {
                Write(writer);
            }
        }