LoadXml() public method

引数に指定された XML ファイルから、ユーザ毎の設定情報をロード します。
public LoadXml ( string path ) : bool
path string
return bool
Example #1
0
        /* ----------------------------------------------------------------- */
        ///
        /// SetupUserSetting
        ///
        /// <summary>
        /// プログラムに指定された引数等を用いて、UserSetting オブジェクトを
        /// 初期化します。
        /// </summary>
        ///
        /* ----------------------------------------------------------------- */
        private static void SetupUserSetting(UserSetting setting, CubePdf.Settings.CommandLine cmdline)
        {
            var docname = cmdline.Options.ContainsKey("DocumentName") ? cmdline.Options["DocumentName"] : "";
            bool is_config = false;
            try
            {
                if (!string.IsNullOrEmpty(docname) &&
                    IoEx.Path.GetExtension(docname) == setting.Extension &&
                    IoEx.File.Exists(docname))
                {
                    is_config = true;
                }
            }
            catch (Exception err)
            {
                // docname に Windows のファイル名に使用できない記号が含まれる
                // 場合に例外が送出されるので、その対策。
                CubePdf.Message.Trace(err.ToString());
                is_config = false;
            }

            if (is_config) setting.LoadXml(docname);
            else
            {
                LoadUserSetting(setting, cmdline);
                var filename = DocumentName.CreateFileName(docname);
                if (filename != null)
                {
                    string ext = Parameter.GetExtension((Parameter.FileTypes)setting.FileType);
                    filename = IoEx.Path.ChangeExtension(filename, ext);
                    string dir = "";
                    if (setting.OutputPath == String.Empty) dir = setting.LibPath;
                    else
                    {
                        dir = (IoEx.Directory.Exists(setting.OutputPath)) ?
                            setting.OutputPath : IoEx.Path.GetDirectoryName(setting.OutputPath);
                    }
                    setting.OutputPath = dir + '\\' + filename;
                    CubePdf.Message.Debug(setting.OutputPath);
                }
            }

            setting.UserName = cmdline.Options.ContainsKey("UserName") ? cmdline.Options["UserName"] : "";
            setting.InputPath = cmdline.Options.ContainsKey("InputFile") ? cmdline.Options["InputFile"] : "";
            setting.DeleteOnClose = cmdline.Options.ContainsKey("DeleteOnClose");

            if (IoEx.Directory.Exists(setting.LibPath))
                System.Environment.SetEnvironmentVariable("TEMP", setting.LibPath, EnvironmentVariableTarget.Process);
            else CubePdf.Message.Trace("LibPath Not Found");
        }