Ejemplo n.º 1
0
        public void Save(System.IO.Stream stream, IO.FileFormat fileFormat, Encoding encoding)
        {
            IFileFormatProvider provider = null;

            if (!FileFormatProviders.TryGetValue(fileFormat, out provider))
            {
                throw new FileFormatNotSupportException("Specified file format is not supported");
            }

            if (this.controlAdapter != null)
            {
                this.controlAdapter.ChangeCursor(CursorStyle.Busy);
            }

            try
            {
                provider.Save(this, stream, encoding, null);
            }
            finally
            {
                if (this.controlAdapter != null)
                {
                    this.controlAdapter.ChangeCursor(CursorStyle.PlatformDefault);
                }

                if (this.WorkbookSaved != null)
                {
                    this.WorkbookSaved(this, null);
                }
            }
        }
Ejemplo n.º 2
0
 public FileLoggerProvider(FileLoggerSettings configuration, IFileFormatProvider fileFormatProvider)
 {
     this.fileFormatProvider = fileFormatProvider;
     _configuration          = configuration;
     _configuration.ChangeToken.RegisterChangeCallback(p =>
     {
         //update loggers settings form new settings
         foreach (var item in this._loggers.Values)
         {
             LoggerOptionsModel model = new LoggerOptionsModel();
             InitLoggerSettings(item.Name, model);
             InitLogger(model, item);
         }
     }, null);
 }
Ejemplo n.º 3
0
        public object Load(System.IO.Stream stream, IO.FileFormat fileFormat, Encoding encoding, object arg)
        {
            object ret = null;

            if (fileFormat == FileFormat._Auto)
            {
                throw new System.ArgumentException("File format 'Auto' is invalid for loading workbook from stream, try specify a file format.");
            }

            IFileFormatProvider provider = null;

            if (!FileFormatProviders.TryGetValue(fileFormat, out provider))
            {
                throw new FileFormatNotSupportException("Specified file format is not supported.");
            }

            if (this.controlAdapter != null)
            {
                this.controlAdapter.ChangeCursor(CursorStyle.Busy);
            }

            if (encoding == null)
            {
                encoding = Encoding.Default;
            }

            try
            {
                ret = provider.Load(this, stream, encoding, arg);
                Recalculate();
                ExpandToContent();
            }
            finally
            {
                if (controlAdapter != null)
                {
                    controlAdapter.ChangeCursor(CursorStyle.PlatformDefault);
                }

                WorkbookLoaded?.Invoke(this, null);
            }
            return(ret);
        }
Ejemplo n.º 4
0
        public void Load(System.IO.Stream stream, IO.FileFormat fileFormat, Encoding encoding, string singleSheet = "")
        {
            if (fileFormat == FileFormat._Auto)
            {
                throw new System.ArgumentException("File format 'Auto' is invalid for loading workbook from stream, try specify a file format.");
            }

            IFileFormatProvider provider = null;

            if (!FileFormatProviders.TryGetValue(fileFormat, out provider))
            {
                throw new FileFormatNotSupportException("Specified file format is not supported.");
            }

            if (this.controlAdapter != null)
            {
                this.controlAdapter.ChangeCursor(CursorStyle.Busy);
            }

            if (encoding == null)
            {
                encoding = Encoding.Default;
            }

            try
            {
                provider.Load(this, stream, encoding, null, singleSheet);
            }
            finally
            {
                if (this.controlAdapter != null)
                {
                    this.controlAdapter.ChangeCursor(CursorStyle.PlatformDefault);
                }

                this.WorkbookLoaded?.Invoke(this, null);
            }
        }
Ejemplo n.º 5
0
 public FileLogger(string categoryName, LoggerOptionsModel options, IFileFormatProvider fileFormatProvider)
 {
     this.Name               = categoryName;
     this.Options            = options;
     this.fileFormatProvider = fileFormatProvider;
 }
Ejemplo n.º 6
0
 public FileFormatter(IFileFormatProvider formatProvider)
 {
     _formatProvider = formatProvider;
 }