Exemplo n.º 1
0
 static void Main(string[] args)
 {
     using (var game = new TemplateClient())
     {
         game.Run();
     }
 }
        public override async Task RunAsync(CancellationToken cancellationToken)
        {
            string         keyVaultUri = GetEnvironmentVariable("KEYVAULT_URL");
            TemplateClient client      = new TemplateClient(keyVaultUri, new DefaultAzureCredential());

            while (!cancellationToken.IsCancellationRequested)
            {
                try
                {
                    // Throttle requests to avoid exceeding service limits
                    await Task.Delay(TimeSpan.FromMilliseconds(Options.Delay), cancellationToken);

                    Response <SecretBundle> secret = await client.GetSecretValueAsync(Options.SecretName, cancellationToken);

                    Interlocked.Increment(ref Metrics.SecretsReceived);

                    if (secret.Value.Value == "TestValue")
                    {
                        Interlocked.Increment(ref Metrics.CorrectValues);
                    }
                    else
                    {
                        Interlocked.Increment(ref Metrics.IncorrectValues);
                    }
                }
                catch (Exception e) when(ContainsOperationCanceledException(e))
                {
                }
                catch (Exception e)
                {
                    Metrics.Exceptions.Enqueue(e);
                }
            }
        }
Exemplo n.º 3
0
        public async Task CanGetSecret()
        {
            TemplateClient client = CreateClient();

            Response <SecretBundle> secret = await client.GetSecretValueAsync("TestSecret");

            Assert.AreEqual("Very secret value", secret.Value.Value);
        }
Exemplo n.º 4
0
 public TemplateIntegrationTest()
 {
     _templateClient = new TemplateClient(new HttpClient(),
                                          Options.Create(new TemplateApiSettings {
         Url = "http://localhost:50001"
     }),
                                          new MockTracer());
 }
        public void GettingASecret()
        {
            #region Snippet:Azure_Template_GetSecret
#if SNIPPET
            string endpoint   = "https://myvault.vault.azure.net";
            var    credential = new DefaultAzureCredential();
#else
            string endpoint   = TestEnvironment.KeyVaultUri;
            var    credential = TestEnvironment.Credential;
#endif
            var client = new TemplateClient(endpoint, credential);

            SecretBundle secret = client.GetSecretValue("TestSecret");

            Console.WriteLine(secret.Value);
            #endregion

            Assert.NotNull(secret.Value);
        }
