public void SetUpFixture()
		{
			using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
				IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
				IEventBindingService eventBindingService = new MockEventBindingService(host);
				Form form = (Form)host.RootComponent;
				form.ClientSize = new Size(200, 300);

				PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
				PropertyDescriptor descriptor = descriptors.Find("Name", false);
				descriptor.SetValue(form, "MainForm");
				
				// Add menu strip.
				MenuStrip menuStrip = (MenuStrip)host.CreateComponent(typeof(MenuStrip), "menuStrip1");
				menuStrip.Text = "menuStrip1";
				menuStrip.TabIndex = 0;
				menuStrip.Location = new Point(0, 0);
				form.Controls.Add(menuStrip);

				descriptor = descriptors.Find("MainMenuStrip", false);
				descriptor.SetValue(form, menuStrip);

				form.Controls.Remove(menuStrip);
				host.Container.Remove(menuStrip);
				
				DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
				using (serializationManager.CreateSession()) {					
					PythonCodeDomSerializer serializer = new PythonCodeDomSerializer("    ");
					generatedPythonCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager, String.Empty, 1);
				}
			}
		}
		public void SetUpFixture()
		{
			using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
				IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
				IEventBindingService eventBindingService = new MockEventBindingService(host);
				host.AddService(typeof(IEventBindingService), eventBindingService);
				
				Form form = (Form)host.RootComponent;
				form.ClientSize = new Size(200, 300);

				PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
				PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
				namePropertyDescriptor.SetValue(form, "MainForm");
				
				// Simulate giving a name to the Load event handler in the property grid.
				EventDescriptorCollection events = TypeDescriptor.GetEvents(form);
				EventDescriptor loadEvent = events.Find("Load", false);
				PropertyDescriptor loadEventProperty = eventBindingService.GetEventProperty(loadEvent);
				loadEventProperty.SetValue(form, "MainFormLoad");
				
				// Add a second event handler method.
				EventDescriptor closedEvent = events.Find("FormClosed", false);
				PropertyDescriptor closedEventProperty = eventBindingService.GetEventProperty(closedEvent);
				closedEventProperty.SetValue(form, "MainFormClosed");

				DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
				using (serializationManager.CreateSession()) {					
					PythonCodeDomSerializer serializer = new PythonCodeDomSerializer("    ");
					generatedPythonCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager, String.Empty, 1);
				}
			}
		}
 internal static void Flush_Rules_DT(IServiceProvider serviceProvider, Activity activity)
 {
     RuleDefinitions definitions = (RuleDefinitions) activity.GetValue(RuleDefinitions.RuleDefinitionsProperty);
     if (definitions != null)
     {
         WorkflowDesignerLoader service = (WorkflowDesignerLoader) serviceProvider.GetService(typeof(WorkflowDesignerLoader));
         if (service != null)
         {
             string filePath = string.Empty;
             if (!string.IsNullOrEmpty(service.FileName))
             {
                 filePath = Path.Combine(Path.GetDirectoryName(service.FileName), Path.GetFileNameWithoutExtension(service.FileName));
             }
             filePath = filePath + ".rules";
             using (TextWriter writer = service.GetFileWriter(filePath))
             {
                 if (writer != null)
                 {
                     using (XmlWriter writer2 = System.Workflow.Activities.Common.Helpers.CreateXmlWriter(writer))
                     {
                         DesignerSerializationManager serializationManager = new DesignerSerializationManager(serviceProvider);
                         using (serializationManager.CreateSession())
                         {
                             new WorkflowMarkupSerializer().Serialize(serializationManager, writer2, definitions);
                         }
                     }
                 }
             }
         }
     }
 }
		public void SetUpFixture()
		{
			using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
				IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
				IEventBindingService eventBindingService = new MockEventBindingService(host);
				Form form = (Form)host.RootComponent;
				form.ClientSize = new Size(200, 300);

				PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
				PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
				namePropertyDescriptor.SetValue(form, "MainForm");
				
				// Add month calendar.
				MonthCalendar calendar = (MonthCalendar)host.CreateComponent(typeof(MonthCalendar), "monthCalendar1");
				calendar.TabIndex = 0;
				calendar.Location = new Point(0, 0);
				calendar.AddMonthlyBoldedDate(new DateTime(2009, 1, 2));
				calendar.AddMonthlyBoldedDate(new DateTime(0));
				
				form.Controls.Add(calendar);
								
				DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
				using (serializationManager.CreateSession()) {					
					PythonCodeDomSerializer serializer = new PythonCodeDomSerializer("    ");
					generatedPythonCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager, String.Empty, 1);
				}
			}
		}
		public void SetUpFixture()
		{
			using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
				IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
				Form form = (Form)host.RootComponent;			
				form.ClientSize = new Size(284, 264);
				
				PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
				PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
				namePropertyDescriptor.SetValue(form, "MainForm");
				
				RichTextBox textBox = (RichTextBox)host.CreateComponent(typeof(RichTextBox), "richTextBox1");
				textBox.Size = new Size(110, 20);
				textBox.TabIndex = 1;
				textBox.Location = new Point(10, 10);
				textBox.Text = "abc\r\n" +
					"def\r\n" +
					"ghi\r\n";
				
				form.Controls.Add(textBox);
				
				DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
				using (serializationManager.CreateSession()) {					
					PythonCodeDomSerializer serializer = new PythonCodeDomSerializer("    ");
					generatedPythonCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager, String.Empty, 1);
				}
			}
		}
		public void SetUpFixture()
		{
			using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
				IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
				IEventBindingService eventBindingService = new MockEventBindingService(host);
				Form form = (Form)host.RootComponent;
				form.ClientSize = new Size(200, 300);
				
				Button button = (Button)host.CreateComponent(typeof(Button), "button1");
				button.Location = new Point(0, 0);
				button.Size = new Size(10, 10);
				button.Text = "button1";
				button.UseCompatibleTextRendering = false;
				
				button.FlatAppearance.BorderSize = 2;
				button.FlatAppearance.BorderColor = Color.Red;
				button.FlatAppearance.MouseOverBackColor = Color.Yellow;
		
				form.Controls.Add(button);

				PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
				PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
				namePropertyDescriptor.SetValue(form, "MainForm");
				
				DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
				using (serializationManager.CreateSession()) {
					RubyCodeDomSerializer serializer = new RubyCodeDomSerializer("    ");
					generatedRubyCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager, 1);
				}
			}
		}
		public void SetUpFixture()
		{
			using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
				IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
				IEventBindingService eventBindingService = new MockEventBindingService(host);
				Form form = (Form)host.RootComponent;
				form.ClientSize = new Size(200, 300);

				PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
				PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
				namePropertyDescriptor.SetValue(form, "MainForm");
				
				// Add table layout panel.
				TableLayoutPanel tableLayoutPanel1 = (TableLayoutPanel)host.CreateComponent(typeof(TableLayoutPanel), "tableLayoutPanel1");
				tableLayoutPanel1.ColumnCount = 2;
				tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 40F));
				tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 60F));
				tableLayoutPanel1.Location = new Point(0, 0);
				tableLayoutPanel1.RowCount = 2;
				tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 20F));
				tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 25F));
				tableLayoutPanel1.Size = new Size(200, 100);
				tableLayoutPanel1.TabIndex = 0;
								
				form.Controls.Add(tableLayoutPanel1);
				
				DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
				using (serializationManager.CreateSession()) {					
					RubyCodeDomSerializer serializer = new RubyCodeDomSerializer("    ");
					generatedRubyCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager, String.Empty, 1);
				}
			}
		}
		public void SetUpFixture()
		{
			using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
				IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
				IEventBindingService eventBindingService = new MockEventBindingService(host);
				Form form = (Form)host.RootComponent;
				form.ClientSize = new Size(200, 300);

				DataGridView dataGridView = (DataGridView)host.CreateComponent(typeof(DataGridView), "dataGridView1");
				dataGridView.Location = new Point(0, 0);
				dataGridView.Size = new Size(100, 100);
				form.Controls.Add(dataGridView);

				DataSet dataSet = (DataSet)host.CreateComponent(typeof(DataSet), "dataSet1");
				dataGridView.DataSource = dataSet;
				
				PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
				PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
				namePropertyDescriptor.SetValue(form, "MainForm");
				
				DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
				using (serializationManager.CreateSession()) {
					PythonCodeDomSerializer serializer = new PythonCodeDomSerializer("    ");
					generatedPythonCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager, String.Empty, 1);
				}
			}
		}
		public void SetUpFixture()
		{
			resourceWriter = new MockResourceWriter();
			componentCreator = new MockComponentCreator();
			componentCreator.SetResourceWriter(resourceWriter);
			
			using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
				IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
				IEventBindingService eventBindingService = new MockEventBindingService(host);
				host.AddService(typeof(IResourceService), componentCreator);
				
				Form form = (Form)host.RootComponent;
				form.ClientSize = new Size(200, 300);

				PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
				PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
				namePropertyDescriptor.SetValue(form, "MainForm");
				
				// Add ImageList.
				icon = new Icon(typeof(GenerateFormResourceTestFixture), "App.ico");
				ImageList imageList = (ImageList)host.CreateComponent(typeof(ImageList), "imageList1");
				imageList.Images.Add("App.ico", icon);
				imageList.Images.Add("", icon);
				imageList.Images.Add("", icon);
				
				DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
				using (serializationManager.CreateSession()) {
					RubyCodeDomSerializer serializer = new RubyCodeDomSerializer("    ");
					generatedRubyCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager, "RootNamespace", 1);
				}
			}
		}
		public void SetUpFixture()
		{
			AvalonEdit.TextEditor textEditor = new AvalonEdit.TextEditor();
			document = textEditor.Document;
			textEditor.Text = GetTextEditorCode();

			RubyParser parser = new RubyParser();
			ICompilationUnit compilationUnit = parser.Parse(new DefaultProjectContent(), @"test.py", document.Text);

			using (DesignSurface designSurface = new DesignSurface(typeof(UserControl))) {
				IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
				UserControl userControl = (UserControl)host.RootComponent;			
				userControl.ClientSize = new Size(489, 389);
				
				PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(userControl);
				PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
				namePropertyDescriptor.SetValue(userControl, "userControl1");
				
				DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
				using (serializationManager.CreateSession()) {
					AvalonEditDocumentAdapter docAdapter = new AvalonEditDocumentAdapter(document, null);
					RubyDesignerGenerator generator = new RubyDesignerGenerator(new MockTextEditorOptions());
					generator.Merge(host, docAdapter, compilationUnit, serializationManager);
				}
			}
		}
		public void SetUpFixture()
		{
			using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
				IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
				IEventBindingService eventBindingService = new MockEventBindingService(host);
				Form form = (Form)host.RootComponent;
				form.ClientSize = new Size(200, 300);

				PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
				PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
				namePropertyDescriptor.SetValue(form, "MainForm");

				// Add timer. This checks that the components Container is only created once in the
				// generated code.
				Timer timer = (Timer)host.CreateComponent(typeof(Timer), "timer1");
				
				// Add menu strip.
				ContextMenuStrip menuStrip = (ContextMenuStrip)host.CreateComponent(typeof(ContextMenuStrip), "contextMenuStrip1");
				
				// Set the context menu strip OwnerItem to simulate leaving the context menu
				// open in the designer before generating the source code. We do not want the
				// OwnerItem to be serialized.
				menuStrip.OwnerItem = new DerivedToolStripMenuItem();
				menuStrip.RightToLeft = RightToLeft.No;
				menuStripSize = menuStrip.Size;
				
				DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
				using (serializationManager.CreateSession()) {
					RubyCodeDomSerializer serializer = new RubyCodeDomSerializer("    ");
					generatedRubyCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager, 1);
				}
			}
		}	
		public void SetUpFixture()
		{
			using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
				IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
				Form form = (Form)host.RootComponent;			
				form.ClientSize = new Size(284, 264);
				
				PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
				PropertyDescriptor descriptor = descriptors.Find("MinimumSize", false);
				descriptor.SetValue(form, new Size(100, 200));
				descriptor = descriptors.Find("AutoScrollMinSize", false);
				descriptor.SetValue(form, new Size(10, 20));
				descriptor = descriptors.Find("AutoScrollMargin", false);
				descriptor.SetValue(form, new Size(11, 22));
				descriptor = descriptors.Find("AutoScroll", false);
				descriptor.SetValue(form, false);
				
				PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
				namePropertyDescriptor.SetValue(form, "MainForm");
				
				DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
				using (serializationManager.CreateSession()) {					
					PythonCodeDomSerializer serializer = new PythonCodeDomSerializer("    ");
					generatedPythonCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager, String.Empty, 1);
				}
			}
		}
		public void SetUpFixture()
		{
			using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
				IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
				IEventBindingService eventBindingService = new MockEventBindingService(host);
				Form form = (Form)host.RootComponent;
				form.ClientSize = new Size(200, 300);

				PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
				PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
				namePropertyDescriptor.SetValue(form, "MainForm");
				
				// Add combo box.
				ComboBox comboBox = (ComboBox)host.CreateComponent(typeof(ComboBox), "comboBox1");
				comboBox.TabIndex = 0;
				comboBox.Location = new Point(0, 0);
				comboBox.Size = new System.Drawing.Size(121, 21);
				comboBox.Items.Add("aaa");
				comboBox.Items.Add("bbb");
				comboBox.Items.Add("ccc");
				
				form.Controls.Add(comboBox);
				
				DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
				using (serializationManager.CreateSession()) {
					PythonCodeDomSerializer serializer = new PythonCodeDomSerializer("    ");
					generatedPythonCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager, String.Empty, 1);
				}	
			}
		}
		public void SetUpFixture()
		{
			using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
				IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
				Form form = (Form)host.RootComponent;			
				form.ClientSize = new Size(284, 264);
				
				PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
				PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
				namePropertyDescriptor.SetValue(form, "MainForm");
				
				Button button = (Button)host.CreateComponent(typeof(Button), "button1");
				button.Location = new Point(0, 0);
				button.Size = new Size(10, 10);
				button.Text = "button1";
				button.TabIndex = 0;
				button.UseCompatibleTextRendering = false;
				form.Controls.Add(button);

				RadioButton radioButton = (RadioButton)host.CreateComponent(typeof(RadioButton), "radioButton1");
				radioButton.Location = new Point(20, 0);
				radioButton.Size = new Size(10, 10);
				radioButton.Text = "radioButton1";
				radioButton.TabIndex = 1;
				radioButton.UseCompatibleTextRendering = false;
				form.Controls.Add(radioButton);
				
				DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
				using (serializationManager.CreateSession()) {
					RubyCodeDomSerializer serializer = new RubyCodeDomSerializer("    ");
					generatedRubyCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager, 1);
				}
			}
		}
		public void SetUpFixture()
		{
			resourceWriter = new MockResourceWriter();
			componentCreator = new MockComponentCreator();
			componentCreator.SetResourceWriter(resourceWriter);
			
			using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
				IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
				IEventBindingService eventBindingService = new MockEventBindingService(host);
				host.AddService(typeof(IResourceService), componentCreator);
				
				Form form = (Form)host.RootComponent;
				form.ClientSize = new Size(200, 300);

				PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
				PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
				namePropertyDescriptor.SetValue(form, "MainForm");
				
				// Set bitmap as form background image.
				bitmap = new Bitmap(10, 10);
				form.BackgroundImage = bitmap;
				
				icon = new Icon(typeof(GenerateFormResourceTestFixture), "App.ico");
				form.Icon = icon;
				
				DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
				using (serializationManager.CreateSession()) {					
					PythonCodeDomSerializer serializer = new PythonCodeDomSerializer("    ");
					generatedPythonCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager, "RootNamespace", 1);
				}
			}
		}
		public void SetUpFixture()
		{
			resourceWriter = new MockResourceWriter();
			resourceService = new MockResourceService();
			resourceService.SetResourceWriter(resourceWriter);
			
			AvalonEdit.TextEditor textEditor = new AvalonEdit.TextEditor();
			document = textEditor.Document;
			textEditor.Text = GetTextEditorCode();
			
			PythonParser parser = new PythonParser();
			ICompilationUnit compilationUnit = parser.Parse(new DefaultProjectContent(), @"test.py", document.Text);

			using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
				IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
				Form form = (Form)host.RootComponent;
				form.ClientSize = new Size(499, 309);

				PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
				PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
				namePropertyDescriptor.SetValue(form, "MainForm");
				
				DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
				using (serializationManager.CreateSession()) {
					AvalonEditDocumentAdapter adapter = new AvalonEditDocumentAdapter(document, null);
					MockTextEditorOptions options = new MockTextEditorOptions();
					PythonDesignerGenerator generator = new PythonDesignerGenerator(options);
					generator.Merge(host, adapter, compilationUnit, serializationManager);
				}
			}
		}
		public void SetUpFixture()
		{
			using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
				IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
				IEventBindingService eventBindingService = new MockEventBindingService(host);
				Form form = (Form)host.RootComponent;
				form.ClientSize = new Size(200, 300);

				PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
				PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
				namePropertyDescriptor.SetValue(form, "MainForm");
				
				// Add list view.
				ListView listView = (ListView)host.CreateComponent(typeof(ListView), "listView1");
				listView.TabIndex = 0;
				listView.Location = new Point(0, 0);
				listView.ClientSize = new Size(200, 100);
				descriptors = TypeDescriptor.GetProperties(listView);
				PropertyDescriptor descriptor = descriptors.Find("UseCompatibleStateImageBehavior", false);
				descriptor.SetValue(listView, true);
				descriptor = descriptors.Find("View", false);
				descriptor.SetValue(listView, View.Details);
				form.Controls.Add(listView);
				
				// Add column headers.
				columnHeader1 = (ColumnHeader)host.CreateComponent(typeof(ColumnHeader), "columnHeader1");
				descriptors = TypeDescriptor.GetProperties(columnHeader1);
				descriptor = descriptors.Find("Text", false);
				descriptor.SetValue(columnHeader1, "columnHeader1");
				listView.Columns.Add(columnHeader1);
				
				columnHeader2 = (ColumnHeader)host.CreateComponent(typeof(ColumnHeader), "columnHeader2");
				descriptors = TypeDescriptor.GetProperties(columnHeader2);
				descriptor = descriptors.Find("Text", false);
				descriptor.SetValue(columnHeader2, "columnHeader2");
				listView.Columns.Add(columnHeader2);
				
				// Add list view items.
				DesignerSerializationManager designerSerializationManager = new DesignerSerializationManager(host);
				IDesignerSerializationManager serializationManager = (IDesignerSerializationManager)designerSerializationManager;
				using (designerSerializationManager.CreateSession()) {
					ListViewItem item = (ListViewItem)serializationManager.CreateInstance(typeof(ListViewItem), new object[] {"aaa"}, "listViewItem1", false);
					item.ToolTipText = "tooltip";
					listView.Items.Add(item);
					
					item = (ListViewItem)serializationManager.CreateInstance(typeof(ListViewItem), new object[] {"bbb"}, "listViewItem2", false);
					listView.Items.Add(item);
					
					item = (ListViewItem)serializationManager.CreateInstance(typeof(ListViewItem), new object[0], "listViewItem3", false);
					listView.Items.Add(item);

					PythonCodeDomSerializer serializer = new PythonCodeDomSerializer("    ");
					generatedPythonCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager, String.Empty, 1);
				}	
			}
		}
		public void SetUpFixture()
		{
			using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
				IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
				IEventBindingService eventBindingService = new MockEventBindingService(host);
				Form form = (Form)host.RootComponent;
				form.ClientSize = new Size(200, 300);

				PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
				PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
				namePropertyDescriptor.SetValue(form, "MainForm");
				
				// Add list view.
				ListView listView = (ListView)host.CreateComponent(typeof(ListView), "listView1");
				listView.TabIndex = 0;
				listView.Location = new Point(0, 0);
				listView.ClientSize = new Size(200, 100);
				descriptors = TypeDescriptor.GetProperties(listView);
				PropertyDescriptor descriptor = descriptors.Find("UseCompatibleStateImageBehavior", false);
				descriptor.SetValue(listView, true);
				descriptor = descriptors.Find("View", false);
				descriptor.SetValue(listView, View.Details);
				form.Controls.Add(listView);
				
				// Add ImageList.
				Icon icon = new Icon(typeof(GenerateFormResourceTestFixture), "App.ico");
				ImageList imageList = (ImageList)host.CreateComponent(typeof(ImageList), "imageList1");
				imageList.Images.Add("App.ico", icon);
				imageList.Images.Add("b.ico", icon);
				imageList.Images.Add("c.ico", icon); 
				
				DesignerSerializationManager designerSerializationManager = new DesignerSerializationManager(host);
				IDesignerSerializationManager serializationManager = (IDesignerSerializationManager)designerSerializationManager;
				using (designerSerializationManager.CreateSession()) {					
					// Add list view items.
					ListViewItem item = (ListViewItem)serializationManager.CreateInstance(typeof(ListViewItem), new object[] {"aaa"}, "listViewItem1", false);
					item.ImageIndex = 1;
					listView.Items.Add(item);
					
					ListViewItem item2 = (ListViewItem)serializationManager.CreateInstance(typeof(ListViewItem), new object[] {"bbb"}, "listViewItem2", false);
					item2.ImageKey = "App.ico";
					listView.Items.Add(item2);
					
					ListViewItem item3 = (ListViewItem)serializationManager.CreateInstance(typeof(ListViewItem), new object[0], "listViewItem3", false);
					item3.ImageIndex = 2;
					listView.Items.Add(item3);
	
					ListViewItem item4 = (ListViewItem)serializationManager.CreateInstance(typeof(ListViewItem), new object[0], "listViewItem4", false);
					item4.ImageKey = "b.ico";
					listView.Items.Add(item4);
				
					PythonCodeDomSerializer serializer = new PythonCodeDomSerializer("    ");
					generatedPythonCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager);
				}
			}
		}
