Last active
December 29, 2015 05:49
-
-
Save akfish/7624307 to your computer and use it in GitHub Desktop.
Reflection utility mock up
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Define a class | |
[FormValidator(typeof(AccountValidator))] | |
[FormHandler(typeof(AccountHandler))] | |
[FormSection(0, "Basic Information")] | |
[FormSection(1, "Connection Settings")] | |
public class Account | |
{ | |
[FormEntry(Section = 0, Step = 0)] | |
public string Email { get; set; } | |
[FormEntry(Section = 0, Step = 1)] | |
public string Password { get; set; } | |
[FormEntry(Section = 1, Step = 0)] | |
public string UserName { get; set; } | |
[FormEntry(Section = 1, Step = 1)] | |
public string HostName { get; set; } | |
[FormEntry(Section = 1, Step = 2)] | |
public int Port { get; set; } | |
[FormEntry(Section = 1, Step = 3)] | |
public bool UseSSL { get; set; } | |
[FormEntry(Section = 1, Step = 4)] | |
public AuthMethod AuthMethod { get; set; } | |
[FormEntry(Section = 1, Step = 5)] | |
public bool IsPrimary { get; set; } | |
} | |
// Make an instance | |
var account = new Acccount(); | |
// Call injection extension | |
account.Inject<FormEntry>( | |
(target) => | |
{ | |
// target.Attribute | |
Cs.Write("Input {0}:", target.Name); | |
var line = Cs.ReadLine(); | |
return Convert(line); | |
}); | |
// Event | |
account | |
.BeforeSet<AccountValidator>( | |
(target, validator) => | |
{ | |
// TODO: validate target | |
}) | |
.AfterSet<AccountHandler>( | |
(target, handler) => | |
{ | |
// TODO: update handler | |
}) | |
.Inject<FormEntry>( | |
(target) => | |
{ | |
// TODO: same as before | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var account = new Account(); | |
var validator = new AccountValidator(); | |
account.Map<validator>( | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment