Example #1
0
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            if (App.CurrentUser != null)
            {
                MW.GoToMenu(App.CurrentUser.RoleId);
                return;
            }

            var win = new AuthTypeWindow(MW);

            win.ShowDialog();
            ChosenType       = win.ChosenType;
            ChosenTypeString = Convert.ToString(ChosenType.ToString()[0]);

            //MessageBox.Show(ChosenTypeString);
        }
    static void Main()
    {
        ChosenType chosentype = RandomChosenType();     //A or B
        // Make an instance of the appropriate repo based on the mapping
        // to the enum value.
        // This is a moderately expensive call, and there's room for improvement
        // by using expression trees and caching lambda expressions.
        var repo = (IRepo)Activator.CreateInstance(
            ((RepoAttribute)typeof(ChosenType).GetMember(chosentype.ToString())
             .Single().GetCustomAttributes(typeof(RepoAttribute), false).Single()
            ).RepoType);
        var list = repo.GetAll();

        repo.SaveAll(list);
        Console.Read();
    }
 private void SetAuthType(ChosenType type)
 {
     ChosenType = type;
     Close();
 }