public static PseudoCallExpression ToCallExpression(this SolutionProjectLanguageMethod Method, object Object = null, params object[] ParameterExpressions) { if (Method.IsExtensionMethod) { if (Object != null) { // promote Object to arg0 return(ToCallExpression(Method, null, new[] { Object }.Concat(ParameterExpressions).ToArray() )); } } return(new PseudoCallExpression { Method = Method, Object = Object, ParameterExpressions = ParameterExpressions }); }
void VisitMethod(SolutionProjectLanguageMethod Method) { Method.DeclaringType.With(VisitType); Method.Code.With(VisitCode); }
public static SolutionBuilder WithAdobeFlashWithFlare3D(this SolutionBuilder sln) { Func <StockSpriteType> GetType = () => new StockSpriteType(sln.Name, "ApplicationSprite"); var sprite = default(SolutionProjectLanguageField); sln.Interactive.GenerateTypes += AddType => { var ApplicationSprite = GetType(); sprite = ApplicationSprite.ToInitializedField("sprite"); sprite.DeclaringType = sln.Interactive.ApplicationType; // as per X:\jsc.svn\market\synergy\actionscript\Flare3DWaterShipComponent\Flare3DWaterShipComponent\ApplicationSprite.cs // jsc does not like field initializers to properties in anonymous type? var Types_ship = new SolutionProjectLanguageType { Namespace = "Flare3DWaterShipComponent", Name = "ship" }; var Types_Viewer3D = new SolutionProjectLanguageType { Namespace = "flare.basic", Name = "Viewer3D" }; var Types_Camera3D = new SolutionProjectLanguageType { Namespace = "flare.core", Name = "Camera3D" }; var Methods_set_scene = new SolutionProjectLanguageMethod { Name = "set_scene", IsProperty = true, DeclaringType = ApplicationSprite }; var Methods_set_camera = new SolutionProjectLanguageMethod { Name = "set_camera", IsProperty = true, DeclaringType = Types_Viewer3D }; var Methods_setPosition = new SolutionProjectLanguageMethod { Name = "setPosition", DeclaringType = Types_Camera3D }; var Methods_lookAt = new SolutionProjectLanguageMethod { Name = "lookAt", DeclaringType = Types_Camera3D }; var Methods_addChild = new SolutionProjectLanguageMethod { Name = "addChild", DeclaringType = Types_Viewer3D, ReturnType = Types_Viewer3D }; var this_camera = Types_Camera3D.ToInitializedField("camera"); var this_ship = Types_ship.ToInitializedField("ship"); var this_scene = new SolutionProjectLanguageField { FieldType = Types_Viewer3D, Name = "scene", IsReadOnly = true }; //ApplicationSprite.Fields.Add(this_ship); ApplicationSprite.Fields.Add(this_camera); ApplicationSprite.Fields.Add(this_scene); var newobj_Viewer3D = new PseudoCallExpression { Method = Types_Viewer3D.GetDefaultConstructorDefinition(), ParameterExpressions = new object[] { new PseudoThisExpression() } }; var set_scene_to_newobj_Viewer3D = Methods_set_scene.ToCallExpression( new PseudoThisExpression(), newobj_Viewer3D ); ApplicationSprite.Constructor.Code.Add(set_scene_to_newobj_Viewer3D); var this_camera_setPosition = Methods_setPosition.ToCallExpression(this_camera, (PseudoDoubleConstantExpression)120.0, (PseudoDoubleConstantExpression)40.0, (PseudoDoubleConstantExpression)(-30.0) ); ApplicationSprite.Constructor.Code.Add(this_camera_setPosition); var this_camera_lookAt = Methods_lookAt.ToCallExpression(this_camera, (PseudoDoubleConstantExpression)0.0, (PseudoDoubleConstantExpression)0.0, (PseudoDoubleConstantExpression)0.0 ); ApplicationSprite.Constructor.Code.Add(this_camera_lookAt); ApplicationSprite.Constructor.Code.Add( Methods_set_camera.ToCallExpression(this_scene, this_camera) ); ApplicationSprite.Constructor.Code.Add( Methods_addChild.ToCallExpression(this_scene, Types_ship.GetDefaultConstructor()) ); AddType(ApplicationSprite); }; sln.Interactive.GenerateApplicationExpressions += AddCode => { AddCode(new CreateMySprite(GetType(), sprite)); }; // ..\packages\Flare3D.1.0.0.0\lib\Flare3D.dll sln.NuGetReferences.Add( new ScriptCoreLib.Ultra.Studio.SolutionBuilder.package { id = "Flare3D" } ); sln.NuGetReferences.Add( new ScriptCoreLib.Ultra.Studio.SolutionBuilder.package { id = "Flare3DWaterShipComponent" } ); return(sln); }
public static SolutionBuilder WithAdobeFlashWithFlare3D(this SolutionBuilder sln) { Func<StockSpriteType> GetType = () => new StockSpriteType(sln.Name, "ApplicationSprite"); var sprite = default(SolutionProjectLanguageField); sln.Interactive.GenerateTypes += AddType => { var ApplicationSprite = GetType(); sprite = ApplicationSprite.ToInitializedField("sprite"); sprite.DeclaringType = sln.Interactive.ApplicationType; // as per X:\jsc.svn\market\synergy\actionscript\Flare3DWaterShipComponent\Flare3DWaterShipComponent\ApplicationSprite.cs // jsc does not like field initializers to properties in anonymous type? var Types_ship = new SolutionProjectLanguageType { Namespace = "Flare3DWaterShipComponent", Name = "ship" }; var Types_Viewer3D = new SolutionProjectLanguageType { Namespace = "flare.basic", Name = "Viewer3D" }; var Types_Camera3D = new SolutionProjectLanguageType { Namespace = "flare.core", Name = "Camera3D" }; var Methods_set_scene = new SolutionProjectLanguageMethod { Name = "set_scene", IsProperty = true, DeclaringType = ApplicationSprite }; var Methods_set_camera = new SolutionProjectLanguageMethod { Name = "set_camera", IsProperty = true, DeclaringType = Types_Viewer3D }; var Methods_setPosition = new SolutionProjectLanguageMethod { Name = "setPosition", DeclaringType = Types_Camera3D }; var Methods_lookAt = new SolutionProjectLanguageMethod { Name = "lookAt", DeclaringType = Types_Camera3D }; var Methods_addChild = new SolutionProjectLanguageMethod { Name = "addChild", DeclaringType = Types_Viewer3D, ReturnType = Types_Viewer3D }; var this_camera = Types_Camera3D.ToInitializedField("camera"); var this_ship = Types_ship.ToInitializedField("ship"); var this_scene = new SolutionProjectLanguageField { FieldType = Types_Viewer3D, Name = "scene", IsReadOnly = true }; //ApplicationSprite.Fields.Add(this_ship); ApplicationSprite.Fields.Add(this_camera); ApplicationSprite.Fields.Add(this_scene); var newobj_Viewer3D = new PseudoCallExpression { Method = Types_Viewer3D.GetDefaultConstructorDefinition(), ParameterExpressions = new object[] { new PseudoThisExpression() } }; var set_scene_to_newobj_Viewer3D = Methods_set_scene.ToCallExpression( new PseudoThisExpression(), newobj_Viewer3D ); ApplicationSprite.Constructor.Code.Add(set_scene_to_newobj_Viewer3D); var this_camera_setPosition = Methods_setPosition.ToCallExpression(this_camera, (PseudoDoubleConstantExpression)120.0, (PseudoDoubleConstantExpression)40.0, (PseudoDoubleConstantExpression)(-30.0) ); ApplicationSprite.Constructor.Code.Add(this_camera_setPosition); var this_camera_lookAt = Methods_lookAt.ToCallExpression(this_camera, (PseudoDoubleConstantExpression)0.0, (PseudoDoubleConstantExpression)0.0, (PseudoDoubleConstantExpression)0.0 ); ApplicationSprite.Constructor.Code.Add(this_camera_lookAt); ApplicationSprite.Constructor.Code.Add( Methods_set_camera.ToCallExpression(this_scene, this_camera) ); ApplicationSprite.Constructor.Code.Add( Methods_addChild.ToCallExpression(this_scene, Types_ship.GetDefaultConstructor()) ); AddType(ApplicationSprite); }; sln.Interactive.GenerateApplicationExpressions += AddCode => { AddCode(new CreateMySprite(GetType(), sprite)); }; // ..\packages\Flare3D.1.0.0.0\lib\Flare3D.dll sln.NuGetReferences.Add( new ScriptCoreLib.Ultra.Studio.SolutionBuilder.package { id = "Flare3D" } ); sln.NuGetReferences.Add( new ScriptCoreLib.Ultra.Studio.SolutionBuilder.package { id = "Flare3DWaterShipComponent" } ); return sln; }
abstract public void WriteMethod(SolutionFile File, SolutionProjectLanguageMethod Method, SolutionBuilder Context);
static SolutionBuilder Internal(SolutionBuilder sln, bool ApplcationWebServiceAsComponent = false, bool IsApplet = false, Action <SolutionProjectLanguageField> NotifyContent = null ) { // should we make an Undo available? sln.ApplicationPage = StockPageDefault.CanvasDefaultPage; var content = default(SolutionProjectLanguageField); sln.Interactive.GenerateTypes += AddType => { #region ApplicationCanvas var ApplicationCanvas = new StockUserControlType(sln.Name, "ApplicationControl"); // in Canvas applications we want to focus only the canvas // to do that we hide other implementation detail classes //sln.Interactive.ApplicationWebServiceType.DependentUpon = ApplicationCanvas; if (ApplcationWebServiceAsComponent) { sln.Interactive.ApplicationWebServiceType.With( ApplicationWebServiceType => { var ApplicationWebServiceDesignerType = new SolutionProjectLanguagePartialType { Name = ApplicationWebServiceType.Name + ".Designer", }; ApplicationWebServiceDesignerType.Type.Name = ApplicationWebServiceType.Name; ApplicationWebServiceType.NamespaceChanged += delegate { ApplicationWebServiceDesignerType.Type.Namespace = ApplicationWebServiceType.Namespace; }; #region components var components = new SolutionProjectLanguageField { IsPrivate = true, Name = "components", Summary = "Required designer variable.", FieldType = new KnownStockTypes.System.ComponentModel.IContainer() }; ApplicationWebServiceDesignerType.Type.Fields.Add(components); #endregion #region InitializeComponent var InitializeComponent = new SolutionProjectLanguageMethod { Summary = @"Required method for Designer support - do not modify the contents of this method with the code editor.", IsPrivate = true, DeclaringType = ApplicationWebServiceDesignerType.Type, Name = "InitializeComponent", Code = new SolutionProjectLanguageCode { //set_Name, //set_Size } }; ApplicationWebServiceDesignerType.Type.Methods.Add(InitializeComponent); #endregion #region ApplicationWebServiceDesignerTypeConstructor var ApplicationWebServiceDesignerTypeConstructor = new SolutionProjectLanguageMethod { DeclaringType = ApplicationWebServiceDesignerType.Type, Name = SolutionProjectLanguageMethod.ConstructorName, Code = new SolutionProjectLanguageCode { new PseudoCallExpression { Object = new PseudoThisExpression(), Method = InitializeComponent } } }; ApplicationWebServiceDesignerType.Type.Methods.Add(ApplicationWebServiceDesignerTypeConstructor); #endregion ApplicationWebServiceType.BaseType = new KnownStockTypes.System.ComponentModel.Component(); ApplicationWebServiceType.DependentPartialTypes = new[] { ApplicationWebServiceDesignerType }; ApplicationWebServiceDesignerType.Type.UsingNamespaces.Add("System.ComponentModel"); } ); } sln.Interactive.ApplicationType.DependentUpon = ApplicationCanvas; sln.Interactive.ProgramType.DependentUpon = ApplicationCanvas; AddType(ApplicationCanvas); content = ApplicationCanvas.ToInitializedField("content"); content.DeclaringType = sln.Interactive.ApplicationType; // we are adding a field. does it show up in the source code later? // SolutionProjectLanguage.WriteType makes it happen! if (NotifyContent != null) { NotifyContent(content); } var Code = sln.Interactive.ProgramType_MainMethod.Code; sln.Interactive.ProgramType_MainMethod.Code = new SolutionProjectLanguageCode { new PseudoIfExpression { IsConditionalCompilationDirective = true, Expression = ("DEBUG"), FalseCase = Code, TrueCase = new SolutionProjectLanguageCode { new KnownStockTypes.ScriptCoreLib.Desktop.Forms.Extensions.DesktopFormsExtensions.Launch().ToCallExpression( null, new SolutionProjectLanguageMethod { ReturnType = ApplicationCanvas, Code = new SolutionProjectLanguageCode { ApplicationCanvas.GetDefaultConstructor() } } ) } } }; #endregion }; sln.Interactive.GenerateApplicationExpressions += AddCode => { // our content has been removed... if (content.DeclaringType != sln.Interactive.ApplicationType) { return; } if (!IsApplet) { AddCode( new KnownStockTypes.ScriptCoreLib.JavaScript.FormExtensions.AttachControlToDocument().ToCallExpression( content ) ); return; } var page_get_Content = new PseudoCallExpression { // Application(page) Object = "page", Method = new SolutionProjectLanguageMethod { IsProperty = true, Name = "get_Content", ReturnType = new KnownStockTypes.ScriptCoreLib.JavaScript.DOM.HTML.IHTMLElement() } }; var page_get_ContentSize = new PseudoCallExpression { // Application(page) Object = "page", Method = new SolutionProjectLanguageMethod { IsProperty = true, Name = "get_ContentSize", ReturnType = new KnownStockTypes.ScriptCoreLib.JavaScript.DOM.HTML.IHTMLElement() } }; AddCode( new KnownStockTypes.ScriptCoreLib.JavaScript.Windows.Forms.WindowsFormsExtensions.AttachControlTo().ToCallExpression( content, page_get_Content ) ); AddCode( new KnownStockTypes.ScriptCoreLib.JavaScript.Windows.Forms.WindowsFormsExtensions.AutoSizeControlTo().ToCallExpression( content, page_get_ContentSize ) ); }; return(sln); }
static SolutionBuilder Internal(SolutionBuilder sln, bool ApplcationWebServiceAsComponent = false, bool IsApplet = false, Action<SolutionProjectLanguageField> NotifyContent = null ) { // should we make an Undo available? sln.ApplicationPage = StockPageDefault.CanvasDefaultPage; var content = default(SolutionProjectLanguageField); sln.Interactive.GenerateTypes += AddType => { #region ApplicationCanvas var ApplicationCanvas = new StockUserControlType(sln.Name, "ApplicationControl"); // in Canvas applications we want to focus only the canvas // to do that we hide other implementation detail classes //sln.Interactive.ApplicationWebServiceType.DependentUpon = ApplicationCanvas; if (ApplcationWebServiceAsComponent) { sln.Interactive.ApplicationWebServiceType.With( ApplicationWebServiceType => { var ApplicationWebServiceDesignerType = new SolutionProjectLanguagePartialType { Name = ApplicationWebServiceType.Name + ".Designer", }; ApplicationWebServiceDesignerType.Type.Name = ApplicationWebServiceType.Name; ApplicationWebServiceType.NamespaceChanged += delegate { ApplicationWebServiceDesignerType.Type.Namespace = ApplicationWebServiceType.Namespace; }; #region components var components = new SolutionProjectLanguageField { IsPrivate = true, Name = "components", Summary = "Required designer variable.", FieldType = new KnownStockTypes.System.ComponentModel.IContainer() }; ApplicationWebServiceDesignerType.Type.Fields.Add(components); #endregion #region InitializeComponent var InitializeComponent = new SolutionProjectLanguageMethod { Summary = @"Required method for Designer support - do not modify the contents of this method with the code editor.", IsPrivate = true, DeclaringType = ApplicationWebServiceDesignerType.Type, Name = "InitializeComponent", Code = new SolutionProjectLanguageCode { //set_Name, //set_Size } }; ApplicationWebServiceDesignerType.Type.Methods.Add(InitializeComponent); #endregion #region ApplicationWebServiceDesignerTypeConstructor var ApplicationWebServiceDesignerTypeConstructor = new SolutionProjectLanguageMethod { DeclaringType = ApplicationWebServiceDesignerType.Type, Name = SolutionProjectLanguageMethod.ConstructorName, Code = new SolutionProjectLanguageCode { new PseudoCallExpression { Object = new PseudoThisExpression(), Method = InitializeComponent } } }; ApplicationWebServiceDesignerType.Type.Methods.Add(ApplicationWebServiceDesignerTypeConstructor); #endregion ApplicationWebServiceType.BaseType = new KnownStockTypes.System.ComponentModel.Component(); ApplicationWebServiceType.DependentPartialTypes = new[] { ApplicationWebServiceDesignerType }; ApplicationWebServiceDesignerType.Type.UsingNamespaces.Add("System.ComponentModel"); } ); } sln.Interactive.ApplicationType.DependentUpon = ApplicationCanvas; sln.Interactive.ProgramType.DependentUpon = ApplicationCanvas; AddType(ApplicationCanvas); content = ApplicationCanvas.ToInitializedField("content"); content.DeclaringType = sln.Interactive.ApplicationType; // we are adding a field. does it show up in the source code later? // SolutionProjectLanguage.WriteType makes it happen! if (NotifyContent != null) NotifyContent(content); var Code = sln.Interactive.ProgramType_MainMethod.Code; sln.Interactive.ProgramType_MainMethod.Code = new SolutionProjectLanguageCode { new PseudoIfExpression { IsConditionalCompilationDirective = true, Expression = ("DEBUG"), FalseCase = Code, TrueCase = new SolutionProjectLanguageCode { new KnownStockTypes.ScriptCoreLib.Desktop.Forms.Extensions.DesktopFormsExtensions.Launch().ToCallExpression( null, new SolutionProjectLanguageMethod { ReturnType = ApplicationCanvas, Code = new SolutionProjectLanguageCode { ApplicationCanvas.GetDefaultConstructor() } } ) } } }; #endregion }; sln.Interactive.GenerateApplicationExpressions += AddCode => { // our content has been removed... if (content.DeclaringType != sln.Interactive.ApplicationType) return; if (!IsApplet) { AddCode( new KnownStockTypes.ScriptCoreLib.JavaScript.FormExtensions.AttachControlToDocument().ToCallExpression( content ) ); return; } var page_get_Content = new PseudoCallExpression { // Application(page) Object = "page", Method = new SolutionProjectLanguageMethod { IsProperty = true, Name = "get_Content", ReturnType = new KnownStockTypes.ScriptCoreLib.JavaScript.DOM.HTML.IHTMLElement() } }; var page_get_ContentSize = new PseudoCallExpression { // Application(page) Object = "page", Method = new SolutionProjectLanguageMethod { IsProperty = true, Name = "get_ContentSize", ReturnType = new KnownStockTypes.ScriptCoreLib.JavaScript.DOM.HTML.IHTMLElement() } }; AddCode( new KnownStockTypes.ScriptCoreLib.JavaScript.Windows.Forms.WindowsFormsExtensions.AttachControlTo().ToCallExpression( content, page_get_Content ) ); AddCode( new KnownStockTypes.ScriptCoreLib.JavaScript.Windows.Forms.WindowsFormsExtensions.AutoSizeControlTo().ToCallExpression( content, page_get_ContentSize ) ); }; return sln; }
public static PseudoCallExpression ToCallExpression(this SolutionProjectLanguageMethod Method, object Object, object ParameterExpression) { return(Method.ToCallExpression(Object, new object[] { ParameterExpression })); }