Пример #1
0
        public void Merge(string[] filePathList)
        {
            foreach (var filePath in filePathList)
            {
                Action <Task <bool> > continuationAction = x =>
                {
                    try
                    {
                        var result = x.Result;
                        if (result)
                        {
                            MergeResult?.Invoke(result, $"マージに成功しました。 : {filePath}");
                        }
                        else
                        {
                            MergeResult?.Invoke(result, $"マージに失敗しました。 : {filePath}");
                        }
                    }
                    catch (Exception)
                    {
                        MergeResult?.Invoke(false, $"マージに失敗しました。 : {filePath}");
                    }
                };

                var info = new FileInfo(filePath);
                Func <string, bool> mergeFunc = null;
                if (info.Name == Path.GetFileName(PluginSettings.Paths.EnemyDataFileName))
                {
                    mergeFunc = this.EnemyData.Merge;
                }
                else if (info.Name == Path.GetFileName(PluginSettings.Paths.MasterDataFileName))
                {
                    mergeFunc = Master.Current.Merge;
                }

                if (mergeFunc != null)
                {
                    Task.Run(() => mergeFunc(filePath))
                    .ContinueWith(continuationAction, TaskScheduler.FromCurrentSynchronizationContext());
                }
                else
                {
                    this.MergeResult?.Invoke(false, "マージ対象のファイル名ではありません。");
                }
            }
        }
Пример #2
0
        public void Merge(string[] filePathList)
        {
            foreach (var filePath in filePathList)
            {
                Action <Task <bool> > continuationAction = x =>
                {
                    try
                    {
                        var result = x.Result;
                        if (result)
                        {
                            MergeResult?.Invoke(result, $"マージに成功しました。 : {filePath}");
                        }
                        else
                        {
                            MergeResult?.Invoke(result, $"マージに失敗しました。 : {filePath}");
                        }
                    }
                    catch (Exception)
                    {
                        MergeResult?.Invoke(false, $"マージに失敗しました。 : {filePath}");
                    }
                };

                var info = new FileInfo(filePath);
                if (info.Name == Settings.Default.EnemyDataFilePath)
                {
                    this.EnemyData.Merge(filePath)
                    .ContinueWith(continuationAction, TaskScheduler.FromCurrentSynchronizationContext());
                }
                else if (info.Name == Settings.Default.MasterDataFilePath)
                {
                    Master.Current.Merge(filePath)
                    .ContinueWith(continuationAction, TaskScheduler.FromCurrentSynchronizationContext());
                }
                else
                {
                    MergeResult?.Invoke(false, "マージ対象のファイル名ではありません。");
                }
            }
        }