CodeDomSerializerException.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / CompMod / System / ComponentModel / Design / Serialization / CodeDomSerializerException.cs / 1 / CodeDomSerializerException.cs

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

namespace System.ComponentModel.Design.Serialization { 
 
    using System;
    using System.CodeDom; 
    using System.Runtime.Serialization;

    /// 
    ///  
    ///     The exception that is thrown when the code dom serializer experiences an error.
    ///     
    ///  
    [Serializable]
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors")] 
    public class CodeDomSerializerException : SystemException {

        private CodeLinePragma linePragma;
 
        /// 
        ///  
        /// Initializes a new instance of the CodeDomSerializerException class. 
        /// 
        public CodeDomSerializerException(string message, CodeLinePragma linePragma) : base(message) { 
            this.linePragma = linePragma;
        }

        ///  
        /// 
        /// Initializes a new instance of the CodeDomSerializerException class. 
        ///  
        public CodeDomSerializerException(Exception ex, CodeLinePragma linePragma) : base(ex.Message, ex) {
            this.linePragma = linePragma; 
        }

        /// 
        ///  
        /// Initializes a new instance of the CodeDomSerializerException class.
        ///  
        public CodeDomSerializerException(string message, IDesignerSerializationManager manager) : base(message) { 
            FillLinePragmaFromContext(manager);
        } 

        /// 
        /// 
        /// Initializes a new instance of the CodeDomSerializerException class. 
        /// 
        public CodeDomSerializerException(Exception ex, IDesignerSerializationManager manager) : base(ex.Message, ex) { 
            FillLinePragmaFromContext(manager); 
        }
 
        /// 
        protected CodeDomSerializerException(SerializationInfo info, StreamingContext context) : base (info, context) {
            linePragma = (CodeLinePragma)info.GetValue("linePragma", typeof(CodeLinePragma));
        } 

        ///  
        ///  
        ///    Gets the line pragma object that is related to this error.
        ///  
        public CodeLinePragma LinePragma {
            get {
                return linePragma;
            } 
        }
 
        ///  
        ///    Sniffs around in the context looking for a code statement.  if it finds one, it will add the statement's
        ///    line # information to the exception. 
        /// 
        private void FillLinePragmaFromContext(IDesignerSerializationManager manager) {
            if (manager == null) throw new ArgumentNullException("manager");
 
            CodeStatement statement = (CodeStatement)manager.Context[typeof(CodeStatement)];
            CodeLinePragma linePragma = null; 
 
            if (statement != null) {
                linePragma = statement.LinePragma; 
            }
        }

        ///  
        public override void GetObjectData(SerializationInfo info, StreamingContext context) {
            if (info==null) { 
                throw new ArgumentNullException("info"); 
            }
            info.AddValue("linePragma", linePragma); 
            base.GetObjectData(info, context);
        }
    }
} 


// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
                        

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