Exemple #1
0
        async public Task <string> Initialize()
        {
            StringBuilder output = new StringBuilder();
            await Task.Run(() => {
                List <DataRoot> roots = new List <DataRoot>();
                ProcessStatus status  = new ProcessStatus();

                Assembly assembly  = Assembly.GetExecutingAssembly();
                string[] resources = assembly.GetManifestResourceNames();

                foreach (string resource in resources)
                {
                    if (!resource.EndsWith(".xml"))
                    {
                        continue;
                    }
                    status.Message = Translator.Translate("Loading game data...");
                    Progress.Report(status);
                    using (Stream stream = assembly.GetManifestResourceStream(resource)) {
                        DataRoot data = DataRoot.FromXml(stream);
                        output.AppendLine(data.ToXml());
                        roots.Add(data);
                    }
                }
                status.MaxValue = roots.Count;
                for (int i = 0; i < roots.Count; i++)
                {
                    status.Value   = i;
                    status.Message = i.ToString();
                    Progress.Report(status);
                }
            });

            return(output.ToString());
        }