public object?DeserializeObject( Type objType, string commandLine, out LinkedList <string> remainArgs) { remainArgs = new LinkedList <string>(ImplUtil.SplitCommandLine(commandLine)); return(DeserializeObject(objType, remainArgs)); }
private ISpec _GenerateSpec(MemberInfo memberInfo, SpecAttribute?attr) { var objType = (memberInfo is PropertyInfo propertyInfo) ? propertyInfo.PropertyType : ((FieldInfo)memberInfo).FieldType; var defaultValueType = ImplUtil.GetDefaultValueType(objType); return(attr != null? ImplUtil.GenerateSpecByAttribute(attr, objType, memberInfo.Name, defaultValueType, null) : new Option(memberInfo.Name, defaultValueType, objType, memberInfo.Name)); }
public object?DeserializeSingleValue(CommandLineSerializer serializer, Type objType, string?value) { if (string.IsNullOrWhiteSpace(value)) { return(null); } var argList = ImplUtil.SplitCommandLine(value); return(serializer.DeserializeObject(objType, argList)); }
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)); }