Exemplo n.º 1
0
        public IModel Import(string filePath)
        {
            try
            {
                return
                    (_modelWriter.Write(
                         _valueParser.Parse(
                             _valueReader.Read(
                                 _fileStreamer.GetStream(filePath)))));
            }
            catch (Exception e)
            {
                string addedContext = default;

                foreach (var f in this.GetType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic))
                {
                    if (f.GetValue(this) is IStateInfoProvider i)
                    {
                        addedContext += i.StateInfo;
                    }
                }

                if (addedContext != default)
                {
                    throw new Exception($"{e.Message} {addedContext}", e);
                }
                else
                {
                    throw;
                }
            }
        }