Exemplo n.º 1
0
 public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
 {
     if (value is string)
     {
         ExpressionInfo expression = ExpressionInfo.FromString((string)value);
         if (EvaluatorService.IsEmptyExpression(expression))
         {
             return(expression);
         }
     }
     return(base.ConvertFrom(context, culture, value));
 }
Exemplo n.º 2
0
 /// <summary>
 /// Checks if a length expression preperty is literal. If so, it validates it against the specified min/max range limit.
 /// </summary>
 /// <param name="evaluator">the evaluator to use for evaluation</param>
 /// <param name="expression"><see cref="ExpressionInfo"/> value to validate.</param>
 /// <param name="min"><see cref="Length"/> value representing the minium size allowed</param>
 /// <param name="max"><see cref="Length"/> value representing the maximum size allowed</param>
 public static void ValidateLength(EvaluatorService evaluator, ExpressionInfo expression, Length min, Length max)
 {
     if (expression != null && expression.IsConstant && !EvaluatorService.IsEmptyExpression(expression))
     {
         object result = evaluator.EvaluateExpression(expression);
         if (result == null)
         {
             return;
         }
         string temp = result.ToString();
         if (temp.Length > 0)
         {
             Length size = temp.Trim();
             ValidateLength(size, min, max);
         }
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Returns <see cref="CultureInfo"/> determined from the specified language.
        /// </summary>
        public static CultureInfo CultureFromLanguage(string languageName)
        {
            if (string.IsNullOrEmpty(languageName) || EvaluatorService.IsEmptyExpression(ExpressionInfo.FromString(languageName)))
            {
                return(null);
            }
            CultureInfo culture = null;

            try
            {
                culture = new CultureInfo(languageName);
                if (culture.IsNeutralCulture)
                {
                    culture = CultureInfo.CreateSpecificCulture(culture.Name);
                }
            }
            catch (ArgumentException)
            {
                Trace.TraceError("Invalid language specified ({0}).", languageName);
            }
            return(culture);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Performs validation using the specified evaluator.
 /// </summary>
 public void Validate(EvaluatorService evaluator)
 {
     ValidationUtils.ValidateLength(evaluator, LineWidth, _minWidth, _maxWidth);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Performs validation using the specified evaluator.
 /// </summary>
 public void Validate(EvaluatorService evaluator)
 {
     ValidationUtils.ValidateLength(evaluator, Size, _minSize, _maxSize);
 }