Пример #1
0
        public IEnumerable <string> SerializeMultiValue(CommandLineSerializer serializer, Type objType, object?obj)
        {
            var argList = new LinkedList <string>();

            if (obj is IList list)
            {
                foreach (var item in list)
                {
                    argList.AddLast(ImplUtil.MergeCommandLine(serializer.SerializeObject(item)));
                }
            }

            return(argList);
        }
        public string SerializeSingleValue(CommandLineSerializer serializer, Type objType, object?obj)
        {
            if (obj == null)
            {
                throw new ArgumentNullException(nameof(obj));
            }

            var memberSpecs = new MemberSpecs(objType);

            memberSpecs.Init();

            var argList = serializer.Serialize(memberSpecs, spec =>
            {
                memberSpecs.TryGetMember(spec, out var memberInfo);
                return(memberInfo.GetValue(obj));
            });

            return(ImplUtil.MergeCommandLine(argList));
        }