Пример #1
0
 public void UpdateGin(Gin gin)
 {
     using (GinzContext context = new GinzContext())
     {
         context.Entry(context.Gins.Where(c => c.Id == gin.Id).First()).CurrentValues.SetValues(gin);
         context.SaveChanges();
     }
 }
Пример #2
0
 public void CreateGin(Gin gin)
 {
     using (GinzContext context = new GinzContext())
     {
         context.Gins.Add(gin);
         context.SaveChanges();
     }
 }
Пример #3
0
 public void DeleteGin(Gin gin)
 {
     using (GinzContext context = new GinzContext())
     {
         context.Gins.Remove(gin);
         context.SaveChanges();
     }
 }
Пример #4
0
 public void SetHelp(string programName, string argName, string argDescr, bool allowTemplates, Gin.Editors.ITemplatedEditor editor, List<ResultInfo> resultInfos)
 {
     labelHelpArgumentDescription.Text = argDescr;
     labelHelpArgumentName.Text = argName + "(" + programName + ")";
     listContextNames.Visible = allowTemplates;
     listContextNames.DataSource = resultInfos;
     listContextNames.Tag = editor;
 }
Пример #5
0
        public override Control Create(Gin.ExecutionContext context)
        {
            OSBBInstanceConfig val = (OSBBInstanceConfig)Value;

            _control = new SQLOSBBConnectionControl(context);
            SQLOSBBConnectionControl control = (SQLOSBBConnectionControl)_control;
            control.Value = val;
            return _control;
        }
Пример #6
0
        static void Main(string[] args)
        {
            var gin = new Gin();

            /* Confugure it for your needs
             * var gin = new Gin(
             *  addExitCommand:  true,
             *  addHelpCommand:  true,
             *  searchBehaviour: SearchCommandBehaviour.ScanAllSolutionAssemblies,
             *  logFileName:     null
             *  );
             */
            //Launches help command
            gin.Execute("help");
            //Launches console input loop
            gin.RunInputLoop();

            Console.WriteLine("Press any key to continue...");
        }
Пример #7
0
 public Gin GetGin(Gin gin)
 {
     throw new System.NotImplementedException();
 }
Пример #8
0
        static void Main(string[] args)
        {
            var scanner = new CommandScanner();

            //scan or append command types manualy here:
            //scanner.Registrate<myCommandType>();
            //or command singletone Instances
            //scanner.Registrate(new myCommand(myCommandSettings))

            //scan only executing assembly:
            scanner.ScanAssembly(Assembly.GetEntryAssembly());

            var gin = new Gin(
                library:  scanner,                       //Specify your own command library
                executor: new Executor(),                //(optional) specify your own command executor (do not forget to catch exceptions and attach the log to commands in it)
                log:      new DecoratorLog               //(optional) combine different logs
                (
                    new ConsoleLog(),
                    new FileLog(maxLogLength: 10000,
                                relativeFileName: "TheLog.txt",
                                writeFilter: FileLogFilter.All)
                ));

            gin.Log.WriteMessage("Gin lauched at " + DateTime.Now);

            //to switch log at runtime:
            //gin.Log = new ConsoleLog();
            if (!Environment.UserInteractive) //if it was launched as a service
            {
                gin.Log.WriteMessage("Executed as a service");
                //Do not forget to setup your service name at WindowsServiceInstaller.cs

                //and do whatever you want here as a service...

                //Will be executed at scheduler timer thread:
                gin.Execute("divide  a 10  b 5  at 02:00  every 24h");
                //You can use different argument styles and combine them
                //gin.Execute("divide a: 10  b: 5  at 02:00  every 24h");
                //gin.Execute("divide -a 10  -b 5  -at 02:00  every \"24h\"");

                //Will be executed at this thread:
                gin.Execute("writeHello");

                gin.WaitForFinsh();
            }
            else if (args.Length > 0)     // if it was launched with parameters:
            {
                gin.Execute(args);
                //close the application after operation will be done
            }
            else               // when it's executed as a console application:
            {
                gin.AddHelp(); // adds the \"help\" command
                gin.AddExit(); // adds the \"exit\" command

                gin.RunInputLoop();

                gin.Log.WriteMessage("Goodbye. Press any key to continue...");
                Console.ReadKey();
            }
        }