Exemplo n.º 6
0
 static Program()
 {
     AreaClient = new AreaClient();
     //SourceClient = new SourceClient();
     TemplateClient = new TemplateClient();
 }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            bool exitLoop = false;

            while (!exitLoop)
            {
                Console.WriteLine();
                Console.WriteLine("Please type the number of type of design patterns to veiw");
                Console.WriteLine("0 - Exit");
                Console.WriteLine("1 - Creational");
                Console.WriteLine("2 - Structural");
                Console.WriteLine("3 - Behaivoral");

                ConsoleKeyInfo keyInfo = Console.ReadKey();
                Console.WriteLine();

                switch (keyInfo.KeyChar.ToString())
                {
                case "0":
                    exitLoop = true;
                    break;

                case "1":
                    while (!exitLoop)
                    {
                        Console.WriteLine("Please select Creational Pattern to demo:");
                        Console.WriteLine("0 - Exit");
                        Console.WriteLine("1 - Simple Factory");
                        Console.WriteLine("2 - Factory Method");
                        Console.WriteLine("3 - Abstract Factory");
                        Console.WriteLine("4 - Builder");
                        Console.WriteLine("5 - Fluent Interface");
                        Console.WriteLine("6 - Prototype");
                        Console.WriteLine("7 - Singleton");

                        keyInfo = Console.ReadKey();
                        Console.WriteLine();

                        switch (keyInfo.KeyChar.ToString())
                        {
                        case "0":
                            exitLoop = true;
                            break;

                        case "1":
                            SimpleFactoryClient simpleFactoryClient = new SimpleFactoryClient();
                            simpleFactoryClient.PrintSimpleFactory();
                            break;

                        case "2":
                            FactoryMethodClient factoryMethodClient = new FactoryMethodClient();
                            factoryMethodClient.PrintFactoryMethod();
                            break;

                        case "3":
                            AbstractFactoryClient abstractFactoryClient = new AbstractFactoryClient();
                            abstractFactoryClient.PrintAbstractFactory();
                            break;

                        case "4":
                            BuilderClient builderClient = new BuilderClient();
                            builderClient.PrintBuilder();
                            break;

                        case "5":
                            FluentInterfaceClient fluentInterfaceClient = new FluentInterfaceClient();
                            fluentInterfaceClient.PrintFluentInterface();
                            break;

                        case "6":
                            PrototypeClient prototypeClient = new PrototypeClient();
                            prototypeClient.PrintPrototype();
                            break;

                        case "7":
                            SingletonClient singletonClient = new SingletonClient();
                            singletonClient.PrintSingleton();
                            break;

                        default:
                            Console.WriteLine("Selection must be 0-7");
                            break;
                        }
                    }

                    exitLoop = false;
                    break;

                case "2":
                    while (!exitLoop)
                    {
                        Console.WriteLine("Please select Structural Pattern to demo:");
                        Console.WriteLine("0 - Exit");
                        Console.WriteLine("1 - Adapter");
                        Console.WriteLine("2 - Facade");
                        Console.WriteLine("3 - Decorator");
                        Console.WriteLine("4 - Bridge");
                        Console.WriteLine("5 - Composite");
                        Console.WriteLine("6 - Proxy");
                        Console.WriteLine("7 - Flyweight");

                        keyInfo = Console.ReadKey();
                        Console.WriteLine();

                        switch (keyInfo.KeyChar.ToString())
                        {
                        case "0":
                            exitLoop = true;
                            break;

                        case "1":
                            AdapterClient adapterClient = new AdapterClient();
                            adapterClient.PrintAdapter();
                            break;

                        case "2":
                            FacadeClient facadeClient = new FacadeClient();
                            facadeClient.PrintFacade();
                            break;

                        case "3":
                            DecoratorClient decoratorClient = new DecoratorClient();
                            decoratorClient.PrintDecorator();
                            break;

                        case "4":
                            BridgeClient bridgeClient = new BridgeClient();
                            bridgeClient.PrintBridge();
                            break;

                        case "5":
                            CompositeClient compositeClient = new CompositeClient();
                            compositeClient.PrintComposite();
                            break;

                        case "6":
                            ProxyClient proxyClient = new ProxyClient();
                            proxyClient.PrintProxy();
                            break;

                        case "7":
                            FlyweightClient flyweightClient = new FlyweightClient();
                            flyweightClient.PrintFlyweight();
                            break;

                        default:
                            Console.WriteLine("Selection must be 0-7");
                            break;
                        }
                    }

                    exitLoop = false;
                    break;

                case "3":
                    while (!exitLoop)
                    {
                        Console.WriteLine("Please select Behaivoral Pattern to demo:");
                        Console.WriteLine("0 - Exit");
                        Console.WriteLine("1 - Iterator");
                        Console.WriteLine("2 - Observer");
                        Console.WriteLine("3 - Chain Of Responsibility");
                        Console.WriteLine("4 - State");
                        Console.WriteLine("5 - Template");
                        Console.WriteLine("6 - Command");
                        Console.WriteLine("7 - Visitor");
                        Console.WriteLine("8 - Strategy");
                        Console.WriteLine("9 - Interpreter");
                        Console.WriteLine("10 - Mediator");
                        Console.WriteLine("11 - Memento");

                        string entered = Console.ReadLine();
                        Console.WriteLine();

                        switch (entered)
                        {
                        case "0":
                            exitLoop = true;
                            break;

                        case "1":
                            IteratorClient iteratorClient = new IteratorClient();
                            iteratorClient.PrintIterator();
                            break;

                        case "2":
                            ObserverClient observerClient = new ObserverClient();
                            observerClient.PrintObserver();
                            break;

                        case "3":
                            ChainOfResponsibilityClient chainOfResponsibilityClient = new ChainOfResponsibilityClient();
                            chainOfResponsibilityClient.PrintChainOfResponsibility();
                            break;

                        case "4":
                            StateClient stateClient = new StateClient();
                            stateClient.PrintState();
                            break;

                        case "5":
                            TemplateClient templateClient = new TemplateClient();
                            templateClient.PrintTemplate();
                            break;

                        case "6":
                            CommandClient commandClient = new CommandClient();
                            commandClient.PrintCommand();
                            break;

                        case "7":
                            VisitorClient visitorClient = new VisitorClient();
                            visitorClient.PrintVisitor();
                            break;

                        case "8":
                            StrategyClient strategyClient = new StrategyClient();
                            strategyClient.PrintStrategy();
                            break;

                        case "9":
                            InterpreterClient interpreterClient = new InterpreterClient();
                            interpreterClient.PrintInterpreter();
                            break;

                        case "10":
                            MediatorClient mediatorClient = new MediatorClient();
                            mediatorClient.PrintMediator();
                            break;

                        case "11":
                            MementoClient mementoClient = new MementoClient();
                            mementoClient.PrintMemento();
                            break;

                        default:
                            Console.WriteLine("Selection must be 0-11");
                            break;
                        }
                    }

                    exitLoop = false;
                    break;

                default:
                    Console.WriteLine("Must enter number 0 -3");
                    break;
                }
            }

            Console.WriteLine("End of Design Patterns examples");
            Console.WriteLine("Type any key to exit");
            Console.ReadKey();
        }
