Difference between Variables and Arguments in Windows Workflow Foundation - workflow-foundation-4

I am pretty new to Windows Workflow Foundation so this question may seem a little simple.
What's the major difference between Argument and Variables in a Workflow? And which one should be used in what situation.
For e.g. if I need to store some object which can be used by all activities in the workflow, and also the activites should be able to modify the object. Which one should I use - Variable or Argument?

Arguments are Input and Output from Activities (a whole workflow also counts as an Activity in WWF)
So any data put into a workflow comes in via an Argument named in the workflow as an InArgument.
(everytime I write InArgumentt I could also use InOutArgument)
Any data put into an Activity comes in via an Argument named in the activity as an InAargument.
Output is the same except the Argument must be marked as Out (or In/Out)
The values in the Arguments are available inside the workflow or activity that set the argument as in InArgument
Variables only exist inside the container where they are named.
So variables in a workflow are created in the workflow and are not passed in.
You can assign a workflow level variable to the InArgument of an activity by assigning the variable to an InArgument in the Properties panel for the Activity.
Variables also have scope so if you have nested workflow activities you can limit the variable to the nested workflow and not the whole workflow.
Arguments only exist in the container they were Input to.
So if you want to pass an Argument from a workflow to an Activity you must add that Argument as a parameter to an InArgument in the Properties panel for the Activity.
You can output from an Activity to an Argument or variable by adding that Argument or variable as a parameter to an OutArgument in the Properties panel for the Activity.

Related

Updating an object in a store in Svelte, is it by value or by reference?

Check out this Svelte REPL. Notice how I access the global state – which is an object – by key and also iterate over its values in App.svelte. So I also create a derived list of these values in global.js.
In general, is this the "Sveltonic" way (regarding performance, syntax, ...)?
I am unsure what happens inside .update() (in SetThings.svelte). Will the full object or parts get copied into the old object? Or will the variable referencing the old object be reassigned to the new object?
Regarding part one of the question: It is unwise to use an outermost object. Instead, I now use a list and let the child objects have their indexes as keys. As shown in the Svelte docs, for example here.
Regarding part two of the question, it seems the object (or parts of it) is not copied. See update() → set() → safe_not_equal() (returns true in this case) → value = value

Access List of Parameters from Within an Action

I would like to be able to generically access a list\dictionary of parameters from within an action. I know its possible to do this from within an ActionFilter by using:
ActionExecutingContext.ActionDescriptor.Parameters
But, I can't figure out a way to access that same list from within the action itself.
Backstory:
The end goal is for all of my actions to call the same function. The function will accept a stored proc name, and a list of parameters, then execute the stored proc using the supplied parameters. I have created each action so that the actions parameters are the same name\type as the stored proc parameters. Using this setup, I want to be able to just send the list of parameters associated with the action to a single generic call.
I have tried using:
HttpContext.Request.Query
But, that won't work, because I could have some action parameters that aren't required and have a default, these don't show up in the http query, and I still need them to be passed into my generic function.
"ModelState" is what I was looking for, it has everything I need, including the default values of the parameters that weren't in the query string.

What is the name rule of chainer.reporter.report's key?

chainer's document is very good, but I found every page in the document, I didn't found what is name rule of chainer report, How should I control the report name, and log it?
For example, the follow code:
trainer.extend(chainer.training.extensions.PrintReport(
['iteration', 'epoch', 'elapsed_time', 'lr',
'main/loss',
'validation/main/all',
]), trigger=print_interval)
Notice that main/loss and validation/main/all, why is there a main before /loss, How should I control to report loss? Also notice the validation/main/all.same question.
The prefix main is the name of the optimizer (and its target link) used in the updater you are using; StandardUpdater and other built-in updaters use the name main as the default name of the optimizer. If you are using one of the built-in updaters as is, this is always main unless you specify a special name. If you are using a customized updater that uses multiple optimizers, the custom updater assigns names to individual optimizers, which will be used as the prefix of items reported inside of the target link of the optimizer.
The prefix validation is the name of Evaluator extension. When you register an Evaluator with trainer.extend(), you can optionally pass name argument to override this prefix. For example, if you want to use multiple Evaluator objects each of which measures different things, you have to pass different names, which will be used as the prefix in the reported values.
As of the current version (v2.0.2), the naming rule of typical reported values are summarized in the document of chainer.report.

Asp.NET MVC Model Binding Not Picking Up A Value for List Item

I've got an object with a list defined inside it which points to a type that can be inherited. From what I understand MVC's default model binder will always instance the base type when reading data back in to this array from a form so by default I will have a list of base types.
So I need to use my own model binder and override CreateModel to instance a specific type (say from a hidden field). However when I do this and use
bindingContext.ValueProvider.GetValue("ModelType")
it always returns null even though through using fiddler I can see that form value Settings[0].ModelType contains my objects type and I need this value in CreateModel to instance the correct type.
Solved it. If your array objects need to be typed based on each item you need to use the following call to get "into" the array item
bindingContext.ValueProvider.GetValue(bindingContext.ModelName + ".ModelType")
I'm not sure if this is the standard way to do it. If anyone has any better suggestions feel free to add them

Create an array in windows workflow foundation

Is it possible to create a new array in windows workflow? More specifically, in the designer.
I've created a variable of System.Int32[], but when I use it I get a NullReferenceException.
I've tried New Int32(5), and various permutations of Dim - nothing I have tried has worked.
I was able to create the array and pass it as an in/out parameter - this works, however the workflow will need to determine the actual size of the array.
To create and instantiate an array, you have to set a default value to your variable with New Int32(FOO SIZE){} or use an Assign activity to instantiate it with the correct size in runtime
You can also use List(Of T) or any other .NET collection structure to achieve dynamic size.
Note that the value must be the right part of a set expression. So, you can google how to do it in VB.NET and you will be fine.
I assume that if you are creating the array in the designer, as you stated, it is either a workflow variable or a workflow argument. The "WF" way to do this would be to use the "Default Value" column under the "Variables" and/or "Arguments" tab.
If it is an argument then the Default Value column only works if the Direction is "In". If your argument is a property, or an Out, or In/Out direction then you would have to use the method mentioned by Davi.
If you are creating it under the "Variables" tag then using the Default value column would be the more built-in approach. The syntax in the default column would be the same syntax mentioned by Davi: New Int32(FOO SIZE) {}

Resources