SpringAST.cs :  » Inversion-of-Control-Dependency-Injection » Spring.net » Spring » Expressions » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Inversion of Control Dependency Injection » Spring.net 
Spring.net » Spring » Expressions » SpringAST.cs
using System;
using System.Runtime.Serialization;
using Spring.Expressions.Parser.antlr;
using Spring.Expressions.Parser.antlr.collections;

namespace Spring.Expressions{
    /// <summary>
    /// For internal purposes only. Use <see cref="BaseNode"/> for expression node implementations.
    /// </summary>
    /// <remarks>
    /// This class is only required to enable serialization of parsed Spring expressions since antlr.CommonAST
    /// unfortunately is not marked as [Serializable].<br/>
    /// <br/>
    /// <b>Note:</b>Since SpringAST implements <see cref="ISerializable"/>, deriving classes 
    /// have to explicitely override <see cref="GetObjectData"/> if they need to persist additional
    /// data during serialization.
    /// </remarks>
    [Serializable]
    public class SpringAST : Parser.antlr.BaseAST, ISerializable
    {
        #region Global SpringAST Factory

        internal class SpringASTCreator : Parser.antlr.ASTNodeCreator
        {
            public override Parser.antlr.collections.AST Create()
            {
                return new SpringAST();
            }

            public override string ASTNodeTypeName
            {
                get { return typeof(SpringAST).FullName; }
            }
        }

        /// <summary>
        /// The global SpringAST node factory
        /// </summary>
        internal static readonly SpringASTCreator Creator = new SpringASTCreator();

        #endregion

        #region Members

        private string text;
        private int ttype;

        #endregion

        /// <summary>
        /// Create an instance
        /// </summary>
        public SpringAST()
        {}

        /// <summary>
        /// Create an instance from a token
        /// </summary>
        public SpringAST(IToken token)
        {
            initialize(token);
        }

        /// <summary>
        /// initialize this instance from an AST
        /// </summary>
        public override void initialize(AST t)
        {
            this.setText(t.getText());
            this.Type = t.Type;
        }

        /// <summary>
        /// initialize this instance from an IToken
        /// </summary>
        public override void initialize(IToken tok)
        {
            this.setText(tok.getText());
            this.Type = tok.Type;
        }

        /// <summary>
        /// initialize this instance from a token type number and a text
        /// </summary>
        public override void initialize(int t, string txt)
        {
            this.Type = t;
            this.setText(txt);
        }

        /// <summary>
        /// gets or sets the token type of this node
        /// </summary>
        public override int Type
        {
            get { return this.ttype; }
            set { this.ttype = value; }
        }

        /// <summary>
        /// gets or sets the text of this node
        /// </summary>
        public string Text
        {
            get { return this.getText(); }
            set { this.setText(value); }
        }

        /// <summary>
        /// sets the text of this node
        /// </summary>
        public override void setText(string txt)
        {
            this.text = txt;
        }

        /// <summary>
        /// gets the text of this node
        /// </summary>
        public override string getText()
        {
            return this.text;
        }

        #region ISerializable Implementation

        /// <summary>
        /// Create a new instance from SerializationInfo
        /// </summary>
        protected SpringAST(SerializationInfo info, StreamingContext context)
        {
            base.down = (BaseAST)info.GetValue("down", typeof(BaseAST));
            base.right = (BaseAST)info.GetValue("right", typeof(BaseAST));
            this.ttype = info.GetInt32("ttype");
            this.text = info.GetString("text");
        }

        /// <summary>
        /// populate SerializationInfo from this instance
        /// </summary>
        public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            info.AddValue("down", base.down, typeof(SpringAST));
            info.AddValue("right", base.right, typeof(SpringAST));
            info.AddValue("ttype", this.Type, typeof(int));
            info.AddValue("text", this.Text, typeof(string));
        }
        
        #endregion
    }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.