Esempio n. 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MessageBlock"/> class.
 /// </summary>
 /// <param name="message">
 /// The message.
 /// </param>
 /// <param name="test">
 /// The tested object.
 /// </param>
 /// <param name="block">
 /// The block attribute.
 /// </param>
 /// <param name="index">The index for enumerable types</param>
 internal MessageBlock(FluentMessage message, object test, GenericLabelBlock block, int index = 0)
     : this(message, test.GetTypeWithoutThrowingException(), block)
 {
     if (!(test is string) && (test is IEnumerable))
     {
         this.value = new EnumerationBlock((IEnumerable) test, index);
     }
     else
     {
         this.value = new ValueBlock(test);
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MessageBlock"/> class.
 /// </summary>
 /// <param name="message">
 /// The message.
 /// </param>
 /// <param name="test">
 /// The tested object.
 /// </param>
 /// <param name="index">Index to focus on.</param>
 /// <param name="block">
 /// The block attribute.
 /// </param>
 internal MessageBlock(FluentMessage message, IEnumerable test, int index, GenericLabelBlock block)
     : this(message, test.GetTypeWithoutThrowingException(), block)
 {
     if (!(test is string))
     {
         this.value = new EnumerationBlock(test, index);
     }
     else
     {
         this.value = new ValueBlock(test);
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MessageBlock"/> class.
 /// </summary>
 /// <param name="message">
 /// The message.
 /// </param>
 /// <param name="test">
 /// The tested object.
 /// </param>
 /// <param name="block">
 /// The block attribute.
 /// </param>
 internal MessageBlock(FluentMessage message, object test, GenericLabelBlock block)
     : this(message, test.GetTypeWithoutThrowingException(), block)
 {
     if (!(test is string) && (test is IEnumerable))
     {
         this.value = new EnumerationBlock(test as IEnumerable, 0);
     }
     else
     {
         this.value = new ValueBlock(test);
     }
 }
Esempio n. 4
0
        public static object GetValueFromValueDescription(IValueDescription description, IObjectService objectService)
        {
            if (description == null)
            {
                return(null);
            }
            var value = description.Value;
            var type  = description.Type;

            if ((type.IsClass || type.IsInterface) && type != typeof(string))
            {
                //尝试进行注入
                if (value is string value1 && !string.IsNullOrEmpty(value1))                  //类型引用
                {
                    value = objectService.GetObject(value1);
                }
                else if (value == null)                    //强类型
                {
                    value = objectService.GetObject(type);
                }
            }
Esempio n. 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MessageBlock"/> class.
        /// </summary>
        /// <param name="message">
        /// The message.
        /// </param>
        /// <param name="type">
        /// The tested type.
        /// </param>
        /// <param name="label">
        /// The block label.
        /// </param>
        internal MessageBlock(FluentMessage message, Type type, GenericLabelBlock label)
        {
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }

            this.value = new InstanceBlock(type);
            this.message = message;
            this.block = label;
        }
Esempio n. 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MessageBlock"/> class.
 /// </summary>
 /// <param name="message">
 /// The message.
 /// </param>
 /// <param name="type">
 /// The tested type.
 /// </param>
 /// <param name="label">
 /// The block label.
 /// </param>
 internal MessageBlock(FluentMessage message, Type type, GenericLabelBlock label)
 {
     this.value   = new InstanceBlock(type);
     this.message = message;
     this.block   = label;
 }