private void CreateToplist_DialogClosing(object sender, DialogClosingEventArgs eventArgs)
        {
            if (Equals(eventArgs.Parameter, false))
            {
                return;
            }

            if (!(eventArgs.Parameter is CreateToplistViewModel createToplistViewModel))
            {
                return;
            }

            string toplistName = createToplistViewModel.ToplistName;

            if (string.IsNullOrWhiteSpace(toplistName))
            {
                eventArgs.Cancel();
                return;
            }

            ToplistType   toplistType   = createToplistViewModel.SelectedToplistType;
            ToplistFormat toplistFormat = createToplistViewModel.SelectedToplistFormat;

            var parameters = new ToplistParametersInfo(toplistName, toplistType, toplistFormat);

            _eventAggregator
            .GetEvent <ConstructToplistMessage>()
            .Publish(parameters);
        }
 public ToplistParametersInfo(string toplistName, ToplistType toplistType,
                              ToplistFormat toplistFormat)
 {
     ToplistName   = toplistName.ThrowIfNullOrWhiteSpace(nameof(toplistName));
     ToplistType   = toplistType.ThrowIfEnumValueIsUndefined(nameof(toplistType));
     ToplistFormat = toplistFormat.ThrowIfEnumValueIsUndefined(nameof(toplistFormat));
 }
Exemplo n.º 3
0
        public static ToplistBase Create(string toplistName, ToplistType toplistType,
                                         ToplistFormat toplistFormat)
        {
            toplistName.ThrowIfNullOrWhiteSpace(nameof(toplistName));
            // Enum parameters are checked in implementation classes.

            _logger.Info($"Creating toplist [Name: {toplistName}, Type: {toplistType.ToString()} " +
                         $"Format: {toplistFormat.ToString()}].");

            return(toplistType switch
            {
                ToplistType.Score => new ScoreToplist(toplistName, toplistFormat),

                ToplistType.Simple => new SimpleToplist(toplistName, toplistFormat),

                _ => throw new ArgumentOutOfRangeException(nameof(toplistType), toplistType,
                                                           "Could not recognize toplist type.")
            });
Exemplo n.º 4
0
 public ScoreToplist(string name, ToplistFormat format)
     : base(name, ToplistType.Score, format)
 {
 }
Exemplo n.º 5
0
 public SimpleToplist(string name, ToplistFormat format)
     : base(name, ToplistType.Simple, format)
 {
 }