/// <summary> /// Constructor /// </summary> public Scripter() { this.Types = new HashSet <TsType>(); // Add mappings for primitives this.TypeLookup = new Dictionary <Type, TsType>() { { typeof(void), TsPrimitive.Void }, { typeof(object), TsPrimitive.Any }, { typeof(string), TsPrimitive.String }, { typeof(bool), TsPrimitive.Boolean }, { typeof(byte), TsPrimitive.Number }, { typeof(short), TsPrimitive.Number }, { typeof(int), TsPrimitive.Number }, { typeof(long), TsPrimitive.Number }, { typeof(float), TsPrimitive.Number }, { typeof(double), TsPrimitive.Number }, }; this.RegisterTypeMapping(CreateGenericDictionaryType(), typeof(Dictionary <,>)); this.RegisterTypeMapping(TsPrimitive.Any, typeof(ValueType)); // initialize the scripter with default implementations this.Reader = new TypeReader(); this.Formatter = new TsFormatter(); }
/// <summary> /// Constructor /// </summary> public Scripter(Compilation compilation) { Types = new HashSet <TsType>(); _compilation = compilation; // Add mappings for primitives TypeLookup = new Dictionary <ITypeSymbol, TsType>(new TypeSymbolEqualityComparer()) { { _compilation.GetSpecialType(SpecialType.System_Void), TsPrimitive.Void }, { _compilation.GetSpecialType(SpecialType.System_Object), TsPrimitive.Any }, { _compilation.GetSpecialType(SpecialType.System_String), TsPrimitive.String }, { _compilation.GetSpecialType(SpecialType.System_Boolean), TsPrimitive.Boolean }, { _compilation.GetSpecialType(SpecialType.System_Byte), TsPrimitive.Number }, { _compilation.GetSpecialType(SpecialType.System_Single), TsPrimitive.Number }, { _compilation.GetSpecialType(SpecialType.System_Int16), TsPrimitive.Number }, { _compilation.GetSpecialType(SpecialType.System_Int32), TsPrimitive.Number }, { _compilation.GetSpecialType(SpecialType.System_Int64), TsPrimitive.Number }, { _compilation.GetSpecialType(SpecialType.System_UInt16), TsPrimitive.Number }, { _compilation.GetSpecialType(SpecialType.System_UInt32), TsPrimitive.Number }, { _compilation.GetSpecialType(SpecialType.System_UInt64), TsPrimitive.Number }, { _compilation.GetSpecialType(SpecialType.System_Decimal), TsPrimitive.Number }, { _compilation.GetSpecialType(SpecialType.System_Double), TsPrimitive.Number }, { _compilation.GetSpecialType(SpecialType.System_DateTime), TsPrimitive.Date }, }; AddAdditionalTypesAsKnown(new[] { new Tuple <Type, TsPrimitive>(typeof(Guid), TsPrimitive.String), new Tuple <Type, TsPrimitive>(typeof(Uri), TsPrimitive.String), new Tuple <Type, TsPrimitive>(typeof(Task), TsPrimitive.Void), }); // initialize the scripter with default implementations Formatter = new LowerCamelCaseFormatter(false); }
void IDisposable.Dispose() { if (mFormatter != null) { mFormatter.Context.IndentLevel--; mFormatter = null; } }
public StringBuilderContext(TsFormatter writer) { Writer = writer; PriorContext = writer.Context; IndentLevel = PriorContext != null ? PriorContext.IndentLevel : 0; StringBuilder = new StringBuilder(); Writer.Context = this; }
/// <summary> /// Configures the scripter to use a particular formatter /// </summary> /// <param name="formatter">The formatter</param> /// <returns></returns> public Scripter UsingFormatter(TsFormatter formatter) { this.Formatter = formatter; return(this); }
public IndentContext(TsFormatter formatter) { mFormatter = formatter; mFormatter.Context.IndentLevel++; }