Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
CustomTemplateSession.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections;
3 using System.Collections.Generic;
4 using System.Dynamic;
5 using System.Runtime.Serialization;
6 using Microsoft.VisualStudio.TextTemplating;
7 
8 namespace SiliconStudio.ProjectTemplating
9 {
10  internal class CustomTemplateSession : ITextTemplatingSession
11  {
12  private readonly ExpandoObject expando;
13  private readonly IDictionary<string, object> backend;
14 
15  public CustomTemplateSession(IEnumerable<KeyValuePair<string, object>> options)
16  {
17  if (options == null) throw new ArgumentNullException("options");
18  Id = Guid.NewGuid();
19  expando = new ExpandoObject();
20  this.backend = expando;
21 
22  // Copy back options to backend dictionary
23  foreach (var option in options)
24  {
25  this[option.Key] = option.Value;
26  }
27  }
28 
29  public dynamic Expando
30  {
31  get
32  {
33  return expando;
34  }
35  }
36 
37  public bool Equals(ITextTemplatingSession other)
38  {
39  return ReferenceEquals(this, other);
40  }
41 
42  public bool Equals(Guid other)
43  {
44  return Id == other;
45  }
46 
47  public Guid Id { get; set; }
48 
49  public IEnumerator<KeyValuePair<string, object>> GetEnumerator()
50  {
51  return backend.GetEnumerator();
52  }
53 
54  public void Add(KeyValuePair<string, object> item)
55  {
56  backend.Add(item);
57  }
58 
59  public void Clear()
60  {
61  backend.Clear();
62  }
63 
64  public bool Contains(KeyValuePair<string, object> item)
65  {
66  return backend.Contains(item);
67  }
68 
69  public void CopyTo(KeyValuePair<string, object>[] array, int arrayIndex)
70  {
71  backend.CopyTo(array, arrayIndex);
72  }
73 
74  public bool Remove(KeyValuePair<string, object> item)
75  {
76  return backend.Remove(item);
77  }
78 
79  public int Count
80  {
81  get
82  {
83  return backend.Count;
84  }
85  }
86 
87  public bool IsReadOnly
88  {
89  get
90  {
91  return backend.IsReadOnly;
92  }
93  }
94 
95  public bool ContainsKey(string key)
96  {
97  return backend.ContainsKey(key);
98  }
99 
100  public void Add(string key, object value)
101  {
102  backend.Add(key, value);
103  }
104 
105  public bool Remove(string key)
106  {
107  return backend.Remove(key);
108  }
109 
110  public bool TryGetValue(string key, out object value)
111  {
112  return backend.TryGetValue(key, out value);
113  }
114 
115  public object this[string key]
116  {
117  get
118  {
119  object value;
120  backend.TryGetValue(key, out value);
121  return value;
122  }
123  set
124  {
125  backend[key] = value;
126  }
127  }
128 
130  {
131  get
132  {
133  return backend.Keys;
134  }
135  }
136 
137  public ICollection<object> Values
138  {
139  get
140  {
141  return backend.Values;
142  }
143  }
144 
145 
146  IEnumerator IEnumerable.GetEnumerator()
147  {
148  return GetEnumerator();
149  }
150 
151  public void GetObjectData(SerializationInfo info, StreamingContext context)
152  {
153  throw new NotImplementedException();
154  }
155  }
156 }
Keys
Enumeration for keys.
Definition: Keys.cs:8
SiliconStudio.Paradox.Input.Keys Keys