public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { VisualBasicValue <string> vbArgument = new VisualBasicValue <string>((string)value); InArgument <string> inArgument = new InArgument <string>(vbArgument); return(inArgument); }
public static InArgument <CorrelationHandle> CreateReplyCorrelatesWith(InArgument <CorrelationHandle> requestCorrelatesWith) { Fx.Assert(requestCorrelatesWith != null, "Argument cannot be null!"); VariableValue <CorrelationHandle> variableValue = requestCorrelatesWith.Expression as VariableValue <CorrelationHandle>; if (variableValue != null) { return(new InArgument <CorrelationHandle>(variableValue.Variable)); } VisualBasicValue <CorrelationHandle> vbvalue = requestCorrelatesWith.Expression as VisualBasicValue <CorrelationHandle>; if (vbvalue != null) { return(new InArgument <CorrelationHandle>(new VisualBasicValue <CorrelationHandle>(vbvalue.ExpressionText))); } // We use XAML roundtrip to clone expression string xamlStr = XamlServices.Save(requestCorrelatesWith.Expression); object obj = XamlServices.Parse(xamlStr); Activity <CorrelationHandle> expression = obj as Activity <CorrelationHandle>; Fx.Assert(expression != null, "Failed to clone CorrelationHandle using XAML roundtrip!"); return(new InArgument <CorrelationHandle>(expression)); }
/// <summary> /// Default Ctor /// </summary> public FlowsheetLookupActivity() { //Initialize the lookup method var lookupMethodExpr = new VisualBasicValue <FlowsheetLookupMethod>("FlowsheetLookupMethod.Earliest"); LookupMethod = new InArgument <FlowsheetLookupMethod>(lookupMethodExpr); }
public String ConvertModelItem(object inputvalue) { //ModelItem modelItem = inputvalue as ModelItem; if (inputvalue != null) { InArgument <string> inArgument = inputvalue as InArgument <string>; if (inArgument != null) { Activity <string> expression = inArgument.Expression; VisualBasicValue <string> vbexpression = expression as VisualBasicValue <string>; Literal <string> literal = expression as Literal <string>; if (literal != null) { return(literal.Value); } else if (vbexpression != null) { return(vbexpression.ExpressionText); } } } return(null); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { ModelItem modelItem = value as ModelItem; if (value != null) { InArgument <string> inArgument = modelItem.GetCurrentValue() as InArgument <string>; if (inArgument != null) { Activity <string> expression = inArgument.Expression; VisualBasicValue <string> vbexpression = expression as VisualBasicValue <string>; Literal <string> literal = expression as Literal <string>; if (literal != null) { return("\"" + literal.Value + "\""); } else if (vbexpression != null) { return(vbexpression.ExpressionText); } } } return(null); }
public Activity Create(DependencyObject target) { ArtificialGuide artificialGuide = new ArtificialGuide(); bool? result = artificialGuide.ShowDialog(); if (result == true) { Artificial artificial = new Artificial(); artificial.DisplayName = artificialGuide.txtDescription.Text; artificial.Description = artificialGuide.txtDescription.Text; artificial.WorkflowActivityID = artificialGuide.WorkflowActivityID; VisualBasicValue <int> workflowfInstanceIDParams = new VisualBasicValue <int>(); workflowfInstanceIDParams.ExpressionText = "WorkflowInstanceID"; artificial.WorkflowInstanceID = workflowfInstanceIDParams; artificial.ExchangeParams = new VisualBasicReference <Dictionary <string, object> > { ExpressionText = "ExchangeParams" }; //artificial.Actor = new VisualBasicValue<string> { ExpressionText = "Actor" }; return(artificial); } return(null); }
public static Activity CreateSalutationRules() { var inProperty = new DynamicActivityProperty { Name = "Person", Type = typeof(InArgument <Person>) }; var activity = new DynamicActivity() { Properties = { inProperty } }; Common.AddVbSetting(activity); var sequence = new Sequence(); activity.Implementation = () => sequence; // First rule var condition1 = new VisualBasicValue <bool>("Person.Gender = \"Male\""); var if1 = new If(new InArgument <bool>(condition1)); if1.Then = new Assign <string> { To = new OutArgument <string>(new VisualBasicReference <string>("Person.Salutation")), Value = new InArgument <string>("Mr") }; if1.Else = new Assign <string> { To = new OutArgument <string>(new VisualBasicReference <string>("Person.Salutation")), Value = new InArgument <string>("Miss") }; // Second rule var condition2 = new VisualBasicValue <bool>("Person.Gender = \"Female\" AND Person.Married"); var if2 = new If(new InArgument <bool>(condition2)); if2.Then = new Assign <string> { To = new OutArgument <string>(new VisualBasicReference <string>("Person.Salutation")), Value = new InArgument <string>("Mrs") }; // Third rule var condition3 = new VisualBasicValue <bool>("Person.Minor"); var if3 = new If(new InArgument <bool>(condition3)); if3.Then = new Assign <string> { To = new OutArgument <string>(new VisualBasicReference <string>("Person.Salutation")), Value = new InArgument <string>("To the parents of") }; // Priority is implicitly defined by the order in which we add the IF-activites sequence.Activities.Add(if1); sequence.Activities.Add(if2); sequence.Activities.Add(if3); return(activity); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { // Convert InArgument<string> to Combo box value string itemContent = string.Empty; ModelItem modelItem = value as ModelItem; if (value != null) { InArgument <string> inArgument = modelItem.GetCurrentValue() as InArgument <string>; if (inArgument != null) { if (inArgument.Expression is VisualBasicValue <string> ) { VisualBasicValue <string> vbexpression = inArgument.Expression as VisualBasicValue <string>; //to avoid extra double quotation marks if (vbexpression.ExpressionText.StartsWith("\"") && vbexpression.ExpressionText.EndsWith("\"")) { itemContent = vbexpression.ExpressionText.Replace("\"", string.Empty); } else { itemContent = vbexpression.ExpressionText; } } else if (inArgument.Expression is Literal <string> ) { Literal <string> literal = inArgument.Expression as Literal <string>; itemContent = literal.Value; } } } return(itemContent); }
object IValueConverter.ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { // Convert Int32 value to InArgument<Int32> Int32 itemContent = (Int32)value; VisualBasicValue <Int32> vbArgument = new VisualBasicValue <Int32> (itemContent); InArgument <Int32> inArgument = new InArgument <Int32> (vbArgument); return(inArgument); }
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { // Convert combo box value to InArgument<string> string itemContent = "\"" + (string)((ComboBoxItem)value).Content + "\""; VisualBasicValue <string> vbArgument = new VisualBasicValue <string>(itemContent); InArgument <string> inArgument = new InArgument <string>(vbArgument); return(inArgument); }
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { var str = value as string; if (!string.IsNullOrEmpty(str)) { str = string.Format("\"{0}\"", str); } var vbArgument = new VisualBasicValue <string>(str); var inArgument = new InArgument <string>(vbArgument); return(inArgument); }
protected override void CacheMetadata(NativeActivityMetadata metadata) { base.CacheMetadata(metadata); Predicate = new VisualBasicValue <TResult>("ExpressionText.Length"); ResultVar = new Variable <TResult>("ResultVar"); Assign = new Assign { To = new OutArgument <TResult>(ResultVar), Value = new InArgument <TResult>(Predicate) }; metadata.AddImplementationVariable(ResultVar); metadata.AddImplementationChild(Assign); }
public static InArgument <CorrelationHandle> CreateReplyCorrelatesWith(InArgument <CorrelationHandle> requestCorrelatesWith) { VariableValue <CorrelationHandle> expression = requestCorrelatesWith.Expression as VariableValue <CorrelationHandle>; if (expression != null) { return(new InArgument <CorrelationHandle>(expression.Variable)); } VisualBasicValue <CorrelationHandle> value3 = requestCorrelatesWith.Expression as VisualBasicValue <CorrelationHandle>; if (value3 != null) { return(new InArgument <CorrelationHandle>(new VisualBasicValue <CorrelationHandle>(value3.ExpressionText))); } return(new InArgument <CorrelationHandle>(XamlServices.Parse(XamlServices.Save(requestCorrelatesWith.Expression)) as Activity <CorrelationHandle>)); }
private void comboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { object selectedValue = (e.OriginalSource as ComboBox).SelectedValue; if (selectedValue == null) { return; } string text = selectedValue.ToString().TrimStart(' '); if (text == "Special Keys") { return; } InArgument <string> inArgument = base.ModelItem.Properties["Text"].ComputedValue as InArgument <string>; if (inArgument == null || inArgument.Expression == null) { base.ModelItem.Properties["Text"].SetValue(new InArgument <string>("[k(" + text + ")]")); } else if (inArgument.Expression.GetType().Equals(typeof(VisualBasicValue <string>))) { VisualBasicValue <string> visualBasicValue = inArgument.Expression as VisualBasicValue <string>; if (visualBasicValue == null || string.IsNullOrWhiteSpace(visualBasicValue.ExpressionText)) { base.ModelItem.Properties["Text"].SetValue(new InArgument <string>("[k(" + text + ")]")); return; } string expressionText = visualBasicValue.ExpressionText; expressionText = ((expressionText[expressionText.Length - 1] != '"') ? (expressionText + "+ \"[k(" + text + ")]\"") : (expressionText.Substring(0, expressionText.Length - 1) + "[k(" + text + ")]\"")); InArgument <string> inArgument2 = new InArgument <string>(); inArgument2.Expression = new VisualBasicValue <string>(expressionText); base.ModelItem.Properties["Text"].SetValue(inArgument2); } else if (inArgument.Expression.GetType().Equals(typeof(Literal <string>))) { Literal <string> literal = inArgument.Expression as Literal <string>; if (literal == null || string.IsNullOrEmpty(literal.Value)) { base.ModelItem.Properties["Text"].SetValue(new InArgument <string>("[k(" + text + ")]")); } else { base.ModelItem.Properties["Text"].SetValue(new InArgument <string>(literal.Value + "[k(" + text + ")]")); } } }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value != null) { Activity <string> expression = (value as InArgument <string>).Expression; VisualBasicValue <string> vbexpression = expression as VisualBasicValue <string>; Literal <string> literal = expression as Literal <string>; if (literal != null) { return(literal.Value.ToString()); } else if (vbexpression != null) { return(vbexpression.ExpressionText); } } return(null); }
public void WorkflowHelperCompileExpressionsWithActivityExpectedFixesExpressions() { const string ExpressionParams = "(\"\",AmbientDataList)"; var fsa = new DsfFlowSwitchActivity { ExpressionText = GlobalConstants.InjectedSwitchDataFetchOld + ExpressionParams }; var fda = new DsfFlowDecisionActivity { ExpressionText = GlobalConstants.InjectedDecisionHandlerOld + ExpressionParams }; var fdv = new VisualBasicValue <Boolean>(GlobalConstants.InjectedDecisionHandlerOld + ExpressionParams); var fsv = new VisualBasicValue <string>(GlobalConstants.InjectedSwitchDataFetchOld + ExpressionParams); var startNode = new FlowStep { Action = new CommentActivityForTest() }; var chart = new Flowchart { StartNode = startNode }; chart.Nodes.Add(startNode); chart.Nodes.Add(new FlowDecision(fda)); chart.Nodes.Add(new FlowSwitch <string> { Expression = fsa }); chart.Nodes.Add(new FlowDecision(fdv)); chart.Nodes.Add(new FlowSwitch <string> { Expression = fsv }); var workflow = new DynamicActivity { Implementation = () => chart }; new WorkflowHelper().CompileExpressions(workflow); Assert.AreEqual(GlobalConstants.InjectedSwitchDataFetch + ExpressionParams, fsa.ExpressionText); Assert.AreEqual(GlobalConstants.InjectedDecisionHandler + ExpressionParams, fda.ExpressionText); }
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { // Convert combo box value to InArgument<string> string itemContent = null; if (value is string) { return(value.ToString()); } else { itemContent = (string)((ComboBoxItem)value).Content; } VisualBasicValue <string> vbArgument = new VisualBasicValue <string>(itemContent); InArgument <string> inArgument = new InArgument <string>(vbArgument); return(inArgument); }
internal static Activity ToIfActivity(SalutationAssignmentRule inRule) { var condition = new VisualBasicValue <bool>(inRule.Condition); var ifActivity = new If(new InArgument <bool>(condition)); ifActivity.Then = new Assign <string> { To = new OutArgument <string>(new VisualBasicReference <string>(inRule.TargetParameter)), Value = new InArgument <string>(inRule.ThenValue) }; if (inRule.ElseValue != null) { ifActivity.Else = new Assign <string> { To = new OutArgument <string>(new VisualBasicReference <string>(inRule.TargetParameter)), Value = new InArgument <string>(inRule.ElseValue) }; } return(ifActivity); }
private string[] InArgumentConverter(ModelItem modelItem) { try { InArgument <string[]> inArgument = modelItem.GetCurrentValue() as InArgument <string[]>; if (inArgument != null) { Activity <string[]> expression = inArgument.Expression; VisualBasicValue <string[]> vbexpression = expression as VisualBasicValue <string[]>; string arrayContent = vbexpression.ExpressionText.ToString(); arrayContent = arrayContent.TrimStart('{'); arrayContent = arrayContent.TrimEnd('}'); string[] sArray = arrayContent.Split('"'); List <string> list = new List <string>(); foreach (string str in sArray) { if (str != "," && str != "") { list.Add(str); } } if (list.ToArray().Length != 0) { return(list.ToArray()); } else { return(null); } } else { return(null); } } catch (NullReferenceException) { return(null); } }
//Update Control public void UpdateControl(string ControlName, string ClipBoardText) { //Case it is not a Close Click if (ClipBoardText != Utils.DefaultSeparator()) { //Reference the Control ModelProperty p2 = this.ModelItem.Properties[ControlName]; //Case it is not null if (ClipBoardText.Length > 0) { string MyOutput = "New Collection(Of String) From " + ClipBoardText; VisualBasicValue <Collection <string> > MyArgList = new VisualBasicValue <Collection <string> >(MyOutput); p2.SetValue(new InArgument <Collection <string> >(MyArgList)); } else { //Case it is null p2.SetValue(null); } } }
public Activity Create(DependencyObject target) { BackToActorGuide customActivityGuide = new BackToActorGuide(); bool? result = customActivityGuide.ShowDialog(); if (result == true) { BackToActor activity = new BackToActor(); activity.DisplayName = "退回到发起人"; activity.Type = Convert.ToInt32(customActivityGuide.cbxTypes.SelectedValue); activity.Item = Convert.ToInt32(customActivityGuide.cbxItems.SelectedValue); activity.Position = customActivityGuide.cbxPosition.SelectedValue == null ? -99 : Convert.ToInt32(customActivityGuide.cbxPosition.SelectedValue); activity.Command = customActivityGuide.txtCmd.Text; activity.Expression = customActivityGuide.Expression; activity.Description = customActivityGuide.txtDescription.Text; activity.WorkflowActivityID = customActivityGuide.WorkflowActivityID; VisualBasicValue <int> workflowfInstanceIDParams = new VisualBasicValue <int>(); workflowfInstanceIDParams.ExpressionText = "WorkflowInstanceID"; activity.WorkflowInstanceID = workflowfInstanceIDParams; activity.ExchangeParams = new VisualBasicReference <Dictionary <string, object> > { ExpressionText = "ExchangeParams" }; activity.FirstActor = new VisualBasicValue <string> { ExpressionText = "FirstActor" }; activity.LastActor = new VisualBasicReference <string> { ExpressionText = "LastActor" }; return(activity); } return(null); }
internal static ActivityWithResult CreateExpressionFromString(Type type, string expressionText, bool isLocation, ParserContext context) { ActivityWithResult newExpression; if (!isLocation) { newExpression = ExpressionHelper.TryCreateLiteral(type, expressionText, context); if (newExpression != null) { return newExpression; } } Type targetExpressionType = null; if (isLocation) { targetExpressionType = typeof(VisualBasicReference<>).MakeGenericType(type); } else { targetExpressionType = typeof(VisualBasicValue<>).MakeGenericType(type); } //create new visual basic value and pass expression text into it newExpression = (ActivityWithResult)Activator.CreateInstance(targetExpressionType, expressionText); //targetExpressionType.GetProperty("Settings").SetValue(newExpression, settings, null); //this code below is never executed - it is placed here only to enable compilation support whenver VisualBasicValue constructor //changes its parameter list. if (null == newExpression) { //if this gives compilation error, please update CreateInstance parameter list above as well! newExpression = new VisualBasicValue<string>(expressionText); } return newExpression; }
public DecryptFile() { Algorithm = SymmetricAlgorithms.AES; KeyEncoding = new VisualBasicValue <Encoding>(typeof(Encoding).FullName + "." + nameof(Encoding.UTF8)); // Kinda ugly. }
public EncryptDataTable() { Encoding = new VisualBasicValue <Encoding>($"{typeof(Encoding).FullName}.{nameof(System.Text.Encoding.UTF8)}"); Iterations = new VisualBasicValue <int>("1000"); ParallelProcessing = false; }
private static If CompileConditions(LogicCondition condition, Dictionary<string, Type> inputs) { var vbExpression = GetVBExpression(condition, inputs); var vbCondition = new VisualBasicValue<bool>(vbExpression); return new If(new InArgument<bool>(vbCondition)); }
public EncryptText() { TextEncoding = new VisualBasicValue <Encoding>($"{typeof(Encoding).FullName}.{nameof(Encoding.UTF8)}"); Iterations = new VisualBasicValue <int>("1000"); }