コード例 #1
0
        public static void MakeConverter(this ResourceDictionary dic,
                                         string key,
                                         ConvertDelegate convert, ConvertBackDelegate convertBack = null)
        {
            var conv = new ValueConverterGenerator(convert, convertBack);

            dic.Add(key, conv);
        }
コード例 #2
0
        public static void MakeConverter(this ResourceDictionary dic,
                                         string key,
                                         Func <object, object, object> convert, ConvertBackDelegate convertBack = null)
        {
            var conv = new ValueConverterGenerator((object value, Type targetType, object parameter, CultureInfo culture) =>
            {
                return(convert(value, parameter));
            }
                                                   , convertBack);

            dic.Add(key, conv);
        }
コード例 #3
0
        public static void WriteValueConverters()
        {
            var settings = Settings();

            foreach (var quantity in settings.Quantities)
            {
                File.WriteAllText($"C:\\Git\\_GuOrg\\Gu.Units\\Gu.Units.Wpf\\{quantity.Name}Converter.generated.cs", ValueConverterGenerator.Code(quantity));
            }
        }