SourceExpressionException.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.Activities / System / Activities / ExpressionParser / SourceExpressionException.cs / 1305376 / SourceExpressionException.cs

                            //------------------------------------------------------------------------------ 
// Copyright (c) Microsoft Corporation.  All rights reserved.
//-----------------------------------------------------------------------------

namespace System.Activities.ExpressionParser 
{
    using System.CodeDom.Compiler; 
    using System.Collections.Generic; 
    using System.Globalization;
    using System.Runtime; 
    using System.Runtime.Serialization;
    using System.Security;
    using System.Security.Permissions;
 
    [Serializable]
    public class SourceExpressionException : Exception, ISerializable 
    { 
        CompilerError[] errors;
 
        public SourceExpressionException()
            : base(SR.CompilerError)
        {
        } 

        public SourceExpressionException(string message) 
            : base(message) 
        {
        } 

        public SourceExpressionException(string message, Exception innerException)
            : base(message, innerException)
        { 
        }
 
        public SourceExpressionException(string message, CompilerErrorCollection errors) 
            : base(message)
        { 
            this.errors = new CompilerError[errors.Count];
            errors.CopyTo(this.errors, 0);
        }
 
        protected SourceExpressionException(SerializationInfo info, StreamingContext context)
            : base(info, context) 
        { 
            if (info == null)
            { 
                throw FxTrace.Exception.ArgumentNull("info");
            }
            int length = info.GetInt32("count");
            this.errors = new CompilerError[length]; 
            for (int i = 0; i < length; ++i)
            { 
                string index = i.ToString(CultureInfo.InvariantCulture); 
                string fileName = info.GetString("file" + index);
                int line = info.GetInt32("line" + index); 
                int column = info.GetInt32("column" + index);
                string errorNumber = info.GetString("number" + index);
                string errorText = info.GetString("text" + index);
                this.errors[i] = new CompilerError(fileName, line, column, errorNumber, errorText); 
            }
        } 
 
        public IEnumerable Errors
        { 
            get
            {
                if (this.errors == null)
                { 
                    this.errors = new CompilerError[0];
                } 
                return this.errors; 
            }
        } 

        public override void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            if (info == null) 
            {
                throw FxTrace.Exception.ArgumentNull("info"); 
            } 
            if (this.errors == null)
            { 
                info.AddValue("count", 0);
            }
            else
            { 
                info.AddValue("count", this.errors.Length);
                for (int i = 0; i < this.errors.Length; ++i) 
                { 
                    CompilerError error = this.errors[i];
                    string index = i.ToString(CultureInfo.InvariantCulture); 
                    info.AddValue("file" + index, error.FileName);
                    info.AddValue("line" + index, error.Line);
                    info.AddValue("column" + index, error.Column);
                    info.AddValue("number" + index, error.ErrorNumber); 
                    info.AddValue("text" + index, error.ErrorText);
                } 
            } 
            base.GetObjectData(info, context);
        } 
    }
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK