diff options
author | Jordi Mas i Hernandez <jordi@mono-cvs.ximian.com> | 2006-09-01 23:53:01 +0400 |
---|---|---|
committer | Jordi Mas i Hernandez <jordi@mono-cvs.ximian.com> | 2006-09-01 23:53:01 +0400 |
commit | db3f43858c94de6414d6d57276d8b6a18c2fa3a3 (patch) | |
tree | 4b6a7d576d3beb6b645e4cae399eb339b26eaf66 /mcs/class/System.Workflow.Activities | |
parent | c91610d541dd6e88aeee71ad6b288bf05b4efe77 (diff) |
Initial work on System.Workflow.Activities
svn path=/trunk/mcs/; revision=64740
Diffstat (limited to 'mcs/class/System.Workflow.Activities')
46 files changed, 3704 insertions, 0 deletions
diff --git a/mcs/class/System.Workflow.Activities/Assembly/AssemblyInfo.cs b/mcs/class/System.Workflow.Activities/Assembly/AssemblyInfo.cs new file mode 100644 index 00000000000..a3597ec06c2 --- /dev/null +++ b/mcs/class/System.Workflow.Activities/Assembly/AssemblyInfo.cs @@ -0,0 +1,64 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Authors: +// +// Andreas Nahr (ClassDevelopment@A-SoftTech.com) +// Jordi Mas i Hernandez <jordimash@gmail.com> +// + + +using System; +using System.Reflection; +using System.Resources; +using System.Security; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + + +[assembly: AssemblyVersion ("3.0.0.0")] +[assembly: SatelliteContractVersion ("3.0.0.0")] +[assembly: AssemblyFileVersion("3.0.0.0")]
+[assembly: CompilationRelaxations (8)] + + +[assembly: AssemblyTitle("System.Workflow.Activities.dll")] +[assembly: AssemblyDescription("System.Workflow.Activities.dll")] +[assembly: AssemblyCompany("MONO development team")] +[assembly: AssemblyProduct("MONO CLI")] +[assembly: AssemblyCopyright("(c) 2006 Various Authors")] + +#if !TARGET_JVM +[assembly: CLSCompliant(true)] +#endif +[assembly: AssemblyDefaultAlias("System.Windows.Activities.dll")] +[assembly: AssemblyInformationalVersion("0.0.0.1")] +[assembly: NeutralResourcesLanguage("en-US")] + +[assembly: ComCompatibleVersion (1, 0, 3300, 0)] +[assembly: ComVisible(false)] +[assembly: AllowPartiallyTrustedCallers] + +#if TARGET_JVM +[assembly: AssemblyDelaySign(false)] +#else +[assembly: AssemblyDelaySign(true)] +[assembly: AssemblyKeyFile("../msfinal3.pub")] +#endif + diff --git a/mcs/class/System.Workflow.Activities/ChangeLog b/mcs/class/System.Workflow.Activities/ChangeLog new file mode 100644 index 00000000000..e5d29422895 --- /dev/null +++ b/mcs/class/System.Workflow.Activities/ChangeLog @@ -0,0 +1,4 @@ +2006-09-02 Jordi Mas i Hernandez <jordimash@gmail.com> + + * Initial check-in + diff --git a/mcs/class/System.Workflow.Activities/Makefile b/mcs/class/System.Workflow.Activities/Makefile new file mode 100644 index 00000000000..c384a87ca11 --- /dev/null +++ b/mcs/class/System.Workflow.Activities/Makefile @@ -0,0 +1,15 @@ +thisdir = class/System.Workflow.Activities +include ../../build/rules.make +SUBDIRS = + +LIBRARY = System.Workflow.Activities.dll + + +LIB_MCS_FLAGS = /r:$(corlib) /nowarn:114 /r:System.dll /r:System.Workflow.ComponentModel.dll + +include ../../build/library.make + +TEST_MCS_FLAGS = $(LIB_MCS_FLAGS) /r:System.Workflow.Activities.dll /r:System.Workflow.Runtime.dll + + + diff --git a/mcs/class/System.Workflow.Activities/README b/mcs/class/System.Workflow.Activities/README new file mode 100644 index 00000000000..7d06c8e1335 --- /dev/null +++ b/mcs/class/System.Workflow.Activities/README @@ -0,0 +1,6 @@ + + See System.Workflow.Runtime/README for an introduction to the + System.Workflow implementation. + + + diff --git a/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/ChangeLog b/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/ChangeLog new file mode 100644 index 00000000000..e5d29422895 --- /dev/null +++ b/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/ChangeLog @@ -0,0 +1,4 @@ +2006-09-02 Jordi Mas i Hernandez <jordimash@gmail.com> + + * Initial check-in + diff --git a/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/IRuleExpression.cs b/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/IRuleExpression.cs new file mode 100644 index 00000000000..0272783bfc6 --- /dev/null +++ b/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/IRuleExpression.cs @@ -0,0 +1,42 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Authors: +// +// Copyright (C) 2006 Jordi Mas i Hernandez <jordimash@gmail.com> +// + +using System; +using System.CodeDom; +using System.Text; + +namespace System.Workflow.Activities.Rules +{
+ public interface IRuleExpression
+ {
+ void AnalyzeUsage (RuleAnalysis analysis, bool isRead, bool isWritten, RulePathQualifier qualifier);
+ CodeExpression Clone ();
+ void Decompile (StringBuilder stringBuilder, CodeExpression parentExpression);
+ RuleExpressionResult Evaluate (RuleExecution execution);
+ bool Match (CodeExpression expression);
+ //RuleExpressionInfo Validate (RuleValidation validation, bool isWritten);
+ }
+ +} + diff --git a/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/Rule.cs b/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/Rule.cs new file mode 100644 index 00000000000..5076b815ffb --- /dev/null +++ b/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/Rule.cs @@ -0,0 +1,77 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// +// Copyright (C) 2006 Jordi Mas i Hernandez <jordimash@gmail.com> +// + +using System; +using System.Collections.Generic; +using System.Workflow.ComponentModel; + +namespace System.Workflow.Activities.Rules +{
+ [Serializable]
+ public class Rule
+ {
+ // Methods
+ public Rule () + { + + } +
+ public Rule (string name) + { + + } +
+ public Rule (string name, RuleCondition condition, IList<RuleAction> thenActions) + { + + } +
+ public Rule (string name, RuleCondition condition, IList<RuleAction> thenActions, IList<RuleAction> elseActions) : + this (name, condition, thenActions) + { + + } + + // Properties +/*
+ public bool Active { get; set; }
+ public RuleCondition Condition { get; set; }
+ public string Description { get; set; }
+
+ public IList<RuleAction> ElseActions { get; }
+ public string Name { get; set; }
+ public int Priority { get; set; }
+ public RuleReevaluationBehavior ReevaluationBehavior { get; set; }
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ public IList<RuleAction> ThenActions { get; }
+
+ public Rule Clone();
+ public override bool Equals(object obj);
+ public override int GetHashCode();
+*/
+ }
+
+
+ +} + diff --git a/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/RuleAction.cs b/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/RuleAction.cs new file mode 100644 index 00000000000..bb8c1dcbde3 --- /dev/null +++ b/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/RuleAction.cs @@ -0,0 +1,43 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Authors: +// +// Copyright (C) 2006 Jordi Mas i Hernandez <jordimash@gmail.com> +// + +using System.Collections.Generic; + +namespace System.Workflow.Activities.Rules +{
+ [Serializable]
+ public abstract class RuleAction
+ {
+ protected RuleAction () + { + + } +
+ public abstract RuleAction Clone ();
+ public abstract void Execute (RuleExecution context);
+ public abstract ICollection<string> GetSideEffects (RuleValidation validation);
+ public abstract bool Validate (RuleValidation validator);
+ } +} + diff --git a/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/RuleAnalysis.cs b/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/RuleAnalysis.cs new file mode 100644 index 00000000000..48e3596de40 --- /dev/null +++ b/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/RuleAnalysis.cs @@ -0,0 +1,54 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Authors: +// +// Copyright (C) 2006 Jordi Mas i Hernandez <jordimash@gmail.com> +// + +using System; +using System.ComponentModel; +using System.Collections.Generic; +using System.Workflow.ComponentModel; + +namespace System.Workflow.Activities.Rules +{
+ public class RuleAnalysis
+ { + private List <string> symbols;
+
+ public RuleAnalysis (RuleValidation validation, bool forWrites) + { + symbols = new List <string> (); + } + + // Methods
+ public void AddSymbol (string symbol) + { + symbols.Add (symbol); + }
+
+ public ICollection <string> GetSymbols () + { + return symbols; + }
+ }
+ +} + diff --git a/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/RuleCondition.cs b/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/RuleCondition.cs new file mode 100644 index 00000000000..3e1eb2b3956 --- /dev/null +++ b/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/RuleCondition.cs @@ -0,0 +1,60 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Authors: +// +// Copyright (C) 2006 Jordi Mas i Hernandez <jordimash@gmail.com> +// + +using System; +using System.ComponentModel; +using System.Collections.Generic; +using System.Workflow.ComponentModel; + +namespace System.Workflow.Activities.Rules +{
+ [Serializable]
+ public abstract class RuleCondition
+ {
+ protected RuleCondition () + { + + } + + // Properties
+ public abstract string Name { get; set; } + + // Methods
+ public abstract RuleCondition Clone();
+ public abstract bool Evaluate (RuleExecution execution);
+ public abstract ICollection<string> GetDependencies (RuleValidation validation); +
+ public virtual void OnRuntimeInitialized () + { + + } +
+ public abstract bool Validate (RuleValidation validation);
+
+
+ }
+
+ +} + diff --git a/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/RuleConditionCollection.cs b/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/RuleConditionCollection.cs new file mode 100644 index 00000000000..5124ffd5274 --- /dev/null +++ b/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/RuleConditionCollection.cs @@ -0,0 +1,64 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// +// Copyright (C) 2006 Jordi Mas i Hernandez <jordimash@gmail.com> +// + + +using System.Collections.ObjectModel; + +namespace System.Workflow.Activities.Rules +{
+ [Serializable]
+ public sealed class RuleConditionCollection : KeyedCollection <string, RuleCondition>
+ { +
+ public RuleConditionCollection () + { + + } +
+ public void Add (RuleCondition item) + { + base.Add (item); + } + + protected override string GetKeyForItem (RuleCondition item)
+ {
+ return item.Name;
+ } + + protected override void InsertItem (int index, RuleCondition item)
+ {
+ base.InsertItem (index, item);
+ } + + protected override void RemoveItem (int index)
+ { + base.RemoveItem (index); + }
+
+ protected override void SetItem (int index, RuleCondition item)
+ { + base.SetItem (index, item); + }
+ } +} + diff --git a/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/RuleConditionReference.cs b/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/RuleConditionReference.cs new file mode 100644 index 00000000000..f7b608d5d26 --- /dev/null +++ b/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/RuleConditionReference.cs @@ -0,0 +1,83 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Authors: +// +// Copyright (C) 2006 Jordi Mas i Hernandez <jordimash@gmail.com> +// + +using System.Collections.ObjectModel; +using System.Workflow.ComponentModel; + + +namespace System.Workflow.Activities.Rules +{
+ public class RuleConditionReference : ActivityCondition
+ { + private string codition_name; +
+ public RuleConditionReference () + { + + } + + // Methods
+ public override bool Evaluate (Activity activity, IServiceProvider provider) + { + + Activity parent = activity; + RuleDefinitions definitions = null; + + while (parent != null) { + + definitions = (RuleDefinitions) parent.GetValue (RuleDefinitions.RuleDefinitionsProperty); + + if (definitions != null) + break; + + parent = parent.Parent; + } + + if (definitions == null) { + Console.WriteLine ("No definition"); + return false; + } + + //Console.WriteLine ("Definition {0} at {1}", definitions, parent); + RuleValidation validation = new RuleValidation (activity.GetType (), null); + RuleExecution execution = new RuleExecution (validation, parent); + RuleCondition condition = definitions.Conditions [ConditionName]; + //Console.WriteLine ("Condition {0}", condition);
+ return condition.Evaluate (execution); + }
+
+ protected override void InitializeProperties () + { + + }
+
+ // Properties
+ public string ConditionName { + get { return codition_name ;} + set { codition_name = value; } + }
+ }
+ +} + diff --git a/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/RuleDefinitions.cs b/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/RuleDefinitions.cs new file mode 100644 index 00000000000..721acb48f9b --- /dev/null +++ b/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/RuleDefinitions.cs @@ -0,0 +1,60 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Authors: +// +// Copyright (C) 2006 Jordi Mas i Hernandez <jordimash@gmail.com> +// + +using System; +using System.ComponentModel; +using System.Collections.Generic; +using System.Workflow.ComponentModel; + +namespace System.Workflow.Activities.Rules +{
+ public sealed class RuleDefinitions
+ { + public static readonly DependencyProperty RuleDefinitionsProperty; + private RuleConditionCollection conditions; + private RuleSetCollection rulesets; + + static RuleDefinitions () + { + RuleDefinitionsProperty = DependencyProperty.RegisterAttached ("RuleDefinitions", + typeof (RuleDefinitions), typeof(RuleDefinitions)); + } +
+ public RuleDefinitions () + { + conditions = new RuleConditionCollection (); + rulesets = new RuleSetCollection (); + }
+ + // Properties
+ public RuleConditionCollection Conditions { + get { return conditions; } + } +
+ public RuleSetCollection RuleSets { + get { return rulesets; } + }
+ } +} + diff --git a/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/RuleExecution.cs b/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/RuleExecution.cs new file mode 100644 index 00000000000..28dd7856dbe --- /dev/null +++ b/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/RuleExecution.cs @@ -0,0 +1,69 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Authors: +// +// Copyright (C) 2006 Jordi Mas i Hernandez <jordimash@gmail.com> +// + +using System; +using System.ComponentModel; +using System.Workflow.ComponentModel; + +namespace System.Workflow.Activities.Rules +{
+ public class RuleExecution
+ { + private object this_object; + private RuleValidation validation; + private ActivityExecutionContext activityExecutionContext; +
+ public RuleExecution (RuleValidation validation, object thisObject) + { + this_object = thisObject; + this.validation = validation; + } +
+ public RuleExecution (RuleValidation validation, object thisObject, ActivityExecutionContext activityExecutionContext) + { + this_object = thisObject; + this.validation = validation; + this.activityExecutionContext = activityExecutionContext; + }
+
+ // Properties
+ //public Activity Activity { get; }
+ public ActivityExecutionContext ActivityExecutionContext { + get { return activityExecutionContext; } + } +
+ //public bool Halted { get; set; } +
+ public object ThisObject { + get { return this_object; } + } +
+ public RuleValidation Validation { + get { return validation; } + set { this_object = value; } + }
+ }
+ +} + diff --git a/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/RuleExpressionBinaryOperatorResolver.cs b/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/RuleExpressionBinaryOperatorResolver.cs new file mode 100644 index 00000000000..a5ba62055d1 --- /dev/null +++ b/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/RuleExpressionBinaryOperatorResolver.cs @@ -0,0 +1,708 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Authors: +// +// Copyright (C) 2006 Jordi Mas i Hernandez <jordimash@gmail.com> +// + +using System; +using System.CodeDom; +using System.Reflection; +using System.Collections.Generic; + +namespace System.Workflow.Activities.Rules +{
+ internal class RuleExpressionBinaryOperatorResolver
+ {
+ protected RuleExpressionBinaryOperatorResolver () + { + + } + + static internal bool Evaluate (RuleExecution execution, CodeExpression expression) + { + CodeBinaryOperatorExpression code = (CodeBinaryOperatorExpression) expression; + //Console.WriteLine ("RuleExpressionBinaryOperatorResolver {0}", expression); + //Console.WriteLine ("Right {0}->{1}", code.Right, ((System.CodeDom.CodePrimitiveExpression)code.Right).Value); + //Console.WriteLine ("Left {0}", code.Left); + + object right = GetValue (execution, code.Right); + object left = GetValue (execution, code.Left); + Type l = left.GetType (); + + //System.CodeDom.CodeFieldReferenceExpression leftexp = (System.CodeDom.CodeFieldReferenceExpression) code.left; + ////Console.WriteLine ("Left Value {0}", leftexp.TargetObject); + //Console.WriteLine ("Left Value {0}", leftexp.TargetObject.UserData); + + //Console.WriteLine ("Right Value {0}", right); + //Console.WriteLine ("Left Value {0}", left); + + //Console.WriteLine ("Right Value type {0}", right.GetType ()); + //Console.WriteLine ("Left Value type {0}", left.GetType ()); + + BinaryOperatorType bot = CreateInstanceForType (l, code, right, left); + return bot.Evaluate (); + } + + private static BinaryOperatorType CreateInstanceForType (Type l, CodeBinaryOperatorExpression code, object right, object left) + { + if (l == typeof (Int32)) + return new BinaryOperatorTypeInt32 (code, right, left); + + if (l == typeof (Int16)) + return new BinaryOperatorTypeInt16 (code, right, left); + + if (l == typeof (Int64)) + return new BinaryOperatorTypeInt64 (code, right, left); + + if (l == typeof (sbyte)) + return new BinaryOperatorTypeSbyte (code, right, left); + + if (l == typeof (float)) + return new BinaryOperatorTypeFloat (code, right, left); + + if (l == typeof (char)) + return new BinaryOperatorTypeChar (code, right, left); + + if (l == typeof (byte)) + return new BinaryOperatorTypeByte (code, right, left); + + throw new InvalidOperationException ("Type not suported as binary operator"); + } + + private static object GetValue (RuleExecution execution, CodeExpression obj) + { + if (obj.GetType () == typeof (System.CodeDom.CodePrimitiveExpression)) { + return (((System.CodeDom.CodePrimitiveExpression) obj).Value); + } + + if (obj.GetType () == typeof (CodeFieldReferenceExpression)) { + return RuleExpressionCondition.CodeFieldReferenceValue (execution, obj); + } + + if (obj.GetType () == typeof (CodePropertyReferenceExpression)) { + return RuleExpressionCondition.CodePropertyReferenceValue (execution, obj); + } + + return null; + }
+ } + + // class BinaryOperatorType + internal class BinaryOperatorType + { + protected CodeBinaryOperatorExpression expression; + protected Type r; + protected object right; + protected object left; + + public BinaryOperatorType (CodeBinaryOperatorExpression expression, object right, object left) + { + this.expression = expression; + this.right = right; + this.left = left; + r = right.GetType (); + } + + public bool TypeNotSupported () + { + throw new InvalidOperationException ("Type not suported as binary operator"); + } + + public bool Evaluate () + { + switch (expression.Operator) { + case CodeBinaryOperatorType.Add: + break;
+ case CodeBinaryOperatorType.Assign: + break;
+ case CodeBinaryOperatorType.BitwiseAnd: + break;
+ case CodeBinaryOperatorType.BitwiseOr: + break;
+ case CodeBinaryOperatorType.BooleanAnd: + break;
+ case CodeBinaryOperatorType.BooleanOr: + break;
+ case CodeBinaryOperatorType.Divide: + break;
+ case CodeBinaryOperatorType.GreaterThan: + return GreaterThan ();
+ case CodeBinaryOperatorType.GreaterThanOrEqual: + return GreaterThanOrEqual ();
+ case CodeBinaryOperatorType.IdentityEquality: + break;
+ case CodeBinaryOperatorType.IdentityInequality: + break;
+ case CodeBinaryOperatorType.LessThan: + return LessThan ();
+ case CodeBinaryOperatorType.LessThanOrEqual: + return LessThanOrEqual ();
+ case CodeBinaryOperatorType.Modulus: + break;
+ case CodeBinaryOperatorType.Multiply: + break;
+ case CodeBinaryOperatorType.Subtract: + break;
+ case CodeBinaryOperatorType.ValueEquality: + return ValueEquality (); + default: + break; + } + + return false; + } + + public virtual bool BitwiseAnd () + { + return TypeNotSupported (); + } + + public virtual bool LessThan () + { + return TypeNotSupported (); + } + + public virtual bool LessThanOrEqual () + { + return TypeNotSupported (); + } + + public virtual bool GreaterThan () + { + return TypeNotSupported (); + } + + public virtual bool GreaterThanOrEqual () + { + return TypeNotSupported (); + } + + public virtual bool ValueEquality () + { + return TypeNotSupported (); + } + } + + // class BinaryOperatorTypeInt32 + internal class BinaryOperatorTypeInt32 : BinaryOperatorType + { + public BinaryOperatorTypeInt32 (CodeBinaryOperatorExpression expression, object right, object left) + : base (expression, right, left) {} + + public override bool LessThan () + { + if (r == typeof (Int32)) return (Int32) left < (Int32) right; + if (r == typeof (Int16)) return (Int32) left < (Int16) right; + if (r == typeof (Int64)) return (Int32) left < (Int64) right; + if (r == typeof (sbyte)) return (Int32) left < (sbyte) right; + if (r == typeof (float)) return (Int32) left < (float) right; + if (r == typeof (char)) return (Int32) left < (char) right; + if (r == typeof (byte)) return (Int32) left < (byte) right; + + return TypeNotSupported (); + } + + public override bool LessThanOrEqual () + { + if (r == typeof (Int32)) return (Int32) left <= (Int32) right; + if (r == typeof (Int16)) return (Int32) left <= (Int16) right; + if (r == typeof (Int64)) return (Int32) left <= (Int64) right; + if (r == typeof (sbyte)) return (Int32) left <= (sbyte) right; + if (r == typeof (float)) return (Int32) left <= (float) right; + if (r == typeof (char)) return (Int32) left <= (char) right; + if (r == typeof (byte)) return (Int32) left <= (byte) right; + + return TypeNotSupported (); + } + + public override bool GreaterThan () + { + if (r == typeof (Int32)) return (Int32) left > (Int32) right; + if (r == typeof (Int16)) return (Int32) left > (Int16) right; + if (r == typeof (Int64)) return (Int32) left > (Int64) right; + if (r == typeof (sbyte)) return (Int32) left > (sbyte) right; + if (r == typeof (float)) return (Int32) left > (float) right; + if (r == typeof (char)) return (Int32) left > (char) right; + if (r == typeof (byte)) return (Int32) left > (byte) right; + + return TypeNotSupported (); + } + + public override bool GreaterThanOrEqual () + { + if (r == typeof (Int32)) return (Int32) left >= (Int32) right; + if (r == typeof (Int16)) return (Int32) left >= (Int16) right; + if (r == typeof (Int64)) return (Int32) left >= (Int64) right; + if (r == typeof (sbyte)) return (Int32) left >= (sbyte) right; + if (r == typeof (float)) return (Int32) left >= (float) right; + if (r == typeof (char)) return (Int32) left >= (char) right; + if (r == typeof (byte)) return (Int32) left >= (byte) right; + + return TypeNotSupported (); + } + + public override bool ValueEquality () + { + if (r == typeof (Int32)) return (Int32) left == (Int32) right; + if (r == typeof (Int16)) return (Int32) left == (Int16) right; + if (r == typeof (Int64)) return (Int32) left == (Int64) right; + if (r == typeof (sbyte)) return (Int32) left == (sbyte) right; + if (r == typeof (float)) return (Int32) left == (float) right; + if (r == typeof (char)) return (Int32) left == (char) right; + if (r == typeof (byte)) return (Int32) left == (byte) right; + + return TypeNotSupported (); + } + } + + // class BinaryOperatorTypeInt16 + internal class BinaryOperatorTypeInt16 : BinaryOperatorType + { + public BinaryOperatorTypeInt16 (CodeBinaryOperatorExpression expression, object right, object left) + : base (expression, right, left) {} + + public override bool LessThan () + { + if (r == typeof (Int32)) return (Int16) left < (Int32) right; + if (r == typeof (Int16)) return (Int16) left < (Int16) right; + if (r == typeof (Int64)) return (Int16) left < (Int64) right; + if (r == typeof (sbyte)) return (Int16) left < (sbyte) right; + if (r == typeof (float)) return (Int16) left < (float) right; + if (r == typeof (char)) return (Int16) left < (char) right; + if (r == typeof (byte)) return (Int16) left < (byte) right; + + return TypeNotSupported (); + } + + public override bool LessThanOrEqual () + { + if (r == typeof (Int32)) return (Int16) left <= (Int32) right; + if (r == typeof (Int16)) return (Int16) left <= (Int16) right; + if (r == typeof (Int64)) return (Int16) left <= (Int64) right; + if (r == typeof (sbyte)) return (Int16) left <= (sbyte) right; + if (r == typeof (float)) return (Int16) left <= (float) right; + if (r == typeof (char)) return (Int16) left <= (char) right; + if (r == typeof (byte)) return (Int16) left <= (byte) right; + + return TypeNotSupported (); + } + + public override bool GreaterThan () + { + if (r == typeof (Int32)) return (Int16) left > (Int32) right; + if (r == typeof (Int16)) return (Int16) left > (Int16) right; + if (r == typeof (Int64)) return (Int16) left > (Int64) right; + if (r == typeof (sbyte)) return (Int16) left > (sbyte) right; + if (r == typeof (float)) return (Int16) left > (float) right; + if (r == typeof (char)) return (Int16) left > (char) right; + if (r == typeof (byte)) return (Int16) left > (byte) right; + + return TypeNotSupported (); + } + + public override bool GreaterThanOrEqual () + { + if (r == typeof (Int32)) return (Int16) left >= (Int32) right; + if (r == typeof (Int16)) return (Int16) left >= (Int16) right; + if (r == typeof (Int64)) return (Int16) left >= (Int64) right; + if (r == typeof (sbyte)) return (Int16) left >= (sbyte) right; + if (r == typeof (float)) return (Int16) left >= (float) right; + if (r == typeof (char)) return (Int16) left >= (char) right; + if (r == typeof (byte)) return (Int16) left >= (byte) right; + + return TypeNotSupported (); + } + + public override bool ValueEquality () + { + if (r == typeof (Int32)) return (Int16) left == (Int32) right; + if (r == typeof (Int16)) return (Int16) left == (Int16) right; + if (r == typeof (Int64)) return (Int16) left == (Int64) right; + if (r == typeof (sbyte)) return (Int16) left == (sbyte) right; + if (r == typeof (float)) return (Int16) left == (float) right; + if (r == typeof (char)) return (Int16) left == (char) right; + if (r == typeof (byte)) return (Int16) left == (byte) right; + + return TypeNotSupported (); + } + } + + // class BinaryOperatorTypeInt64 + internal class BinaryOperatorTypeInt64 : BinaryOperatorType + { + public BinaryOperatorTypeInt64 (CodeBinaryOperatorExpression expression, object right, object left) + : base (expression, right, left) {} + + public override bool LessThan () + { + if (r == typeof (Int32)) return (Int64) left < (Int32) right; + if (r == typeof (Int16)) return (Int64) left < (Int16) right; + if (r == typeof (Int64)) return (Int64) left < (Int64) right; + if (r == typeof (sbyte)) return (Int64) left < (sbyte) right; + if (r == typeof (float)) return (Int64) left < (float) right; + if (r == typeof (char)) return (Int64) left < (char) right; + if (r == typeof (byte)) return (Int64) left < (byte) right; + + return TypeNotSupported (); + } + + public override bool LessThanOrEqual () + { + if (r == typeof (Int32)) return (Int64) left <= (Int32) right; + if (r == typeof (Int16)) return (Int64) left <= (Int16) right; + if (r == typeof (Int64)) return (Int64) left <= (Int64) right; + if (r == typeof (sbyte)) return (Int64) left <= (sbyte) right; + if (r == typeof (float)) return (Int64) left <= (float) right; + if (r == typeof (char)) return (Int64) left <= (char) right; + if (r == typeof (byte)) return (Int64) left <= (byte) right; + + return TypeNotSupported (); + } + + public override bool GreaterThan () + { + if (r == typeof (Int32)) return (Int64) left > (Int32) right; + if (r == typeof (Int16)) return (Int64) left > (Int16) right; + if (r == typeof (Int64)) return (Int64) left > (Int64) right; + if (r == typeof (sbyte)) return (Int64) left > (sbyte) right; + if (r == typeof (float)) return (Int64) left > (float) right; + if (r == typeof (char)) return (Int64) left > (char) right; + if (r == typeof (byte)) return (Int64) left > (byte) right; + + return TypeNotSupported (); + } + + public override bool GreaterThanOrEqual () + { + if (r == typeof (Int32)) return (Int64) left >= (Int32) right; + if (r == typeof (Int16)) return (Int64) left >= (Int16) right; + if (r == typeof (Int64)) return (Int64) left >= (Int64) right; + if (r == typeof (sbyte)) return (Int64) left >= (sbyte) right; + if (r == typeof (float)) return (Int64) left >= (float) right; + if (r == typeof (char)) return (Int64) left >= (char) right; + if (r == typeof (byte)) return (Int64) left >= (byte) right; + + return TypeNotSupported (); + } + + public override bool ValueEquality () + { + if (r == typeof (Int32)) return (Int64) left == (Int32) right; + if (r == typeof (Int16)) return (Int64) left == (Int16) right; + if (r == typeof (Int64)) return (Int64) left == (Int64) right; + if (r == typeof (sbyte)) return (Int64) left == (sbyte) right; + if (r == typeof (float)) return (Int64) left == (float) right; + if (r == typeof (char)) return (Int64) left == (char) right; + if (r == typeof (byte)) return (Int64) left == (byte) right; + + return TypeNotSupported (); + } + } + + // class BinaryOperatorTypeSbyte + internal class BinaryOperatorTypeSbyte : BinaryOperatorType + { + public BinaryOperatorTypeSbyte (CodeBinaryOperatorExpression expression, object right, object left) + : base (expression, right, left) {} + + public override bool LessThan () + { + if (r == typeof (Int32)) return (sbyte) left < (Int32) right; + if (r == typeof (Int16)) return (sbyte) left < (Int16) right; + if (r == typeof (Int64)) return (sbyte) left < (Int64) right; + if (r == typeof (sbyte)) return (sbyte) left < (sbyte) right; + if (r == typeof (float)) return (sbyte) left < (float) right; + if (r == typeof (char)) return (sbyte) left < (char) right; + if (r == typeof (byte)) return (sbyte) left < (byte) right; + + return TypeNotSupported (); + } + + public override bool LessThanOrEqual () + { + if (r == typeof (Int32)) return (sbyte) left <= (Int32) right; + if (r == typeof (Int16)) return (sbyte) left <= (Int16) right; + if (r == typeof (Int64)) return (sbyte) left <= (Int64) right; + if (r == typeof (sbyte)) return (sbyte) left <= (sbyte) right; + if (r == typeof (float)) return (sbyte) left <= (float) right; + if (r == typeof (char)) return (sbyte) left <= (char) right; + if (r == typeof (byte)) return (sbyte) left <= (byte) right; + + return TypeNotSupported (); + } + + public override bool GreaterThan () + { + if (r == typeof (Int32)) return (sbyte) left > (Int32) right; + if (r == typeof (Int16)) return (sbyte) left > (Int16) right; + if (r == typeof (Int64)) return (sbyte) left > (Int64) right; + if (r == typeof (sbyte)) return (sbyte) left > (sbyte) right; + if (r == typeof (float)) return (sbyte) left > (float) right; + if (r == typeof (char)) return (sbyte) left > (char) right; + if (r == typeof (byte)) return (sbyte) left > (byte) right; + + return TypeNotSupported (); + } + + public override bool GreaterThanOrEqual () + { + if (r == typeof (Int32)) return (sbyte) left >= (Int32) right; + if (r == typeof (Int16)) return (sbyte) left >= (Int16) right; + if (r == typeof (Int64)) return (sbyte) left >= (Int64) right; + if (r == typeof (sbyte)) return (sbyte) left >= (sbyte) right; + if (r == typeof (float)) return (sbyte) left >= (float) right; + if (r == typeof (char)) return (sbyte) left >= (char) right; + if (r == typeof (byte)) return (sbyte) left >= (byte) right; + + return TypeNotSupported (); + } + + public override bool ValueEquality () + { + if (r == typeof (Int32)) return (sbyte) left == (Int32) right; + if (r == typeof (Int16)) return (sbyte) left == (Int16) right; + if (r == typeof (Int64)) return (sbyte) left == (Int64) right; + if (r == typeof (sbyte)) return (sbyte) left == (sbyte) right; + if (r == typeof (float)) return (sbyte) left == (float) right; + if (r == typeof (char)) return (sbyte) left == (char) right; + if (r == typeof (byte)) return (sbyte) left == (byte) right; + + return TypeNotSupported (); + } + } + + // class BinaryOperatorTypeFloat + internal class BinaryOperatorTypeFloat : BinaryOperatorType + { + public BinaryOperatorTypeFloat (CodeBinaryOperatorExpression expression, object right, object left) + : base (expression, right, left) {} + + public override bool LessThan () + { + if (r == typeof (Int32)) return (float) left < (Int32) right; + if (r == typeof (Int16)) return (float) left < (Int16) right; + if (r == typeof (Int64)) return (float) left < (Int64) right; + if (r == typeof (sbyte)) return (float) left < (sbyte) right; + if (r == typeof (float)) return (float) left < (float) right; + if (r == typeof (char)) return (float) left < (char) right; + if (r == typeof (byte)) return (float) left < (byte) right; + + return TypeNotSupported (); + } + + public override bool LessThanOrEqual () + { + if (r == typeof (Int32)) return (float) left <= (Int32) right; + if (r == typeof (Int16)) return (float) left <= (Int16) right; + if (r == typeof (Int64)) return (float) left <= (Int64) right; + if (r == typeof (sbyte)) return (float) left <= (sbyte) right; + if (r == typeof (float)) return (float) left <= (float) right; + if (r == typeof (char)) return (float) left <= (char) right; + if (r == typeof (byte)) return (float) left <= (byte) right; + + return TypeNotSupported (); + } + + public override bool GreaterThan () + { + if (r == typeof (Int32)) return (float) left > (Int32) right; + if (r == typeof (Int16)) return (float) left > (Int16) right; + if (r == typeof (Int64)) return (float) left > (Int64) right; + if (r == typeof (sbyte)) return (float) left > (sbyte) right; + if (r == typeof (float)) return (float) left > (float) right; + if (r == typeof (char)) return (float) left > (char) right; + if (r == typeof (byte)) return (float) left > (byte) right; + + return TypeNotSupported (); + } + + public override bool GreaterThanOrEqual () + { + if (r == typeof (Int32)) return (float) left >= (Int32) right; + if (r == typeof (Int16)) return (float) left >= (Int16) right; + if (r == typeof (Int64)) return (float) left >= (Int64) right; + if (r == typeof (sbyte)) return (float) left >= (sbyte) right; + if (r == typeof (float)) return (float) left >= (float) right; + if (r == typeof (char)) return (float) left >= (char) right; + if (r == typeof (byte)) return (float) left >= (byte) right; + + return TypeNotSupported (); + } + + public override bool ValueEquality () + { + if (r == typeof (Int32)) return (float) left == (Int32) right; + if (r == typeof (Int16)) return (float) left == (Int16) right; + if (r == typeof (Int64)) return (float) left == (Int64) right; + if (r == typeof (sbyte)) return (float) left == (sbyte) right; + if (r == typeof (float)) return (float) left == (float) right; + if (r == typeof (char)) return (float) left == (char) right; + if (r == typeof (byte)) return (float) left == (byte) right; + + return TypeNotSupported (); + } + } + + // class BinaryOperatorTypeChar + internal class BinaryOperatorTypeChar : BinaryOperatorType + { + public BinaryOperatorTypeChar (CodeBinaryOperatorExpression expression, object right, object left) + : base (expression, right, left) {} + + public override bool LessThan () + { + if (r == typeof (Int32)) return (char) left < (Int32) right; + if (r == typeof (Int16)) return (char) left < (Int16) right; + if (r == typeof (Int64)) return (char) left < (Int64) right; + if (r == typeof (sbyte)) return (char) left < (sbyte) right; + if (r == typeof (float)) return (char) left < (float) right; + if (r == typeof (char)) return (char) left < (char) right; + if (r == typeof (byte)) return (char) left < (byte) right; + + return TypeNotSupported (); + } + + public override bool LessThanOrEqual () + { + if (r == typeof (Int32)) return (char) left <= (Int32) right; + if (r == typeof (Int16)) return (char) left <= (Int16) right; + if (r == typeof (Int64)) return (char) left <= (Int64) right; + if (r == typeof (sbyte)) return (char) left <= (sbyte) right; + if (r == typeof (float)) return (char) left <= (float) right; + if (r == typeof (char)) return (char) left <= (char) right; + if (r == typeof (byte)) return (char) left <= (byte) right; + + return TypeNotSupported (); + } + + public override bool GreaterThan () + { + if (r == typeof (Int32)) return (char) left > (Int32) right; + if (r == typeof (Int16)) return (char) left > (Int16) right; + if (r == typeof (Int64)) return (char) left > (Int64) right; + if (r == typeof (sbyte)) return (char) left > (sbyte) right; + if (r == typeof (float)) return (char) left > (float) right; + if (r == typeof (char)) return (char) left > (char) right; + if (r == typeof (byte)) return (char) left > (byte) right; + + return TypeNotSupported (); + } + + public override bool GreaterThanOrEqual () + { + if (r == typeof (Int32)) return (char) left >= (Int32) right; + if (r == typeof (Int16)) return (char) left >= (Int16) right; + if (r == typeof (Int64)) return (char) left >= (Int64) right; + if (r == typeof (sbyte)) return (char) left >= (sbyte) right; + if (r == typeof (float)) return (char) left >= (float) right; + if (r == typeof (char)) return (char) left >= (char) right; + if (r == typeof (byte)) return (char) left >= (byte) right; + + return TypeNotSupported (); + } + + public override bool ValueEquality () + { + if (r == typeof (Int32)) return (char) left == (Int32) right; + if (r == typeof (Int16)) return (char) left == (Int16) right; + if (r == typeof (Int64)) return (char) left == (Int64) right; + if (r == typeof (sbyte)) return (char) left == (sbyte) right; + if (r == typeof (float)) return (char) left == (float) right; + if (r == typeof (char)) return (char) left == (char) right; + if (r == typeof (byte)) return (char) left == (byte) right; + + return TypeNotSupported (); + } + } + + // class BinaryOperatorTypeByte + internal class BinaryOperatorTypeByte : BinaryOperatorType + { + public BinaryOperatorTypeByte (CodeBinaryOperatorExpression expression, object right, object left) + : base (expression, right, left) {} + + public override bool LessThan () + { + if (r == typeof (Int32)) return (byte) left < (Int32) right; + if (r == typeof (Int16)) return (byte) left < (Int16) right; + if (r == typeof (Int64)) return (byte) left < (Int64) right; + if (r == typeof (sbyte)) return (byte) left < (sbyte) right; + if (r == typeof (float)) return (byte) left < (float) right; + if (r == typeof (char)) return (byte) left < (char) right; + if (r == typeof (byte)) return (byte) left < (byte) right; + + return TypeNotSupported (); + } + + public override bool LessThanOrEqual () + { + if (r == typeof (Int32)) return (byte) left <= (Int32) right; + if (r == typeof (Int16)) return (byte) left <= (Int16) right; + if (r == typeof (Int64)) return (byte) left <= (Int64) right; + if (r == typeof (sbyte)) return (byte) left <= (sbyte) right; + if (r == typeof (float)) return (byte) left <= (float) right; + if (r == typeof (char)) return (byte) left <= (char) right; + if (r == typeof (byte)) return (byte) left <= (byte) right; + + return TypeNotSupported (); + } + + public override bool GreaterThan () + { + if (r == typeof (Int32)) return (byte) left > (Int32) right; + if (r == typeof (Int16)) return (byte) left > (Int16) right; + if (r == typeof (Int64)) return (byte) left > (Int64) right; + if (r == typeof (sbyte)) return (byte) left > (sbyte) right; + if (r == typeof (float)) return (byte) left > (float) right; + if (r == typeof (char)) return (byte) left > (char) right; + if (r == typeof (byte)) return (byte) left > (byte) right; + + return TypeNotSupported (); + } + + public override bool GreaterThanOrEqual () + { + if (r == typeof (Int32)) return (byte) left >= (Int32) right; + if (r == typeof (Int16)) return (byte) left >= (Int16) right; + if (r == typeof (Int64)) return (byte) left >= (Int64) right; + if (r == typeof (sbyte)) return (byte) left >= (sbyte) right; + if (r == typeof (float)) return (byte) left >= (float) right; + if (r == typeof (char)) return (byte) left >= (char) right; + if (r == typeof (byte)) return (byte) left >= (byte) right; + + return TypeNotSupported (); + } + + public override bool ValueEquality () + { + if (r == typeof (Int32)) return (byte) left == (Int32) right; + if (r == typeof (Int16)) return (byte) left == (Int16) right; + if (r == typeof (Int64)) return (byte) left == (Int64) right; + if (r == typeof (sbyte)) return (byte) left == (sbyte) right; + if (r == typeof (float)) return (byte) left == (float) right; + if (r == typeof (char)) return (byte) left == (char) right; + if (r == typeof (byte)) return (byte) left == (byte) right; + + return TypeNotSupported (); + } + } +} + diff --git a/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/RuleExpressionCondition.cs b/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/RuleExpressionCondition.cs new file mode 100644 index 00000000000..b60c982a44c --- /dev/null +++ b/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/RuleExpressionCondition.cs @@ -0,0 +1,171 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Authors: +// +// Copyright (C) 2006 Jordi Mas i Hernandez <jordimash@gmail.com> +// +// +// See: http://windowssdk.msdn.microsoft.com/en-us/library/ms733601.aspx +// + +using System.Collections.Generic; +using System.CodeDom; +using System.Reflection; + +namespace System.Workflow.Activities.Rules +{
+ [Serializable]
+ public sealed class RuleExpressionCondition : RuleCondition
+ { + private string name; + private CodeExpression expression; +
+ public RuleExpressionCondition () + { + + } +
+ public RuleExpressionCondition (CodeExpression expression) + { + this.expression = expression; + } +
+ public RuleExpressionCondition (string conditionName) + { + name = conditionName; + } +
+ public RuleExpressionCondition (string conditionName, CodeExpression expression) + { + name = conditionName; + this.expression = expression; + } + + // Properties
+ public CodeExpression Expression { + get { return expression; } + set { expression = value; } + }
+ public override string Name { + get { return name; } + set { name = value; } + }
+ + + // Methods + [MonoTODO]
+ public override RuleCondition Clone () + { + return null; + } +
+ public override bool Equals (object obj) + { + RuleExpressionCondition target = (obj as RuleExpressionCondition); + + if (target== null) { + return false; + } + + if (Name == target.Name && Expression == target.Expression) { + return true; + } + + return false; + + } +
+ public override bool Evaluate (RuleExecution execution) + { + Type type = expression.GetType (); + Console.WriteLine ("RuleExpressionCondition.RuleExpressionCondition {0}", type); + + if (type == typeof (CodeBinaryOperatorExpression)) + return RuleExpressionBinaryOperatorResolver.Evaluate (execution, expression); + + if (type == typeof (CodePropertyReferenceExpression)) { + return (bool) CodePropertyReferenceValue (execution, expression); + } + + if (type == typeof (CodeFieldReferenceExpression)) { + return (bool) CodePropertyReferenceValue (execution, expression); + } + + throw new InvalidOperationException (); + } + + public override ICollection <string> GetDependencies (RuleValidation validation) + { + return null; + }
+
+ public override int GetHashCode () + { + return name.GetHashCode () ^ expression.GetHashCode (); + } +
+ public override void OnRuntimeInitialized () + { + + } + + [MonoTODO]
+ public override string ToString () + { + return base.ToString (); + } +
+ public override bool Validate (RuleValidation validation) + { + return true; + } + + // Private Methods + internal static object CodePropertyReferenceValue (RuleExecution execution, CodeExpression expression) + { + CodePropertyReferenceExpression property = (CodePropertyReferenceExpression) expression; + Type type; + + // Assumes CodeThisReferenceExpression + type = execution.ThisObject.GetType (); + + PropertyInfo info = type.GetProperty (property.PropertyName, BindingFlags.FlattenHierarchy | + BindingFlags.Public | BindingFlags.GetProperty | BindingFlags.Instance); + + return info.GetValue (execution.ThisObject, null); + } + + internal static object CodeFieldReferenceValue (RuleExecution execution, CodeExpression expression) + { + CodeFieldReferenceExpression field = (CodeFieldReferenceExpression) expression; + Type type; + + // Assumes CodeThisReferenceExpression + type = execution.ThisObject.GetType (); + + FieldInfo info = type.GetField(field.FieldName, BindingFlags.FlattenHierarchy | + BindingFlags.Public | BindingFlags.GetField | BindingFlags.Instance); + + return info.GetValue (execution.ThisObject); + }
+
+ } +} + diff --git a/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/RuleExpressionResult.cs b/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/RuleExpressionResult.cs new file mode 100644 index 00000000000..7c3ffb951fd --- /dev/null +++ b/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/RuleExpressionResult.cs @@ -0,0 +1,38 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// +// Copyright (C) 2006 Jordi Mas i Hernandez <jordimash@gmail.com> +// + + +namespace System.Workflow.Activities.Rules +{
+ public abstract class RuleExpressionResult
+ {
+ protected RuleExpressionResult () + { + + }
+
+ // Properties
+ public abstract object Value { get; set; }
+ } +} + diff --git a/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/RuleExpressionWalker.cs b/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/RuleExpressionWalker.cs new file mode 100644 index 00000000000..7be56051b20 --- /dev/null +++ b/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/RuleExpressionWalker.cs @@ -0,0 +1,50 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Authors: +// +// Copyright (C) 2006 Jordi Mas i Hernandez <jordimash@gmail.com> +// + +using System.Collections.Generic; +using System.CodeDom; +using System.Text; + +namespace System.Workflow.Activities.Rules +{
+ public static class RuleExpressionWalker
+ {
+ static RuleExpressionWalker () + { + + } +
+ //public static void AnalyzeUsage(RuleAnalysis analysis, CodeExpression expression, bool isRead, bool isWritten, RulePathQualifier qualifier);
+ //public static CodeExpression Clone(CodeExpression originalExpression);
+ //public static void Decompile(StringBuilder stringBuilder, CodeExpression expression, CodeExpression parentExpression);
+ public static RuleExpressionResult Evaluate (RuleExecution execution, CodeExpression expression) + { + throw new NotImplementedException (); + }
+
+ //public static bool Match(CodeExpression firstExpression, CodeExpression secondExpression);
+ //public static RuleExpressionInfo Validate(RuleValidation validation, CodeExpression expression, bool isWritten);
+ } +} + diff --git a/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/RulePathQualifier.cs b/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/RulePathQualifier.cs new file mode 100644 index 00000000000..3d13672e93a --- /dev/null +++ b/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/RulePathQualifier.cs @@ -0,0 +1,48 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Authors: +// +// Copyright (C) 2006 Jordi Mas i Hernandez <jordimash@gmail.com> +// + +namespace System.Workflow.Activities.Rules +{
+ public class RulePathQualifier
+ { + private string name; + private RulePathQualifier next; +
+ public RulePathQualifier (string name, RulePathQualifier next) + { + this.name = name; + this.next = next; + }
+
+ // Properties
+ public string Name { + get { return name; } + } +
+ public RulePathQualifier Next { + get { return next; } + } + } +} + diff --git a/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/RuleSet.cs b/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/RuleSet.cs new file mode 100644 index 00000000000..2a23a385a11 --- /dev/null +++ b/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/RuleSet.cs @@ -0,0 +1,102 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Authors: +// +// Copyright (C) 2006 Jordi Mas i Hernandez <jordimash@gmail.com> +// + +using System; +using System.Collections.Generic; +using System.Workflow.ComponentModel; +using System.Workflow.ComponentModel.Compiler; + +namespace System.Workflow.Activities.Rules +{
+ [Serializable]
+ public class RuleSet
+ { + private string name; + private string description; +
+ public RuleSet () + { + + } +
+ public RuleSet (string name) + { + this.name = name; + } +
+ public RuleSet (string name, string description) : this (name) + { + this.description = description; + } +
+ //public RuleSet Clone () + + // Properties
+ //public RuleChainingBehavior ChainingBehavior { get; set; }
+ public string Description { + get { return description; } + set { description = value; } + } +
+ public string Name { + get { return name; } + set { name = value; } + } +
+ //public ICollection <Rule> Rules { get; }
+ + // Methods
+ public override bool Equals (object obj) + { + RuleSet target = (obj as RuleSet); + + if (target == null) { + return false; + } + + if (Name == target.Name && Description == target.Description) { + return true; + } + + return false; + } +
+ public void Execute (RuleExecution ruleExecution) + { + + } +
+ public override int GetHashCode () + { + return name.GetHashCode () ^ description.GetHashCode (); + } +
+ /*public bool Validate (RuleValidation validation) + { + + }*/
+ }
+ +} + diff --git a/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/RuleSetCollection.cs b/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/RuleSetCollection.cs new file mode 100644 index 00000000000..4516437d004 --- /dev/null +++ b/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/RuleSetCollection.cs @@ -0,0 +1,64 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Authors: +// +// Copyright (C) 2006 Jordi Mas i Hernandez <jordimash@gmail.com> +// + +using System.Collections.ObjectModel; + +namespace System.Workflow.Activities.Rules +{
+ public sealed class RuleSetCollection : KeyedCollection <string, RuleSet>
+ {
+
+ public RuleSetCollection () + { + + } + + // Methods
+ public void Add (RuleSet item) + { + base.Add (item); + }
+
+ protected override string GetKeyForItem (RuleSet item) + { + return item.Name; + } +
+ protected override void InsertItem (int index, RuleSet item) + { + base.InsertItem (index, item); + } +
+ protected override void RemoveItem (int index) + { + base.RemoveItem (index); + } +
+ protected override void SetItem (int index, RuleSet item) + { + base.SetItem (index, item); + }
+ } +} + diff --git a/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/RuleValidation.cs b/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/RuleValidation.cs new file mode 100644 index 00000000000..01b4d37876f --- /dev/null +++ b/mcs/class/System.Workflow.Activities/System.Workflow.Activities.Rules/RuleValidation.cs @@ -0,0 +1,47 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// +// Copyright (C) 2006 Jordi Mas i Hernandez <jordimash@gmail.com> +// + +using System; +using System.Collections.Generic; +using System.Workflow.ComponentModel; +using System.Workflow.ComponentModel.Compiler; + + +namespace System.Workflow.Activities.Rules +{
+ public class RuleValidation + {
+ public RuleValidation (Type thisType, ITypeProvider typeProvider) + { + + } +
+ public RuleValidation (Activity activity, ITypeProvider typeProvider, bool checkStaticType) + { + + } + + // TODO: Missing methods and properties. Just define what we need + } +} + diff --git a/mcs/class/System.Workflow.Activities/System.Workflow.Activities.dll.sources b/mcs/class/System.Workflow.Activities/System.Workflow.Activities.dll.sources new file mode 100644 index 00000000000..a1168a8da98 --- /dev/null +++ b/mcs/class/System.Workflow.Activities/System.Workflow.Activities.dll.sources @@ -0,0 +1,38 @@ +Assembly/AssemblyInfo.cs +../../build/common/Consts.cs +../../build/common/Locale.cs +../../build/common/MonoTODOAttribute.cs +System.Workflow.Activities/CodeActivity.cs +System.Workflow.Activities/SequentialWorkflowActivity.cs +System.Workflow.Activities/SequenceActivity.cs +System.Workflow.Activities/DelayActivity.cs +System.Workflow.Activities/WhileActivity.cs +System.Workflow.Activities/ConditionalEventArgs.cs +System.Workflow.Activities/CodeCondition.cs +System.Workflow.Activities/IfElseActivity.cs +System.Workflow.Activities/IfElseBranchActivity.cs +System.Workflow.Activities/ParallelActivity.cs +System.Workflow.Activities/StateActivity.cs +System.Workflow.Activities/StateFinalizationActivity.cs +System.Workflow.Activities/StateInitializationActivity.cs +System.Workflow.Activities/StateMachineWorkflowActivity.cs +System.Workflow.Activities/SetStateActivity.cs +System.Workflow.Activities/EventDrivenActivity.cs +System.Workflow.Activities/IEventActivity.cs +System.Workflow.Activities.Rules/RuleAnalysis.cs +System.Workflow.Activities.Rules/RuleValidation.cs +System.Workflow.Activities.Rules/RuleDefinitions.cs +System.Workflow.Activities.Rules/RuleCondition.cs +System.Workflow.Activities.Rules/RuleConditionCollection.cs +System.Workflow.Activities.Rules/RuleExecution.cs +System.Workflow.Activities.Rules/RuleSet.cs +System.Workflow.Activities.Rules/Rule.cs +System.Workflow.Activities.Rules/RuleAction.cs +System.Workflow.Activities.Rules/RuleSetCollection.cs +System.Workflow.Activities.Rules/RuleExpressionCondition.cs +System.Workflow.Activities.Rules/RulePathQualifier.cs +System.Workflow.Activities.Rules/RuleConditionReference.cs +System.Workflow.Activities.Rules/RuleExpressionWalker.cs +System.Workflow.Activities.Rules/IRuleExpression.cs +System.Workflow.Activities.Rules/RuleExpressionResult.cs +System.Workflow.Activities.Rules/RuleExpressionBinaryOperatorResolver.cs
\ No newline at end of file diff --git a/mcs/class/System.Workflow.Activities/System.Workflow.Activities/ChangeLog b/mcs/class/System.Workflow.Activities/System.Workflow.Activities/ChangeLog new file mode 100644 index 00000000000..e5d29422895 --- /dev/null +++ b/mcs/class/System.Workflow.Activities/System.Workflow.Activities/ChangeLog @@ -0,0 +1,4 @@ +2006-09-02 Jordi Mas i Hernandez <jordimash@gmail.com> + + * Initial check-in + diff --git a/mcs/class/System.Workflow.Activities/System.Workflow.Activities/CodeActivity.cs b/mcs/class/System.Workflow.Activities/System.Workflow.Activities/CodeActivity.cs new file mode 100644 index 00000000000..4bbfbd63268 --- /dev/null +++ b/mcs/class/System.Workflow.Activities/System.Workflow.Activities/CodeActivity.cs @@ -0,0 +1,73 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Authors: +// +// Copyright (C) 2006 Jordi Mas i Hernandez <jordimash@gmail.com> +// + +using System; +using System.ComponentModel; +using System.Workflow.ComponentModel; + +namespace System.Workflow.Activities +{ + public sealed class CodeActivity : Activity
+ { + public static readonly DependencyProperty ExecuteCodeEvent;
+ + static CodeActivity () + { + ExecuteCodeEvent = DependencyProperty.Register ("ExecuteCode", typeof (EventHandler), + typeof (CodeActivity)); + } + + public CodeActivity () + { + + } +
+ public CodeActivity (string name) : base (name) + { + + } + + // Event handlers + public event EventHandler ExecuteCode + { + add { AddHandler (ExecuteCodeEvent, value); } + remove { RemoveHandler (ExecuteCodeEvent, value); } + } + + // Methods + protected sealed override ActivityExecutionStatus Execute (ActivityExecutionContext executionContext)
+ { + EventHandler [] evs = GetInvocationList <EventHandler> (ExecuteCodeEvent); + + // Execute the list of handlers + foreach (EventHandler handler in evs) { + handler (this, new EventArgs ()); + } + + NeedsExecution = false; + return ActivityExecutionStatus.Closed; + } + } +} + diff --git a/mcs/class/System.Workflow.Activities/System.Workflow.Activities/CodeCondition.cs b/mcs/class/System.Workflow.Activities/System.Workflow.Activities/CodeCondition.cs new file mode 100644 index 00000000000..523b89b67f2 --- /dev/null +++ b/mcs/class/System.Workflow.Activities/System.Workflow.Activities/CodeCondition.cs @@ -0,0 +1,68 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Authors: +// +// Copyright (C) 2006 Jordi Mas i Hernandez <jordimash@gmail.com> +// + +using System; +using System.Workflow.ComponentModel; + +namespace System.Workflow.Activities +{ + public class CodeCondition : ActivityCondition
+ { + public static readonly DependencyProperty ConditionEvent; + + static CodeCondition () + { + ConditionEvent = DependencyProperty.Register ("Condition", typeof (EventHandler <ConditionalEventArgs>), + typeof (CodeCondition)); + } + + public CodeCondition () + { + + } +
+ // Event
+ public event EventHandler <ConditionalEventArgs> Condition + { + add { AddHandler (ConditionEvent, value); } + remove { RemoveHandler (ConditionEvent, value); } + } + + public override bool Evaluate (Activity ownerActivity, IServiceProvider provider) + { + EventHandler <ConditionalEventArgs> [] evs = GetInvocationList <EventHandler <ConditionalEventArgs>> (ConditionEvent); + ConditionalEventArgs event_args = new ConditionalEventArgs (); + + foreach (EventHandler <ConditionalEventArgs> handler in evs) { + handler (ownerActivity, event_args); + } + + return event_args.Result; + + } +
+ //protected override object GetBoundValue (ActivityBind bind, Type targetType);
+ }
+} + diff --git a/mcs/class/System.Workflow.Activities/System.Workflow.Activities/ConditionalEventArgs.cs b/mcs/class/System.Workflow.Activities/System.Workflow.Activities/ConditionalEventArgs.cs new file mode 100644 index 00000000000..91377ec9048 --- /dev/null +++ b/mcs/class/System.Workflow.Activities/System.Workflow.Activities/ConditionalEventArgs.cs @@ -0,0 +1,50 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Authors: +// +// Copyright (C) 2006 Jordi Mas i Hernandez <jordimash@gmail.com> +// + +namespace System.Workflow.Activities +{ + [Serializable]
+ public sealed class ConditionalEventArgs : EventArgs
+ { + private bool result;
+
+ public ConditionalEventArgs () + { + + } +
+ public ConditionalEventArgs (bool result) + { + this.result = result; + }
+
+ // Properties
+ public bool Result { + get { return result; } + set { result = value; } + }
+
+ } +} + diff --git a/mcs/class/System.Workflow.Activities/System.Workflow.Activities/DelayActivity.cs b/mcs/class/System.Workflow.Activities/System.Workflow.Activities/DelayActivity.cs new file mode 100644 index 00000000000..29884e37921 --- /dev/null +++ b/mcs/class/System.Workflow.Activities/System.Workflow.Activities/DelayActivity.cs @@ -0,0 +1,103 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Authors: +// +// Copyright (C) 2006 Jordi Mas i Hernandez <jordimash@gmail.com> +// + +using System; +using System.ComponentModel; +using System.Threading; +using System.Workflow.ComponentModel; + +namespace System.Workflow.Activities +{ + public sealed class DelayActivity : Activity + //IEventActivity, IActivityEventListener<QueueEventArgs>
+ { + static public readonly DependencyProperty InitializeTimeoutDurationEvent;
+ static public readonly DependencyProperty TimeoutDurationProperty; + static private AutoResetEvent reset_event = new AutoResetEvent (false); + private TimeSpan timeout; + private bool delayed = false; +
+ public DelayActivity () + { + + } +
+ public DelayActivity (string name) : base (name) + { + + } + + // Event
+ public event EventHandler InitializeTimeoutDuration; + + // Properties + public TimeSpan TimeoutDuration { + get {return timeout;} + set {timeout = value;} + } + + // Private Properties + static public AutoResetEvent WaitEvent { + get {return reset_event;} + } + + public bool Delayed { + get { + return delayed; + } + }
+
+ // Methods
+ //protected override ActivityExecutionStatus Cancel(ActivityExecutionContext executionContext); +
+ protected override ActivityExecutionStatus Execute (ActivityExecutionContext executionContext) + { + DateTime expiresAt = DateTime.UtcNow; + + if (InitializeTimeoutDuration != null) { + InitializeTimeoutDuration (this, new EventArgs ()); + } + + expiresAt += TimeoutDuration; + delayed = true; + SetTimer (executionContext, expiresAt); + + NeedsExecution = false; + return ActivityExecutionStatus.Executing; + } + + protected override void OnQueueTimerItemArrived (Object sender, object args) + { + delayed = false; + //Console.WriteLine ("Timer arrived!"); + reset_event.Set (); + }
+ + //protected sealed override ActivityExecutionStatus HandleFault (ActivityExecutionContext executionContext, Exception exception) + //protected override void Initialize (IServiceProvider provider)
+ //protected override void OnClosed(IServiceProvider provider); + }
+
+} + diff --git a/mcs/class/System.Workflow.Activities/System.Workflow.Activities/EventDrivenActivity.cs b/mcs/class/System.Workflow.Activities/System.Workflow.Activities/EventDrivenActivity.cs new file mode 100644 index 00000000000..19c039512df --- /dev/null +++ b/mcs/class/System.Workflow.Activities/System.Workflow.Activities/EventDrivenActivity.cs @@ -0,0 +1,47 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Authors: +// +// Copyright (C) 2006 Jordi Mas i Hernandez <jordimash@gmail.com> +// + +namespace System.Workflow.Activities +{ + public sealed class EventDrivenActivity : SequenceActivity
+ {
+ public EventDrivenActivity () + { + + } +
+ public EventDrivenActivity(string name) : base (name) + { + + }
+
+ public IEventActivity EventActivity { + get { + // TODO: This should always work when validators are implemented + // since the first activity has always to be IEventActivity + return (IEventActivity) Activities [0]; + } + }
+ } +} diff --git a/mcs/class/System.Workflow.Activities/System.Workflow.Activities/IEventActivity.cs b/mcs/class/System.Workflow.Activities/System.Workflow.Activities/IEventActivity.cs new file mode 100644 index 00000000000..138d4dc10b2 --- /dev/null +++ b/mcs/class/System.Workflow.Activities/System.Workflow.Activities/IEventActivity.cs @@ -0,0 +1,42 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Authors: +// +// Copyright (C) 2006 Jordi Mas i Hernandez <jordimash@gmail.com> +// + +using System; +using System.Workflow.ComponentModel; + +namespace System.Workflow.Activities +{ + public interface IEventActivity
+ {
+
+ void Subscribe(ActivityExecutionContext parentContext, IActivityEventListener <QueueEventArgs> parentEventHandler);
+ void Unsubscribe(ActivityExecutionContext parentContext, IActivityEventListener <QueueEventArgs> parentEventHandler);
+
+ // Properties
+ IComparable QueueName { get; }
+ }
+
+ +} + diff --git a/mcs/class/System.Workflow.Activities/System.Workflow.Activities/IfElseActivity.cs b/mcs/class/System.Workflow.Activities/System.Workflow.Activities/IfElseActivity.cs new file mode 100644 index 00000000000..6b25c0966e8 --- /dev/null +++ b/mcs/class/System.Workflow.Activities/System.Workflow.Activities/IfElseActivity.cs @@ -0,0 +1,93 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Authors: +// +// Copyright (C) 2006 Jordi Mas i Hernandez <jordimash@gmail.com> +// + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Threading; +using System.Workflow.ComponentModel; + +namespace System.Workflow.Activities +{ + public sealed class IfElseActivity : CompositeActivity
+ { + public IfElseActivity () + { + + } +
+ public IfElseActivity (string name) : base (name) + { + + } + + // Methods
+ public IfElseBranchActivity AddBranch (ICollection <Activity> activities) + { + return AddBranch (activities, null); + } +
+ public IfElseBranchActivity AddBranch (ICollection <Activity> activities, ActivityCondition branchCondition) + { + IfElseBranchActivity branch_activity = new IfElseBranchActivity (); + branch_activity.Condition = branchCondition; + + foreach (Activity activity in activities) { + branch_activity.Activities.Add (activity); + } + + return branch_activity; + } +
+ //protected override ActivityExecutionStatus Cancel(ActivityExecutionContext executionContext) + + protected override ActivityExecutionStatus Execute (ActivityExecutionContext executionContext) + { + bool condition_true = false; + + foreach (IfElseBranchActivity activity in Activities) { + + if (activity == null || activity.Condition == null) + continue; + + if (activity.Condition.Evaluate (this, executionContext) == true) { + condition_true = true; + break; + } + } + + if (Activities.Count > 1) { + if (condition_true == true) { + ActivitiesToExecute.Enqueue (Activities[0]); + } else { + ActivitiesToExecute.Enqueue (Activities[1]); + } + } + + NeedsExecution = false; + return ActivityExecutionStatus.Closed; + }
+ }
+} + diff --git a/mcs/class/System.Workflow.Activities/System.Workflow.Activities/IfElseBranchActivity.cs b/mcs/class/System.Workflow.Activities/System.Workflow.Activities/IfElseBranchActivity.cs new file mode 100644 index 00000000000..028fa890f5e --- /dev/null +++ b/mcs/class/System.Workflow.Activities/System.Workflow.Activities/IfElseBranchActivity.cs @@ -0,0 +1,57 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Authors: +// +// Copyright (C) 2006 Jordi Mas i Hernandez <jordimash@gmail.com> +// + +using System; +using System.ComponentModel; +using System.Workflow.ComponentModel; + +namespace System.Workflow.Activities +{ + public sealed class IfElseBranchActivity : SequenceActivity
+ { + public static readonly DependencyProperty ConditionProperty; + + static IfElseBranchActivity () + { + ConditionProperty = DependencyProperty.Register ("Condition", typeof (ActivityCondition) + , typeof (IfElseBranchActivity), new PropertyMetadata ()); + } + + public IfElseBranchActivity () + { + + } +
+ public IfElseBranchActivity (string name) : base (name) + { + + } + + // Properties
+ public ActivityCondition Condition { + get { return (ActivityCondition) GetValue (ConditionProperty); } + set { SetValue (ConditionProperty, value); } + }
+ } +} diff --git a/mcs/class/System.Workflow.Activities/System.Workflow.Activities/ParallelActivity.cs b/mcs/class/System.Workflow.Activities/System.Workflow.Activities/ParallelActivity.cs new file mode 100644 index 00000000000..8a75cd323a6 --- /dev/null +++ b/mcs/class/System.Workflow.Activities/System.Workflow.Activities/ParallelActivity.cs @@ -0,0 +1,98 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Authors: +// +// Copyright (C) 2006 Jordi Mas i Hernandez <jordimash@gmail.com> +// + +using System; +using System.ComponentModel; +using System.Threading; +using System.Workflow.ComponentModel; +using System.Collections.Generic; + +namespace System.Workflow.Activities +{ + public sealed class ParallelActivity : CompositeActivity + //, IActivityEventListener<ActivityExecutionStatusChangedEventArgs>
+ {
+ static ParallelActivity () + { + + } +
+ public ParallelActivity () + { + + } +
+ public ParallelActivity (string name) : base (name) + { + + } + + // Methods
+ protected override ActivityExecutionStatus Cancel (ActivityExecutionContext executionContext) + { + return ActivityExecutionStatus.Canceling; + } +
+ protected override ActivityExecutionStatus Execute (ActivityExecutionContext executionContext) + { + List <Activity> list = new List <Activity> (); + Activity child = this; + + // Indicate that all children activites can be executed in paralell + while (child != null) { + //Console.WriteLine ("Child {0}", child); + // TODO: if (IsBasedOnType (current, typeof (CompositeActivity))) { + if (child.GetType ().BaseType == typeof (CompositeActivity)) { + CompositeActivity composite = (CompositeActivity) child; + foreach (Activity activity in composite.Activities) { + list.Add (activity); + } + } + + if (list.Count == 0) { + break; + } + + child = list [0]; + child.ParallelParent = this; + list.Remove (child); + } + + foreach (Activity activity in Activities) { + ActivitiesToExecute.Enqueue (activity); + } + + NeedsExecution = false; + return ActivityExecutionStatus.Closed; + } +
+ //protected override void OnActivityChangeAdd (ActivityExecutionContext executionContext, Activity addedActivity) + //protected override void OnActivityChangeRemove (ActivityExecutionContext rootExecutionContext, Activity removedActivity) + //protected override void OnClosed (IServiceProvider provider) + //protected override void OnWorkflowChangesCompleted (ActivityExecutionContext executionContext) +
+ }
+
+} + diff --git a/mcs/class/System.Workflow.Activities/System.Workflow.Activities/SequenceActivity.cs b/mcs/class/System.Workflow.Activities/System.Workflow.Activities/SequenceActivity.cs new file mode 100644 index 00000000000..e11e202bef5 --- /dev/null +++ b/mcs/class/System.Workflow.Activities/System.Workflow.Activities/SequenceActivity.cs @@ -0,0 +1,66 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Authors: +// +// Copyright (C) 2006 Jordi Mas i Hernandez <jordimash@gmail.com> +// + +using System; +using System.ComponentModel; +using System.Workflow.ComponentModel; + +namespace System.Workflow.Activities +{
+ public class SequenceActivity : CompositeActivity + //IActivityEventListener<ActivityExecutionStatusChangedEventArgs>
+ {
+
+ public SequenceActivity () + { + + } +
+ public SequenceActivity (string name) : base (name) + { + + } + + // Methods
+ //protected override ActivityExecutionStatus Cancel (ActivityExecutionContext executionContext) + + protected override ActivityExecutionStatus Execute (ActivityExecutionContext executionContext) + { + foreach (Activity activity in Activities) { + ActivitiesToExecute.Enqueue (activity); + } + + NeedsExecution = false; + return ActivityExecutionStatus.Executing; + } + +
+ //protected override ActivityExecutionStatus HandleFault (ActivityExecutionContext executionContext, Exception exception);
+ //protected override void OnActivityChangeRemove (ActivityExecutionContext executionContext, Activity removedActivity);
+ //protected virtual void OnSequenceComplete (ActivityExecutionContext executionContext);
+ //protected override void OnWorkflowChangesCompleted (ActivityExecutionContext executionContext);
+ //void IActivityEventListener<ActivityExecutionStatusChangedEventArgs>.OnEvent(object sender, ActivityExecutionStatusChangedEventArgs e); + } +} + diff --git a/mcs/class/System.Workflow.Activities/System.Workflow.Activities/SequentialWorkflowActivity.cs b/mcs/class/System.Workflow.Activities/System.Workflow.Activities/SequentialWorkflowActivity.cs new file mode 100644 index 00000000000..a2babb6cb81 --- /dev/null +++ b/mcs/class/System.Workflow.Activities/System.Workflow.Activities/SequentialWorkflowActivity.cs @@ -0,0 +1,63 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Authors: +// +// Copyright (C) 2006 Jordi Mas i Hernandez <jordimash@gmail.com> +// + +using System; +using System.ComponentModel; +using System.Workflow.ComponentModel; + +namespace System.Workflow.Activities +{ + public class SequentialWorkflowActivity : SequenceActivity
+ { + public SequentialWorkflowActivity () + { + + } +
+ public SequentialWorkflowActivity (string name) : base (name) + {
+ + } + + //protected override ActivityExecutionStatus Cancel(ActivityExecutionContext executionContext); +
+ protected override ActivityExecutionStatus Execute (ActivityExecutionContext executionContext) + { + foreach (Activity activity in Activities) { + ActivitiesToExecute.Enqueue (activity); + } + + NeedsExecution = false; + return ActivityExecutionStatus.Closed; + } +
+ //protected override ActivityExecutionStatus HandleFault(ActivityExecutionContext executionContext, Exception exception);
+ //protected override void OnActivityChangeRemove(ActivityExecutionContext executionContext, Activity removedActivity);
+ //protected virtual void OnSequenceComplete(ActivityExecutionContext executionContext);
+ //protected override void OnWorkflowChangesCompleted(ActivityExecutionContext executionContext); + + }
+ +} + diff --git a/mcs/class/System.Workflow.Activities/System.Workflow.Activities/SetStateActivity.cs b/mcs/class/System.Workflow.Activities/System.Workflow.Activities/SetStateActivity.cs new file mode 100644 index 00000000000..498771c1268 --- /dev/null +++ b/mcs/class/System.Workflow.Activities/System.Workflow.Activities/SetStateActivity.cs @@ -0,0 +1,72 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Authors: +// +// Copyright (C) 2006 Jordi Mas i Hernandez <jordimash@gmail.com> +// + +using System; +using System.ComponentModel; +using System.Workflow.ComponentModel; + +namespace System.Workflow.Activities +{ + public sealed class SetStateActivity : Activity
+ { + public static readonly DependencyProperty TargetStateNameProperty;
+
+ static SetStateActivity () + {
+ TargetStateNameProperty = DependencyProperty.Register ("TargetStateName", + typeof (string), typeof (SetStateActivity));
+ } +
+ public SetStateActivity () + { + + } +
+ public SetStateActivity (string name) : base (name) + { + + } + + // Properties
+ public string TargetStateName { + get { + return (string) GetValue (TargetStateNameProperty); + } + set { + SetValue (TargetStateNameProperty, value); + } + } + + // Methods
+ protected override ActivityExecutionStatus Execute (ActivityExecutionContext executionContext) + { + Activity next_activity = GetActivityByName (TargetStateName, false); + next_activity.NeedsExecution = true; + ActivitiesToExecute.Enqueue (next_activity); + NeedsExecution = false; + return ActivityExecutionStatus.Closed; + }
+ } +} + diff --git a/mcs/class/System.Workflow.Activities/System.Workflow.Activities/StateActivity.cs b/mcs/class/System.Workflow.Activities/System.Workflow.Activities/StateActivity.cs new file mode 100644 index 00000000000..df9e1e337e6 --- /dev/null +++ b/mcs/class/System.Workflow.Activities/System.Workflow.Activities/StateActivity.cs @@ -0,0 +1,94 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Authors: +// +// Copyright (C) 2006 Jordi Mas i Hernandez <jordimash@gmail.com> +// + +using System; +using System.ComponentModel; +using System.Workflow.ComponentModel; + +namespace System.Workflow.Activities +{
+ public class StateActivity : CompositeActivity
+ { + public const string StateChangeTrackingDataKey = "StateActivity.StateChange";
+ + static StateActivity () + { + + } +
+ public StateActivity () + { + + } +
+ public StateActivity (string name) + { + + } +
+ //public Activity GetDynamicActivity(string childActivityName); +
+ protected override void Initialize (IServiceProvider provider) + { + base.Initialize (provider); + } + + protected override ActivityExecutionStatus Execute (ActivityExecutionContext executionContext)
+ { + // If there is StateInitializationActivity should go first + StateInitializationActivity init = null; + + foreach (Activity activity in Activities) { + if (IsBasedOnType (activity, typeof (StateInitializationActivity))) { + init = (StateInitializationActivity) activity; + ActivitiesToExecute.Enqueue (init); + break; + } + } + + foreach (Activity activity in Activities) { + if (activity == init) { + continue; + } + ActivitiesToExecute.Enqueue (activity); + } + + NeedsExecution = false; + return ActivityExecutionStatus.Executing; + } + + // Private methods + static private bool IsBasedOnType (object obj, Type target) + { + for (Type type = obj.GetType (); type != null; type = type.BaseType) { + if (type == target) { + return true; + } + } + + return false; + } + } +} + diff --git a/mcs/class/System.Workflow.Activities/System.Workflow.Activities/StateFinalizationActivity.cs b/mcs/class/System.Workflow.Activities/System.Workflow.Activities/StateFinalizationActivity.cs new file mode 100644 index 00000000000..90b4c7bdab8 --- /dev/null +++ b/mcs/class/System.Workflow.Activities/System.Workflow.Activities/StateFinalizationActivity.cs @@ -0,0 +1,45 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Authors: +// +// Copyright (C) 2006 Jordi Mas i Hernandez <jordimash@gmail.com> +// + +using System; +using System.ComponentModel; +using System.Workflow.ComponentModel; + +namespace System.Workflow.Activities +{
+ public sealed class StateFinalizationActivity : SequenceActivity
+ {
+ public StateFinalizationActivity () + { + + } +
+ public StateFinalizationActivity (string name) : base (name) + { + + }
+ }
+ +} + diff --git a/mcs/class/System.Workflow.Activities/System.Workflow.Activities/StateInitializationActivity.cs b/mcs/class/System.Workflow.Activities/System.Workflow.Activities/StateInitializationActivity.cs new file mode 100644 index 00000000000..1c9a4c0c029 --- /dev/null +++ b/mcs/class/System.Workflow.Activities/System.Workflow.Activities/StateInitializationActivity.cs @@ -0,0 +1,45 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Authors: +// +// Copyright (C) 2006 Jordi Mas i Hernandez <jordimash@gmail.com> +// + +using System; +using System.ComponentModel; +using System.Workflow.ComponentModel; + +namespace System.Workflow.Activities +{
+ public sealed class StateInitializationActivity : SequenceActivity
+ {
+ public StateInitializationActivity () + { + + } +
+ public StateInitializationActivity (string name) : base (name) + { + + }
+ }
+ +} + diff --git a/mcs/class/System.Workflow.Activities/System.Workflow.Activities/StateMachineWorkflowActivity.cs b/mcs/class/System.Workflow.Activities/System.Workflow.Activities/StateMachineWorkflowActivity.cs new file mode 100644 index 00000000000..5fd63ed3e75 --- /dev/null +++ b/mcs/class/System.Workflow.Activities/System.Workflow.Activities/StateMachineWorkflowActivity.cs @@ -0,0 +1,103 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Authors: +// +// Copyright (C) 2006 Jordi Mas i Hernandez <jordimash@gmail.com> +// + +using System; +using System.ComponentModel; +using System.Workflow.ComponentModel; + +namespace System.Workflow.Activities +{
+ + public class StateMachineWorkflowActivity : StateActivity
+ { + public static readonly DependencyProperty CompletedStateNameProperty;
+ public static readonly DependencyProperty InitialStateNameProperty;
+ public const string SetStateQueueName = "SetStateQueue"; + private string current_state; + private string previous_state;
+
+ static StateMachineWorkflowActivity () + { + InitialStateNameProperty = DependencyProperty.Register ("InitialStateName", + typeof (string), typeof (StateMachineWorkflowActivity)); +
+ CompletedStateNameProperty = DependencyProperty.Register ("CompletedStateName", + typeof (string), typeof (StateMachineWorkflowActivity));
+ } +
+ public StateMachineWorkflowActivity () + { + + } +
+ public StateMachineWorkflowActivity (string name) : base (name) + { + + }
+
+ // Properties
+ public string CompletedStateName { + get { + return (string) GetValue (CompletedStateNameProperty); + } + set { + SetValue (CompletedStateNameProperty, value); + } + } +
+ public string CurrentStateName { + get { + return current_state; + } + } + + [MonoTODO]
+ public ActivityCondition DynamicUpdateCondition { + get { return null; } + set {} + } +
+ public string InitialStateName { + get { + return (string) GetValue (InitialStateNameProperty); + } + set { + SetValue (InitialStateNameProperty, value); + } + } +
+ public string PreviousStateName { + get { return previous_state; } + } + + // Private + // TODO: This breaks API compatibility + public void SetCurrentStateName (string state) + { + previous_state = current_state; + current_state = state; + }
+ } +} + diff --git a/mcs/class/System.Workflow.Activities/System.Workflow.Activities/WhileActivity.cs b/mcs/class/System.Workflow.Activities/System.Workflow.Activities/WhileActivity.cs new file mode 100644 index 00000000000..7eb5a862031 --- /dev/null +++ b/mcs/class/System.Workflow.Activities/System.Workflow.Activities/WhileActivity.cs @@ -0,0 +1,78 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Authors: +// +// Copyright (C) 2006 Jordi Mas i Hernandez <jordimash@gmail.com> +// + +using System; +using System.ComponentModel; +using System.Threading; +using System.Workflow.ComponentModel; + +namespace System.Workflow.Activities +{ + public sealed class WhileActivity : CompositeActivity + //IActivityEventListener <ActivityExecutionStatusChangedEventArgs>
+ {
+ public static readonly DependencyProperty ConditionProperty; + private ActivityCondition activity_condition;
+
+ public WhileActivity () + { + + } +
+ public WhileActivity (string name) : base (name) + { + + } + + // Properties
+ public ActivityCondition Condition { + get { return activity_condition; } + set { activity_condition = value; } + } +
+ //public Activity DynamicActivity { get; } + + // Methods
+ + //protected override ActivityExecutionStatus Cancel(ActivityExecutionContext executionContext);
+ protected override ActivityExecutionStatus Execute (ActivityExecutionContext executionContext) + { + Activities[0].NeedsExecution = true; + ActivitiesToExecute.Enqueue (Activities[0]); + + if (Condition.Evaluate (this, executionContext) == false) { + NeedsExecution = false; + return ActivityExecutionStatus.Closed; + } + + NeedsExecution = true; + return ActivityExecutionStatus.Executing; + }
+ + //void IActivityEventListener<ActivityExecutionStatusChangedEventArgs>.OnEvent(object sender, ActivityExecutionStatusChangedEventArgs e);
+
+ }
+
+} + diff --git a/mcs/class/System.Workflow.Activities/System.Workflow.Activities_test.dll.sources b/mcs/class/System.Workflow.Activities/System.Workflow.Activities_test.dll.sources new file mode 100644 index 00000000000..d55a369775a --- /dev/null +++ b/mcs/class/System.Workflow.Activities/System.Workflow.Activities_test.dll.sources @@ -0,0 +1,3 @@ +System.Workflow.Activities/CodeActivityTest.cs
+System.Workflow.Activities/IfElseActivityTest.cs
+System.Workflow.Activities/RulesTest.cs
\ No newline at end of file diff --git a/mcs/class/System.Workflow.Activities/Test/System.Workflow.Activities/ChangeLog b/mcs/class/System.Workflow.Activities/Test/System.Workflow.Activities/ChangeLog new file mode 100644 index 00000000000..e5d29422895 --- /dev/null +++ b/mcs/class/System.Workflow.Activities/Test/System.Workflow.Activities/ChangeLog @@ -0,0 +1,4 @@ +2006-09-02 Jordi Mas i Hernandez <jordimash@gmail.com> + + * Initial check-in + diff --git a/mcs/class/System.Workflow.Activities/Test/System.Workflow.Activities/CodeActivityTest.cs b/mcs/class/System.Workflow.Activities/Test/System.Workflow.Activities/CodeActivityTest.cs new file mode 100644 index 00000000000..d61da33eaf8 --- /dev/null +++ b/mcs/class/System.Workflow.Activities/Test/System.Workflow.Activities/CodeActivityTest.cs @@ -0,0 +1,87 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Authors: +// +// Copyright (C) 2006 Jordi Mas i Hernandez <jordimash@gmail.com> +// +// Test Code Activity with two handlers +// + +using System; +using System.Threading; +using NUnit.Framework; +using System.Security.Permissions; +using System.Workflow.Activities; +using System.Workflow.Runtime; + +namespace MonoTests.System.Workflow.Activities +{ + public sealed class SimpleWorkFlow : SequentialWorkflowActivity + {
+ public SimpleWorkFlow ()
+ {
+ CodeActivity ca1 = new CodeActivity ();
+ ca1.ExecuteCode += new EventHandler (ExecuteCode1);
+ ca1.ExecuteCode += new EventHandler (ExecuteCode2);
+ Activities.Add (ca1);
+ }
+
+ private void ExecuteCode1 (object sender, EventArgs e)
+ {
+ CodeActivityTest.executed1 = true;
+ }
+
+ private void ExecuteCode2 (object sender, EventArgs e)
+ {
+ CodeActivityTest.executed2 = true;
+ } + } + + [TestFixture] + public class CodeActivityTest + { + static public bool executed1 = false; + static public bool executed2 = false; + static AutoResetEvent waitHandle = new AutoResetEvent(false); + + [Test] + public void WorkFlowTest () + { + WorkflowRuntime workflowRuntime = new WorkflowRuntime (); + + Type type = typeof (SimpleWorkFlow);
+ workflowRuntime.WorkflowCompleted += OnWorkflowCompleted; + + workflowRuntime.CreateWorkflow (type).Start ();
+ waitHandle.WaitOne ();
+ workflowRuntime.Dispose (); + + Assert.AreEqual (true, executed1, "C1#1"); + Assert.AreEqual (true, executed2, "C1#2"); + } + + void OnWorkflowCompleted (object sender, WorkflowCompletedEventArgs e)
+ {
+ waitHandle.Set ();
+ } + } + +} + diff --git a/mcs/class/System.Workflow.Activities/Test/System.Workflow.Activities/IfElseActivityTest.cs b/mcs/class/System.Workflow.Activities/Test/System.Workflow.Activities/IfElseActivityTest.cs new file mode 100644 index 00000000000..960d4d38a14 --- /dev/null +++ b/mcs/class/System.Workflow.Activities/Test/System.Workflow.Activities/IfElseActivityTest.cs @@ -0,0 +1,193 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Authors: +// +// Copyright (C) 2006 Jordi Mas i Hernandez <jordimash@gmail.com> +// + + +using System; +using System.Threading; +using NUnit.Framework; +using System.Security.Permissions; +using System.Workflow.Activities; +using System.Workflow.Runtime; + +namespace MonoTests.System.Workflow.Activities +{ + public class WorkFlowIfElseDoubleCondition : WorkFlowIfElse + { + public WorkFlowIfElseDoubleCondition ()
+ { + CodeCondition ifelse_condition2 = new CodeCondition (); + ifelse_condition2.Condition += new EventHandler <ConditionalEventArgs> (IfElseCondition2); + branch2.Condition = ifelse_condition2; + } + + private void IfElseCondition2 (object sender, ConditionalEventArgs e)
+ {
+ e.Result = IfElseActivityTest.ifelse_condition2;
+ } + } + + public class WorkFlowIfElse : SequentialWorkflowActivity + { + protected IfElseBranchActivity branch2; + + public WorkFlowIfElse ()
+ {
+ IfElseActivity ifelse_activity = new IfElseActivity (); + IfElseBranchActivity branch1 = new IfElseBranchActivity (); + CodeCondition ifelse_condition1 = new CodeCondition (); + CodeActivity code_branch1 = new CodeActivity (); + CodeActivity code_branch2 = new CodeActivity (); + branch2 = new IfElseBranchActivity (); + + code_branch1.Name ="Code1"; + code_branch2.Name ="Code2"; + code_branch1.ExecuteCode += new EventHandler (ExecuteCode1); + code_branch2.ExecuteCode += new EventHandler (ExecuteCode2); + + branch1.Activities.Add (code_branch1); + branch2.Activities.Add (code_branch2); + + ifelse_condition1.Condition += new EventHandler <ConditionalEventArgs> (IfElseCondition1); + branch1.Condition = ifelse_condition1; + + ifelse_activity.Activities.Add (branch1); + ifelse_activity.Activities.Add (branch2);
+
+ Activities.Add (ifelse_activity);
+ } + + private void IfElseCondition1 (object sender, ConditionalEventArgs e)
+ {
+ e.Result = IfElseActivityTest.ifelse_condition1;
+ } + + private void ExecuteCode1 (object sender, EventArgs e)
+ {
+ IfElseActivityTest.executed1 = true;
+ }
+
+ private void ExecuteCode2 (object sender, EventArgs e)
+ {
+ IfElseActivityTest.executed2 = true;
+ } + } + + [TestFixture] + public class IfElseActivityTest + { + static public bool ifelse_condition1; + static public bool ifelse_condition2; + static public bool executed1; + static public bool executed2; + static AutoResetEvent waitHandle = new AutoResetEvent(false); + + [Test] + public void IfElseConditionFalse () + { + WorkflowRuntime workflowRuntime = new WorkflowRuntime (); + + Type type = typeof (WorkFlowIfElse);
+ workflowRuntime.WorkflowCompleted += OnWorkflowCompleted; + + ifelse_condition1 = false; + executed1 = false; + executed2 = false; + workflowRuntime.CreateWorkflow (type).Start ();
+ waitHandle.WaitOne (); + + Assert.AreEqual (false, executed1, "C1#1"); + Assert.AreEqual (true, executed2, "C1#2"); + + workflowRuntime.Dispose (); + } + + [Test] + public void IfElseConditionTrue () + { + WorkflowRuntime workflowRuntime = new WorkflowRuntime (); + + Type type = typeof (WorkFlowIfElse);
+ workflowRuntime.WorkflowCompleted += OnWorkflowCompleted; + + ifelse_condition1 = true; + executed1 = false; + executed2 = false; + workflowRuntime.CreateWorkflow (type).Start ();
+ waitHandle.WaitOne (); + + Assert.AreEqual (true, executed1, "C1#1"); + Assert.AreEqual (false, executed2, "C1#2"); + + workflowRuntime.Dispose (); + } + + [Test] + public void IfElseConditionDoubleTrue () + { + WorkflowRuntime workflowRuntime = new WorkflowRuntime (); + + Type type = typeof (WorkFlowIfElseDoubleCondition);
+ workflowRuntime.WorkflowCompleted += OnWorkflowCompleted; + + ifelse_condition1 = true; + ifelse_condition2 = true; + executed1 = false; + executed2 = false; + workflowRuntime.CreateWorkflow (type).Start ();
+ waitHandle.WaitOne (); + + Assert.AreEqual (true, executed1, "C1#1"); + Assert.AreEqual (false, executed2, "C1#2"); + + workflowRuntime.Dispose (); + } + + [Test] + public void IfElseConditionDoubleFalse () + { + WorkflowRuntime workflowRuntime = new WorkflowRuntime (); + + Type type = typeof (WorkFlowIfElseDoubleCondition);
+ workflowRuntime.WorkflowCompleted += OnWorkflowCompleted; + + ifelse_condition1 = true; + ifelse_condition2 = false; + executed1 = false; + executed2 = false; + workflowRuntime.CreateWorkflow (type).Start ();
+ waitHandle.WaitOne (); + + Assert.AreEqual (true, executed1, "C1#1"); + Assert.AreEqual (false, executed2, "C1#2"); + + workflowRuntime.Dispose (); + } + + void OnWorkflowCompleted (object sender, WorkflowCompletedEventArgs e)
+ {
+ waitHandle.Set ();
+ } + } +} + diff --git a/mcs/class/System.Workflow.Activities/Test/System.Workflow.Activities/RulesTest.cs b/mcs/class/System.Workflow.Activities/Test/System.Workflow.Activities/RulesTest.cs new file mode 100644 index 00000000000..74e8dbcb50c --- /dev/null +++ b/mcs/class/System.Workflow.Activities/Test/System.Workflow.Activities/RulesTest.cs @@ -0,0 +1,305 @@ +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +// Authors: +// +// Copyright (C) 2006 Jordi Mas i Hernandez <jordimash@gmail.com> +// +// +// + +using System; +using System.Threading; +using System.CodeDom; +using NUnit.Framework; +using System.Security.Permissions; +using System.Workflow.Activities; +using System.Workflow.Runtime; +using System.Workflow.Activities.Rules;
+ + +namespace MonoTests.System.Workflow.Activities +{ + public class WorkFlowIfElseRule : SequentialWorkflowActivity + { + private IfElseBranchActivity branch2; + private IfElseBranchActivity branch1; + private RuleDefinitions definitions = new RuleDefinitions(); + + public WorkFlowIfElseRule ()
+ { + IfElseActivity ifelse_activity = new IfElseActivity ();
+ branch1 = new IfElseBranchActivity (); + + CodeActivity code_branch1 = new CodeActivity (); + CodeActivity code_branch2 = new CodeActivity (); + branch2 = new IfElseBranchActivity (); + + code_branch1.Name ="Code1"; + code_branch2.Name ="Code2"; + code_branch1.ExecuteCode += new EventHandler (ExecuteCode1); + code_branch2.ExecuteCode += new EventHandler (ExecuteCode2); + + branch1.Activities.Add (code_branch1); + branch2.Activities.Add (code_branch2); + + RuleConditionReference condition1 = new RuleConditionReference (); + condition1.ConditionName = "Condition1"; + RuleExpressionCondition rc = new RuleExpressionCondition ("Condition1", + RulesTest.check_condition); +
+ definitions.Conditions.Add (rc); + branch1.Condition = condition1; + + ifelse_activity.Activities.Add (branch1); + ifelse_activity.Activities.Add (branch2); + + SetValue (RuleDefinitions.RuleDefinitionsProperty, definitions);
+ Activities.Add (ifelse_activity);
+ } + + private void ExecuteCode1 (object sender, EventArgs e)
+ {
+ RulesTest.executed1 = true;
+ }
+
+ private void ExecuteCode2 (object sender, EventArgs e)
+ {
+ RulesTest.executed2 = true;
+ } + } + + [TestFixture] + public class RulesTest + { + static public bool ifelse_condition1; + static public bool ifelse_condition2; + static public bool executed1; + static public bool executed2; + static public CodeBinaryOperatorExpression check_condition; + static AutoResetEvent waitHandle = new AutoResetEvent(false); + + private void CheckRule (CodeBinaryOperatorExpression expression, bool executed, string error) + { + WorkflowInstance wi; + WorkflowRuntime workflowRuntime = new WorkflowRuntime (); + Type type = typeof (WorkFlowIfElseRule);
+ workflowRuntime.WorkflowCompleted += OnWorkflowCompleted; + + executed1 = false; + executed2 = false; + check_condition = expression; + wi = workflowRuntime.CreateWorkflow (type); + wi.Start ();
+ waitHandle.WaitOne (); + + if (executed) { + Assert.AreEqual (true, executed1, error); + Assert.AreEqual (false, executed2, error); + } else { + Assert.AreEqual (false, executed1, error); + Assert.AreEqual (true, executed2, error); + } + + workflowRuntime.Dispose (); + } + + [Test] + public void RuleGreaterThanOrEqual () + { + CodeBinaryOperatorExpression check = new CodeBinaryOperatorExpression ();
+ check.Operator = CodeBinaryOperatorType.GreaterThanOrEqual; + + check.Left = new CodePrimitiveExpression ((Int32) 4); + RuleCheckWithDifferentTypes (check, false); + + check.Left = new CodePrimitiveExpression ((Int16) 4); + RuleCheckWithDifferentTypes (check, false); + + check.Left = new CodePrimitiveExpression ((Int64) 4); + RuleCheckWithDifferentTypes (check, false); + + check.Left = new CodePrimitiveExpression ((sbyte) 4); + RuleCheckWithDifferentTypes (check, false); + + check.Left = new CodePrimitiveExpression ((float) 4); + RuleCheckWithDifferentTypes (check, false); + + check.Left = new CodePrimitiveExpression ((byte) 4); + RuleCheckWithDifferentTypes (check, false); + + check.Left = new CodePrimitiveExpression ((Int32)6); + RuleCheckWithDifferentTypes (check, true); + + check.Left = new CodePrimitiveExpression ((Int32)5); + RuleCheckWithDifferentTypes (check, true); + } + + [Test] + public void RuleGreaterThan () + { + CodeBinaryOperatorExpression check = new CodeBinaryOperatorExpression ();
+ check.Operator = CodeBinaryOperatorType.GreaterThan; + + check.Left = new CodePrimitiveExpression ((Int32) 4); + RuleCheckWithDifferentTypes (check, false); + + check.Left = new CodePrimitiveExpression ((Int16) 4); + RuleCheckWithDifferentTypes (check, false); + + check.Left = new CodePrimitiveExpression ((Int64) 4); + RuleCheckWithDifferentTypes (check, false); + + check.Left = new CodePrimitiveExpression ((sbyte) 4); + RuleCheckWithDifferentTypes (check, false); + + check.Left = new CodePrimitiveExpression ((float) 4); + RuleCheckWithDifferentTypes (check, false); + + check.Left = new CodePrimitiveExpression ((byte) 4); + RuleCheckWithDifferentTypes (check, false); + + check.Left = new CodePrimitiveExpression ((Int32)6); + RuleCheckWithDifferentTypes (check, true); + + check.Left = new CodePrimitiveExpression ((Int32)5); + RuleCheckWithDifferentTypes (check, false); + } + + [Test] + public void RuleLessThan () + { + CodeBinaryOperatorExpression check = new CodeBinaryOperatorExpression ();
+ check.Operator = CodeBinaryOperatorType.LessThan; + + check.Left = new CodePrimitiveExpression ((Int32) 4); + RuleCheckWithDifferentTypes (check, true); + + check.Left = new CodePrimitiveExpression ((Int16) 4); + RuleCheckWithDifferentTypes (check, true); + + check.Left = new CodePrimitiveExpression ((Int64) 4); + RuleCheckWithDifferentTypes (check, true); + + check.Left = new CodePrimitiveExpression ((sbyte) 4); + RuleCheckWithDifferentTypes (check, true); + + check.Left = new CodePrimitiveExpression ((float) 4); + RuleCheckWithDifferentTypes (check, true); + + check.Left = new CodePrimitiveExpression ((byte) 4); + RuleCheckWithDifferentTypes (check, true); + + check.Left = new CodePrimitiveExpression ((Int32) 6); + RuleCheckWithDifferentTypes (check, false); + + check.Left = new CodePrimitiveExpression ((Int32) 5); + RuleCheckWithDifferentTypes (check, false); + } + + [Test] + public void LessThanOrEqual () + { + CodeBinaryOperatorExpression check = new CodeBinaryOperatorExpression ();
+ check.Operator = CodeBinaryOperatorType.LessThanOrEqual; + + check.Left = new CodePrimitiveExpression ((Int32) 4); + RuleCheckWithDifferentTypes (check, true); + + check.Left = new CodePrimitiveExpression ((Int16) 4); + RuleCheckWithDifferentTypes (check, true); + + check.Left = new CodePrimitiveExpression ((Int64) 4); + RuleCheckWithDifferentTypes (check, true); + + check.Left = new CodePrimitiveExpression ((sbyte) 4); + RuleCheckWithDifferentTypes (check, true); + + check.Left = new CodePrimitiveExpression ((float) 4); + RuleCheckWithDifferentTypes (check, true); + + check.Left = new CodePrimitiveExpression ((byte) 4); + RuleCheckWithDifferentTypes (check, true); + + check.Left = new CodePrimitiveExpression ((Int32) 6); + RuleCheckWithDifferentTypes (check, false); + + check.Left = new CodePrimitiveExpression ((Int32) 5); + RuleCheckWithDifferentTypes (check, true); + } + + [Test] + public void ValueEquality () + { + CodeBinaryOperatorExpression check = new CodeBinaryOperatorExpression ();
+ check.Operator = CodeBinaryOperatorType.ValueEquality; + + check.Left = new CodePrimitiveExpression ((Int32) 4); + RuleCheckWithDifferentTypes (check, false); + + check.Left = new CodePrimitiveExpression ((Int16) 4); + RuleCheckWithDifferentTypes (check, false); + + check.Left = new CodePrimitiveExpression ((Int64) 4); + RuleCheckWithDifferentTypes (check, false); + + check.Left = new CodePrimitiveExpression ((sbyte) 4); + RuleCheckWithDifferentTypes (check, false); + + check.Left = new CodePrimitiveExpression ((float) 4); + RuleCheckWithDifferentTypes (check, false); + + check.Left = new CodePrimitiveExpression ((byte) 4); + RuleCheckWithDifferentTypes (check, false); + + check.Left = new CodePrimitiveExpression ((Int32) 6); + RuleCheckWithDifferentTypes (check, false); + + check.Left = new CodePrimitiveExpression ((Int32) 5); + RuleCheckWithDifferentTypes (check, true); + } + + private void OnWorkflowCompleted (object sender, WorkflowCompletedEventArgs e)
+ {
+ waitHandle.Set ();
+ } + + private void RuleCheckWithDifferentTypes (CodeBinaryOperatorExpression check, bool result) + { + check.Right = new CodePrimitiveExpression ((Int32) 5); + CheckRule (check, result, "C1#"); + + check.Right = new CodePrimitiveExpression ((Int16) 5); + CheckRule (check, result, "C2#"); + + check.Right = new CodePrimitiveExpression ((Int64) 5); + CheckRule (check, result, "C3#"); + + check.Right = new CodePrimitiveExpression ((sbyte) 5); + CheckRule (check, result, "C4#"); + + check.Right = new CodePrimitiveExpression ((float) 5); + CheckRule (check, result, "C5#"); + + check.Right = new CodePrimitiveExpression ((byte) 5); + CheckRule (check, result, "C6#"); + } + } +} + |