Ejemplo n.º 1
0
        public static MessageResult Validate(SaveSpansArgs args)
        {
            var result = MessageResult.FailResult(string.Empty);

            if (args == null)
            {
                result.Message = "参数不能为空";
                return(result);
            }

            if (args.Items == null)
            {
                result.Message = "Items不能为空";
                return(result);
            }

            if (args.Items.Count == 0)
            {
                result.Message = "Items数量不能为0";
                return(result);
            }


            foreach (var clientSpan in args.Items)
            {
                var validateSave = clientSpan.ValidateSave(true);
                if (!validateSave.Success)
                {
                    return(validateSave);
                }
            }

            result.Success = true;
            return(result);
        }
Ejemplo n.º 2
0
        public static SaveSpansArgs Create(params IClientSpan[] clientSpans)
        {
            var spans = new List <ClientSpan>();

            foreach (var someImpl in clientSpans)
            {
                if (someImpl == null)
                {
                    continue;
                }

                if (someImpl is ClientSpan)
                {
                    spans.Add((ClientSpan)someImpl);
                }
                else
                {
                    var clientSpan = new ClientSpan();
                    MyModelHelper.SetProperties(clientSpan, someImpl);
                    spans.Add(clientSpan);
                }
            }

            var saveSpansArgs = new SaveSpansArgs {
                Items = spans
            };

            return(saveSpansArgs);
        }