/// <summary> /// If properties on the given object contain default value attributes then this method will initalize those properties with /// the right defaults /// </summary> /// <param name="o">the object to initialize</param> public static void InitializeDefaults(object o) { if (o == null) { throw new ArgumentNullException("o cannot be null"); } var def = new CommandLineArgumentsDefinition(o.GetType()); var context = new ArgHook.HookContext(); context.Definition = def; context.Args = o; foreach (var arg in def.Arguments) { context.ArgumentValue = null; context.CurrentArgument = arg; context.RevivedProperty = null; if (arg.HasDefaultValue == false) { continue; } arg.Populate(context); } def.SetPropertyValues(o); }