Inheritance: IEnumerable
Example #1
0
        /// <summary>
        /// Reads and returns a domain object from the specified DDL string.
        /// </summary>
        public static DocumentObject ObjectFromString(string ddl, DdlReaderErrors errors)
        {
            StringReader   stringReader = null;
            DocumentObject domObj       = null;
            DdlReader      reader       = null;

            try
            {
                stringReader = new StringReader(ddl);

                reader = new DdlReader(stringReader);
                domObj = reader.ReadObject();
            }
            finally
            {
                if (stringReader != null)
                {
                    stringReader.Close();
                }
                if (reader != null)
                {
                    reader.Close();
                }
            }
            return(domObj);
        }
Example #2
0
        /// <summary>
        /// Reads and returns a domain object from the specified DDL string.
        /// </summary>
        public static DocumentObject ObjectFromString(string ddl, DdlReaderErrors errors)
        {
            StringReader   stringReader = null;
            DocumentObject domObj;
            DdlReader      reader = null;

            try
            {
                stringReader = new StringReader(ddl);

                reader = new DdlReader(stringReader);
                domObj = reader.ReadObject();
            }
            finally
            {
                if (stringReader != null)
                {
#if !NETFX_CORE && !NETCORE
                    stringReader.Close();
#else
                    stringReader.Dispose();
#endif
                }
                if (reader != null)
                {
                    reader.Close();
                }
            }
            return(domObj);
        }
Example #3
0
        /// <summary>
        /// Initializes a new instance of the DdlParser class.
        /// </summary>
        internal DdlParser(string fileName, string ddl, DdlReaderErrors errors)
        {
            if (errors != null)
            this.errors = errors;
              else
            this.errors = new DdlReaderErrors();

              scanner = new DdlScanner(fileName, ddl, errors);
        }
Example #4
0
        /// <summary>
        /// Initializes a new instance of the DdlReader class with the specified filename and ErrorManager2.
        /// </summary>
        public DdlReader(string filename, DdlReaderErrors errors)
        {
            _fileName = filename;
            _errorManager = errors;
#if !NETFX_CORE
            _reader = new StreamReader(filename, Encoding.UTF8);
#else
            _reader = new StreamReader(null, Encoding.UTF8);
#endif
            //#if SILVERLIGHT
            //  _reader = new StreamReader(filename, Encoding.UTF8);
            //#else
            //  _reader = new StreamReader(filename, Encoding.Default);
            //#endif
        }
Example #5
0
        /// <summary>
        /// Initializes a new instance of the DdlReader class with the specified filename and ErrorManager2.
        /// </summary>
        public DdlReader(string filename, DdlReaderErrors errors)
        {
            _fileName     = filename;
            _errorManager = errors;
#if !NETFX_CORE && !NETCORE
            _reader = new StreamReader(filename, Encoding.UTF8);
#else
            _reader = new StreamReader(null, Encoding.UTF8);
#endif
            //#if SILVERLIGHT
            //  _reader = new StreamReader(filename, Encoding.UTF8);
            //#else
            //  _reader = new StreamReader(filename, Encoding.Default);
            //#endif
        }
Example #6
0
        /// <summary>
        /// Reads and returns a domain object from the specified file.
        /// </summary>
        public static DocumentObject ObjectFromFile(string documentFileName, DdlReaderErrors errors)
        {
            DdlReader      reader = null;
            DocumentObject domObj = null;

            try
            {
                reader = new DdlReader(documentFileName, errors);
                domObj = reader.ReadObject();
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
            return(domObj);
        }
Example #7
0
 /// <summary>
 /// Initializes a new instance of the DdlReader class with the specified filename and ErrorManager2.
 /// </summary>
 public DdlReader(string filename, DdlReaderErrors errors)
 {
   this.fileName = filename;
   this.errorManager = errors;
   this.reader = new StreamReader(filename, Encoding.Default);
 }
Example #8
0
 /// <summary>
 /// Initializes a new instance of the DdlReader class with the specified Stream and ErrorManager2.
 /// </summary>
 public DdlReader(Stream stream, DdlReaderErrors errors)
 {
   this.errorManager = errors;
   this.reader = new StreamReader(stream);
 }
Example #9
0
    /// <summary>
    /// Reads and returns a domain object from the specified DDL string.
    /// </summary>
    public static DocumentObject ObjectFromString(string ddl, DdlReaderErrors errors)
    {
      StringReader stringReader = null;
      DocumentObject domObj = null;
      DdlReader reader = null;
      try
      {
        stringReader = new StringReader(ddl);

        reader = new DdlReader(stringReader);
        domObj = reader.ReadObject();
      }
      finally
      {
        if (stringReader != null)
          stringReader.Close();
        if (reader != null)
          reader.Close();
      }
      return domObj;
    }
Example #10
0
 /// <summary>
 /// Initializes a new instance of the DdlReader class with the specified TextReader and ErrorManager2.
 /// </summary>
 public DdlReader(TextReader reader, DdlReaderErrors errors)
 {
     this.doClose      = false;
     this.errorManager = errors;
     this.reader       = reader;
 }
Example #11
0
 /// <summary>
 /// Initializes a new instance of the DdlReader class with the specified Stream and ErrorManager2.
 /// </summary>
 public DdlReader(Stream stream, DdlReaderErrors errors)
 {
     _errorManager = errors;
     _reader       = new StreamReader(stream);
 }
Example #12
0
 private Document GetDocument()
 {
     var s = GetMDDLStream();
     var errors = new DdlReaderErrors();
     DdlReader rd = new DdlReader(s, errors);
     try
     {
         var doc = rd.ReadDocument();
         LogErrors(errors, null, s);
         ReportErrors(errors, null, s);
         return doc;
     }
     catch (Exception ex)
     {
         LogErrors(errors, ex, s);
         ReportErrors(errors, ex, s);
         throw;
     }
 }
Example #13
0
 /// <summary>
 /// Initializes a new instance of the DdlParser class.
 /// </summary>
 internal DdlParser(string fileName, string ddl, DdlReaderErrors errors)
 {
     _errors = errors ?? new DdlReaderErrors();
     _scanner = new DdlScanner(fileName, ddl, errors);
 }
Example #14
0
 /// <summary>
 /// Initializes a new instance of the DdlParser class.
 /// </summary>
 internal DdlParser(string ddl, DdlReaderErrors errors)
     : this("", ddl, errors)
 {
 }
Example #15
0
        private void ReportErrors(DdlReaderErrors errors, Exception ex, System.IO.Stream mddl)
        {
            if (ex != null || (errors != null && errors.ErrorCount > 0))
            {
                if (ErrorsAreFatal)
                {
                    var msg = new StringBuilder("Errors while rendering document:");
                    if (ex != null)
                    {
                        msg.Append("\n" + ex.ToString());
                    }
                    foreach (var error in errors)
                    {
                        msg.Append("\n" + error.ToString());
                    }
                    throw new ApplicationException(msg.ToString());
                }

                if (ex != null)
                {
                    Logging.Log.Error("Unable to create report:", ex);
                }

                if (errors != null && errors.ErrorCount > 0)
                {
                    StringBuilder sb = new StringBuilder();

                    foreach (DdlReaderError e in errors)
                    {
                        switch (e.ErrorLevel)
                        {
                            case DdlErrorLevel.Error:
                                sb.Append("E: ");
                                break;
                            case DdlErrorLevel.Warning:
                                sb.Append("W: ");
                                break;
                            default:
                                sb.Append("?: ");
                                break;
                        }
                        sb.AppendLine(e.ToString());
                    }
                    Logging.Log.Info(sb.ToString());
                }
            }
        }
Example #16
0
 /// <summary>
 /// Initializes a new instance of the DdlScanner class.
 /// </summary>
 public DdlScanner(string ddl, DdlReaderErrors errors)
     : this("", ddl, errors)
 {
 }
Example #17
0
        private void ReportErrors(DdlReaderErrors errors, Exception ex, System.IO.Stream mddl)
        {
            if (ex != null || (errors != null && errors.ErrorCount > 0))
            {
                if (ErrorsAreFatal)
                {
                    var msg = new StringBuilder("Errors while rendering document:");
                    if (ex != null)
                    {
                        msg.Append("\n" + ex.ToString());
                    }
                    foreach (var error in errors)
                    {
                        msg.Append("\n" + error.ToString());
                    }
                    throw new InvalidOperationException(msg.ToString(), ex);
                }

                _errorReporter.ReportErrors(errors, ex, mddl);
            }
        }
Example #18
0
        private void LogErrors(DdlReaderErrors errors, Exception ex, System.IO.Stream mddl)
        {
            if (ex != null)
            {
                Zetbox.API.Utils.Logging.Log.Error("Exception during report creation", ex);
            }

            if (errors != null)
            {
                foreach (DdlReaderError e in errors)
                {
                    switch (e.ErrorLevel)
                    {
                        case DdlErrorLevel.Error:
                            Zetbox.API.Utils.Logging.Log.Error(e.ToString());
                            break;
                        case DdlErrorLevel.Warning:
                            Zetbox.API.Utils.Logging.Log.Warn(e.ToString());
                            break;
                        default:
                            Zetbox.API.Utils.Logging.Log.Info(e.ToString());
                            break;
                    }
                }
            }
        }
Example #19
0
 /// <summary>
 /// Initializes a new instance of the DdlReader class with the specified TextReader and ErrorManager2.
 /// </summary>
 public DdlReader(TextReader reader, DdlReaderErrors errors)
 {
   this.doClose = false;
   this.errorManager = errors;
   this.reader = reader;
 }
Example #20
0
        /// <summary>
        /// Reads and returns a domain object from the specified DDL string.
        /// </summary>
        public static DocumentObject ObjectFromString(string ddl, DdlReaderErrors errors)
        {
            StringReader stringReader = null;
            DocumentObject domObj;
            DdlReader reader = null;
            try
            {
                stringReader = new StringReader(ddl);

                reader = new DdlReader(stringReader);
                domObj = reader.ReadObject();
            }
            finally
            {
                if (stringReader != null)
                {
#if !NETFX_CORE
                    stringReader.Close();
#else
                    stringReader.Dispose();
#endif
                }
                if (reader != null)
                    reader.Close();
            }
            return domObj;
        }
Example #21
0
 /// <summary>
 /// Initializes a new instance of the DdlParser class.
 /// </summary>
 internal DdlParser(string ddl, DdlReaderErrors errors)
     : this(String.Empty, ddl, errors)
 { }
Example #22
0
 /// <summary>
 /// Initializes a new instance of the DdlReader class with the specified TextReader and ErrorManager2.
 /// </summary>
 public DdlReader(TextReader reader, DdlReaderErrors errors)
 {
     _doClose      = false;
     _errorManager = errors;
     _reader       = reader;
 }
Example #23
0
 /// <summary>
 /// Reads and returns a domain object from the specified file.
 /// </summary>
 public static DocumentObject ObjectFromFile(string documentFileName, DdlReaderErrors errors)
 {
     DdlReader reader = null;
     DocumentObject domObj;
     try
     {
         reader = new DdlReader(documentFileName, errors);
         domObj = reader.ReadObject();
     }
     finally
     {
         if (reader != null)
             reader.Close();
     }
     return domObj;
 }
Example #24
0
 /// <summary>
 /// Initializes a new instance of the DdlScanner class.
 /// </summary>
 internal DdlScanner(string documentFileName, string ddl, DdlReaderErrors errors)
 {
   this.errors = errors;
   Init(ddl, documentFileName);
 }
Example #25
0
 /// <summary>
 /// Initializes a new instance of the DdlReader class with the specified Stream and ErrorManager2.
 /// </summary>
 public DdlReader(Stream stream, DdlReaderErrors errors)
 {
     _errorManager = errors;
     _reader = new StreamReader(stream);
 }
Example #26
0
 /// <summary>
 /// Initializes a new instance of the DdlScanner class.
 /// </summary>
 internal DdlScanner(string documentFileName, string ddl, DdlReaderErrors errors)
 {
     _errors = errors;
     Init(ddl, documentFileName);
 }
Example #27
0
 /// <summary>
 /// Initializes a new instance of the DdlReader class with the specified TextReader and ErrorManager2.
 /// </summary>
 public DdlReader(TextReader reader, DdlReaderErrors errors)
 {
     _doClose = false;
     _errorManager = errors;
     _reader = reader;
 }
Example #28
0
 /// <summary>
 /// Initializes a new instance of the DdlReader class with the specified Stream and ErrorManager2.
 /// </summary>
 public DdlReader(Stream stream, DdlReaderErrors errors)
 {
     this.errorManager = errors;
     this.reader       = new StreamReader(stream);
 }
Example #29
0
 /// <summary>
 /// Initializes a new instance of the DdlScanner class.
 /// </summary>
 internal DdlScanner(string ddl, DdlReaderErrors errors)
     : this("", ddl, errors)
 {
 }
Example #30
0
 /// <summary>
 /// Initializes a new instance of the DdlReader class with the specified filename and ErrorManager2.
 /// </summary>
 public DdlReader(string filename, DdlReaderErrors errors)
 {
     this.fileName     = filename;
     this.errorManager = errors;
     this.reader       = new StreamReader(filename, Encoding.Default);
 }