Browse Source

Loader updates

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2390 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Russell Wilkins 19 years ago
parent
commit
a891a19a97
  1. 2
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Loaders/BasicWorkflowDesignerLoader.cs
  2. 66
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Loaders/CodeDesignerLoader.cs
  3. 2
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Loaders/XomlDesignerLoader.cs
  4. 10
      src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/EventBindingService/EventPropertyDescriptor.cs

2
src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Loaders/BasicWorkflowDesignerLoader.cs

@ -135,10 +135,8 @@ namespace WorkflowDesigner.Loaders @@ -135,10 +135,8 @@ namespace WorkflowDesigner.Loaders
protected override void PerformLoad(IDesignerSerializationManager serializationManager)
{
base.PerformLoad(serializationManager);
DoPerformLoad(serializationManager);
LoadRules();
LoaderHost.Activate();
}
protected abstract void DoPerformLoad(IDesignerSerializationManager serializationManager);

66
src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Loaders/CodeDesignerLoader.cs

@ -8,7 +8,9 @@ @@ -8,7 +8,9 @@
#region Using
using System;
using System.CodeDom;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.ComponentModel.Design.Serialization;
using System.IO;
@ -22,24 +24,10 @@ using ICSharpCode.SharpDevelop.Dom; @@ -22,24 +24,10 @@ using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.Ast;
using ICSharpCode.NRefactory.Visitors;
#endregion
#endregion
namespace WorkflowDesigner.Loaders
{
public class IdentifierCreationService : IIdentifierCreationService
{
public void EnsureUniqueIdentifiers(CompositeActivity parentActivity, System.Collections.ICollection childActivities)
{
// throw new NotImplementedException();
}
public void ValidateIdentifier(Activity activity, string identifier)
{
// throw new NotImplementedException();
}
}
/// <summary>
/// Description of CodeDesignerLoader.
@ -49,15 +37,14 @@ namespace WorkflowDesigner.Loaders @@ -49,15 +37,14 @@ namespace WorkflowDesigner.Loaders
public CodeDesignerLoader(IViewContent viewContent) : base(viewContent)
{
}
protected override void Initialize()
{
base.Initialize();
LoaderHost.AddService(typeof(IMemberCreationService), new MemberCreationService(LoaderHost));
//LoaderHost.AddService(typeof(IEventBindingService), new CSharpWorkflowDesignerEventBindingService(LoaderHost, ViewContent.PrimaryFileName));
//LoaderHost.RemoveService(typeof(IIdentifierCreationService));
//LoaderHost.AddService(typeof(IIdentifierCreationService), new IdentifierCreationService());
LoaderHost.AddService(typeof(CodeDomProvider), Project.LanguageProperties.CodeDomProvider);
LoaderHost.AddService(typeof(IEventBindingService), new CSharpWorkflowDesignerEventBindingService(LoaderHost, ViewContent.PrimaryFileName));
}
protected override void DoPerformLoad(IDesignerSerializationManager serializationManager)
@ -67,25 +54,40 @@ namespace WorkflowDesigner.Loaders @@ -67,25 +54,40 @@ namespace WorkflowDesigner.Loaders
CodeCompileUnit ccu = Parse();
// Step 2, Find the first class
CodeTypeDeclaration cdt = ccu.Namespaces[0].Types[0];
CodeTypeDeclaration codeTypeDeclaration = ccu.Namespaces[0].Types[0];
TypeResolutionService typeResolutionService = GetService(typeof(ITypeResolutionService)) as TypeResolutionService;
Type baseType = typeResolutionService.GetType(codeTypeDeclaration.BaseTypes[0].BaseType);
if (baseType == null)
throw new WorkflowDesignerLoadException("Unable to resolve type " + codeTypeDeclaration.BaseTypes[0].BaseType);
TypeResolutionService srv = GetService(typeof(ITypeResolutionService)) as TypeResolutionService;
Type t = srv.GetType(cdt.BaseTypes[0].BaseType);
if (t == null)
throw new WorkflowDesignerLoadException("Unable to resolve type " + cdt.BaseTypes[0].BaseType);
// Step 3, Deserialize it!
TypeCodeDomSerializer cds = serializationManager.GetSerializer(t, typeof(TypeCodeDomSerializer)) as TypeCodeDomSerializer;
TypeCodeDomSerializer serializer = serializationManager.GetSerializer(baseType, typeof(TypeCodeDomSerializer)) as TypeCodeDomSerializer;
// Step 4, load up the designer.
Activity rootActivity = null;
rootActivity = cds.Deserialize(serializationManager, cdt) as Activity;
rootActivity.Name = cdt.Name;
#if DEBUG
Project.LanguageProperties.CodeDomProvider.GenerateCodeFromType(codeTypeDeclaration, Console.Out, null);
#endif
LoaderHost.Container.Add(rootActivity, rootActivity.QualifiedName);
// Step 4, load up the designer.
Activity rootActivity = serializer.Deserialize(serializationManager, codeTypeDeclaration) as Activity;
SetBaseComponentClassName(ccu.Namespaces[0].Name + "." + cdt.Name);
// FIXME: This is a workaraound as the deserializer does not appear to add the
// components to the container with the activity.name so
// the designer complains the name is already used when the
// name of an activity is the same as a field name in the workflow!
// When I work out how the IMemberCreationService fits into
// the scheme of things this will probably go away!
// (Worth noting CodeDomDesignerLoader has the same problem!)
//int i = 0;
foreach(IComponent c in LoaderHost.Container.Components) {
if (c is Activity) {
LoaderHost.Container.Remove(c);
LoaderHost.Container.Add(c, ((Activity)c).Name);
}
}
SetBaseComponentClassName(ccu.Namespaces[0].Name + "." + codeTypeDeclaration.Name);
}
protected override void DoPerformFlush(IDesignerSerializationManager serializationManager)

2
src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Loaders/XomlDesignerLoader.cs

@ -46,7 +46,7 @@ namespace WorkflowDesigner.Loaders @@ -46,7 +46,7 @@ namespace WorkflowDesigner.Loaders
public XomlDesignerLoader(IViewContent viewContent) : base(viewContent)
{
// Loock for a code beside file for CodeSeparation mode.
// Look for a code beside file for CodeSeparation mode.
if (Project != null) {
FileProjectItem fpi = Project.FindFile(FileName);
string codeFileName = FileName + "." + Project.LanguageProperties.CodeDomProvider.FileExtension;

10
src/AddIns/DisplayBindings/WorkflowDesigner/Project/Src/Services/EventBindingService/EventPropertyDescriptor.cs

@ -94,16 +94,16 @@ namespace WorkflowDesigner @@ -94,16 +94,16 @@ namespace WorkflowDesigner
public override void SetValue(object component, object value)
{
// Validate the parameters.
Activity activity = component as Activity;
if (component == null)
throw new ArgumentException("component must be derived from Activity");
DependencyObject dependencyObject = component as DependencyObject;
if (dependencyObject == null)
throw new ArgumentException(component.ToString() + " must be derived from DependencyObject", "component");
// Get the event list form the dependency object.
Hashtable events = activity.GetValue(WorkflowMarkupSerializer.EventsProperty) as Hashtable;
Hashtable events = dependencyObject.GetValue(WorkflowMarkupSerializer.EventsProperty) as Hashtable;
if (events == null) {
events = new Hashtable();
activity.SetValue(WorkflowMarkupSerializer.EventsProperty, events);
dependencyObject.SetValue(WorkflowMarkupSerializer.EventsProperty, events);
}
string oldValue = events[this.eventDescriptor.Name] as string;

Loading…
Cancel
Save