public override void WriteType(SolutionFile File, SolutionProjectLanguageType Type, SolutionBuilder Context) { File.Write(this, Context, Type.Comments); File.WriteUsingNamespaceList(this, Type); File.WriteLine(); File.Region( delegate { WriteNamespace(File, Type.Namespace, delegate { if (Type.Summary != null) { this.WriteSummary( File, Type.Summary ); } File.Region( delegate { File.WriteIndent(); if (Type.IsInternal) { File.WriteSpace(Keywords.@internal); } else { File.WriteSpace(Keywords.@public); } if (Type.IsStatic) { File.WriteSpace(Keywords.@static); } if (Type.IsSealed) { File.WriteSpace(Keywords.@sealed); } if (Type.IsPartial) { File.WriteSpace(Keywords.@partial); } if (Type.IsInterface) { File.WriteSpace(Keywords.@interface); } else { File.WriteSpace(Keywords.@class); } File.Write(Type); if (Type.BaseType != null) { File.WriteSpaces(":"); WriteTypeName(File, Type.BaseType); } File.WriteLine(); File.WriteIndent(); File.WriteLine("{"); File.Indent(this, delegate { #region Fields Type.Fields.WithEach( Field => { this.WriteSummary(File, Field.Summary); File.WriteIndent(); if (Field.IsPrivate) { File.WriteSpace(Keywords.@private); } else { File.WriteSpace(Keywords.@public); } if (Field.IsReadOnly) { File.WriteSpace(Keywords.@readonly); } WriteTypeName(File, Field.FieldType); File.WriteSpace().Write(Field.Name); if (Field.FieldConstructor != null) { File.WriteSpaces("="); this.WritePseudoCallExpression(File, Field.FieldConstructor, Context); } File.WriteLine(";"); File.WriteLine(); } ); #endregion #region Properties foreach (var m in Type.Properties.ToArray()) { File.WriteIndent(); if (Type.IsInterface) { } else { File.Write(Keywords.@public); File.WriteSpace(); if (m.IsStatic) { File.Write(Keywords.@static); File.WriteSpace(); } } WriteTypeName(File, m.PropertyType); File.WriteSpace(); File.Write(m.Name); if (m.IsAutoProperty) { File.WriteSpace(); File.Write("{"); } else { File.WriteLine(); File.WriteIndent(); File.WriteLine("{"); } Action <SolutionProjectLanguageMethod, Keyword> Property = (mm, kk) => { if (mm != null) { if (m.IsAutoProperty) { File.WriteSpace(); } else { File.WriteIndent(); } File.Write(kk); if (mm.Code == null) { File.Write(";"); if (m.IsAutoProperty) { } else { File.WriteLine(); } } else { File.WriteLine(); this.WriteMethodBody(File, mm.Code, Context); } } }; Action PropertyBody = delegate { Property(m.GetMethod, Keywords.get); Property(m.SetMethod, Keywords.set); }; Action <Action> PropertyIndent = Body => File.Indent(this, Body); if (m.IsAutoProperty) { PropertyBody(); File.WriteSpace(); } else { File.Indent(this, PropertyBody); File.WriteIndent(); } File.WriteLine("}"); } #endregion if (Type.Properties.Any()) { File.WriteLine(); } foreach (var item in Type.Methods.ToArray()) { if (item.DeclaringType == null) { item.DeclaringType = Type; } this.WriteMethod( File, item, Context ); File.WriteLine(); } } ); File.WriteIndent().WriteLine("}"); } ); } ); } ); }
public override void WriteType(SolutionFile File, SolutionProjectLanguageType Type, SolutionBuilder Context) { // http://msdn.microsoft.com/en-us/library/dd233205.aspx File.Write(this, Context, Type.Comments); File.Region( delegate { WriteNamespace(File, Type.Namespace, delegate { File.WriteUsingNamespaceList(this, Type); File.WriteLine(); this.WriteSummary( File, Type.Summary ); File.Region( delegate { File.WriteIndent(); var Constructor = Type.Methods.SingleOrDefault(k => k.IsConstructor); if (Type.IsStatic) { File.WriteSpace(Keywords.@module); WriteTypeName(File, Type); File.WriteSpace(); File.Write("="); File.WriteLine(); } else { File.Write("[<Sealed>]"); File.WriteLine(); File.WriteIndent(); File.WriteSpace(Keywords.type); if (Type.IsInternal) { File.WriteSpace(Keywords.@internal); } WriteTypeName(File, Type); File.Write("("); if (Constructor != null) { this.InternalWriteParameters(File, Constructor, Constructor.Parameters.ToArray()); } File.WriteSpace(")"); File.WriteSpace(Keywords.@as); File.WriteSpace("me"); File.WriteSpace("="); File.WriteLine(); File.Indent(this, delegate { if (Type.BaseType != null) { File.WriteIndent(); File.WriteSpace(Keywords.@inherit); WriteTypeName(File, Type.BaseType); File.Write("("); File.WriteSpace(")"); File.WriteLine(); } // only need this if there are any members beyond ctor? File.WriteIndent(); File.WriteSpace(Keywords.@let); File.Write("this"); File.WriteSpaces("="); File.Write("me"); File.WriteLine(); File.WriteLine(); File.WriteIndent(); File.WriteSpace(Keywords.@do); File.Write("()"); File.WriteLine(); File.WriteLine(); } ); } // .ctor ! File.Indent(this, delegate { if (!Type.IsStatic) { #region Fields with FieldConstructor Type.Fields.WithEach( Field => { // http://msdn.microsoft.com/en-us/library/dd469494.aspx if (Field.FieldConstructor != null) { File.WriteIndent().WriteSpace(Keywords.let).Write(Field.Name).WriteSpaces("="); this.WritePseudoCallExpression(File, Field.FieldConstructor, Context); } else { // first asignment shall do a let if (Field.IsReadOnly) { return; } File.WriteIndent().WriteSpace(Keywords.let).WriteSpace(Keywords.mutable); File.Write(Field.Name).WriteSpaces(":"); WriteTypeName(File, Field.FieldType); File.WriteSpaces("=").Write(Keywords.@null); } File.WriteLine(); } ); #endregion if (Constructor != null) { this.WriteMethodBody( File, Constructor.Code, Context ); } File.WriteLine(); File.WriteLine(); } foreach (var item in (from m in Type.Methods where !m.IsConstructor select m).ToArray()) { if (item.DeclaringType == null) { item.DeclaringType = Type; } this.WriteMethod( File, item, Context ); File.WriteLine(); } } ); } ); } ); } ); }
public override void WriteMethod(SolutionFile File, SolutionProjectLanguageMethod m, SolutionBuilder Context) { if (!m.IsLambda) { if (m.Summary != null) { this.WriteSummary(File, m.Summary, m.Parameters.ToArray()); } } File.Region( delegate { if (m.IsLambda) { var Parameters = m.Parameters.ToArray(); if (Parameters.Length != 1) { File.Write("("); } for (int i = 0; i < Parameters.Length; i++) { if (i > 0) { File.WriteSpace(","); } File.Write(Parameters[i].Name); } if (Parameters.Length != 1) { File.WriteSpace(")"); } else { File.WriteSpace(); } File.WriteSpace("=>"); if (m.Code.History.Count != 1) { File.WriteLine(); } this.WriteMethodBody(File, m.Code, Context); return; } #region not lambda File.WriteIndent(); if (m.IsPrivate) { File.Write(Keywords.@private); } else if (m.IsProtected) { File.Write(Keywords.@protected); } else { File.Write(Keywords.@public); } File.WriteSpace(); if (m.IsOverride) { File.WriteSpace(Keywords.@override); } if (m.IsStatic) { File.WriteSpace(Keywords.@static); } if (m.IsConstructor) { WriteTypeName(File, m.DeclaringType); } else { File.WriteSpace(Keywords.@void).Write(m.Name); } #endregion { var Parameters = m.Parameters.ToArray(); File.Write("("); for (int i = 0; i < Parameters.Length; i++) { if (i > 0) { File.WriteSpace(","); } this.WriteTypeName(File, Parameters[i].Type); File.WriteSpace(); File.Write(Parameters[i].Name); } File.Write(")"); } if (m.Code == null) { File.WriteLine(";"); } else { File.WriteLine(); this.WriteMethodBody(File, m.Code, Context); if (!m.IsLambda) { File.WriteLine(); } } } ); }
public override void WriteType(SolutionFile File, SolutionProjectLanguageType Type, SolutionBuilder Context) { File.Write(this, Context, Type.Comments); // should the namespaces be clickable? File.WriteUsingNamespaceList(this, Type); File.WriteLine(); File.Region( delegate { WriteNamespace(File, Type.Namespace, delegate { this.WriteSummary( File, Type.Summary ); File.Region( delegate { File.WriteIndent(); if (Type.IsPartial) { File.WriteSpace(Keywords.Partial); } File.WriteSpace(Keywords.Public); if (Type.IsSealed) { File.WriteSpace(Keywords.NotInheritable); } if (!Type.IsStatic) { File.WriteSpace(Keywords.Class); } else { File.WriteSpace(Keywords.Module); } File.Write(Type); File.WriteLine(); File.Indent(this, delegate { Type.BaseType.With( BaseType => { File.WriteIndent().WriteSpace(Keywords.Inherits); WriteTypeName(File, BaseType); File.WriteLine(); } ); #region Fields Type.Fields.WithEach( Field => { this.WriteSummary(File, Field.Summary); File.WriteIndent(); if (Field.IsPrivate) { File.WriteSpace(Keywords.Private); } else { File.WriteSpace(Keywords.Public); } if (Field.IsReadOnly) { File.WriteSpace(Keywords.ReadOnly); } File.WriteSpace(Field.Name); File.WriteSpace(Keywords.As); if (Field.FieldConstructor == null) { WriteTypeName(File, Field.FieldType); } else { WritePseudoCallExpression(File, Field.FieldConstructor, Context); } File.WriteLine(); File.WriteLine(); } ); #endregion #region Methods foreach (var item in Type.Methods.ToArray()) { if (item.DeclaringType == null) { item.DeclaringType = Type; } this.WriteMethod( File, item, Context ); File.WriteLine(); } #endregion File.WriteLine(); } ); File.WriteIndent(); File.Write(Keywords.End); File.WriteSpace(); if (!Type.IsStatic) { File.Write(Keywords.Class); } else { File.Write(Keywords.Module); } } ); File.WriteLine(); } ); } ); File.WriteLine(); }
public override void WriteMethod(SolutionFile File, SolutionProjectLanguageMethod Method, SolutionBuilder Context) { var m = Method; if (!m.IsLambda) { this.WriteSummary(File, m.Summary, m.Parameters.ToArray()); } File.Region( delegate { if (m.IsLambda) { if (Method.IsFunction) { File.WriteSpace(Keywords.Function); } else { File.WriteSpace(Keywords.Sub); } } else { File.WriteIndent(); if (m.IsProtected) { File.WriteSpace(Keywords.Protected); } else { File.WriteSpace(Keywords.Public); } if (m.IsStatic) { var IsModule = false; if (m.DeclaringType != null) { if (m.DeclaringType.IsStatic) { IsModule = true; } } if (IsModule) { } else { File.WriteSpace(Keywords.Shared); } } if (m.IsOverride) { File.WriteSpace(Keywords.Overrides); } if (Method.IsFunction) { File.WriteSpace(Keywords.Function); } else { File.WriteSpace(Keywords.Sub); } if (m.IsConstructor) { File.Write(Keywords.New); } else { File.Write(m.Name); } } File.Write("("); #region Parameters var Parameters = m.Parameters.ToArray(); for (int i = 0; i < Parameters.Length; i++) { if (i > 0) { File.WriteSpace(","); } File.Write(Parameters[i].Name); if (Method.Code.IsLambdaExpression) { // omit type ? :) } else { Parameters[i].Type.With( ParameterType => { File.WriteSpaces(Keywords.As); this.WriteTypeName(File, ParameterType); } ); } } #endregion File.Write(")"); if (Method.Code.IsLambdaExpression) { File.WriteSpace(); this.WriteMethodBody(File, m.Code, Context); } else { File.WriteLine(); this.WriteMethodBody(File, m.Code, Context); File.WriteIndent(); File.WriteSpace(Keywords.End); if (Method.IsFunction) { File.WriteSpace(Keywords.Function); } else { File.WriteSpace(Keywords.Sub); } } File.WriteLine(); } ); }
public override void WriteType(SolutionFile File, SolutionProjectLanguageType Type, SolutionBuilder Context) { File.Write(this, Context, Type.Comments); File.WriteUsingNamespaceList(this, Type); File.WriteLine(); File.Region( delegate { WriteNamespace(File, Type.Namespace, delegate { if (Type.Summary != null) this.WriteSummary( File, Type.Summary ); File.Region( delegate { File.WriteIndent(); if (Type.IsInternal) { File.WriteSpace(Keywords.@internal); } else { File.WriteSpace(Keywords.@public); } if (Type.IsStatic) { File.WriteSpace(Keywords.@static); } if (Type.IsSealed) { File.WriteSpace(Keywords.@sealed); } if (Type.IsPartial) { File.WriteSpace(Keywords.@partial); } if (Type.IsInterface) { File.WriteSpace(Keywords.@interface); } else { File.WriteSpace(Keywords.@class); } File.Write(Type); if (Type.BaseType != null) { File.WriteSpaces(":"); WriteTypeName(File, Type.BaseType); } File.WriteLine(); File.WriteIndent(); File.WriteLine("{"); File.Indent(this, delegate { #region Fields Type.Fields.WithEach( Field => { this.WriteSummary(File, Field.Summary); File.WriteIndent(); if (Field.IsPrivate) { File.WriteSpace(Keywords.@private); } else { File.WriteSpace(Keywords.@public); } if (Field.IsReadOnly) { File.WriteSpace(Keywords.@readonly); } WriteTypeName(File, Field.FieldType); File.WriteSpace().Write(Field.Name); if (Field.FieldConstructor != null) { File.WriteSpaces("="); this.WritePseudoCallExpression(File, Field.FieldConstructor, Context); } File.WriteLine(";"); File.WriteLine(); } ); #endregion #region Properties foreach (var m in Type.Properties.ToArray()) { File.WriteIndent(); if (Type.IsInterface) { } else { File.Write(Keywords.@public); File.WriteSpace(); if (m.IsStatic) { File.Write(Keywords.@static); File.WriteSpace(); } } WriteTypeName(File, m.PropertyType); File.WriteSpace(); File.Write(m.Name); if (m.IsAutoProperty) { File.WriteSpace(); File.Write("{"); } else { File.WriteLine(); File.WriteIndent(); File.WriteLine("{"); } Action<SolutionProjectLanguageMethod, Keyword> Property = (mm, kk) => { if (mm != null) { if (m.IsAutoProperty) { File.WriteSpace(); } else { File.WriteIndent(); } File.Write(kk); if (mm.Code == null) { File.Write(";"); if (m.IsAutoProperty) { } else { File.WriteLine(); } } else { File.WriteLine(); this.WriteMethodBody(File, mm.Code, Context); } } }; Action PropertyBody = delegate { Property(m.GetMethod, Keywords.get); Property(m.SetMethod, Keywords.set); }; Action<Action> PropertyIndent = Body => File.Indent(this, Body); if (m.IsAutoProperty) { PropertyBody(); File.WriteSpace(); } else { File.Indent(this, PropertyBody); File.WriteIndent(); } File.WriteLine("}"); } #endregion if (Type.Properties.Any()) File.WriteLine(); foreach (var item in Type.Methods.ToArray()) { if (item.DeclaringType == null) item.DeclaringType = Type; this.WriteMethod( File, item, Context ); File.WriteLine(); } } ); File.WriteIndent().WriteLine("}"); } ); } ); } ); }
public override void WriteMethod(SolutionFile File, SolutionProjectLanguageMethod m, SolutionBuilder Context) { if (!m.IsLambda) if (m.Summary != null) this.WriteSummary(File, m.Summary, m.Parameters.ToArray()); File.Region( delegate { if (m.IsLambda) { var Parameters = m.Parameters.ToArray(); if (Parameters.Length != 1) File.Write("("); for (int i = 0; i < Parameters.Length; i++) { if (i > 0) { File.WriteSpace(","); } File.Write(Parameters[i].Name); } if (Parameters.Length != 1) File.WriteSpace(")"); else File.WriteSpace(); File.WriteSpace("=>"); if (m.Code.History.Count != 1) File.WriteLine(); this.WriteMethodBody(File, m.Code, Context); return; } #region not lambda File.WriteIndent(); if (m.IsPrivate) { File.Write(Keywords.@private); } else if (m.IsProtected) { File.Write(Keywords.@protected); } else { File.Write(Keywords.@public); } File.WriteSpace(); if (m.IsOverride) { File.WriteSpace(Keywords.@override); } if (m.IsStatic) { File.WriteSpace(Keywords.@static); } if (m.IsConstructor) { WriteTypeName(File, m.DeclaringType); } else { File.WriteSpace(Keywords.@void).Write(m.Name); } #endregion { var Parameters = m.Parameters.ToArray(); File.Write("("); for (int i = 0; i < Parameters.Length; i++) { if (i > 0) { File.WriteSpace(","); } this.WriteTypeName(File, Parameters[i].Type); File.WriteSpace(); File.Write(Parameters[i].Name); } File.Write(")"); } if (m.Code == null) { File.WriteLine(";"); } else { File.WriteLine(); this.WriteMethodBody(File, m.Code, Context); if (!m.IsLambda) { File.WriteLine(); } } } ); }
public override void WriteType(SolutionFile File, SolutionProjectLanguageType Type, SolutionBuilder Context) { // http://msdn.microsoft.com/en-us/library/dd233205.aspx File.Write(this, Context, Type.Comments); File.Region( delegate { WriteNamespace(File, Type.Namespace, delegate { File.WriteUsingNamespaceList(this, Type); File.WriteLine(); this.WriteSummary( File, Type.Summary ); File.Region( delegate { File.WriteIndent(); var Constructor = Type.Methods.SingleOrDefault(k => k.IsConstructor); if (Type.IsStatic) { File.WriteSpace(Keywords.@module); WriteTypeName(File, Type); File.WriteSpace(); File.Write("="); File.WriteLine(); } else { File.Write("[<Sealed>]"); File.WriteLine(); File.WriteIndent(); File.WriteSpace(Keywords.type); if (Type.IsInternal) { File.WriteSpace(Keywords.@internal); } WriteTypeName(File, Type); File.Write("("); if (Constructor != null) this.InternalWriteParameters(File, Constructor, Constructor.Parameters.ToArray()); File.WriteSpace(")"); File.WriteSpace(Keywords.@as); File.WriteSpace("me"); File.WriteSpace("="); File.WriteLine(); File.Indent(this, delegate { if (Type.BaseType != null) { File.WriteIndent(); File.WriteSpace(Keywords.@inherit); WriteTypeName(File, Type.BaseType); File.Write("("); File.WriteSpace(")"); File.WriteLine(); } // only need this if there are any members beyond ctor? File.WriteIndent(); File.WriteSpace(Keywords.@let); File.Write("this"); File.WriteSpaces("="); File.Write("me"); File.WriteLine(); File.WriteLine(); File.WriteIndent(); File.WriteSpace(Keywords.@do); File.Write("()"); File.WriteLine(); File.WriteLine(); } ); } // .ctor ! File.Indent(this, delegate { if (!Type.IsStatic) { #region Fields with FieldConstructor Type.Fields.WithEach( Field => { // http://msdn.microsoft.com/en-us/library/dd469494.aspx if (Field.FieldConstructor != null) { File.WriteIndent().WriteSpace(Keywords.let).Write(Field.Name).WriteSpaces("="); this.WritePseudoCallExpression(File, Field.FieldConstructor, Context); } else { // first asignment shall do a let if (Field.IsReadOnly) return; File.WriteIndent().WriteSpace(Keywords.let).WriteSpace(Keywords.mutable); File.Write(Field.Name).WriteSpaces(":"); WriteTypeName(File, Field.FieldType); File.WriteSpaces("=").Write(Keywords.@null); } File.WriteLine(); } ); #endregion if (Constructor != null) { this.WriteMethodBody( File, Constructor.Code, Context ); } File.WriteLine(); File.WriteLine(); } foreach (var item in (from m in Type.Methods where !m.IsConstructor select m).ToArray()) { if (item.DeclaringType == null) item.DeclaringType = Type; this.WriteMethod( File, item, Context ); File.WriteLine(); } } ); } ); } ); } ); }
public override void WriteMethod(SolutionFile File, SolutionProjectLanguageMethod Method, SolutionBuilder Context) { var m = Method; if (!m.IsLambda) this.WriteSummary(File, m.Summary, m.Parameters.ToArray()); File.Region( delegate { if (m.IsLambda) { if (Method.IsFunction) File.WriteSpace(Keywords.Function); else File.WriteSpace(Keywords.Sub); } else { File.WriteIndent(); if (m.IsProtected) File.WriteSpace(Keywords.Protected); else File.WriteSpace(Keywords.Public); if (m.IsStatic) { var IsModule = false; if (m.DeclaringType != null) { if (m.DeclaringType.IsStatic) { IsModule = true; } } if (IsModule) { } else { File.WriteSpace(Keywords.Shared); } } if (m.IsOverride) File.WriteSpace(Keywords.Overrides); if (Method.IsFunction) File.WriteSpace(Keywords.Function); else File.WriteSpace(Keywords.Sub); if (m.IsConstructor) { File.Write(Keywords.New); } else { File.Write(m.Name); } } File.Write("("); #region Parameters var Parameters = m.Parameters.ToArray(); for (int i = 0; i < Parameters.Length; i++) { if (i > 0) { File.WriteSpace(","); } File.Write(Parameters[i].Name); if (Method.Code.IsLambdaExpression) { // omit type ? :) } else { Parameters[i].Type.With( ParameterType => { File.WriteSpaces(Keywords.As); this.WriteTypeName(File, ParameterType); } ); } } #endregion File.Write(")"); if (Method.Code.IsLambdaExpression) { File.WriteSpace(); this.WriteMethodBody(File, m.Code, Context); } else { File.WriteLine(); this.WriteMethodBody(File, m.Code, Context); File.WriteIndent(); File.WriteSpace(Keywords.End); if (Method.IsFunction) File.WriteSpace(Keywords.Function); else File.WriteSpace(Keywords.Sub); } File.WriteLine(); } ); }
public override void WriteType(SolutionFile File, SolutionProjectLanguageType Type, SolutionBuilder Context) { File.Write(this, Context, Type.Comments); // should the namespaces be clickable? File.WriteUsingNamespaceList(this, Type); File.WriteLine(); File.Region( delegate { WriteNamespace(File, Type.Namespace, delegate { this.WriteSummary( File, Type.Summary ); File.Region( delegate { File.WriteIndent(); if (Type.IsPartial) File.WriteSpace(Keywords.Partial); File.WriteSpace(Keywords.Public); if (Type.IsSealed) { File.WriteSpace(Keywords.NotInheritable); } if (!Type.IsStatic) { File.WriteSpace(Keywords.Class); } else { File.WriteSpace(Keywords.Module); } File.Write(Type); File.WriteLine(); File.Indent(this, delegate { Type.BaseType.With( BaseType => { File.WriteIndent().WriteSpace(Keywords.Inherits); WriteTypeName(File, BaseType); File.WriteLine(); } ); #region Fields Type.Fields.WithEach( Field => { this.WriteSummary(File, Field.Summary); File.WriteIndent(); if (Field.IsPrivate) { File.WriteSpace(Keywords.Private); } else { File.WriteSpace(Keywords.Public); } if (Field.IsReadOnly) { File.WriteSpace(Keywords.ReadOnly); } File.WriteSpace(Field.Name); File.WriteSpace(Keywords.As); if (Field.FieldConstructor == null) { WriteTypeName(File, Field.FieldType); } else { WritePseudoCallExpression(File, Field.FieldConstructor, Context); } File.WriteLine(); File.WriteLine(); } ); #endregion #region Methods foreach (var item in Type.Methods.ToArray()) { if (item.DeclaringType == null) item.DeclaringType = Type; this.WriteMethod( File, item, Context ); File.WriteLine(); } #endregion File.WriteLine(); } ); File.WriteIndent(); File.Write(Keywords.End); File.WriteSpace(); if (!Type.IsStatic) { File.Write(Keywords.Class); } else { File.Write(Keywords.Module); } } ); File.WriteLine(); } ); } ); File.WriteLine(); }