Exemplo n.º 8
0
        public TemplateClientTest(TemplateClientPerfOptions options) : base(options)
        {
            string keyVaultUri = GetEnvironmentVariable("KEYVAULT_URL");

            _templateClient = new TemplateClient(keyVaultUri, new DefaultAzureCredential());
        }
Exemplo n.º 9
0
        public void Test1()
        {
            var c = new TemplateClient(new Uri("http://localhost:3000/"));

            Assert.NotNull(c);
        }
Exemplo n.º 10
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="TemplateExamples" /> class.
 /// </summary>
 /// <param name="templateApi">The template api.</param>
 public TemplateExamples(TemplateClient templateApi) => this.templateApi = templateApi;
Exemplo n.º 11
0
 static Program()
 {
     TemplateClient = new TemplateClient();
     UserClient     = new UserClient();
 }
Exemplo n.º 12
0
        /// <summary>
        /// Gets the WFM Service Configured based on your requirements
        /// </summary>
        /// <param name="serviceType">The Service Type Required ("Client", "Contact" ...)</param>
        /// <returns>The Service, fully populated</returns>
        public static Object GetWcfSvc(string serviceType)
        {
            Uri             serviceUri;
            EndpointAddress endpointAddress;
            var             binding = BindingFactory.CreateInstance();
            object          service = null;

            string serviceBase = "http://modernpractice2013.cloudapp.net";

            if (DefaultRegion == "NZ")
            {
                serviceBase = "http://modernpractice2013-nz.cloudapp.net";
            }

            //serviceBase = "http://localhost:56019";

            switch (serviceType)
            {
            case "Client":
                serviceUri      = new Uri(serviceBase + "/ClientService.svc");
                endpointAddress = new EndpointAddress(serviceUri);
                service         = new ClientClient(binding, endpointAddress);
                break;

            case "Contact":
                serviceUri      = new Uri(serviceBase + "/ContactService.svc");
                endpointAddress = new EndpointAddress(serviceUri);
                service         = new ContactClient(binding, endpointAddress);
                break;

            case "CustomField":
                serviceUri      = new Uri(serviceBase + "/CustomFieldDefinitionService.svc");
                endpointAddress = new EndpointAddress(serviceUri);
                service         = new CustomFieldDefinitionClient(binding, endpointAddress);
                break;

            case "Invoice":
                serviceUri      = new Uri(serviceBase + "/InvoiceService.svc");
                endpointAddress = new EndpointAddress(serviceUri);
                service         = new InvoiceClient(binding, endpointAddress);
                break;

            case "Job":
                serviceUri      = new Uri(serviceBase + "/JobService.svc");
                endpointAddress = new EndpointAddress(serviceUri);
                service         = new JobClient(binding, endpointAddress);
                break;

            case "Lead":
                serviceUri      = new Uri(serviceBase + "/LeadService.svc");
                endpointAddress = new EndpointAddress(serviceUri);
                service         = new LeadClient(binding, endpointAddress);
                break;

            case "Quote":
                serviceUri      = new Uri(serviceBase + "/QuoteService.svc");
                endpointAddress = new EndpointAddress(serviceUri);
                service         = new QuoteClient(binding, endpointAddress);
                break;

            case "Task":
                serviceUri      = new Uri(serviceBase + "/TaskService.svc");
                endpointAddress = new EndpointAddress(serviceUri);
                service         = new TaskClient(binding, endpointAddress);
                break;

            case "Staff":
                serviceUri      = new Uri(serviceBase + "/StaffService.svc");
                endpointAddress = new EndpointAddress(serviceUri);
                service         = new StaffClient(binding, endpointAddress);
                break;

            case "Template":
                serviceUri      = new Uri(serviceBase + "/TemplateService.svc");
                endpointAddress = new EndpointAddress(serviceUri);
                service         = new TemplateClient(binding, endpointAddress);
                break;

            case "Cost":
                serviceUri      = new Uri(serviceBase + "/CostService.svc");
                endpointAddress = new EndpointAddress(serviceUri);
                service         = new CostClient(binding, endpointAddress);
                break;

            case "Supplier":
                serviceUri      = new Uri(serviceBase + "/SupplierService.svc");
                endpointAddress = new EndpointAddress(serviceUri);
                service         = new SupplierClient(binding, endpointAddress);
                break;

            case "PurchaseOrder":
                serviceUri      = new Uri(serviceBase + "/PurchaseOrderService.svc");
                endpointAddress = new EndpointAddress(serviceUri);
                service         = new PurchaseOrderClient(binding, endpointAddress);
                break;

            case "Time":
                serviceUri      = new Uri(serviceBase + "/TimeService.svc");
                endpointAddress = new EndpointAddress(serviceUri);
                service         = new SupplierClient(binding, endpointAddress);
                break;
            }
            return(service);
        }