Introduction
When changing from Windows Legacy to Windows target framework the package: Microsoft.Activities.Extensions is no longer available. This package offered a few Activities for working with Dictionaries.
Issue
As the package is not available, so also the offered activities are no longer available and alternate handling is needed.
Workaround
Instead of using the activities from above, the same result can be achieved with the following options, mostly done on .Net API base.
Initialization
Example Case: myDict - a String, String Dictionary
Default Value
Assign Activity:
myDict = new Dictionary(Of String, String)
Build a Dictionary with initial entries
Usage of an Assign Activity for initialization and pre-population:
New Dictionary(Of String, String) From {
{"ES","Spain"},
{"AT", "Austria"}
}
Replacements
Add to Dictionary
Usage of an Assign Acitivty:
The value “France” will be added under the key “FR”
Get From Dictionary
Using an Assign Activity and retrieving the value for the particular key
Key exists in dictionary
Direct: myDict.ContainsKey("FR")
- will return a boolean value
Assign Acitvity:
hasKey = myDict.ContainsKey("FR")
Value exists in dictionary
Direct: myDict.ContainsValue("France")
- will return a boolean value
Assign Acitvity:
hasValue = myDict.ContainsValue("France")
Remove from dictionary - using the Key
Removing a dictionary item by using the particular key value
Direct Approach: myDict.Remove("FR")
- will return a boolean value indicating if the removal was done or not, as the item with this key was not present
wasRemoved = myDict.Remove("FR")
Clear Dictionary
Option with Invoke method:
Kindly note: when using the Clear() method of the dictionary the original object instance is kept
Option with Assign Activity
will overwrite with a new empty dictionary
myDict = new Dictionary(Of String, String)
Others
Count Dictionary:
Direct usage: myDict.Count
- will return an Int32 value
Assign Activity:
Conclusion
- The lack of the formerly offered activities can be solved by rewriting them into a code approach
- For further or special tasks can be fallen back on additional possibilities like e.g. LINQ
Documentation
Recommendations - Migration help
Questions
For questions on your specific case open a new topic and get individual support.