Exemple #1
0
        /// <summary>
        /// Converts the specified value.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <param name="targetType">Type of the target.</param>
        /// <param name="parameter">The parameter.</param>
        /// <returns>System.Object.</returns>
        protected override object Convert(object value, System.Type targetType, object parameter)
        {
            var parameterAsString = ObjectToStringHelper.ToString(parameter);

            var isSupported        = false;
            var supportedPlatforms = parameterAsString.Split(new[] { '|' });

            foreach (var supportedPlatform in supportedPlatforms)
            {
                KnownPlatforms platform = KnownPlatforms.Unknown;
                if (Enum <KnownPlatforms> .TryParse(supportedPlatform, out platform))
                {
                    if (Platforms.IsPlatformSupported(platform))
                    {
                        isSupported = true;
                        break;
                    }
                }
            }

            if (SupportInversionUsingCommandParameter && ConverterHelper.ShouldInvert(parameter))
            {
                isSupported = !isSupported;
            }

            return(isSupported);
        }
Exemple #2
0
        /// <summary>
        /// Converts the specified value.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <param name="targetType">Type of the target.</param>
        /// <param name="parameter">The parameter.</param>
        /// <returns>System.Object.</returns>
        protected override object Convert(object value, System.Type targetType, object parameter)
        {
            var parameterAsString = ObjectToStringHelper.ToString(parameter);

            var supportedPlatforms = parameterAsString.Split(new[] { '|' });

            foreach (var supportedPlatform in supportedPlatforms)
            {
                KnownPlatforms platform = KnownPlatforms.Unknown;
                if (Enum <KnownPlatforms> .TryParse(supportedPlatform, out platform))
                {
                    if (Platforms.IsPlatformSupported(platform))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Exemple #3
0
 public void ReturnsFalseForUnsupportedPlatform(KnownPlatforms platformToCheck, SupportedPlatforms currentPlatform)
 {
     Assert.IsFalse(Platforms.IsPlatformSupported(platformToCheck, currentPlatform));
 }