~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to contrib/NRefactory/Project/Src/Ast/General/PrimitiveExpression.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// <file>
2
 
//     <copyright see="prj:///doc/copyright.txt"/>
3
 
//     <license see="prj:///doc/license.txt"/>
4
 
//     <owner name="none" email=""/>
5
 
//     <version>$Revision: 4482 $</version>
6
 
// </file>
7
 
 
8
 
using ICSharpCode.OldNRefactory.PrettyPrinter;
9
 
using System;
10
 
 
11
 
namespace ICSharpCode.OldNRefactory.Ast
12
 
{
13
 
        public class PrimitiveExpression : Expression
14
 
        {
15
 
                string stringValue;
16
 
                
17
 
                public Parser.LiteralFormat LiteralFormat { get; set; }
18
 
                public object Value { get; set; }
19
 
                
20
 
                public string StringValue {
21
 
                        get {
22
 
                                if (stringValue == null)
23
 
                                        return CSharpOutputVisitor.ToCSharpString(this);
24
 
                                else
25
 
                                        return stringValue;
26
 
                        }
27
 
                        set {
28
 
                                stringValue = value == null ? String.Empty : value;
29
 
                        }
30
 
                }
31
 
                
32
 
                public bool HasStringValue {
33
 
                        get {
34
 
                                return stringValue != null;
35
 
                        }
36
 
                }
37
 
                
38
 
                public PrimitiveExpression(object val)
39
 
                {
40
 
                        this.Value = val;
41
 
                }
42
 
                
43
 
                public PrimitiveExpression(object val, string stringValue)
44
 
                {
45
 
                        this.Value       = val;
46
 
                        this.StringValue = stringValue;
47
 
                }
48
 
                
49
 
                public override object AcceptVisitor(IAstVisitor visitor, object data)
50
 
                {
51
 
                        return visitor.VisitPrimitiveExpression(this, data);
52
 
                }
53
 
                
54
 
                public override string ToString()
55
 
                {
56
 
                        return String.Format("[PrimitiveExpression: Value={1}, ValueType={2}, StringValue={0}]",
57
 
                                             this.StringValue,
58
 
                                             this.Value,
59
 
                                             this.Value == null ? "null" : this.Value.GetType().FullName
60
 
                                            );
61
 
                }
62
 
        }
63
 
}