static bool IsExtensionMethod(PseudoCallExpression m)
        {
            if (!m.Method.IsExtensionMethod)
                return false;

            // it seems Visual Basic only supports extensions that also return a value which is used
            // or Visual Basic supports extension methods on objects
            // which ae not literals nor constructors

            var Object = m.ParameterExpressions.First();

            var Call = Object as PseudoCallExpression;

            if (Call != null)
            {
                if (Call.Method.IsConstructor)
                    return false;
            }

            var Constant = Object as PseudoConstantExpression;

            if (Constant != null)
            {
                return false;
            }

            return true;
        }
        static bool IsExtensionMethod(PseudoCallExpression m)
        {
            if (!m.Method.IsExtensionMethod)
                return false;

            // F# has some trouble with overloaded extensions?

            return false;
        }
            public CreateMyApplet(StockAppletType Type)
            {
                var page_Page1 =
                    new PseudoCallExpression
                    {
                        // Application(page)
                        Object = "page",

                        Method =
                            new SolutionProjectLanguageMethod
                            {
                                IsProperty = true,
                                Name = "get_Content",
                                ReturnType = new SolutionProjectLanguageType
                                {
                                    Name = "IHTMLElement"
                                }
                            }
                    };

                var new_Page1 =
                    new PseudoCallExpression
                    {
                        // Application(page)

                        Method =
                            new SolutionProjectLanguageMethod
                            {
                                Name = SolutionProjectLanguageMethod.ConstructorName,
                                DeclaringType = new SolutionProjectLanguageType
                                {
                                    Namespace = Type.Namespace,
                                    Name = Type.Name
                                }
                            }
                    };

                this.Comment = "Initialize " + Type.Name;

                this.Method =
                    new SolutionProjectLanguageMethod
                    {
                        IsStatic = true,
                        IsExtensionMethod = true,
                        Name = "AttachAppletTo",
                        ReturnType = new SolutionProjectLanguageType
                        {
                            Name = "AppletExtensions"
                        }
                    };

                this.ParameterExpressions = new[]
			    {
				    new_Page1,
				    page_Page1
			    };
            }
		public StockReplaceWithNewSpriteExpression(string Namespace, string Name)
		{
			var page_Page1 =
				new PseudoCallExpression
				{
					// Application(page)
					Object = "page",

					Method =
						new SolutionProjectLanguageMethod
						{
							IsProperty = true,
							Name = "get_" + Name,
							ReturnType = new SolutionProjectLanguageType
							{
								Name = "IHTMLImage"
							}
						}
				};

			var new_Page1 =
				new PseudoCallExpression
				{
					// Application(page)

					Method =
						new SolutionProjectLanguageMethod
						{
							Name = SolutionProjectLanguageMethod.ConstructorName,
							DeclaringType = new SolutionProjectLanguageType
							{
								Namespace = Namespace,
								Name = Name
							}
						}
				};

			this.Comment = "Initialize " + Name + " by replacing the placeholder";

			this.Method =
				new SolutionProjectLanguageMethod
				{
					IsStatic = true,
					IsExtensionMethod = true,
					Name = "ReplaceWith",
					ReturnType = new SolutionProjectLanguageType
					{
						Name = "SpriteExtensions"
					}
				};

			this.ParameterExpressions = new[]
			{
				page_Page1,
				new_Page1
			};
		}
 public static SolutionProjectLanguageMethod ToAnonymousMethod(this PseudoCallExpression e)
 {
     return(new SolutionProjectLanguageMethod
     {
         Code = new SolutionProjectLanguageCode
         {
             e
         }
     });
 }
		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 StockMethodInitializeCamera(SolutionProjectLanguageField video)
        {
            var camera = new SolutionProjectLanguageArgument
            {
                Name = "camera",
                Type = new KnownStockTypes.ScriptCoreLib.ActionScript.flash.media.Camera()
            };

            this.Parameters.Add(camera);



            var camera_setMode =new KnownStockTypes.ScriptCoreLib.ActionScript.flash.media.Camera.setMode().ToCallExpression(
                  camera,
                        (PseudoInt32ConstantExpression)ScriptApplicationEntryPointAttribute.DefaultWidth,
                        (PseudoInt32ConstantExpression)ScriptApplicationEntryPointAttribute.DefaultHeight,
                (PseudoInt32ConstantExpression)(1000 / 24)
            );

            var video_attachCamera = new KnownStockTypes.ScriptCoreLib.ActionScript.flash.media.Video.attachCamera().ToCallExpression(
                video,
                camera
            );

         


            var AttachTo = new SolutionProjectLanguageMethod
            {
                IsStatic = true,
                IsExtensionMethod = true,
                Name = "AttachTo",
                DeclaringType = new KnownStockTypes.ScriptCoreLib.ActionScript.Extensions.CommonExtensions()
            };

            var video_AttachTo_this =
                new PseudoCallExpression
                {
                    Method = AttachTo,
                    ParameterExpressions = new object[]
                    {
                        video,
                        new PseudoThisExpression()
                    }
                };

            this.Code = new SolutionProjectLanguageCode
            {
                camera_setMode,
                video_attachCamera,
                video_AttachTo_this
            };
        }
            public CreateMySprite(StockSpriteType Type, SolutionProjectLanguageField sprite)
            {
                var page_Page1 =
                    new PseudoCallExpression
                    {
                        // Application(page)
                        Object = "page",

                        Method =
                            new SolutionProjectLanguageMethod
                            {
                                IsProperty = true,
                                Name = "get_Content",
                                ReturnType = new SolutionProjectLanguageType
                                {
                                    Name = "IHTMLElement"
                                }
                            }
                    };

                //var new_Page1 =
                //    new PseudoCallExpression
                //    {
                //        // Application(page)

                //        Method =
                //            new SolutionProjectLanguageMethod
                //            {
                //                Name = SolutionProjectLanguageMethod.ConstructorName,
                //                DeclaringType = new SolutionProjectLanguageType
                //                {
                //                    Namespace = Type.Namespace,
                //                    Name = Type.Name
                //                }
                //            }
                //    };

                this.Comment = "Initialize " + Type.Name;

                this.Method = new KnownStockTypes.ScriptCoreLib.JavaScript.Extensions.SpriteExtensions.AttachSpriteTo();

                this.ParameterExpressions = new object[]
			    {
				    sprite,
				    page_Page1
			    };
            }
		abstract public void WritePseudoCallExpression(SolutionFile File, PseudoCallExpression Lambda, SolutionBuilder Context);
        static SolutionBuilder InternalWithCanvas(SolutionBuilder sln,
            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 StockCanvasType(sln.Name, "ApplicationCanvas");


                    // in Canvas applications we want to focus only the canvas
                    // to do that we hide other implementation detail classes

                    sln.Interactive.ApplicationWebServiceType.DependentUpon = ApplicationCanvas;
                    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.Extensions.DesktopAvalonExtensions.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;

                    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.Extensions.AvalonExtensions.AttachToContainer().ToCallExpression(
                            content,
                            page_get_Content
                      )
                  );

                    AddCode(
                        new KnownStockTypes.ScriptCoreLib.JavaScript.Extensions.AvalonUltraExtensions.AutoSizeTo().ToCallExpression(
                            content,
                            page_get_ContentSize
                        )
                    );
                };

            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;
        }
        private void InternalWriteParameterList(SolutionFile File, PseudoCallExpression Lambda, SolutionBuilder Context)
        {
            File.Write("(");

            #region HasComplexParameter
            var HasComplexParameter = Lambda.ParameterExpressions.Any(
                k =>
                {
                    if (k is XElement)
                        return true;

                    // anonymous method!
                    if (k is SolutionProjectLanguageMethod)
                        return true;


                    var Call = k as PseudoCallExpression;
                    if (Call != null)
                    {
                        // what? :) 
                        if (Call.XLinq != null)
                            return true;
                    }

                    
                    return false;
                }
            );
            #endregion

            Action Body =
                delegate
                {
                    var Parameters = Lambda.ParameterExpressions.ToArray();

                    var FirstParameter = 0;

                    if (IsExtensionMethod(Lambda))
                        FirstParameter = 1;

                    for (int i = FirstParameter; i < Parameters.Length; i++)
                    {
                        if (i > FirstParameter)
                        {
                            if (HasComplexParameter)
                            {
                                File.WriteLine(",");
                                File.WriteIndent();
                            }
                            else
                            {
                                File.WriteSpace(",");
                            }
                        }

                        var Parameter = Parameters[i];

                        WritePseudoExpression(File, Parameter, Context);
                    }
                };

            if (HasComplexParameter)
            {
                File.WriteLine();
                File.Indent(this,
                    delegate
                    {
                        if (Lambda.ParameterExpressions.FirstOrDefault() is XElement)
                        {
                            // xlinq has no indent...
                        }
                        else
                        {
                            File.WriteIndent();
                        }

                        Body();

                        //File.WriteLine();
                    }
                );
                File.WriteIndent();
            }
            else
            {
                Body();
            }

            File.Write(")");
        }
Пример #13
0
        public override void WritePseudoCallExpression(SolutionFile File, ScriptCoreLib.Ultra.Studio.PseudoExpressions.PseudoCallExpression Lambda, SolutionBuilder Context)
        {
            if (Lambda.Method.IsConstructor)
            {
                File.Write(Keywords.@new);
                File.WriteSpace();
                WriteTypeName(File, Lambda.Method.DeclaringType);
                InternalWriteParameterList(File, Lambda, Context);
                return;
            }

            if (Lambda.Method.OperatorName != null)
            {
                if (Lambda.ParameterExpressions.Length == 2)
                {
                    WritePseudoExpression(File, Lambda.ParameterExpressions[0], Context);
                    File.WriteSpaces(Lambda.Method.OperatorName);
                    WritePseudoExpression(File, Lambda.ParameterExpressions[1], Context);

                    return;
                }
            }


            var Objectless = true;

            if (IsExtensionMethod(Lambda))
            {
                WritePseudoExpression(File, Lambda.ParameterExpressions[0], Context);
                Objectless = false;
            }
            else
            {
                if (Lambda.Method.IsStatic)
                {
                    if (Lambda.Method.DeclaringType != null)
                    {
                        WriteTypeName(File, Lambda.Method.DeclaringType);
                        Objectless = false;
                    }
                }
                else
                {
                    if (Lambda.Object != null)
                    {
                        var Constructor = Lambda.Object as PseudoExpressions.PseudoCallExpression;
                        if (Constructor != null)
                        {
                            if (!Constructor.Method.IsConstructor)
                            {
                                Constructor = null;
                            }
                        }

                        if (Constructor != null)
                        {
                            File.Write("(");
                        }
                        WritePseudoExpression(File, Lambda.Object, Context);
                        if (Constructor != null)
                        {
                            File.Write(")");
                        }
                        Objectless = false;
                    }
                }
            }



            var Target = Lambda.Method.Name;

            if (Lambda.Method.IsProperty)
            {
                Target = Target.SkipUntilIfAny("set_").SkipUntilIfAny("get_");
            }

            if (!Objectless)
            {
                File.Write(".");
            }

            File.Write(
                new SolutionFileWriteArguments
            {
                Fragment = SolutionFileTextFragment.None,
                Text     = Target,
                Tag      = Lambda.Method
            }
                );

            if (Lambda.Method.IsProperty)
            {
                if (Lambda.ParameterExpressions.Length == 1)
                {
                    File.WriteSpace();
                    if (Lambda.IsAttributeContext)
                    {
                        File.WriteSpace("=");
                    }
                    else
                    {
                        File.WriteSpace("<-");
                    }
                    WritePseudoExpression(File, Lambda.ParameterExpressions[0], Context);
                }
            }
            else
            {
                InternalWriteParameterList(File, Lambda, Context);
            }
        }
        public static SolutionBuilder WithFormsApplet(this SolutionBuilder sln)
        {
            var content = default(SolutionProjectLanguageField);
            var sprite = default(SolutionProjectLanguageField);

            Internal(sln,
                IsApplet: true,
                ApplcationWebServiceAsComponent: false,
                NotifyContent: value => content = value);

            sln.Interactive.GenerateTypes +=
                AddType =>
                {
                    var ApplicationSprite = new StockAppletType(sln.Name, "ApplicationApplet", content);


                    ApplicationSprite.DependentUpon = content.FieldType;


                    content.DeclaringType = ApplicationSprite;

                    sprite = ApplicationSprite.ToInitializedField("applet");

                    sprite.DeclaringType = sln.Interactive.ApplicationType;

                    AddType(ApplicationSprite);
                };


            sln.Interactive.GenerateApplicationExpressions +=
                AddCode =>
                {
                    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.Extensions.AppletExtensions.AutoSizeAppletTo().ToCallExpression(
                            sprite,
                            page_get_ContentSize
                        )
                    );

                    AddCode(
                        new KnownStockTypes.ScriptCoreLib.JavaScript.Extensions.AppletExtensions.AttachAppletTo().ToCallExpression(
                            sprite,
                            page_get_Content
                        )
                    );
                };

            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 override void WritePseudoCallExpression(SolutionFile File, PseudoCallExpression Lambda, SolutionBuilder Context)
        {
            if (Lambda.Method.Name == SolutionProjectLanguageMethod.op_Implicit)
            {
                WritePseudoExpression(File, Lambda.ParameterExpressions[0], Context);
                return;
            }

            if (Lambda.Method.OperatorName != null)
            {
                if (Lambda.ParameterExpressions.Length == 2)
                {
                    WritePseudoExpression(File, Lambda.ParameterExpressions[0], Context);
                    File.WriteSpaces(Lambda.Method.OperatorName);
                    WritePseudoExpression(File, Lambda.ParameterExpressions[1], Context);

                    return;
                }
            }

            if (Lambda.Method.IsConstructor)
            {
                File.Write(Keywords.New);
                File.WriteSpace();
                WriteTypeName(File, Lambda.Method.DeclaringType);
                InternalWriteParameterList(File, Lambda, Context);
                return;
            }

            if (Lambda.Method.IsEvent)
            {
                if (Lambda.Method.Name.StartsWith("add_"))
                {
                    File.WriteSpace(Keywords.AddHandler);
                }
            }

            var Objectless = true;

            if (IsExtensionMethod(Lambda))
            {
                WritePseudoExpression(File, Lambda.ParameterExpressions[0], Context);
                Objectless = false;
            }
            else
            {
                if (Lambda.Method.IsStatic)
                {
                    if (Lambda.Method.DeclaringType != null)
                    {
                        WriteTypeName(File, Lambda.Method.DeclaringType);
                        Objectless = false;
                    }
                }
                else
                {
                    if (Lambda.Object != null)
                    {
                        WritePseudoExpression(File, Lambda.Object, Context);
                        Objectless = false;
                    }
                }
            }


            if (Lambda.Method.Name == "Invoke")
            {
                // in c# we can omit the .Invoke on a delegate
            }
            else
            {
                var Target = Lambda.Method.Name;

                if (Lambda.Method.IsProperty)
                {
                    Target = Target.SkipUntilIfAny("set_").SkipUntilIfAny("get_");
                }
                else if (Lambda.Method.IsEvent)
                {
                    Target = Target.SkipUntilIfAny("add_").SkipUntilIfAny("remove_");
                }

                if (!Objectless)
                {
                    File.Write(".");
                }

                File.Write(
                    new SolutionFileWriteArguments
                    {
                        Fragment = SolutionFileTextFragment.None,
                        Text = Target,
                        Tag = Lambda.Method
                    }
                );
            }

            if (Lambda.Method.IsEvent)
            {
                if (Lambda.Method.Name.StartsWith("add_"))
                {
                    File.WriteSpace(",");
                    WritePseudoExpression(File, Lambda.ParameterExpressions[0], Context);
                }
            }
            else if (Lambda.Method.IsProperty)
            {

                if (Lambda.ParameterExpressions.Length == 1)
                {
                    File.WriteSpace();

                    if (Lambda.IsAttributeContext)
                    {
                        File.Write(":=");
                    }
                    else
                    {
                        File.Write("=");
                    }

                    File.WriteSpace();
                    WritePseudoExpression(File, Lambda.ParameterExpressions[0], Context);
                }

            }
            else
            {

                InternalWriteParameterList(File, Lambda, Context);
            }


        }
		public void Add(PseudoCallExpression e)
		{
			// no DLR yet. we use our lite version instead.
			this.History.Add(e);
		}
 void VisitCall(PseudoCallExpression Call)
 {
     Call.Method.With(VisitMethod);
     Call.ParameterExpressions.WithEach(VisitExpression);
 }
        public StockUserControlType(string Namespace, string Name)
        {
            var UserControl1DesignerType =
                new SolutionProjectLanguagePartialType
                {
                    Name = Name + ".Designer",
                    Type = new SolutionProjectLanguageType
                    {
                        Namespace = Namespace,
                        Name = Name,
                    },
                };

            #region Dispose
            var disposing = new SolutionProjectLanguageArgument
            {
                Summary = "true if managed resources should be disposed; otherwise, false.",
                Name = "disposing",
                Type = new KnownStockTypes.System.Boolean(),
            };

            var Dispose = new SolutionProjectLanguageMethod
            {
                IsProtected = true,
                IsOverride = true,
                Summary = "Clean up any resources being used.",
                Name = "Dispose",
                DeclaringType = UserControl1DesignerType.Type,
                Code = new SolutionProjectLanguageCode
				{
					"Note: This jsc project does not support unmanaged resources.",
					new PseudoCallExpression
					{
						Object = new PseudoBaseExpression(),
						Method = new SolutionProjectLanguageMethod
						{
							Name = "Dispose",
						},
						ParameterExpressions = new[]
						{
							disposing
						}
					}
				}
            };

            Dispose.Parameters.Add(disposing);
            #endregion

            #region components
            var components =
                new SolutionProjectLanguageField
                {
                    IsPrivate = true,
                    Name = "components",
                    Summary = "Required designer variable.",
                    FieldType = new KnownStockTypes.System.ComponentModel.IContainer()
                };

            UserControl1DesignerType.Type.Fields.Add(components);
            #endregion



            #region set_Name
            var set_Name = new PseudoCallExpression
            {
                Object = new PseudoThisExpression(),
                Method = new SolutionProjectLanguageMethod
                {
                    IsProperty = true,
                    Name = "set_Name",
                },
                ParameterExpressions = new[]
				{
					new PseudoStringConstantExpression
					{
						Value = Name
					}
				}
            };
            #endregion

            #region set_Size
            var set_Size = new PseudoCallExpression
            {
                Object = new PseudoThisExpression(),
                Method = new SolutionProjectLanguageMethod
                {
                    IsProperty = true,
                    Name = "set_Size",
                },
                ParameterExpressions = new[]
				{
					new PseudoCallExpression
					{
						Method = new SolutionProjectLanguageMethod
						{
							DeclaringType = new SolutionProjectLanguageType
							{
								Namespace = "System.Drawing",
								Name = "Size"
							},
							Name = SolutionProjectLanguageMethod.ConstructorName
						},
						ParameterExpressions = new []
						{
							(PseudoInt32ConstantExpression) 400,
							(PseudoInt32ConstantExpression) 300,
						}
					}
				}
            };
            #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 = UserControl1DesignerType.Type,
                    Name = "InitializeComponent",
                    Code = new SolutionProjectLanguageCode
					{
						set_Name,
						set_Size
					}
                };

            UserControl1DesignerType.Type.Methods.Add(InitializeComponent);
            #endregion


            #region UserControl1Constructor
            var UserControl1Constructor =
                new SolutionProjectLanguageMethod
                {
                    DeclaringType = UserControl1DesignerType.Type,
                    Name = SolutionProjectLanguageMethod.ConstructorName,
                    Code = new SolutionProjectLanguageCode
					{
						new PseudoCallExpression
						{
							Object = new PseudoThisExpression(),
							Method = InitializeComponent
						}
					}
                };
            this.Methods.Add(UserControl1Constructor);
            #endregion

            this.Namespace = Namespace;
            this.Name = Name;

            this.BaseType = new KnownStockTypes.System.Windows.Forms.UserControl();

            this.DependentPartialTypes = new[]
				{
					UserControl1DesignerType
				};



            UserControl1DesignerType.Type.UsingNamespaces.Add("System.ComponentModel");
            UserControl1DesignerType.Type.UsingNamespaces.Add("System.Windows.Forms");

            this.UsingNamespaces.Add("System.Collections.Generic");
            this.UsingNamespaces.Add("System.ComponentModel");
            this.UsingNamespaces.Add("System.Drawing");
            this.UsingNamespaces.Add("System.Linq");
            this.UsingNamespaces.Add("System.Text");
            this.UsingNamespaces.Add("System.Windows.Forms");



            UserControl1DesignerType.Type.Methods.Add(Dispose);

        }