public StockAttributeObfuscation() { Type = new SolutionProjectLanguageType { Namespace = "System", Name = "Obfuscation" }; var set_Feature = new SolutionProjectLanguageMethod { IsProperty = true, Name = "set_Feature", DeclaringType = Type }; var merge = new PseudoStringConstantExpression { Value = "merge" }; var p = new Dictionary<SolutionProjectLanguageMethod, object> { { set_Feature, merge} }; this.Properties = p; }
public StockMethodMain(SolutionProjectLanguageType ApplicationType) { // note: this method will run under javascript #region Parameters args var _args = new SolutionProjectLanguageArgument { Type = new SolutionProjectLanguageType { ElementType = new KnownStockTypes.System.String() }, Name = "args", Summary = "Commandline arguments" }; #endregion this.Name = "Main"; //this.Summary = "In debug build you can just hit F5 and debug the server side code."; this.IsStatic = true; var AsProgram_Launch = new PseudoCallExpression { Method = new SolutionProjectLanguageMethod { DeclaringType = new SolutionProjectLanguageType { DeclaringType = new SolutionProjectLanguageType { Namespace = "jsc.meta.Commands.Rewrite.RewriteToUltraApplication", Name = "RewriteToUltraApplication" }, Name = "AsProgram" }, IsStatic = true, Name = "Launch" }, ParameterExpressions = new[] { ApplicationType } }; this.Code = new SolutionProjectLanguageCode { AsProgram_Launch }; this.Parameters.Add(_args); }
public StockAttributeGeneralInformation(SolutionProjectLanguageType Type, PseudoStringConstantExpression Constant) { this.Type = Type; this.Parameters = new[] { Constant }; }
public StockMethodApplication(SolutionProjectLanguageType DeclaringType, SolutionBuilderInteractive Interactive /*, SolutionProjectLanguageField style*/) { // note: this method will run under javascript #region Parameters args var _page = new SolutionProjectLanguageArgument { Type = new SolutionProjectLanguageType { Name = "IApp" }, //Name = "document", Name = "page", Summary = "HTML document rendered by the web server which can now be enhanced." }; #endregion this.Name = SolutionProjectLanguageMethod.ConstructorName; this.Summary = "This is a javascript application."; this.Code = new SolutionProjectLanguageCode(); Interactive.RaiseGenerateApplicationExpressions(this.Code.Add); //#region style.Content.AttachToHead //var style_get_Content = // new PseudoCallExpression // { // Object = style, // Method = // new SolutionProjectLanguageMethod // { // IsProperty = true, // Name = "get_Content", // ReturnType = new KnownStockTypes.ScriptCoreLib.JavaScript.DOM.HTML.IHTMLElement() // } // }; //this.Code.Add( // new KnownStockTypes.ScriptCoreLib.JavaScript.Extensions.INodeExtensions.AttachToHead().ToCallExpression( // style_get_Content // ) //); //#endregion this.Code.Add(Interactive.ApplicationToDocumentTitle); // visual basic demands a local variable! this.Code.Add(Interactive.ApplicationCallWebMethod); this.DeclaringType = DeclaringType; this.Parameters.Add(_page); }
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([email protected]); } else { File.WriteSpace([email protected]); } if (Type.IsStatic) { File.WriteSpace([email protected]); } if (Type.IsSealed) { File.WriteSpace([email protected]); } if (Type.IsPartial) { File.WriteSpace([email protected]); } if (Type.IsInterface) { File.WriteSpace([email protected]); } else { File.WriteSpace([email protected]); } 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([email protected]); } else { File.WriteSpace([email protected]); } if (Field.IsReadOnly) { File.WriteSpace([email protected]); } 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([email protected]); File.WriteSpace(); if (m.IsStatic) { File.Write([email protected]); 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 WriteTypeName(SolutionFile File, SolutionProjectLanguageType Type) { if (Type is KnownStockTypes.System.Boolean) { File.Write([email protected]); return; } if (Type is KnownStockTypes.System.String) { File.Write([email protected]); return; } if (Type.DeclaringType != null) { WriteTypeName(File, Type.DeclaringType); File.Write("."); } if (Type.ElementType != null) { WriteTypeName(File, Type.ElementType); File.Write("[]"); return; } File.Write(Type); if (Type.Arguments.Count > 0) { File.Write("<"); var Arguments = Type.Arguments.ToArray(); for (int i = 0; i < Arguments.Length; i++) { if (i > 0) { File.Write(","); File.WriteSpace(); } this.WriteTypeName(File, Arguments[i].Type); } File.Write(">"); } }
public static PseudoCallExpression ToPseudoCallExpression(this XElement e) { // we need a factory or context for equality var XElement = new SolutionProjectLanguageType { Namespace = "System.Xml.Linq", Name = "XElement" }; var XAttribute = new SolutionProjectLanguageType { Namespace = "System.Xml.Linq", Name = "XAttribute" }; var XName = new SolutionProjectLanguageType { Namespace = "System.Xml.Linq", Name = "XName" }; var XComment = new SolutionProjectLanguageType { Namespace = "System.Xml.Linq", Name = "XComment" }; #region XNameFromString Func<string, PseudoCallExpression> XNameFromString = Name => { return new PseudoCallExpression { Method = new SolutionProjectLanguageMethod { DeclaringType = XName, IsStatic = true, Name = SolutionProjectLanguageMethod.op_Implicit }, ParameterExpressions = new[] { new PseudoStringConstantExpression { Value = Name } } }; }; #endregion var CreateXElement = default(Func<XElement, PseudoCallExpression>); Func<XElement, object[]> GetParameters = ee => { var NewParameters = new ArrayList(); NewParameters.Add(XNameFromString(ee.Name.LocalName)); var Content = new PseudoArrayExpression(); Content.ElementType = new SolutionProjectLanguageType { Name = "object" }; foreach (var item in ee.Attributes().ToArray()) { Content.Items.Add( new PseudoCallExpression { Method = new SolutionProjectLanguageMethod { Name = SolutionProjectLanguageMethod.ConstructorName, DeclaringType = XAttribute, ReturnType = XAttribute }, ParameterExpressions = new object [] { XNameFromString(item.Name.LocalName), new PseudoStringConstantExpression { Value = item.Value } } } ); } foreach (var item in ee.Nodes().ToArray()) { var _XText = item as XText; if (_XText != null) { Content.Items.Add( new PseudoStringConstantExpression { Value = _XText.Value } ); } var _XElement = item as XElement; if (_XElement != null) { Content.Items.Add( CreateXElement(_XElement) ); } var _XComment = item as XComment; if (_XComment != null) { Content.Items.Add( new PseudoCallExpression { Method = new SolutionProjectLanguageMethod { Name = SolutionProjectLanguageMethod.ConstructorName, DeclaringType = XComment, ReturnType = XComment }, ParameterExpressions = new object[] { new PseudoStringConstantExpression { Value = _XComment.Value } } } ); } } NewParameters.Add(Content); return NewParameters.ToArray(); }; CreateXElement = ee => { return new PseudoCallExpression { XLinq = ee, Method = new SolutionProjectLanguageMethod { Name = SolutionProjectLanguageMethod.ConstructorName, DeclaringType = XElement, ReturnType = XElement }, ParameterExpressions = GetParameters(ee) }; }; return CreateXElement(e); }
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([email protected]); 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([email protected]); } WriteTypeName(File, Type); File.Write("("); if (Constructor != null) this.InternalWriteParameters(File, Constructor, Constructor.Parameters.ToArray()); File.WriteSpace(")"); File.WriteSpace([email protected]); File.WriteSpace("me"); File.WriteSpace("="); File.WriteLine(); File.Indent(this, delegate { if (Type.BaseType != null) { File.WriteIndent(); File.WriteSpace([email protected]); WriteTypeName(File, Type.BaseType); File.Write("("); File.WriteSpace(")"); File.WriteLine(); } // only need this if there are any members beyond ctor? File.WriteIndent(); File.WriteSpace([email protected]); File.Write("this"); File.WriteSpaces("="); File.Write("me"); File.WriteLine(); File.WriteLine(); File.WriteIndent(); File.WriteSpace([email protected]); 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([email protected]); } 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 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 WriteTypeName(SolutionFile File, SolutionProjectLanguageType Type) { if (Type == null) return; if (Type.DeclaringType != null) { WriteTypeName(File, Type.DeclaringType); File.Write("."); } if (Type.ElementType != null) { WriteTypeName(File, Type.ElementType); File.Write("()"); return; } File.Write( new SolutionFileWriteArguments { Fragment = SolutionFileTextFragment.Type, Tag = Type, Text = Type.Name } ); if (Type.Arguments.Count > 0) { File.Write("("); File.Write(Keywords.Of); File.WriteSpace(); var Arguments = Type.Arguments.ToArray(); for (int i = 0; i < Arguments.Length; i++) { if (i > 0) { File.Write(","); File.WriteSpace(); } this.WriteTypeName(File, Arguments[i].Type); } File.Write(")"); } }