예제 #1
0
        public async Task Bake(ISheetImporter importer, TimeZoneInfo timeZoneInfo)
        {
            AllSheets.Clear();

            var context = new SheetConvertingContext
            {
                Container    = this,
                Logger       = _logger,
                TimeZoneInfo = timeZoneInfo
            };

            var sheetProps = GetType()
                             .GetProperties(BindingFlags.Instance | BindingFlags.Public)
                             .Where(p => p.PropertyType.IsSubclassOf(typeof(Sheet)));

            var success = await importer.Load();

            if (!success)
            {
                _logger.LogError($"Failed to import");
                return;
            }

            foreach (var prop in sheetProps)
            {
                var data = importer.GetData(prop.Name);
                if (data == null)
                {
                    _logger.LogError($"Failed to find sheet: {prop.Name}");
                    continue;
                }

                var rawSheet = new RawSheet(data);
                var sheet    = Activator.CreateInstance(prop.PropertyType) as Sheet;
                sheet.ConvertFromRaw(rawSheet, context);
                prop.SetValue(this, sheet);

                sheet.Name = prop.Name;
                AllSheets.Add(sheet);
            }

            PostLoad(context);

            IsLoaded = true;
        }
예제 #2
0
 internal abstract void ConvertFromRaw(RawSheet gsheet, SheetConvertingContext context);