Пример #9
0
 public void Create(Gin gin)
 {
     _ginDatabase[gin.GinId] = gin;
 }
Пример #10
0
 public void Create(Gin gin)
 {
     _informationRepository.Create(gin);
 }
Пример #11
0
        public static void Main(string[] args)
        {
            // setting up localization, just in case
            var appLocale = ConfigurationManager.AppSettings.Get("appLocale");

            System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(appLocale);

            // declaring variables
            bool isProgramStarted = true;
            bool isCartEmpty      = true;

            int userCommandInput;
            int userQtyInput;

            // creating null objects for further work
            Beer   beer   = null;
            Wine   wine   = null;
            Vodka  vodka  = null;
            Gin    gin    = null;
            Cognac cognac = null;
            Whisky whisky = null;

            // saying hello to user
            Console.Clear();
            MessageLib.SayHello();
            Console.ReadKey();

            do
            {
                // showing menu to user
                Console.Clear();
                MessageLib.Menu();

                // accepting and validating input from user
                ParseUserInputToInt(true, out userCommandInput);

                switch (userCommandInput)
                {
                // adding beer to cart
                case (int)MenuActions.AddBeer:
                    MessageLib.AskHowMuchBottles();
                    ParseUserInputToInt(false, out userQtyInput);

                    beer = new Beer(userQtyInput);

                    isCartEmpty = false;

                    break;

                // adding wine to cart
                case (int)MenuActions.AddWine:
                    MessageLib.AskHowMuchBottles();
                    ParseUserInputToInt(false, out userQtyInput);

                    wine = new Wine(userQtyInput);

                    isCartEmpty = false;

                    break;

                // adding vodka to cart
                case (int)MenuActions.AddVodka:
                    MessageLib.AskHowMuchBottles();
                    ParseUserInputToInt(false, out userQtyInput);

                    vodka = new Vodka(userQtyInput);

                    isCartEmpty = false;

                    break;

                // adding gin to cart
                case (int)MenuActions.AddGin:
                    MessageLib.AskHowMuchBottles();
                    ParseUserInputToInt(false, out userQtyInput);

                    gin = new Gin(userQtyInput);

                    isCartEmpty = false;

                    break;

                // adding cognac to cart
                case (int)MenuActions.AddCognac:
                    MessageLib.AskHowMuchBottles();
                    ParseUserInputToInt(false, out userQtyInput);

                    cognac = new Cognac(userQtyInput);

                    isCartEmpty = false;

                    break;

                // adding whisky to cart
                case (int)MenuActions.AddWhisky:
                    MessageLib.AskHowMuchBottles();
                    ParseUserInputToInt(false, out userQtyInput);

                    whisky = new Whisky(userQtyInput);

                    isCartEmpty = false;

                    break;

                // showing user his cart
                case (int)MenuActions.ShowCart:

                    // if cart is empty show user appropriate message
                    if (isCartEmpty)
                    {
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.WriteLine("\nYour cart is empty!");
                        Console.ResetColor();

                        Console.WriteLine("\nPress any key to return to menu...");
                        Console.ReadKey();

                        break;
                    }

                    // otherwise user's cart will be processed and shown
                    Inventory.ShowInventory(beer, wine, vodka, gin, cognac, whisky);

                    Console.WriteLine("\nPress any key to return to menu...");
                    Console.ReadKey();

                    break;

                // exiting the program
                case (int)MenuActions.Exit:
                    MessageLib.SayGoodbye();

                    isProgramStarted = false;

                    break;

                // otherwise throw an error
                default:
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.Write("\nInvalid input! Please try again: ");
                    Console.ResetColor();

                    break;
                }
            }while (isProgramStarted);
        }