Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
ComplexSerializerCodeGenerator.cs
Go to the documentation of this file.
1 // ------------------------------------------------------------------------------
2 // <auto-generated>
3 // This code was generated by a tool.
4 // Runtime Version: 12.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.AssemblyProcessor
11 {
12  using System.IO;
13  using System.Linq;
14  using System.Reflection;
15  using System.Collections.Generic;
16  using Mono.Cecil;
17  using SiliconStudio.Core.Serialization.Serializers;
18  using System;
19 
20  /// <summary>
21  /// Class to produce the template output
22  /// </summary>
23 
24  #line 1 "C:\DEV\paradox\sources\common\core\SiliconStudio.AssemblyProcessor.Common\ComplexSerializerCodeGenerator.tt"
25  [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "12.0.0.0")]
26  internal partial class ComplexSerializerCodeGenerator : ComplexSerializerCodeGeneratorBase
27  {
28 #line hidden
29  /// <summary>
30  /// Create the template output
31  /// </summary>
32  public virtual string TransformText()
33  {
34  this.Write(@"
35 using System;
36 using System.Collections.Generic;
37 using System.Reflection;
38 using SiliconStudio.Core.Serialization;
39 using SiliconStudio.Core.Reflection;
40 using SiliconStudio.Core.Serialization.Serializers;
41 using SiliconStudio.DataSerializers;
42 
43 [assembly: AssemblyVersion(""");
44 
45  #line 17 "C:\DEV\paradox\sources\common\core\SiliconStudio.AssemblyProcessor.Common\ComplexSerializerCodeGenerator.tt"
46  this.Write(this.ToStringHelper.ToStringWithCulture(assembly.Name.Version.ToString()));
47 
48  #line default
49  #line hidden
50  this.Write("\")]\r\n");
51 
52  #line 18 "C:\DEV\paradox\sources\common\core\SiliconStudio.AssemblyProcessor.Common\ComplexSerializerCodeGenerator.tt"
53  if (targetFramework != null) {
54 
55  #line default
56  #line hidden
57  this.Write("[assembly: System.Runtime.Versioning.TargetFramework(");
58 
59  #line 19 "C:\DEV\paradox\sources\common\core\SiliconStudio.AssemblyProcessor.Common\ComplexSerializerCodeGenerator.tt"
60  this.Write(this.ToStringHelper.ToStringWithCulture(targetFramework));
61 
62  #line default
63  #line hidden
64  this.Write(")]\r\n");
65 
66  #line 20 "C:\DEV\paradox\sources\common\core\SiliconStudio.AssemblyProcessor.Common\ComplexSerializerCodeGenerator.tt"
67  }
68 
69  #line default
70  #line hidden
71  this.Write("\r\n[assembly: SiliconStudio.Core.Serialization.Serializers.AssemblySerializerFacto" +
72  "ry(Type = typeof(SiliconStudio.DataSerializers.");
73 
74  #line 22 "C:\DEV\paradox\sources\common\core\SiliconStudio.AssemblyProcessor.Common\ComplexSerializerCodeGenerator.tt"
75  this.Write(this.ToStringHelper.ToStringWithCulture(assemblySerializerFactoryClassName));
76 
77  #line default
78  #line hidden
79  this.Write(@"))]
80 
81 namespace SiliconStudio.Core.Serialization.Serializers
82 {
83  class AssemblySerializerFactoryAttribute : Attribute
84  {
85  public Type Type;
86  }
87 }
88 
89 namespace SiliconStudio.DataSerializers
90 {
91  // Assembly attributes that defines supported serializer (only generics one so that other assemblies can do generic instantiations by themselves)
92 ");
93 
94  #line 35 "C:\DEV\paradox\sources\common\core\SiliconStudio.AssemblyProcessor.Common\ComplexSerializerCodeGenerator.tt"
95  foreach (var profile in cecilSerializerContext.SerializableTypesProfiles) {
96  foreach (var type in profile.Value.SerializableTypes.Where(x => x.Value.Local && x.Value.SerializerType != null)) {
97 
98  #line default
99  #line hidden
100  this.Write(" [DataSerializerGlobalAttribute(typeof(");
101 
102  #line 37 "C:\DEV\paradox\sources\common\core\SiliconStudio.AssemblyProcessor.Common\ComplexSerializerCodeGenerator.tt"
103  this.Write(this.ToStringHelper.ToStringWithCulture(type.Value.SerializerType.ConvertCSharp(false)));
104 
105  #line default
106  #line hidden
107  this.Write("), typeof(");
108 
109  #line 37 "C:\DEV\paradox\sources\common\core\SiliconStudio.AssemblyProcessor.Common\ComplexSerializerCodeGenerator.tt"
110  this.Write(this.ToStringHelper.ToStringWithCulture(type.Key.ConvertCSharp(false)));
111 
112  #line default
113  #line hidden
114  this.Write("), DataSerializerGenericMode.");
115 
116  #line 37 "C:\DEV\paradox\sources\common\core\SiliconStudio.AssemblyProcessor.Common\ComplexSerializerCodeGenerator.tt"
117  this.Write(this.ToStringHelper.ToStringWithCulture(type.Value.Mode.ToString()));
118 
119  #line default
120  #line hidden
121  this.Write(", ");
122 
123  #line 37 "C:\DEV\paradox\sources\common\core\SiliconStudio.AssemblyProcessor.Common\ComplexSerializerCodeGenerator.tt"
124  this.Write(this.ToStringHelper.ToStringWithCulture(type.Value.Inherited ? "true" : "false"));
125 
126  #line default
127  #line hidden
128  this.Write(", ");
129 
130  #line 37 "C:\DEV\paradox\sources\common\core\SiliconStudio.AssemblyProcessor.Common\ComplexSerializerCodeGenerator.tt"
131  this.Write(this.ToStringHelper.ToStringWithCulture(type.Value.ComplexSerializer ? "true" : "false"));
132 
133  #line default
134  #line hidden
135  this.Write(", Profile = \"");
136 
137  #line 37 "C:\DEV\paradox\sources\common\core\SiliconStudio.AssemblyProcessor.Common\ComplexSerializerCodeGenerator.tt"
138  this.Write(this.ToStringHelper.ToStringWithCulture(profile.Key));
139 
140  #line default
141  #line hidden
142  this.Write("\")]\r\n");
143 
144  #line 38 "C:\DEV\paradox\sources\common\core\SiliconStudio.AssemblyProcessor.Common\ComplexSerializerCodeGenerator.tt"
145  }
146  foreach (var type in profile.Value.GenericSerializableTypes.Where(x => x.Value.Local && x.Value.SerializerType != null)) {
147 
148  #line default
149  #line hidden
150  this.Write(" [DataSerializerGlobalAttribute(typeof(");
151 
152  #line 40 "C:\DEV\paradox\sources\common\core\SiliconStudio.AssemblyProcessor.Common\ComplexSerializerCodeGenerator.tt"
153  this.Write(this.ToStringHelper.ToStringWithCulture(type.Value.SerializerType.ConvertCSharp(true)));
154 
155  #line default
156  #line hidden
157  this.Write("), typeof(");
158 
159  #line 40 "C:\DEV\paradox\sources\common\core\SiliconStudio.AssemblyProcessor.Common\ComplexSerializerCodeGenerator.tt"
160  this.Write(this.ToStringHelper.ToStringWithCulture(type.Key.ConvertCSharp(true)));
161 
162  #line default
163  #line hidden
164  this.Write("), DataSerializerGenericMode.");
165 
166  #line 40 "C:\DEV\paradox\sources\common\core\SiliconStudio.AssemblyProcessor.Common\ComplexSerializerCodeGenerator.tt"
167  this.Write(this.ToStringHelper.ToStringWithCulture(type.Value.Mode.ToString()));
168 
169  #line default
170  #line hidden
171  this.Write(", ");
172 
173  #line 40 "C:\DEV\paradox\sources\common\core\SiliconStudio.AssemblyProcessor.Common\ComplexSerializerCodeGenerator.tt"
174  this.Write(this.ToStringHelper.ToStringWithCulture(type.Value.Inherited ? "true" : "false"));
175 
176  #line default
177  #line hidden
178  this.Write(", ");
179 
180  #line 40 "C:\DEV\paradox\sources\common\core\SiliconStudio.AssemblyProcessor.Common\ComplexSerializerCodeGenerator.tt"
181  this.Write(this.ToStringHelper.ToStringWithCulture(type.Value.ComplexSerializer ? "true" : "false"));
182 
183  #line default
184  #line hidden
185  this.Write(", Profile = \"");
186 
187  #line 40 "C:\DEV\paradox\sources\common\core\SiliconStudio.AssemblyProcessor.Common\ComplexSerializerCodeGenerator.tt"
188  this.Write(this.ToStringHelper.ToStringWithCulture(profile.Key));
189 
190  #line default
191  #line hidden
192  this.Write("\")]\r\n");
193 
194  #line 41 "C:\DEV\paradox\sources\common\core\SiliconStudio.AssemblyProcessor.Common\ComplexSerializerCodeGenerator.tt"
195  }
196  }
197 
198  #line default
199  #line hidden
200  this.Write(" \tpublic static class ");
201 
202  #line 43 "C:\DEV\paradox\sources\common\core\SiliconStudio.AssemblyProcessor.Common\ComplexSerializerCodeGenerator.tt"
203  this.Write(this.ToStringHelper.ToStringWithCulture(assemblySerializerFactoryClassName));
204 
205  #line default
206  #line hidden
207  this.Write("\r\n\t{\r\n\t [SiliconStudio.Core.ModuleInitializer]\r\n internal static void I" +
208  "nitialize()\r\n {\r\n");
209 
210  #line 48 "C:\DEV\paradox\sources\common\core\SiliconStudio.AssemblyProcessor.Common\ComplexSerializerCodeGenerator.tt"
211  foreach (var profile in cecilSerializerContext.SerializableTypesProfiles) {
212 
213  #line default
214  #line hidden
215  this.Write("\t\t\tDataSerializerFactory.RegisterSerializationProfile(\"");
216 
217  #line 49 "C:\DEV\paradox\sources\common\core\SiliconStudio.AssemblyProcessor.Common\ComplexSerializerCodeGenerator.tt"
218  this.Write(this.ToStringHelper.ToStringWithCulture(profile.Key));
219 
220  #line default
221  #line hidden
222  this.Write("\", Register");
223 
224  #line 49 "C:\DEV\paradox\sources\common\core\SiliconStudio.AssemblyProcessor.Common\ComplexSerializerCodeGenerator.tt"
225  this.Write(this.ToStringHelper.ToStringWithCulture(profile.Key));
226 
227  #line default
228  #line hidden
229  this.Write(");\r\n");
230 
231  #line 50 "C:\DEV\paradox\sources\common\core\SiliconStudio.AssemblyProcessor.Common\ComplexSerializerCodeGenerator.tt"
232  }
233 
234  #line default
235  #line hidden
236  this.Write(" }\r\n\r\n");
237 
238  #line 53 "C:\DEV\paradox\sources\common\core\SiliconStudio.AssemblyProcessor.Common\ComplexSerializerCodeGenerator.tt"
239  foreach (var profile in cecilSerializerContext.SerializableTypesProfiles) {
240 
241  #line default
242  #line hidden
243  this.Write("\t\tpublic static void Register");
244 
245  #line 54 "C:\DEV\paradox\sources\common\core\SiliconStudio.AssemblyProcessor.Common\ComplexSerializerCodeGenerator.tt"
246  this.Write(this.ToStringHelper.ToStringWithCulture(profile.Key));
247 
248  #line default
249  #line hidden
250  this.Write("(DataSerializerFactory serializerFactory)\r\n\t\t{\r\n\t\t\t// Force module .ctor of refer" +
251  "enced assemblies to be initialized as well\r\n");
252 
253  #line 57 "C:\DEV\paradox\sources\common\core\SiliconStudio.AssemblyProcessor.Common\ComplexSerializerCodeGenerator.tt"
254  foreach (var referencedAssemblySerializerFactoryType in referencedAssemblySerializerFactoryTypes) {
255 
256  #line default
257  #line hidden
258  this.Write("\t\t\tModuleRuntimeHelpers.RunModuleConstructor(typeof(");
259 
260  #line 58 "C:\DEV\paradox\sources\common\core\SiliconStudio.AssemblyProcessor.Common\ComplexSerializerCodeGenerator.tt"
261  this.Write(this.ToStringHelper.ToStringWithCulture(referencedAssemblySerializerFactoryType.ConvertCSharp()));
262 
263  #line default
264  #line hidden
265  this.Write(").GetTypeInfo().Module);\r\n");
266 
267  #line 59 "C:\DEV\paradox\sources\common\core\SiliconStudio.AssemblyProcessor.Common\ComplexSerializerCodeGenerator.tt"
268  }
269 
270  #line default
271  #line hidden
272  this.Write("\r\n\t\t\t// Register types used by this assembly\r\n");
273 
274  #line 62 "C:\DEV\paradox\sources\common\core\SiliconStudio.AssemblyProcessor.Common\ComplexSerializerCodeGenerator.tt"
275  foreach (var type in profile.Value.SerializableTypes.Where(x => x.Value.Local)) {
276 
277  #line default
278  #line hidden
279  this.Write("\t\t\tif (!serializerFactory.CanSerialize(typeof(");
280 
281  #line 63 "C:\DEV\paradox\sources\common\core\SiliconStudio.AssemblyProcessor.Common\ComplexSerializerCodeGenerator.tt"
282  this.Write(this.ToStringHelper.ToStringWithCulture(type.Key.ConvertCSharp()));
283 
284  #line default
285  #line hidden
286  this.Write(")))\r\n\t\t\t{\r\n");
287 
288  #line 65 "C:\DEV\paradox\sources\common\core\SiliconStudio.AssemblyProcessor.Common\ComplexSerializerCodeGenerator.tt"
289  if (type.Value.SerializerType != null) {
290 
291  #line default
292  #line hidden
293  this.Write("\t\t\t\tserializerFactory.RegisterSerializer(");
294 
295  #line 66 "C:\DEV\paradox\sources\common\core\SiliconStudio.AssemblyProcessor.Common\ComplexSerializerCodeGenerator.tt"
296  this.Write(this.ToStringHelper.ToStringWithCulture(type.Key.ConvertTypeId()));
297 
298  #line default
299  #line hidden
300  this.Write(", new ");
301 
302  #line 66 "C:\DEV\paradox\sources\common\core\SiliconStudio.AssemblyProcessor.Common\ComplexSerializerCodeGenerator.tt"
303  this.Write(this.ToStringHelper.ToStringWithCulture(type.Value.SerializerType.ConvertCSharp()));
304 
305  #line default
306  #line hidden
307  this.Write("());\r\n");
308 
309  #line 67 "C:\DEV\paradox\sources\common\core\SiliconStudio.AssemblyProcessor.Common\ComplexSerializerCodeGenerator.tt"
310  } else {
311 
312  #line default
313  #line hidden
314  this.Write("\t\t\t\tserializerFactory.RegisterNullSerializer(");
315 
316  #line 68 "C:\DEV\paradox\sources\common\core\SiliconStudio.AssemblyProcessor.Common\ComplexSerializerCodeGenerator.tt"
317  this.Write(this.ToStringHelper.ToStringWithCulture(type.Key.ConvertTypeId()));
318 
319  #line default
320  #line hidden
321  this.Write(", typeof(");
322 
323  #line 68 "C:\DEV\paradox\sources\common\core\SiliconStudio.AssemblyProcessor.Common\ComplexSerializerCodeGenerator.tt"
324  this.Write(this.ToStringHelper.ToStringWithCulture(type.Key.ConvertCSharp()));
325 
326  #line default
327  #line hidden
328  this.Write("));\r\n");
329 
330  #line 69 "C:\DEV\paradox\sources\common\core\SiliconStudio.AssemblyProcessor.Common\ComplexSerializerCodeGenerator.tt"
331  }
332 
333  #line default
334  #line hidden
335  this.Write("\t\t\t}\r\n");
336 
337  #line 71 "C:\DEV\paradox\sources\common\core\SiliconStudio.AssemblyProcessor.Common\ComplexSerializerCodeGenerator.tt"
338  }
339 
340  #line default
341  #line hidden
342  this.Write("\t\t}\r\n\r\n");
343 
344  #line 74 "C:\DEV\paradox\sources\common\core\SiliconStudio.AssemblyProcessor.Common\ComplexSerializerCodeGenerator.tt"
345  } // foreach (profile)
346 
347  #line default
348  #line hidden
349  this.Write("\t}\r\n}\r\n\r\n");
350 
351  #line 78 "C:\DEV\paradox\sources\common\core\SiliconStudio.AssemblyProcessor.Common\ComplexSerializerCodeGenerator.tt"
352 
353 // Generate complex serializers
354 foreach (var complexType in cecilSerializerContext.ComplexTypes)
355 {
356  var complexClassSerializerGenerator = new ComplexClassSerializerGenerator(complexType.Key, complexType.Value.ComplexSerializerProcessParentType);
357  Write(complexClassSerializerGenerator.TransformText());
358 }
359 
360  #line default
361  #line hidden
362  return this.GenerationEnvironment.ToString();
363  }
364  }
365 
366  #line default
367  #line hidden
368  #region Base class
369  /// <summary>
370  /// Base class for this transformation
371  /// </summary>
372  [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "12.0.0.0")]
373  internal class ComplexSerializerCodeGeneratorBase
374  {
375  #region Fields
376  private global::System.Text.StringBuilder generationEnvironmentField;
377  private global::System.CodeDom.Compiler.CompilerErrorCollection errorsField;
378  private global::System.Collections.Generic.List<int> indentLengthsField;
379  private string currentIndentField = "";
380  private bool endsWithNewline;
381  private global::System.Collections.Generic.IDictionary<string, object> sessionField;
382  #endregion
383  #region Properties
384  /// <summary>
385  /// The string builder that generation-time code is using to assemble generated output
386  /// </summary>
387  protected System.Text.StringBuilder GenerationEnvironment
388  {
389  get
390  {
391  if ((this.generationEnvironmentField == null))
392  {
393  this.generationEnvironmentField = new global::System.Text.StringBuilder();
394  }
395  return this.generationEnvironmentField;
396  }
397  set
398  {
399  this.generationEnvironmentField = value;
400  }
401  }
402  /// <summary>
403  /// The error collection for the generation process
404  /// </summary>
405  public System.CodeDom.Compiler.CompilerErrorCollection Errors
406  {
407  get
408  {
409  if ((this.errorsField == null))
410  {
411  this.errorsField = new global::System.CodeDom.Compiler.CompilerErrorCollection();
412  }
413  return this.errorsField;
414  }
415  }
416  /// <summary>
417  /// A list of the lengths of each indent that was added with PushIndent
418  /// </summary>
419  private System.Collections.Generic.List<int> indentLengths
420  {
421  get
422  {
423  if ((this.indentLengthsField == null))
424  {
425  this.indentLengthsField = new global::System.Collections.Generic.List<int>();
426  }
427  return this.indentLengthsField;
428  }
429  }
430  /// <summary>
431  /// Gets the current indent we use when adding lines to the output
432  /// </summary>
433  public string CurrentIndent
434  {
435  get
436  {
437  return this.currentIndentField;
438  }
439  }
440  /// <summary>
441  /// Current transformation session
442  /// </summary>
443  public virtual global::System.Collections.Generic.IDictionary<string, object> Session
444  {
445  get
446  {
447  return this.sessionField;
448  }
449  set
450  {
451  this.sessionField = value;
452  }
453  }
454  #endregion
455  #region Transform-time helpers
456  /// <summary>
457  /// Write text directly into the generated output
458  /// </summary>
459  public void Write(string textToAppend)
460  {
461  if (string.IsNullOrEmpty(textToAppend))
462  {
463  return;
464  }
465  // If we're starting off, or if the previous text ended with a newline,
466  // we have to append the current indent first.
467  if (((this.GenerationEnvironment.Length == 0)
468  || this.endsWithNewline))
469  {
470  this.GenerationEnvironment.Append(this.currentIndentField);
471  this.endsWithNewline = false;
472  }
473  // Check if the current text ends with a newline
474  if (textToAppend.EndsWith(global::System.Environment.NewLine, global::System.StringComparison.CurrentCulture))
475  {
476  this.endsWithNewline = true;
477  }
478  // This is an optimization. If the current indent is "", then we don't have to do any
479  // of the more complex stuff further down.
480  if ((this.currentIndentField.Length == 0))
481  {
482  this.GenerationEnvironment.Append(textToAppend);
483  return;
484  }
485  // Everywhere there is a newline in the text, add an indent after it
486  textToAppend = textToAppend.Replace(global::System.Environment.NewLine, (global::System.Environment.NewLine + this.currentIndentField));
487  // If the text ends with a newline, then we should strip off the indent added at the very end
488  // because the appropriate indent will be added when the next time Write() is called
489  if (this.endsWithNewline)
490  {
491  this.GenerationEnvironment.Append(textToAppend, 0, (textToAppend.Length - this.currentIndentField.Length));
492  }
493  else
494  {
495  this.GenerationEnvironment.Append(textToAppend);
496  }
497  }
498  /// <summary>
499  /// Write text directly into the generated output
500  /// </summary>
501  public void WriteLine(string textToAppend)
502  {
503  this.Write(textToAppend);
504  this.GenerationEnvironment.AppendLine();
505  this.endsWithNewline = true;
506  }
507  /// <summary>
508  /// Write formatted text directly into the generated output
509  /// </summary>
510  public void Write(string format, params object[] args)
511  {
512  this.Write(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args));
513  }
514  /// <summary>
515  /// Write formatted text directly into the generated output
516  /// </summary>
517  public void WriteLine(string format, params object[] args)
518  {
519  this.WriteLine(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args));
520  }
521  /// <summary>
522  /// Raise an error
523  /// </summary>
524  public void Error(string message)
525  {
526  System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError();
527  error.ErrorText = message;
528  this.Errors.Add(error);
529  }
530  /// <summary>
531  /// Raise a warning
532  /// </summary>
533  public void Warning(string message)
534  {
535  System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError();
536  error.ErrorText = message;
537  error.IsWarning = true;
538  this.Errors.Add(error);
539  }
540  /// <summary>
541  /// Increase the indent
542  /// </summary>
543  public void PushIndent(string indent)
544  {
545  if ((indent == null))
546  {
547  throw new global::System.ArgumentNullException("indent");
548  }
549  this.currentIndentField = (this.currentIndentField + indent);
550  this.indentLengths.Add(indent.Length);
551  }
552  /// <summary>
553  /// Remove the last indent that was added with PushIndent
554  /// </summary>
555  public string PopIndent()
556  {
557  string returnValue = "";
558  if ((this.indentLengths.Count > 0))
559  {
560  int indentLength = this.indentLengths[(this.indentLengths.Count - 1)];
561  this.indentLengths.RemoveAt((this.indentLengths.Count - 1));
562  if ((indentLength > 0))
563  {
564  returnValue = this.currentIndentField.Substring((this.currentIndentField.Length - indentLength));
565  this.currentIndentField = this.currentIndentField.Remove((this.currentIndentField.Length - indentLength));
566  }
567  }
568  return returnValue;
569  }
570  /// <summary>
571  /// Remove any indentation
572  /// </summary>
573  public void ClearIndent()
574  {
575  this.indentLengths.Clear();
576  this.currentIndentField = "";
577  }
578  #endregion
579  #region ToString Helpers
580  /// <summary>
581  /// Utility class to produce culture-oriented representation of an object as a string.
582  /// </summary>
584  {
585  private System.IFormatProvider formatProviderField = global::System.Globalization.CultureInfo.InvariantCulture;
586  /// <summary>
587  /// Gets or sets format provider to be used by ToStringWithCulture method.
588  /// </summary>
589  public System.IFormatProvider FormatProvider
590  {
591  get
592  {
593  return this.formatProviderField ;
594  }
595  set
596  {
597  if ((value != null))
598  {
599  this.formatProviderField = value;
600  }
601  }
602  }
603  /// <summary>
604  /// This is called from the compile/run appdomain to convert objects within an expression block to a string
605  /// </summary>
606  public string ToStringWithCulture(object objectToConvert)
607  {
608  if ((objectToConvert == null))
609  {
610  throw new global::System.ArgumentNullException("objectToConvert");
611  }
612  System.Type t = objectToConvert.GetType();
613  System.Reflection.MethodInfo method = t.GetMethod("ToString", new System.Type[] {
614  typeof(System.IFormatProvider)});
615  if ((method == null))
616  {
617  return objectToConvert.ToString();
618  }
619  else
620  {
621  return ((string)(method.Invoke(objectToConvert, new object[] {
622  this.formatProviderField })));
623  }
624  }
625  }
626  private ToStringInstanceHelper toStringHelperField = new ToStringInstanceHelper();
627  /// <summary>
628  /// Helper to produce culture-oriented representation of an object as a string
629  /// </summary>
630  public ToStringInstanceHelper ToStringHelper
631  {
632  get
633  {
634  return this.toStringHelperField;
635  }
636  }
637  #endregion
638  }
639  #endregion
640 }
Utility class to produce culture-oriented representation of an object as a string.
An error message (level 4).
string ToStringWithCulture(object objectToConvert)
This is called from the compile/run appdomain to convert objects within an expression block to a stri...
_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).