Example #1
0
        public static async Task ImportConditionsAsync(this OGLContext context)
        {
            context.Conditions.Clear();
            context.ConditionsSimple.Clear();
            var files = await PCLSourceManager.EnumerateFilesAsync(context, context.Config.Conditions_Directory).ConfigureAwait(false);

            foreach (var f in files)
            {
                try
                {
                    using (Stream reader = await f.Key.OpenAsync(FileAccess.Read).ConfigureAwait(false))
                    {
                        OGL.Condition s = (OGL.Condition)OGL.Condition.Serializer.Deserialize(reader);
                        s.Source = f.Value;
                        s.Register(context, f.Key.Path);
                    }
                }
                catch (Exception e)
                {
                    ConfigManager.LogError("Error reading " + Path(f.Key.Path), e);
                }
            }
        }