示例#1
0
        /// <summary>Create a new <c>Result</c> AML tag</summary>
        public IResult Result(params object[] content)
        {
            var result = new Result(this);

            if (content?.Length < 1)
            {
                // do nothing
            }
            else if (content.Length == 1 && content[0] is ServerException)
            {
                result.Exception = (ServerException)content[0];
            }
            else if (content.OfType <IReadOnlyItem>().Any())
            {
                foreach (var item in content.OfType <IReadOnlyItem>())
                {
                    result.AddReadOnly(item);
                }
            }
            else if (content.OfType <IEnumerable>().Any(e => e.OfType <IReadOnlyItem>().Any()))
            {
                foreach (var item in content.OfType <IEnumerable>().SelectMany(e => e.OfType <IReadOnlyItem>()))
                {
                    result.AddReadOnly(item);
                }
            }
            else if (content.Length == 1)
            {
                result.Value = LocalizationContext.Format(content[0]);
            }
            else
            {
                throw new NotSupportedException();
            }
            return(result);
        }