mekasu0124

Untitled

Oct 17th, 2023
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.01 KB | None | 0 0
  1. using Avalonia.Data.Converters;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Globalization;
  5.  
  6. namespace MeksMathGame.Services;
  7.  
  8. public static class ValueConverters
  9. {
  10.     public static IValueConverter OperationToString = new OperationValueConverter();
  11.  
  12.     private class OperationValueConverter : IValueConverter
  13.     {
  14.         public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
  15.             => value is Operation operation && _operationSymbols.TryGetValue(operation, out var symbol)
  16.             ? symbol
  17.             : null;
  18.  
  19.         public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => throw new NotImplementedException();
  20.  
  21.         private Dictionary<Operation, string> _operationSymbols = new()
  22.         {
  23.             [Operation.Addition] = "➕",
  24.             [Operation.Subtraction] = "➖",
  25.             [Operation.Multiplication] = "✖️",
  26.             [Operation.Division] = "➗"
  27.         };
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment