Esempio n. 1
0
        public static ValidatedExportResult ValidatedExport(string baseFolderPath, ExportSetting setting, bool forceExport = false, bool forceOpenScene = false)
        {
            if (setting == null)
            {
                throw new ArgumentNullException("Argument `setting` is null.");
            }
            if (baseFolderPath == null)
            {
                throw new ArgumentNullException("Argument `baseFolderPath` is null.");
            }
            var exportFolderPath = setting.ExportFolderPath;

            if (string.IsNullOrEmpty(exportFolderPath) || !exportFolderPath.StartsWith("Assets"))
            {
                throw new ArgumentNullException("Invalid export folder path:" + exportFolderPath);
            }
            ExportSettingStock settingStock = new ExportSettingStock(setting);
            var result = new ValidatedExportResult(forceExport);

            //validate
            if (!forceExport)
            {
                if (!string.IsNullOrEmpty(setting.ruleSetName))
                {
                    var ruleSet = GetRuleSet(setting.ruleSetName);
                    if (ruleSet == null)
                    {
                        result.log += string.Format("ルールチェック中に問題が発生しました。" + "ルール{0}が見つかりませんでした。", setting.ruleSetName);
                        return(result);
                    }
                    try
                    {
                        result.validationResults = Validator.Validator.Validate(ruleSet, baseFolderPath, forceOpenScene);
                    }
                    catch (FatalValidationErrorException e)
                    {
                        result.log += "ルールチェック中に問題が発生しました。" + System.Environment.NewLine + e.Message;
                        return(result);
                    }
                    if (!result.HasValidationIssues(setting.ignoreValidationWarning ? IssueLevel.Error : IssueLevel.Warning))
                    {
                        result.log += "ルールチェックで問題が発見されました。" + System.Environment.NewLine;
                        return(result);
                    }
                }
                else
                {
                    result.log += "ルールセット指定がないため事前チェックを省略します。" + System.Environment.NewLine;
                }
            }

            //export
            result.exportResult = Exporter.Exporter.Export(baseFolderPath, settingStock.GetSetting(), forceExport);
            if (!result.IsExportSuccess)
            {
                result.log += "エクスポートに失敗しました。" + System.Environment.NewLine;
            }
            return(result);
        }
        public static ValidatedExportResult ValidatedExport(string baseFolderPath, ExportSetting setting, bool forceExport = false, bool forceOpenScene = false)
        {
            if (setting == null)
            {
                throw new ArgumentNullException("Argument `setting` is null.");
            }
            if (baseFolderPath == null)
            {
                throw new ArgumentNullException("Argument `baseFolderPath` is null.");
            }
            var exportFolderPath = setting.ExportFolderPath;

            if (string.IsNullOrEmpty(exportFolderPath) || !exportFolderPath.StartsWith("Assets"))
            {
                throw new ArgumentNullException("Invalid export folder path:" + exportFolderPath);
            }
            ExportSettingStock settingStock = new ExportSettingStock(setting);
            var result = new ValidatedExportResult(forceExport);

            //validate
            if (!forceExport)
            {
                if (!string.IsNullOrEmpty(setting.ruleSetName))
                {
                    var ruleSet = GetRuleSet(setting.ruleSetName);
                    if (ruleSet == null)
                    {
                        result.log += LocalizedMessage.Get("ValidatedExporter.ProblemOccurredWhileValidating") +
                                      LocalizedMessage.Get("ValidatedExporter.RuleNotFound", setting.ruleSetName);
                        return(result);
                    }
                    try
                    {
                        result.validationResults = Validator.Validator.Validate(ruleSet, baseFolderPath, forceOpenScene);
                    }
                    catch (FatalValidationErrorException e)
                    {
                        result.log += LocalizedMessage.Get("ValidatedExporter.ProblemOccurredWhileValidating")
                                      + System.Environment.NewLine + e.Message;
                        return(result);
                    }
                    if (!result.HasValidationIssues(setting.ignoreValidationWarning ? IssueLevel.Error : IssueLevel.Warning))
                    {
                        result.log += LocalizedMessage.Get("ValidatedExporter.IssueFound") + System.Environment.NewLine;
                        return(result);
                    }
                }
                else
                {
                    result.log += LocalizedMessage.Get("ValidatedExporter.SkipValidation") + System.Environment.NewLine;
                }
            }

            //export
            result.exportResult = Exporter.Exporter.Export(baseFolderPath, settingStock.GetSetting(), forceExport);
            if (!result.IsExportSuccess)
            {
                result.log += LocalizedMessage.Get("ValidatedExporter.Failed") + System.Environment.NewLine;
            }
            return(result);
        }