Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
ShaderKeySourceGenerator.cs
Go to the documentation of this file.
1 // ------------------------------------------------------------------------------
2 // <auto-generated>
3 // This code was generated by a tool.
4 // Runtime Version: 11.0.0.0
5 //
6 // Changes to this file may cause incorrect behavior and will be lost if
7 // the code is regenerated.
8 // </auto-generated>
9 // ------------------------------------------------------------------------------
10 namespace SiliconStudio.Paradox.VisualStudio.Commands.Shaders
11 {
12  using System.Linq;
13  using System.Text;
14  using System.Collections.Generic;
15  using System;
16 
17  /// <summary>
18  /// Class to produce the template output
19  /// </summary>
20 
21  #line 1 "C:\DEV\paradox\sources\tools\SiliconStudio.Paradox.VisualStudio.Commands\Shaders\ShaderKeySourceGenerator.tt"
22  [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "11.0.0.0")]
23  internal partial class ShaderKeySourceGenerator : ShaderKeySourceGeneratorBase
24  {
25 #line hidden
26  /// <summary>
27  /// Create the template output
28  /// </summary>
29  public virtual string TransformText()
30  {
31  this.Write(@"// AUTO-GENERATED, DO NOT MODIFY!
32 using System;
33 using SiliconStudio.Paradox.Effects;
34 using SiliconStudio.Paradox.Graphics;
35 using SiliconStudio.Core.Mathematics;
36 using Buffer = SiliconStudio.Paradox.Graphics.Buffer;
37 
38 namespace SiliconStudio.Paradox.Effects.Modules
39 {
40 ");
41 
42  #line 15 "C:\DEV\paradox\sources\tools\SiliconStudio.Paradox.VisualStudio.Commands\Shaders\ShaderKeySourceGenerator.tt"
43 if (ShaderKeyClass != null) {
44 
45  #line default
46  #line hidden
47  this.Write(" public static partial class ");
48 
49  #line 16 "C:\DEV\paradox\sources\tools\SiliconStudio.Paradox.VisualStudio.Commands\Shaders\ShaderKeySourceGenerator.tt"
50  this.Write(this.ToStringHelper.ToStringWithCulture(ShaderKeyClass.Name));
51 
52  #line default
53  #line hidden
54  this.Write("\r\n {\r\n");
55 
56  #line 18 "C:\DEV\paradox\sources\tools\SiliconStudio.Paradox.VisualStudio.Commands\Shaders\ShaderKeySourceGenerator.tt"
57 foreach (var shaderKeyVariable in ShaderKeyClass.Variables) {
58 
59 
60  #line default
61  #line hidden
62  this.Write(" public static readonly ParameterKey<");
63 
64  #line 20 "C:\DEV\paradox\sources\tools\SiliconStudio.Paradox.VisualStudio.Commands\Shaders\ShaderKeySourceGenerator.tt"
65  this.Write(this.ToStringHelper.ToStringWithCulture(shaderKeyVariable.Type));
66 
67  #line default
68  #line hidden
69  this.Write("> ");
70 
71  #line 20 "C:\DEV\paradox\sources\tools\SiliconStudio.Paradox.VisualStudio.Commands\Shaders\ShaderKeySourceGenerator.tt"
72  this.Write(this.ToStringHelper.ToStringWithCulture(shaderKeyVariable.Name));
73 
74  #line default
75  #line hidden
76  this.Write(" = ");
77 
78  #line 20 "C:\DEV\paradox\sources\tools\SiliconStudio.Paradox.VisualStudio.Commands\Shaders\ShaderKeySourceGenerator.tt"
79 if (shaderKeyVariable.Map == null){
80 
81  #line default
82  #line hidden
83  this.Write("ParameterKeys.New<");
84 
85  #line 20 "C:\DEV\paradox\sources\tools\SiliconStudio.Paradox.VisualStudio.Commands\Shaders\ShaderKeySourceGenerator.tt"
86  this.Write(this.ToStringHelper.ToStringWithCulture(shaderKeyVariable.Type));
87 
88  #line default
89  #line hidden
90  this.Write(">(");
91 
92  #line 20 "C:\DEV\paradox\sources\tools\SiliconStudio.Paradox.VisualStudio.Commands\Shaders\ShaderKeySourceGenerator.tt"
93  this.Write(this.ToStringHelper.ToStringWithCulture(shaderKeyVariable.InitialValue ?? string.Empty));
94 
95  #line default
96  #line hidden
97  this.Write(")");
98 
99  #line 20 "C:\DEV\paradox\sources\tools\SiliconStudio.Paradox.VisualStudio.Commands\Shaders\ShaderKeySourceGenerator.tt"
100 }else{
101 
102  #line default
103  #line hidden
104 
105  #line 20 "C:\DEV\paradox\sources\tools\SiliconStudio.Paradox.VisualStudio.Commands\Shaders\ShaderKeySourceGenerator.tt"
106  this.Write(this.ToStringHelper.ToStringWithCulture(shaderKeyVariable.Map));
107 
108  #line default
109  #line hidden
110 
111  #line 20 "C:\DEV\paradox\sources\tools\SiliconStudio.Paradox.VisualStudio.Commands\Shaders\ShaderKeySourceGenerator.tt"
112 }
113 
114  #line default
115  #line hidden
116  this.Write(";\r\n");
117 
118  #line 21 "C:\DEV\paradox\sources\tools\SiliconStudio.Paradox.VisualStudio.Commands\Shaders\ShaderKeySourceGenerator.tt"
119 }
120 
121  #line default
122  #line hidden
123  this.Write(" }\r\n");
124 
125  #line 23 "C:\DEV\paradox\sources\tools\SiliconStudio.Paradox.VisualStudio.Commands\Shaders\ShaderKeySourceGenerator.tt"
126 }
127 
128  #line default
129  #line hidden
130  this.Write("}");
131  return this.GenerationEnvironment.ToString();
132  }
133  }
134 
135  #line default
136  #line hidden
137  #region Base class
138  /// <summary>
139  /// Base class for this transformation
140  /// </summary>
141  [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "11.0.0.0")]
142  internal class ShaderKeySourceGeneratorBase
143  {
144  #region Fields
145  private global::System.Text.StringBuilder generationEnvironmentField;
146  private global::System.CodeDom.Compiler.CompilerErrorCollection errorsField;
147  private global::System.Collections.Generic.List<int> indentLengthsField;
148  private string currentIndentField = "";
149  private bool endsWithNewline;
150  private global::System.Collections.Generic.IDictionary<string, object> sessionField;
151  #endregion
152  #region Properties
153  /// <summary>
154  /// The string builder that generation-time code is using to assemble generated output
155  /// </summary>
156  protected System.Text.StringBuilder GenerationEnvironment
157  {
158  get
159  {
160  if ((this.generationEnvironmentField == null))
161  {
162  this.generationEnvironmentField = new global::System.Text.StringBuilder();
163  }
164  return this.generationEnvironmentField;
165  }
166  set
167  {
168  this.generationEnvironmentField = value;
169  }
170  }
171  /// <summary>
172  /// The error collection for the generation process
173  /// </summary>
174  public System.CodeDom.Compiler.CompilerErrorCollection Errors
175  {
176  get
177  {
178  if ((this.errorsField == null))
179  {
180  this.errorsField = new global::System.CodeDom.Compiler.CompilerErrorCollection();
181  }
182  return this.errorsField;
183  }
184  }
185  /// <summary>
186  /// A list of the lengths of each indent that was added with PushIndent
187  /// </summary>
188  private System.Collections.Generic.List<int> indentLengths
189  {
190  get
191  {
192  if ((this.indentLengthsField == null))
193  {
194  this.indentLengthsField = new global::System.Collections.Generic.List<int>();
195  }
196  return this.indentLengthsField;
197  }
198  }
199  /// <summary>
200  /// Gets the current indent we use when adding lines to the output
201  /// </summary>
202  public string CurrentIndent
203  {
204  get
205  {
206  return this.currentIndentField;
207  }
208  }
209  /// <summary>
210  /// Current transformation session
211  /// </summary>
212  public virtual global::System.Collections.Generic.IDictionary<string, object> Session
213  {
214  get
215  {
216  return this.sessionField;
217  }
218  set
219  {
220  this.sessionField = value;
221  }
222  }
223  #endregion
224  #region Transform-time helpers
225  /// <summary>
226  /// Write text directly into the generated output
227  /// </summary>
228  public void Write(string textToAppend)
229  {
230  if (string.IsNullOrEmpty(textToAppend))
231  {
232  return;
233  }
234  // If we're starting off, or if the previous text ended with a newline,
235  // we have to append the current indent first.
236  if (((this.GenerationEnvironment.Length == 0)
237  || this.endsWithNewline))
238  {
239  this.GenerationEnvironment.Append(this.currentIndentField);
240  this.endsWithNewline = false;
241  }
242  // Check if the current text ends with a newline
243  if (textToAppend.EndsWith(global::System.Environment.NewLine, global::System.StringComparison.CurrentCulture))
244  {
245  this.endsWithNewline = true;
246  }
247  // This is an optimization. If the current indent is "", then we don't have to do any
248  // of the more complex stuff further down.
249  if ((this.currentIndentField.Length == 0))
250  {
251  this.GenerationEnvironment.Append(textToAppend);
252  return;
253  }
254  // Everywhere there is a newline in the text, add an indent after it
255  textToAppend = textToAppend.Replace(global::System.Environment.NewLine, (global::System.Environment.NewLine + this.currentIndentField));
256  // If the text ends with a newline, then we should strip off the indent added at the very end
257  // because the appropriate indent will be added when the next time Write() is called
258  if (this.endsWithNewline)
259  {
260  this.GenerationEnvironment.Append(textToAppend, 0, (textToAppend.Length - this.currentIndentField.Length));
261  }
262  else
263  {
264  this.GenerationEnvironment.Append(textToAppend);
265  }
266  }
267  /// <summary>
268  /// Write text directly into the generated output
269  /// </summary>
270  public void WriteLine(string textToAppend)
271  {
272  this.Write(textToAppend);
273  this.GenerationEnvironment.AppendLine();
274  this.endsWithNewline = true;
275  }
276  /// <summary>
277  /// Write formatted text directly into the generated output
278  /// </summary>
279  public void Write(string format, params object[] args)
280  {
281  this.Write(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args));
282  }
283  /// <summary>
284  /// Write formatted text directly into the generated output
285  /// </summary>
286  public void WriteLine(string format, params object[] args)
287  {
288  this.WriteLine(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args));
289  }
290  /// <summary>
291  /// Raise an error
292  /// </summary>
293  public void Error(string message)
294  {
295  System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError();
296  error.ErrorText = message;
297  this.Errors.Add(error);
298  }
299  /// <summary>
300  /// Raise a warning
301  /// </summary>
302  public void Warning(string message)
303  {
304  System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError();
305  error.ErrorText = message;
306  error.IsWarning = true;
307  this.Errors.Add(error);
308  }
309  /// <summary>
310  /// Increase the indent
311  /// </summary>
312  public void PushIndent(string indent)
313  {
314  if ((indent == null))
315  {
316  throw new global::System.ArgumentNullException("indent");
317  }
318  this.currentIndentField = (this.currentIndentField + indent);
319  this.indentLengths.Add(indent.Length);
320  }
321  /// <summary>
322  /// Remove the last indent that was added with PushIndent
323  /// </summary>
324  public string PopIndent()
325  {
326  string returnValue = "";
327  if ((this.indentLengths.Count > 0))
328  {
329  int indentLength = this.indentLengths[(this.indentLengths.Count - 1)];
330  this.indentLengths.RemoveAt((this.indentLengths.Count - 1));
331  if ((indentLength > 0))
332  {
333  returnValue = this.currentIndentField.Substring((this.currentIndentField.Length - indentLength));
334  this.currentIndentField = this.currentIndentField.Remove((this.currentIndentField.Length - indentLength));
335  }
336  }
337  return returnValue;
338  }
339  /// <summary>
340  /// Remove any indentation
341  /// </summary>
342  public void ClearIndent()
343  {
344  this.indentLengths.Clear();
345  this.currentIndentField = "";
346  }
347  #endregion
348  #region ToString Helpers
349  /// <summary>
350  /// Utility class to produce culture-oriented representation of an object as a string.
351  /// </summary>
353  {
354  private System.IFormatProvider formatProviderField = global::System.Globalization.CultureInfo.InvariantCulture;
355  /// <summary>
356  /// Gets or sets format provider to be used by ToStringWithCulture method.
357  /// </summary>
358  public System.IFormatProvider FormatProvider
359  {
360  get
361  {
362  return this.formatProviderField ;
363  }
364  set
365  {
366  if ((value != null))
367  {
368  this.formatProviderField = value;
369  }
370  }
371  }
372  /// <summary>
373  /// This is called from the compile/run appdomain to convert objects within an expression block to a string
374  /// </summary>
375  public string ToStringWithCulture(object objectToConvert)
376  {
377  if ((objectToConvert == null))
378  {
379  throw new global::System.ArgumentNullException("objectToConvert");
380  }
381  System.Type t = objectToConvert.GetType();
382  System.Reflection.MethodInfo method = t.GetMethod("ToString", new System.Type[] {
383  typeof(System.IFormatProvider)});
384  if ((method == null))
385  {
386  return objectToConvert.ToString();
387  }
388  else
389  {
390  return ((string)(method.Invoke(objectToConvert, new object[] {
391  this.formatProviderField })));
392  }
393  }
394  }
395  private ToStringInstanceHelper toStringHelperField = new ToStringInstanceHelper();
396  /// <summary>
397  /// Helper to produce culture-oriented representation of an object as a string
398  /// </summary>
399  public ToStringInstanceHelper ToStringHelper
400  {
401  get
402  {
403  return this.toStringHelperField;
404  }
405  }
406  #endregion
407  }
408  #endregion
409 }
string ToStringWithCulture(object objectToConvert)
This is called from the compile/run appdomain to convert objects within an expression block to a stri...
Utility class to produce culture-oriented representation of an object as a string.
An error message (level 4).
_In_ size_t _In_ size_t _In_ DXGI_FORMAT format
Definition: DirectXTexP.h:175
The template can be applied to an existing PackageSession.
A warning message (level 3).