Example #1
0
        public IUshortsFormatter VisitDictionaryMatchFormatter(DictionaryMatchingFormatterViewModel formatterViewModel)
        {
            var formatter = new DictionaryMatchingFormatter();

            formatter.StringDictionary = new Dictionary <ushort, string>();
            foreach (BindableKeyValuePair <ushort, string> bkvp in formatterViewModel.KeyValuesDictionary)
            {
                formatter.StringDictionary.Add(bkvp.Key, bkvp.Value);
            }
            formatter.IsKeysAreNumbersOfBits = formatterViewModel.IsKeysAreNumbersOfBits;
            formatter.UseDefaultMessage      = formatterViewModel.UseDefaultMessage;
            formatter.DefaultMessage         = formatterViewModel.DefaultMessage;
            return(formatter);
        }
        public IUshortsFormatterViewModel VisitDictionaryMatchFormatter(IUshortsFormatter formatter)
        {
            var vm = new DictionaryMatchingFormatterViewModel();

            if (!(formatter is IDictionaryMatchingFormatter dictionaryMatchingFormatter))
            {
                return(null);
            }
            foreach (KeyValuePair <ushort, string> kvp in dictionaryMatchingFormatter.StringDictionary)
            {
                vm.KeyValuesDictionary.Add(new BindableKeyValuePair <ushort, string>(kvp.Key, kvp.Value));
            }

            vm.IsKeysAreNumbersOfBits = dictionaryMatchingFormatter.IsKeysAreNumbersOfBits;
            vm.DefaultMessage         = dictionaryMatchingFormatter.DefaultMessage;
            vm.UseDefaultMessage      = dictionaryMatchingFormatter.UseDefaultMessage;
            return(vm);
        }