public override void VisitOutArgument(OutArgument outArg) { if (outArg.Expression is Identifier outId) { definitions.Add(outId); } }
public static ReceiveMessageContent Create(OutArgument message, Type declaredMessageType) { return(new ReceiveMessageContent(message) { DeclaredMessageType = declaredMessageType }); }
public DataType VisitOutArgument(OutArgument outArgument) { var dt = outArgument.Expression.Accept(this); Expression exp = outArgument; return(RecordDataType(PointerTo(outArgument.TypeVariable), exp)); }
public MethodCall(Type handlerType, MethodInfo method) : base(method.IsAsync()) { HandlerType = handlerType; Method = method; if (method.ReturnType != typeof(void) && method.ReturnType != typeof(Task)) { var variableType = method.ReturnType.CanBeCastTo <Task>() ? method.ReturnType.GetTypeInfo().GetGenericArguments().First() : method.ReturnType; var name = variableType.IsSimple() || variableType == typeof(object) || variableType == typeof(object[]) ? "result_of_" + method.Name : Variable.DefaultArgName(variableType); ReturnVariable = new Variable(variableType, name, this); } var parameters = method.GetParameters(); Arguments = new Variable[parameters.Length]; for (int i = 0; i < parameters.Length; i++) { var param = parameters[i]; if (param.IsOut) { var paramType = param.ParameterType.IsByRef ? param.ParameterType.GetElementType() : param.ParameterType; Arguments[i] = new OutArgument(paramType, this); } } }
public override void VisitApplication(Application appl) { appl.Procedure.Accept(this); for (int i = 0; i < appl.Arguments.Length; ++i) { bitUseOffset = 0; cbitsUse = 0; var outArg = appl.Arguments[i] as OutArgument; if (outArg != null) { Identifier id = outArg.Expression as Identifier; if (id != null) { Def(id); } } } for (int i = 0; i < appl.Arguments.Length; ++i) { OutArgument u = appl.Arguments[i] as OutArgument; if (u == null || !(u.Expression is Identifier)) { appl.Arguments[i].Accept(this); } } }
public TranslitActivity(IOrganizationService service) { _service = service; LCID_From = new InArgument <int>(1049); LCID_To = new InArgument <int>(1033); Text = new InArgument <string>(); Result = new OutArgument <string>(); }
public static void AddRuntimeArgument <T>( this ActivityMetadata metadata, OutArgument <T> argument, string argumentName, bool isRequired) { metadata.AddRuntimeArgument <T>(argument, argumentName, isRequired, (List <string>)null); }
public override void VisitOutArgument(OutArgument outArg) { if (outArg.Expression is Identifier) { return; } outArg.Expression.Accept(this); }
void IExpressionVisitor.VisitOutArgument(OutArgument outArg) { Method("Out"); outArg.DataType.Accept(this); writer.Write(", "); outArg.Expression.Accept(this); writer.Write(")"); }
public DataType VisitOutArgument(OutArgument outArg) { outArg.Expression.Accept(this); return(handler.PointerTrait( outArg, outArg.DataType.Size, outArg.Expression)); }
internal override void ConfigureInternalReceiveReply(InternalReceiveMessage internalReceiveMessage, out FromReply responseFormatter) { responseFormatter = new FromReply(); foreach (KeyValuePair <string, OutArgument> parameter in this.Parameters) { responseFormatter.Parameters.Add(OutArgument.CreateReference(parameter.Value, parameter.Key)); } }
// Updates and returns the version of the specified attribute. private string UpdateVersion(string attributeName, string format, OutArgument <Version> maxVersion) { var oldValue = this.file[attributeName]; if (oldValue == null || string.IsNullOrWhiteSpace(format)) { // do nothing return(oldValue); } // parse old version (handle * character) bool containsWildcard = oldValue.Contains('*'); string versionPattern = "{0}.{1}.{2}.{3}"; if (containsWildcard) { if (oldValue.Split('.').Length == 3) { oldValue = oldValue.Replace("*", "0.0"); versionPattern = "{0}.{1}.*"; } else { oldValue = oldValue.Replace("*", "0"); versionPattern = "{0}.{1}.{2}.*"; } } if (!versionParser.IsMatch(oldValue)) { throw new FormatException("Current value for attribute '" + attributeName + "' is not in a correct version format."); } var version = new Version(oldValue); // update version var tokens = format.Split('.'); if (tokens.Length != 4) { throw new FormatException("Specified value for attribute '" + attributeName + "' is not a correct version format."); } version = new Version( Convert.ToInt32(this.ReplaceTokens(tokens[0], version.Major)), Convert.ToInt32(this.ReplaceTokens(tokens[1], version.Minor)), Convert.ToInt32(this.ReplaceTokens(tokens[2], version.Build)), Convert.ToInt32(this.ReplaceTokens(tokens[3], version.Revision))); this.file[attributeName] = string.Format(versionPattern, version.Major, version.Minor, version.Build, version.Revision); if (version > maxVersion.Get(this.ActivityContext)) { maxVersion.Set(this.ActivityContext, version); } return(version.ToString()); }
public static string ToString <T>(OutArgument <T> argument) { if (argument != null) { return(ToString(argument.Expression)); } return(null); }
public void ParameterAssign() { //Define the input argument for the activity var inputValue = new InArgument <int>(); var outputValue = new OutArgument <int>(); //Create the activity, property, and implementation Activity dynamicWorkflow = new DynamicActivity() { Properties = { new DynamicActivityProperty { Name = "InputInteger", Type = typeof(InArgument <int>), Value = inputValue }, new DynamicActivityProperty { Name = "OutputInteger", Type = typeof(OutArgument <int>), Value = outputValue }, }, Implementation = () => new Sequence() { Activities = { new Assign() { To = new OutArgument <int>(env => outputValue.Get(env)), Value = new InArgument <int>(env => inputValue.Get(env)) }, new WriteLine() { Text = new InArgument <string>("Assign was successful") } } } }; //Execute the activity with a parameter dictionary var o = WorkflowInvoker.Invoke(dynamicWorkflow, new Dictionary <string, object> { { "InputInteger", 42 } }); foreach (var kvp in o) { Console.WriteLine(kvp.Key + " : " + kvp.Value.ToString()); } if (o.TryGetValue("OutputInteger", out object value)) { int returnedInt = (int)value; Assert.Equal(42, returnedInt); } }
public static void CacheMetadataHelper( ActivityMetadata metadata, InArgument <IEnumerable> input, OutArgument <Collection <ErrorRecord> > errors, string commandText, string typeName, string displayName, IDictionary <string, Argument> variables, IDictionary <string, InArgument> parameters, IDictionary <string, Argument> childVariables, IDictionary <string, InArgument> childParameters) { childVariables.Clear(); childParameters.Clear(); RuntimeArgument inputArgument = new RuntimeArgument("Input", typeof(IEnumerable), ArgumentDirection.In); metadata.Bind(input, inputArgument); metadata.AddArgument(inputArgument); RuntimeArgument errorArgument = new RuntimeArgument("Errors", typeof(Collection <ErrorRecord>), ArgumentDirection.Out); metadata.Bind(errors, errorArgument); metadata.AddArgument(errorArgument); if (commandText == null || string.IsNullOrEmpty(commandText.Trim())) { metadata.AddValidationError(string.Format(ErrorMessages.PowerShellRequiresCommand, displayName)); } foreach (KeyValuePair <string, Argument> variable in variables) { string name = variable.Key; Argument argument = variable.Value; RuntimeArgument ra = new RuntimeArgument(name, argument.ArgumentType, argument.Direction, true); metadata.Bind(argument, ra); metadata.AddArgument(ra); Argument childArgument = Argument.Create(argument.ArgumentType, argument.Direction); childVariables.Add(name, Argument.CreateReference(argument, name)); } foreach (KeyValuePair <string, InArgument> parameter in parameters) { string name = parameter.Key; InArgument argument = parameter.Value; RuntimeArgument ra; if (argument.ArgumentType == typeof(bool)) { ra = new RuntimeArgument(name, argument.ArgumentType, argument.Direction, false); } else { ra = new RuntimeArgument(name, argument.ArgumentType, argument.Direction, true); } metadata.Bind(argument, ra); metadata.AddArgument(ra); Argument childArgument = Argument.Create(argument.ArgumentType, argument.Direction); childParameters.Add(name, Argument.CreateReference(argument, name) as InArgument); } }
public BitRange VisitOutArgument(OutArgument outArgument) { if (outArgument.Expression is Identifier) { return(BitRange.Empty); } else { return(outArgument.Expression.Accept(this)); } }
protected override void Execute(CodeActivityContext context) { Message inMessage = this.Message.Get(context); if (inMessage == null) { throw FxTrace.Exception.AsError(new InvalidOperationException(SR.NullReplyMessageContractMismatch)); } if (inMessage.IsFault) { FaultConverter faultConverter = FaultConverter.GetDefaultFaultConverter(inMessage.Version); Exception exception = DeserializeFault(inMessage, faultConverter); // We simply throw the exception throw FxTrace.Exception.AsError(exception); } else { object[] outObjects; if (this.parameters != null) { outObjects = new object[this.parameters.Count]; } else { outObjects = Constants.EmptyArray; } object returnValue = this.Formatter.DeserializeReply(inMessage, outObjects); if (this.Result != null) { this.Result.Set(context, returnValue); } if (parameters != null) { for (int i = 0; i < this.parameters.Count; i++) { OutArgument outArgument = this.parameters[i]; Fx.Assert(outArgument != null, "Parameter cannot be null"); object obj = outObjects[i]; if (obj == null) { obj = ProxyOperationRuntime.GetDefaultParameterValue(outArgument.ArgumentType); } outArgument.Set(context, obj); } } } }
public static void AddRuntimeArgument <T>( this ActivityMetadata metadata, OutArgument <T> argument, string argumentName, bool isRequired, List <string> overloadGroupNames) { RuntimeArgument runtimeArgument = new RuntimeArgument(argumentName, typeof(T), ArgumentDirection.Out, isRequired, overloadGroupNames); metadata.Bind((Argument)argument, runtimeArgument); metadata.AddArgument(runtimeArgument); }
// Copies the specified attribute string value to the specified argument if present. private void ReadStringAttribute(string attributeName, OutArgument argument) { var value = this.file[attributeName]; if (value == null) { // do nothing return; } argument.Set(this.ActivityContext, value); }
// Copies the specified attribute GUID value to the specified argument if present. private void ReadGuidAttribute(string attributeName, OutArgument argument) { var value = this.file[attributeName]; if (value == null) { argument.Set(this.ActivityContext, null); return; } argument.Set(this.ActivityContext, new System.Guid(value)); }
// Copies the specified attribute boolean value to the specified argument if present. private void ReadBoolAttribute(string attributeName, OutArgument argument) { var value = this.file[attributeName]; if (value == null) { argument.Set(this.ActivityContext, null); return; } argument.Set(this.ActivityContext, Convert.ToBoolean(value)); }
public static void OnGetArguments <TItem>(Collection <InArgument> indices, OutArgument <Location <TItem> > result, CodeActivityMetadata metadata) { for (int i = 0; i < indices.Count; i++) { RuntimeArgument argument = new RuntimeArgument("Index" + i, indices[i].ArgumentType, ArgumentDirection.In, true); metadata.Bind(indices[i], argument); metadata.AddArgument(argument); } RuntimeArgument argument2 = new RuntimeArgument("Result", typeof(Location <TItem>), ArgumentDirection.Out); metadata.Bind(result, argument2); metadata.AddArgument(argument2); }
public override void VisitOutArgument(OutArgument outArg) { Identifier id = outArg.Expression as Identifier; if (id != null) { MarkDefined(id); } else { outArg.Expression.Accept(this); } }
public override void VisitOutArgument(OutArgument outArg) { Identifier id = outArg.Expression as Identifier; if (id != null) { Def(id, outArg, true); } else { outArg.Expression.Accept(this); } }
public virtual Expression VisitOutArgument(OutArgument outArg) { Expression exp; if (outArg.Expression is Identifier) { exp = outArg.Expression; } else { exp = outArg.Expression.Accept(this); } return(new OutArgument(outArg.DataType, exp)); }
public static TOutput Invoke <TActivity, TOutput>(this TActivity activity, Action <TActivity, OutArgument <TOutput> > setOutput) where TActivity : Activity { var inToken = new InArgument <string>("inToken"); var inBaseUrl = new InArgument <string>("inBaseUrl"); var indicoScope = new IndicoScope { Host = new InArgument <string>(ctx => inBaseUrl.Get(ctx)), Token = new InArgument <string>(ctx => inToken.Get(ctx)), Body = { Handler = activity }, }; OutArgument <TOutput> outArg = new OutArgument <TOutput>(); var root = new DynamicActivity { Properties = { new DynamicActivityProperty { Name = nameof(IndicoScope.Token), Value = inToken, Type = inToken.GetType(), }, new DynamicActivityProperty { Name = nameof(IndicoScope.Host), Value = inBaseUrl, Type = inBaseUrl.GetType(), }, new DynamicActivityProperty { Name = "OutArg", Type = typeof(OutArgument <TOutput>), Value = outArg, } }, Implementation = () => indicoScope }; setOutput(activity, new OutArgument <TOutput>(ctx => outArg.Get(ctx))); var resultDictionary = WorkflowInvoker.Invoke(root, GetScopeParams()); var result = (TOutput)resultDictionary.Single().Value; return(result); }
public override Expression VisitOutArgument(OutArgument outArg) { var id = outArg.Expression as Identifier; Expression exp; if (id != null) { exp = NewDef(id, outArg, true); } else { exp = outArg.Expression.Accept(this); } return(new OutArgument(outArg.DataType, exp)); }
internal override void ConfigureInternalReceive(InternalReceiveMessage internalReceiveMessage, out FromRequest requestFormatter) { if (this.InternalDeclaredMessageType == MessageDescription.TypeOfUntypedMessage) { internalReceiveMessage.Message = new OutArgument <Message>(context => ((OutArgument <Message>) this.Message).Get(context)); requestFormatter = null; } else { requestFormatter = new FromRequest(); if (this.Message != null) { requestFormatter.Parameters.Add(OutArgument.CreateReference(this.Message, "Message")); } } }
public MethodCall(Type handlerType, MethodInfo method) : base(method.IsAsync()) { HandlerType = handlerType; Method = method; Type returnType = correctedReturnType(method.ReturnType); if (returnType != null) { #if !NET4x if (returnType.IsValueTuple()) { var values = returnType.GetGenericArguments().Select(x => new Variable(x, this)).ToArray(); ReturnVariable = new ValueTypeReturnVariable(returnType, values); } else { #endif var name = returnType.IsSimple() || returnType == typeof(object) || returnType == typeof(object[]) ? "result_of_" + method.Name : Variable.DefaultArgName(returnType); ReturnVariable = new Variable(returnType, name, this); #if !NET4x } #endif } var parameters = method.GetParameters(); Arguments = new Variable[parameters.Length]; for (int i = 0; i < parameters.Length; i++) { var param = parameters[i]; if (param.IsOut) { var paramType = param.ParameterType.IsByRef ? param.ParameterType.GetElementType() : param.ParameterType; Arguments[i] = new OutArgument(paramType, this); } } }
/// <summary> /// Assigns <paramref name="value"/> to <paramref name="to"/>. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="to"></param> /// <param name="value"></param> /// <param name="displayName"></param> /// <returns></returns> public static Assign <T> Assign <T>(OutArgument <T> to, Activity <T> value, string displayName = null) { if (to == null) { throw new ArgumentNullException(nameof(to)); } if (value == null) { throw new ArgumentNullException(nameof(value)); } return(new Assign <T>() { DisplayName = displayName, To = to, Value = value, }); }
public void VisitOutArgument(OutArgument outArg) { throw new NotImplementedException(); }
private Expression ParseArgument(TokenSet followers) //^ ensures followers[this.currentToken] || this.currentToken == Token.EndOfFile; { switch (this.currentToken) { case Token.Ref: SourceLocationBuilder slb = new SourceLocationBuilder(this.scanner.SourceLocationOfLastScannedToken); this.GetNextToken(); Expression expr = this.ParseExpression(followers); slb.UpdateToSpan(expr.SourceLocation); Expression refArg = new RefArgument(new AddressableExpression(expr), slb); //^ assume followers[this.currentToken] || this.currentToken == Token.EndOfFile; return refArg; case Token.Out: slb = new SourceLocationBuilder(this.scanner.SourceLocationOfLastScannedToken); this.GetNextToken(); expr = this.ParseExpression(followers); slb.UpdateToSpan(expr.SourceLocation); Expression outArg = new OutArgument(new TargetExpression(expr), slb); //^ assume followers[this.currentToken] || this.currentToken == Token.EndOfFile; return outArg; //case Token.ArgList: // slb = new SourceLocationBuilder(this.scanner.CurrentSourceContext); // this.GetNextToken(); // if (this.currentToken == Token.LeftParenthesis) { // ExpressionList el = this.ParseExpressionList(followers, ref sctx); // return new ArglistArgumentExpression(el, sctx); // } // return new ArglistExpression(sctx); default: return this.ParseExpression(followers); } }
/// <summary> /// 初始化 /// </summary> /// <param name="flowNodeIndex">对应的索引</param> public Custom(int flowNodeIndex) { this.FlowNodeIndex = flowNodeIndex; this.Result = new OutArgument<string>(); }
public override void VisitOutArgument(OutArgument outArg) { outArg.Expression.Accept(this); EnsureTypeVariable(outArg); }
public override Expression VisitOutArgument(OutArgument outArg) { var id = outArg.Expression as Identifier; Expression exp; if (id != null) exp = NewDef(id, outArg, true); else exp = outArg.Expression.Accept(this); return new OutArgument(outArg.DataType, exp); }
public override void VisitOutArgument(OutArgument outArg) { Identifier id = outArg.Expression as Identifier; if (id != null) MarkDefined(id); else outArg.Expression.Accept(this); }
public void VisitOutArgument(OutArgument outArg) { writer.WriteKeyword("out"); writer.Write(" "); WriteExpression(outArg.Expression); }
public override void VisitOutArgument(OutArgument outArg) { if (outArg.Expression is Identifier) return; outArg.Expression.Accept(this); }
public virtual void VisitOutArgument(OutArgument outArg) { outArg.Expression.Accept(this); }
public override void VisitOutArgument(OutArgument outArg) { Identifier id = outArg.Expression as Identifier; if (id != null) Def(id, outArg, true); else outArg.Expression.Accept(this); }