You've already forked linux-packaging-mono
Imported Upstream version 4.6.0.125
Former-commit-id: a2155e9bd80020e49e72e86c44da02a8ac0e57a4
This commit is contained in:
parent
a569aebcfd
commit
e79aa3c0ed
@@ -0,0 +1,72 @@
|
||||
namespace System.Workflow.ComponentModel.Compiler
|
||||
{
|
||||
using System;
|
||||
using System.CodeDom;
|
||||
using System.Workflow.ComponentModel.Design;
|
||||
using System.Workflow.ComponentModel.Serialization;
|
||||
|
||||
#region Class ActivityCodeGenerator
|
||||
[Obsolete("The System.Workflow.* types are deprecated. Instead, please use the new types from System.Activities.*")]
|
||||
public class ActivityCodeGenerator
|
||||
{
|
||||
public virtual void GenerateCode(CodeGenerationManager manager, object obj)
|
||||
{
|
||||
if (manager == null)
|
||||
throw new ArgumentNullException("manager");
|
||||
if (obj == null)
|
||||
throw new ArgumentNullException("obj");
|
||||
|
||||
Activity activity = obj as Activity;
|
||||
if (activity == null)
|
||||
throw new ArgumentException(SR.GetString(SR.Error_UnexpectedArgumentType, typeof(Activity).FullName), "obj");
|
||||
|
||||
manager.Context.Push(activity);
|
||||
|
||||
// Generate code for all the member Binds.
|
||||
Walker walker = new Walker();
|
||||
walker.FoundProperty += delegate(Walker w, WalkerEventArgs args)
|
||||
{
|
||||
//
|
||||
ActivityBind bindBase = args.CurrentValue as ActivityBind;
|
||||
if (bindBase != null)
|
||||
{
|
||||
// push
|
||||
if (args.CurrentProperty != null)
|
||||
manager.Context.Push(args.CurrentProperty);
|
||||
manager.Context.Push(args.CurrentPropertyOwner);
|
||||
|
||||
// call generate code
|
||||
foreach (ActivityCodeGenerator codeGenerator in manager.GetCodeGenerators(bindBase.GetType()))
|
||||
codeGenerator.GenerateCode(manager, args.CurrentValue);
|
||||
|
||||
// pops
|
||||
manager.Context.Pop();
|
||||
if (args.CurrentProperty != null)
|
||||
manager.Context.Pop();
|
||||
}
|
||||
};
|
||||
walker.WalkProperties(activity, obj);
|
||||
manager.Context.Pop();
|
||||
}
|
||||
|
||||
protected CodeTypeDeclaration GetCodeTypeDeclaration(CodeGenerationManager manager, string fullClassName)
|
||||
{
|
||||
if (manager == null)
|
||||
throw new ArgumentNullException("manager");
|
||||
if (fullClassName == null)
|
||||
throw new ArgumentNullException("fullClassName");
|
||||
|
||||
string namespaceName;
|
||||
string className;
|
||||
Helpers.GetNamespaceAndClassName(fullClassName, out namespaceName, out className);
|
||||
|
||||
CodeNamespaceCollection codeNamespaces = manager.Context[typeof(CodeNamespaceCollection)] as CodeNamespaceCollection;
|
||||
if (codeNamespaces == null)
|
||||
throw new InvalidOperationException(SR.GetString(SR.Error_ContextStackItemMissing, typeof(CodeNamespaceCollection).Name));
|
||||
|
||||
CodeNamespace codeNS = null;
|
||||
return Helpers.GetCodeNamespaceAndClass(codeNamespaces, namespaceName, className, out codeNS);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
namespace System.Workflow.ComponentModel.Compiler
|
||||
{
|
||||
using System;
|
||||
using System.ComponentModel.Design.Serialization;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
#region CodeGenerationManager
|
||||
|
||||
[Obsolete("The System.Workflow.* types are deprecated. Instead, please use the new types from System.Activities.*")]
|
||||
public sealed class CodeGenerationManager : IServiceProvider
|
||||
{
|
||||
private Hashtable hashOfGenerators = new Hashtable();
|
||||
private IServiceProvider serviceProvider = null;
|
||||
private ContextStack context = null;
|
||||
|
||||
public CodeGenerationManager(IServiceProvider serviceProvider)
|
||||
{
|
||||
this.serviceProvider = serviceProvider;
|
||||
}
|
||||
|
||||
public ContextStack Context
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.context == null)
|
||||
this.context = new ContextStack();
|
||||
|
||||
return this.context;
|
||||
}
|
||||
}
|
||||
|
||||
#region IServiceProvider Members
|
||||
|
||||
public object GetService(Type serviceType)
|
||||
{
|
||||
if (this.serviceProvider == null)
|
||||
return null;
|
||||
|
||||
return this.serviceProvider.GetService(serviceType);
|
||||
}
|
||||
#endregion
|
||||
|
||||
public ActivityCodeGenerator[] GetCodeGenerators(Type type)
|
||||
{
|
||||
if (type == null)
|
||||
throw new ArgumentNullException("type");
|
||||
|
||||
if (this.hashOfGenerators.Contains(type))
|
||||
return ((List<ActivityCodeGenerator>)this.hashOfGenerators[type]).ToArray();
|
||||
|
||||
List<ActivityCodeGenerator> generators = new List<ActivityCodeGenerator>();
|
||||
|
||||
// Return validators for other types such as Bind, XmolDocument, etc.
|
||||
foreach (ActivityCodeGenerator generator in ComponentDispenser.CreateComponents(type, typeof(ActivityCodeGeneratorAttribute)))
|
||||
{
|
||||
generators.Add(generator);
|
||||
}
|
||||
|
||||
this.hashOfGenerators[type] = generators;
|
||||
return generators.ToArray();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
namespace System.Workflow.ComponentModel.Compiler
|
||||
{
|
||||
[AttributeUsageAttribute(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = false, Inherited = true)]
|
||||
[Obsolete("The System.Workflow.* types are deprecated. Instead, please use the new types from System.Activities.*")]
|
||||
public sealed class ActivityCodeGeneratorAttribute : Attribute
|
||||
{
|
||||
string codeGeneratorTypeName = null;
|
||||
|
||||
public ActivityCodeGeneratorAttribute(Type codeGeneratorType)
|
||||
{
|
||||
if (codeGeneratorType == null)
|
||||
throw new ArgumentNullException("codeGeneratorType");
|
||||
|
||||
if (!typeof(ActivityCodeGenerator).IsAssignableFrom(codeGeneratorType))
|
||||
throw new ArgumentException(SR.GetString(SR.Error_NotCodeGeneratorType), "codeGeneratorType");
|
||||
|
||||
if (codeGeneratorType.GetConstructor(new Type[0] { }) == null)
|
||||
throw new ArgumentException(SR.GetString(SR.Error_MissingDefaultConstructor, codeGeneratorType.FullName), "codeGeneratorType");
|
||||
|
||||
this.codeGeneratorTypeName = codeGeneratorType.AssemblyQualifiedName;
|
||||
}
|
||||
|
||||
public ActivityCodeGeneratorAttribute(string codeGeneratorTypeName)
|
||||
{
|
||||
if (codeGeneratorTypeName == null)
|
||||
throw new ArgumentNullException("codeGeneratorTypeName");
|
||||
|
||||
this.codeGeneratorTypeName = codeGeneratorTypeName;
|
||||
}
|
||||
|
||||
public string CodeGeneratorTypeName
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.codeGeneratorTypeName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using System.Workflow.ComponentModel.Design;
|
||||
namespace System.Workflow.ComponentModel.Compiler
|
||||
{
|
||||
#region Class CompositeActivityCodeGenerator
|
||||
|
||||
using System.Workflow.ComponentModel.Design;
|
||||
|
||||
[Obsolete("The System.Workflow.* types are deprecated. Instead, please use the new types from System.Activities.*")]
|
||||
public class CompositeActivityCodeGenerator : ActivityCodeGenerator
|
||||
{
|
||||
public override void GenerateCode(CodeGenerationManager manager, object obj)
|
||||
{
|
||||
if (manager == null)
|
||||
throw new ArgumentNullException("manager");
|
||||
if (obj == null)
|
||||
throw new ArgumentNullException("obj");
|
||||
|
||||
CompositeActivity compositeActivity = obj as CompositeActivity;
|
||||
if (compositeActivity == null)
|
||||
throw new ArgumentException(SR.GetString(SR.Error_UnexpectedArgumentType, typeof(CompositeActivity).FullName), "obj");
|
||||
|
||||
base.GenerateCode(manager, obj);
|
||||
|
||||
foreach (Activity child in Helpers.GetAllEnabledActivities(compositeActivity))
|
||||
{
|
||||
foreach (ActivityCodeGenerator codeGenerator in manager.GetCodeGenerators(child.GetType()))
|
||||
codeGenerator.GenerateCode(manager, child);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
Reference in New Issue
Block a user