﻿using System;
using System.Globalization;
using System.Windows.Data;

namespace NatCruise.Wpf.Converters
{
    public class ReplaceNullConverter : IValueConverter
    {
        public object Value { get; set; }

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return value ?? parameter ?? Value;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return value == null || value.Equals(parameter ?? Value) ? null : value;
        }
    }
}