Beispiel #19
0
		protected virtual void Initialize ()
		{
			_serializationMananger = new DesignerSerializationManager (_host);

			DesignSurfaceServiceContainer serviceContainer = _host.GetService (typeof (IServiceContainer)) as DesignSurfaceServiceContainer;
			if (serviceContainer != null) {
				serviceContainer.AddService (typeof (IDesignerLoaderService), (IDesignerLoaderService) this);
				serviceContainer.AddNonReplaceableService (typeof (IDesignerSerializationManager), _serializationMananger);
			}
		}
		public void SetUpFixture()
		{
			using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
				IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
				IEventBindingService eventBindingService = new MockEventBindingService(host);
				Form form = (Form)host.RootComponent;
				form.ClientSize = new Size(200, 300);

				PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
				PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
				namePropertyDescriptor.SetValue(form, "MainForm");
				
				// Add menu strip.
				MenuStrip menuStrip = (MenuStrip)host.CreateComponent(typeof(MenuStrip), "menuStrip1");
				menuStrip.Text = "menuStrip1";
				menuStrip.TabIndex = 0;
				menuStrip.Location = new Point(0, 0);
				menuStrip.Size = new System.Drawing.Size(200, 24);
				
				// Add menu strip items.
				ToolStripMenuItem fileMenuItem = (ToolStripMenuItem)host.CreateComponent(typeof(ToolStripMenuItem), "fileToolStripMenuItem");
				fileMenuItem.Text = "&File";
				
				ToolStripMenuItem openMenuItem = (ToolStripMenuItem)host.CreateComponent(typeof(ToolStripMenuItem), "openToolStripMenuItem");
				openMenuItem.Text = "&Open";
				
				ToolStripMenuItem exitMenuItem = (ToolStripMenuItem)host.CreateComponent(typeof(ToolStripMenuItem), "exitToolStripMenuItem");
				exitMenuItem.Text = "E&xit";
				fileMenuItem.DropDownItems.Add(openMenuItem);
				fileMenuItem.DropDownItems.Add(exitMenuItem);
				
				// Add non-sited component.
				fileMenuItem.DropDownItems.Add(new ToolStripMenuItem());
				
				menuStrip.Items.Add(fileMenuItem);
								
				ToolStripMenuItem editMenuItem = (ToolStripMenuItem)host.CreateComponent(typeof(ToolStripMenuItem), "editToolStripMenuItem");
				editMenuItem.Text = "&Edit";
				menuStrip.Items.Add(editMenuItem);

				form.Controls.Add(menuStrip);
				
				fileMenuItemSize = fileMenuItem.Size;
				openMenuItemSize = openMenuItem.Size;
				exitMenuItemSize = exitMenuItem.Size;
				editMenuItemSize = editMenuItem.Size;

				DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
				using (serializationManager.CreateSession()) {					
					RubyCodeDomSerializer serializer = new RubyCodeDomSerializer("    ");
					generatedRubyCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager, String.Empty, 1);
				}
			}
		}
        public object Deserialize(XmlReader reader)
        {
            if (reader == null)
                throw new ArgumentNullException("reader");

            DesignerSerializationManager designerSerializationManager = new DesignerSerializationManager();
            using (designerSerializationManager.CreateSession())
            {
                return Deserialize(designerSerializationManager, reader);
            }
        }
		public void SetUpFixture()
		{
			RubyCodeDomSerializer serializer = new RubyCodeDomSerializer("    ");
			using (Form form = new Form()) {
				form.Site = new MockSite();
				CodeMemberMethod method = CreateMethod();
				DesignerSerializationManager serializationManager = new DesignerSerializationManager();
				using (serializationManager.CreateSession()) {
					generatedRubyCode = serializer.GenerateMethodBody(form, method, serializationManager, String.Empty, 0);
				}
			}
		}
		public void SetUpFixture()
		{
			resourceWriter = new MockResourceWriter();
			componentCreator = new MockComponentCreator();
			componentCreator.SetResourceWriter(resourceWriter);

			resourceWriter2 = new MockResourceWriter();
			componentCreator2 = new MockComponentCreator();
			componentCreator2.SetResourceWriter(resourceWriter2);
			
			using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
				IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
				IEventBindingService eventBindingService = new MockEventBindingService(host);
				host.AddService(typeof(IResourceService), componentCreator);
				
				Form form = (Form)host.RootComponent;
				form.ClientSize = new Size(200, 300);

				PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
				PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
				namePropertyDescriptor.SetValue(form, "MainForm");
				
				// Add picture box
				PictureBox pictureBox = (PictureBox)host.CreateComponent(typeof(PictureBox), "pictureBox1");
				pictureBox.Location = new Point(0, 0);
				bitmap = new Bitmap(10, 10);
				pictureBox.Image = bitmap;
				pictureBox.Size = new Size(100, 120);
				pictureBox.TabIndex = 0;
				form.Controls.Add(pictureBox);
				
				// Add bitmap to form.
				form.BackgroundImage = new Bitmap(10, 10);

				DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
				using (serializationManager.CreateSession()) {					
					PythonCodeDomSerializer serializer = new PythonCodeDomSerializer("    ");
					generatedPythonCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager, String.Empty, 1);
				}

				// Check that calling the GenerateInitializeComponentMethodBody also generates a resource file.
				host.RemoveService(typeof(IResourceService));
				host.AddService(typeof(IResourceService), componentCreator2);
				
				serializationManager = new DesignerSerializationManager(host);
				using (serializationManager.CreateSession()) {					
					PythonCodeDomSerializer serializer = new PythonCodeDomSerializer("    ");
					serializer.GenerateInitializeComponentMethodBody(host, serializationManager, String.Empty, 1);
				}			
			}
		}
 protected internal override Activity CreateInstance(XmlReader workflowDefinitionReader, XmlReader rulesReader)
 {
     if (workflowDefinitionReader == null)
     {
         throw new ArgumentNullException("workflowDefinitionReader");
     }
     Activity activity = null;
     ValidationErrorCollection errors = new ValidationErrorCollection();
     ServiceContainer container = new ServiceContainer();
     ITypeProvider service = base.Runtime.GetService<ITypeProvider>();
     if (service != null)
     {
         container.AddService(typeof(ITypeProvider), service);
     }
     DesignerSerializationManager manager = new DesignerSerializationManager(container);
     try
     {
         using (manager.CreateSession())
         {
             WorkflowMarkupSerializationManager serializationManager = new WorkflowMarkupSerializationManager(manager);
             activity = new WorkflowMarkupSerializer().Deserialize(serializationManager, workflowDefinitionReader) as Activity;
             if ((activity != null) && (rulesReader != null))
             {
                 object obj2 = new WorkflowMarkupSerializer().Deserialize(serializationManager, rulesReader);
                 activity.SetValue(ConditionTypeConverter.DeclarativeConditionDynamicProp, obj2);
             }
             foreach (object obj3 in manager.Errors)
             {
                 if (obj3 is WorkflowMarkupSerializationException)
                 {
                     errors.Add(new ValidationError(((WorkflowMarkupSerializationException) obj3).Message, 0x15b));
                 }
                 else
                 {
                     errors.Add(new ValidationError(obj3.ToString(), 0x15b));
                 }
             }
         }
     }
     catch (Exception exception)
     {
         errors.Add(new ValidationError(exception.Message, 0x15b));
     }
     if (errors.HasErrors)
     {
         throw new WorkflowValidationFailedException(ExecutionStringManager.WorkflowValidationFailure, errors);
     }
     return activity;
 }
		public void SetUpFixture()
		{
			using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
				IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
				IEventBindingService eventBindingService = new MockEventBindingService(host);
				Form form = (Form)host.RootComponent;
				form.ClientSize = new Size(200, 300);

				PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
				PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
				namePropertyDescriptor.SetValue(form, "MainForm");
				
				// Add tree view.
				TreeView treeView = (TreeView)host.CreateComponent(typeof(TreeView), "treeView1");
				treeView.LineColor = Color.Black;
				treeView.Location = new Point(0, 0);
				treeView.Size = new Size(100, 100);
				
				DesignerSerializationManager designerSerializationManager = new DesignerSerializationManager(host);
				IDesignerSerializationManager serializationManager = (IDesignerSerializationManager)designerSerializationManager;
				using (designerSerializationManager.CreateSession()) {

					// Add first root node.
					TreeNode firstRootNode = (TreeNode)serializationManager.CreateInstance(typeof(TreeNode), new object[0], "treeNode3", false);
					firstRootNode.Name = "RootNode0";
					firstRootNode.Text = "RootNode0.Text";
					treeView.Nodes.Add(firstRootNode);
					
					// Add first child node.
					TreeNode firstChildNode = (TreeNode)serializationManager.CreateInstance(typeof(TreeNode), new object[0], "treeNode2", false);
					firstChildNode.Name = "ChildNode0";
					firstChildNode.Text = "ChildNode0.Text";
					firstRootNode.Nodes.Add(firstChildNode);
					
					// Add second child node.
					TreeNode secondChildNode = (TreeNode)serializationManager.CreateInstance(typeof(TreeNode), new object[0], "treeNode1", false);
					secondChildNode.Name = "ChildNode1";
					secondChildNode.Text = "ChildNode1.Text";
					firstChildNode.Nodes.Add(secondChildNode);
					
					form.Controls.Add(treeView);
					
					RubyCodeDomSerializer serializer = new RubyCodeDomSerializer("    ");
					generatedRubyCode = serializer.GenerateInitializeComponentMethodBody(host, designerSerializationManager, String.Empty, 1);
				}
			}
		}
		public void SetUpFixture()
		{
			using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
				IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
				IEventBindingService eventBindingService = new MockEventBindingService(host);
				Form form = (Form)host.RootComponent;
				form.ClientSize = new Size(200, 300);

				PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
				PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
				namePropertyDescriptor.SetValue(form, "MainForm");
				
				// Add list view.
				ListView listView = (ListView)host.CreateComponent(typeof(ListView), "listView1");
				listView.TabIndex = 0;
				listView.Location = new Point(0, 0);
				listView.ClientSize = new Size(200, 100);
				descriptors = TypeDescriptor.GetProperties(listView);
				PropertyDescriptor descriptor = descriptors.Find("UseCompatibleStateImageBehavior", false);
				descriptor.SetValue(listView, true);
				descriptor = descriptors.Find("View", false);
				descriptor.SetValue(listView, View.Details);
				form.Controls.Add(listView);

				DesignerSerializationManager designerSerializationManager = new DesignerSerializationManager(host);
				IDesignerSerializationManager serializationManager = (IDesignerSerializationManager)designerSerializationManager;
				using (designerSerializationManager.CreateSession()) {					
				
					// Add groups.
					ListViewGroup group1 = (ListViewGroup)serializationManager.CreateInstance(typeof(ListViewGroup), new object[0], "listViewGroup1", false);
					group1.Header = "ListViewGroup";
					group1.HeaderAlignment = HorizontalAlignment.Right;
					group1.Name = "defaultGroup";
					group1.Tag = "tag1";		
					listView.Groups.Add(group1);
					
					ListViewGroup group2 = (ListViewGroup)serializationManager.CreateInstance(typeof(ListViewGroup), new object[0], "listViewGroup2", false);
					group2.Header = "ListViewGroup";
					group2.HeaderAlignment = HorizontalAlignment.Center;
					group2.Name = "listViewGroup2";
					listView.Groups.Add(group2);
				
					PythonCodeDomSerializer serializer = new PythonCodeDomSerializer("    ");
					generatedPythonCode = serializer.GenerateInitializeComponentMethodBody(host, designerSerializationManager, String.Empty, 1);
				}
			}
		}
                public InstanceRedirectorDesignerSerializationManager(IServiceProvider provider, IContainer container,
                                                                      bool validateRecycledTypes)
                {
                    if (provider == null)
                    {
                        throw new ArgumentNullException("provider");
                    }
                    DesignerSerializationManager manager = new DesignerSerializationManager(provider);

                    manager.PreserveNames = false;
                    if (container != null)
                    {
                        manager.Container = container;
                    }
                    manager.ValidateRecycledTypes = validateRecycledTypes;
                    _manager = manager;
                }
		public void SetUpFixture()
		{
			using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
				IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
				Form form = (Form)host.RootComponent;			
				form.ClientSize = new Size(284, 264);
				
				PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
				PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
				namePropertyDescriptor.SetValue(form, "MainForm");
				
				DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
				using (serializationManager.CreateSession()) {
					RubyCodeDomSerializer serializer = new RubyCodeDomSerializer("    ");
					generatedRubyCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager, 1);
				}
			}
		}
        // This function will create a new root activity definition tree by deserializing the xoml and the rules file.
        protected internal override Activity CreateInstance(XmlReader workflowDefinitionReader, XmlReader rulesReader)
        {
            if (workflowDefinitionReader == null)
                throw new ArgumentNullException("workflowDefinitionReader");

            Activity root = null;
            ValidationErrorCollection errors = new ValidationErrorCollection();
            ServiceContainer serviceContainer = new ServiceContainer();
            ITypeProvider typeProvider = this.Runtime.GetService<ITypeProvider>();
            if (typeProvider != null)
                serviceContainer.AddService(typeof(ITypeProvider), typeProvider);

            DesignerSerializationManager manager = new DesignerSerializationManager(serviceContainer);
            try
            {
                using (manager.CreateSession())
                {
                    WorkflowMarkupSerializationManager xomlSerializationManager = new WorkflowMarkupSerializationManager(manager);
                    root = new WorkflowMarkupSerializer().Deserialize(xomlSerializationManager, workflowDefinitionReader) as Activity;
                    if (root != null && rulesReader != null)
                    {
                        object rules = new WorkflowMarkupSerializer().Deserialize(xomlSerializationManager, rulesReader);
                        root.SetValue(ConditionTypeConverter.DeclarativeConditionDynamicProp, rules);
                    }

                    foreach (object error in manager.Errors)
                    {
                        if (error is WorkflowMarkupSerializationException)
                            errors.Add(new ValidationError(((WorkflowMarkupSerializationException)error).Message, ErrorNumbers.Error_SerializationError));
                        else
                            errors.Add(new ValidationError(error.ToString(), ErrorNumbers.Error_SerializationError));
                    }
                }
            }
            catch (Exception e)
            {
                errors.Add(new ValidationError(e.Message, ErrorNumbers.Error_SerializationError));
            }

            if (errors.HasErrors)
                throw new WorkflowValidationFailedException(ExecutionStringManager.WorkflowValidationFailure, errors);

            return root;
        }
		public void SetUpFixture()
		{
			AvalonEdit.TextEditor textEditor = new AvalonEdit.TextEditor();
			document = textEditor.Document;
			textEditor.Text = GetTextEditorCode();

			RubyParser parser = new RubyParser();
			MockProjectContent projectContent = new MockProjectContent();
			MockProject project = new MockProject();
			project.RootNamespace = "RootNamespace";
			projectContent.Project = project;
			ICompilationUnit compilationUnit = parser.Parse(projectContent, @"test.py", document.Text);

			using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
				IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
				IEventBindingService eventBindingService = new MockEventBindingService(host);
				Form form = (Form)host.RootComponent;
				form.ClientSize = new Size(200, 300);

				PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
				PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
				namePropertyDescriptor.SetValue(form, "MainForm");
			
				// Add picture box
				PictureBox pictureBox = (PictureBox)host.CreateComponent(typeof(PictureBox), "pictureBox1");
				pictureBox.Location = new Point(0, 0);
				pictureBox.Image = new Bitmap(10, 10);
				pictureBox.Size = new Size(100, 120);
				pictureBox.TabIndex = 0;
				form.Controls.Add(pictureBox);
				
				MockTextEditorOptions options = new MockTextEditorOptions();
				options.ConvertTabsToSpaces = true;
				options.IndentationSize = 4;
				
				DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
				using (serializationManager.CreateSession()) {
					AvalonEditDocumentAdapter docAdapter = new AvalonEditDocumentAdapter(document, null);
					RubyDesignerGenerator generator = new RubyDesignerGenerator(options);
					generator.Merge(host, docAdapter, compilationUnit, serializationManager);
				}
			}
		}
		public void SetUpFixture()
		{
			using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
				IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
				IEventBindingService eventBindingService = new MockEventBindingService(host);
				host.AddService(typeof(IEventBindingService), eventBindingService);

				Form form = (Form)host.RootComponent;
				form.ClientSize = new Size(284, 264);
				
				PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
				PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
				namePropertyDescriptor.SetValue(form, "MainForm");
				
				Panel panel = (Panel)host.CreateComponent(typeof(Panel), "panel1");
				panel.Location = new Point(10, 15);
				panel.Anchor = AnchorStyles.Bottom | AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
				panel.TabIndex = 0;
				panel.Size = new Size(100, 120);
				TextBox textBox = (TextBox)host.CreateComponent(typeof(TextBox), "textBox1");
				textBox.Location = new Point(5, 5);
				textBox.TabIndex = 0;
				textBox.Size = new Size(110, 20);
				panel.Controls.Add(textBox);
				
				// Add an event handler to the panel to check that this code is generated
				// before the text box is initialized.
				EventDescriptorCollection events = TypeDescriptor.GetEvents(panel);
				EventDescriptor clickEvent = events.Find("Click", false);
				PropertyDescriptor clickEventProperty = eventBindingService.GetEventProperty(clickEvent);
				clickEventProperty.SetValue(panel, "Panel1Click");

				form.Controls.Add(panel);
				
				DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
				using (serializationManager.CreateSession()) {					
					PythonCodeDomSerializer serializer = new PythonCodeDomSerializer("    ");
					generatedPythonCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager, String.Empty, 1);
				}
			}
		}
