Deveel.Configuration.ReflectedOptions.SetToObject C# (CSharp) Method

SetToObject() public static method

public static SetToObject ( Options options, ICommandLine cmdLine, object obj ) : void
options Options
cmdLine ICommandLine
obj object
return void
        public static void SetToObject(Options options, ICommandLine cmdLine, object obj)
        {
            if (obj == null)
                return;

            var type = obj.GetType();
            MemberInfo[] members = type.FindMembers(MemberTypes.Field | MemberTypes.Property,
                                        BindingFlags.Public | BindingFlags.Instance,
                                        FilterMember, null);

            foreach (var member in members) {
                SetOptionsToMember(member, options, cmdLine);
            }
        }

Usage Example

Ejemplo n.º 1
0
        public static object ParseObject(this ICommandLineParser parser, Type type, Options options, string[] args, bool stopAtNotOption)
        {
            var commandLine = parser.Parse(options, args, stopAtNotOption);
            var obj         = Activator.CreateInstance(type, true);

            ReflectedOptions.SetToObject(options, commandLine, obj);
            return(obj);
        }