Beispiel #32
0
        public override void BeginLoad(IDesignerLoaderHost host)
        {
            if (host == null)
            {
                throw new ArgumentNullException("host");
            }
            if (this._state[StateLoaded])
            {
                Exception exception = new InvalidOperationException(System.Design.SR.GetString("BasicDesignerLoaderAlreadyLoaded"))
                {
                    HelpLink = "BasicDesignerLoaderAlreadyLoaded"
                };
                throw exception;
            }
            if ((this._host != null) && (this._host != host))
            {
                Exception exception2 = new InvalidOperationException(System.Design.SR.GetString("BasicDesignerLoaderDifferentHost"))
                {
                    HelpLink = "BasicDesignerLoaderDifferentHost"
                };
                throw exception2;
            }
            this._state[StateLoaded | StateLoadFailed] = false;
            this._loadDependencyCount = 0;
            if (this._host == null)
            {
                this._host                 = host;
                this._hostInitialized      = true;
                this._serializationManager = new DesignerSerializationManager(this._host);
                DesignSurfaceServiceContainer container = this.GetService(typeof(DesignSurfaceServiceContainer)) as DesignSurfaceServiceContainer;
                if (container != null)
                {
                    container.AddFixedService(typeof(IDesignerSerializationManager), this._serializationManager);
                }
                else
                {
                    IServiceContainer container2 = this.GetService(typeof(IServiceContainer)) as IServiceContainer;
                    if (container2 == null)
                    {
                        this.ThrowMissingService(typeof(IServiceContainer));
                    }
                    container2.AddService(typeof(IDesignerSerializationManager), this._serializationManager);
                }
                this.Initialize();
                host.Activated   += new EventHandler(this.OnDesignerActivate);
                host.Deactivated += new EventHandler(this.OnDesignerDeactivate);
            }
            bool      successful           = true;
            ArrayList errorCollection      = null;
            IDesignerLoaderService service = this.GetService(typeof(IDesignerLoaderService)) as IDesignerLoaderService;

            try
            {
                if (service != null)
                {
                    service.AddLoadDependency();
                }
                else
                {
                    this._loading = true;
                    this.OnBeginLoad();
                }
                this.PerformLoad(this._serializationManager);
            }
            catch (Exception innerException)
            {
                while (innerException is TargetInvocationException)
                {
                    innerException = innerException.InnerException;
                }
                errorCollection = new ArrayList();
                errorCollection.Add(innerException);
                successful = false;
            }
            if (service != null)
            {
                service.DependentLoadComplete(successful, errorCollection);
            }
            else
            {
                this.OnEndLoad(successful, errorCollection);
                this._loading = false;
            }
        }
Beispiel #33
0
 public Session(DesignerSerializationManager manager)
 {
     _manager = manager;
 }
Beispiel #34
0
 internal SerializationSession(DesignerSerializationManager serializationManager)
 {
     this.serializationManager = serializationManager;
 }