static void Main()
        {
            Console.WriteLine("Type 1 for Personal expense:");
            Console.WriteLine("Type 2 for Travel expense:");
            Console.WriteLine("Type any number for Health expense:");
            string input = Console.ReadLine();

            CheckFactory checkFactory = new CheckFactory();
            CheckBook currentExpense = checkFactory.ChooseExpense(int.Parse(input));
            Console.WriteLine("Call from parent class " + currentExpense.GetExpense());
        }
예제 #2
0
        /// <summary>

        /// Submission constructor

        /// </summary>

        /// <param name="session">Current session</param>

        /// <param name="candidate">Candidate to work with</param>
        internal Submission(HunterSession session, SubmissionCandidate candidate)
        {
            // Assign references
            _session   = session;
            _candidate = candidate;

            // Assign Defaults
            FirstName           = string.Empty;
            LastName            = string.Empty;
            StudentID           = string.Empty;
            ContentLength       = 0;
            ContentHash         = string.Empty;
            Content             = string.Empty;
            MetaLastModifiedBy  = string.Empty;
            MetaCreator         = string.Empty;
            MetaUsername        = string.Empty;
            MetaDateLastPrinted = DateTime.MinValue;
            MetaDateModified    = DateTime.MinValue;
            MetaDateCreated     = DateTime.MinValue;

            // Create our relative path based on the working directory (just remove it and add a directory character)
            _relativePath = AbsolutePath.Replace(session.WorkingDirectory, string.Empty);

            DetectName();

            // Figure out the processor
            _processor = candidate.FileType.CreateProcessor(this);

            // Do a quick check of the meta data filling out some of our details
            if (Processor != null)
            {
                Processor.Process();
            }

            // Check Processor
            if (!Processor.IsProcessed())
            {
                _session.Log.Add("- " + Markdown.Emphasis("Unable to process this submission. Please confirm that it is a supported file type."));
            }

            // Create Checks
            _checks = CheckFactory.CreateChecks(this, Processor.GetCheckTypes());



            // Create simple ID

            _guidHash = Core.Compare.Hash(_candidate.Guid.ToString()).Substring(0, 6);
        }
예제 #3
0
        public void Start()
        {
            if (Fiddler.FiddlerApplication.IsStarted())
            {
                throw new WaspToucherException("Passive listener has already started");
            }

            checkList = CheckFactory.GetPassiveChecks(configuration.Compliance);

            Fiddler.FiddlerApplication.Log.OnLogString      += new EventHandler <Fiddler.LogEventArgs>(Log_OnLogString);
            Fiddler.FiddlerApplication.OnNotification       += new EventHandler <Fiddler.NotificationEventArgs>(FiddlerApplication_OnNotification);
            Fiddler.FiddlerApplication.AfterSessionComplete += new Fiddler.SessionStateHandler(FiddlerApplication_AfterSessionComplete);
            Fiddler.FiddlerApplication.Startup(configuration.ListenProxyPort, true, true, true);

            logger.Info("Proxy listening on port {0}", configuration.ListenProxyPort);
        }
        /// <summary>
        /// 工厂代码存在Check
        /// </summary>
        private void ruleFactoryExist_CustomValidationMethod(object sender, CustomValidationEventArgs e)
        {
            CheckFactory check = new CheckFactory();

            this.lblFactoryNm.Text = "";
            TFactoryMs vo = check.Check01Vo(this.atxtFactoryCd.Text);

            if (vo != null && !String.IsNullOrEmpty(vo.IFacCd))
            {
                e.IsValid = true;
                this.lblFactoryNm.Text = vo.IFacArgDesc;
            }
            else
            {
                e.IsValid = false;
            }
        }
예제 #5
0
        public void Registered_At_CheckFactory()
        {
            var checkType = typeof(RequiredCheck);
            var settings  = new Dictionary <string, string>();

            var sut = new CheckFactory();

            var checkDefinition = new CheckDefinition {
                Type = "required", Settings = settings
            };

            var check = sut.CreateCheck(checkDefinition, new FieldDefinition {
                Key = "key1"
            });

            check.Should().NotBeNull();
            check.Should().BeOfType(checkType);
        }
        public void Registered_At_CheckFactory()
        {
            var settings = new Dictionary <string, string> {
                { "Min", "2" }, { "Max", "6" }
            } as IDictionary <string, string>;
            var checkType = typeof(StringLengthCheck);

            var sut = new CheckFactory();

            var checkDefinition = new CheckDefinition {
                Type = "length", Settings = settings
            };
            var check = sut.CreateCheck(checkDefinition, new FieldDefinition {
                Key = "key1"
            });

            check.Should().NotBeNull();
            check.Should().BeOfType(checkType);
        }
        public void Install(IServiceCollection services, IConfigurationRoot configuration)
        {
            // health checks
            // telemetry recorder
            string instrumentationKey = configuration["ApplicationInsights:InstrumentationKey"];
            string endpointAddress    = configuration["ApplicationInsights:EndpointAddress"];

            if (!string.IsNullOrEmpty(instrumentationKey) && !string.IsNullOrEmpty(endpointAddress))
            {
                TelemetryConfiguration telemetryConfiguration = new TelemetryConfiguration(instrumentationKey, new InMemoryChannel {
                    EndpointAddress = endpointAddress
                });
                TelemetryClient telemetryClient = new TelemetryClient(telemetryConfiguration);
                services.AddSingleton(telemetryClient);
                services.AddTransient <IAvailabilityRecorder, ApplicationInsightsRecorder>();
            }
            else
            {
                services.AddTransient <IAvailabilityRecorder, NullRecorder>();
            }

            // configuration
            services.AddSingleton(configuration.GetSection("HealthCheckHostedService").Get <HealthCheckServiceConfiguration>());
            services.AddSingleton(configuration.GetSection("Build").Get <BuildModel>());

            // checks
            services.AddTransient <UrlCheck>();
            services.AddTransient <DbContextCheck>();
            services.AddTransient <ExampleCheck>();

            // check factory and hosted service
            services.AddSingleton(sp => {
                var cache         = sp.GetService <IMemoryCache>();
                var logger        = sp.GetService <ILogger <Check> >();
                var recorder      = sp.GetService <IAvailabilityRecorder>();
                var configuration = sp.GetService <IConfiguration>();

                var factory = new CheckFactory(cache, logger, recorder, sp, configuration);
                factory.RegisterCheck("example", typeof(ExampleCheck));
                return(factory as ICheckFactory);
            });
            services.AddHostedService <HealthCheckHostedService>();
        }
예제 #8
0
        public void ShouldResolveUrlCheck()
        {
            // assert
            var cache         = new Mock <IMemoryCache>();
            var logger        = new Mock <ILogger <Check> >();
            var recorder      = new Mock <IAvailabilityRecorder>();
            var configuration = new Mock <IConfiguration>();
            var sp            = serviceCollection.BuildServiceProvider();
            var factory       = new CheckFactory(cache.Object, logger.Object, recorder.Object, sp, configuration.Object);

            // act
            var config = new CheckConfiguration()
            {
                Name = "foo", Type = "url"
            };
            var check = factory.Create(config);

            // assert
            check.Should().NotBeNull();
        }
예제 #9
0
        public void Registered_At_CheckFactory()
        {
            var settings =
                new Dictionary <string, string>
            {
                { "Hint", "this is the hint" }, { "RegEx", "false|true" }
            } as IDictionary <string, string>;
            var checkType = typeof(StringRegExCheck);

            var sut = new CheckFactory();

            var checkDefinition = new CheckDefinition {
                Type = "regex", Settings = settings
            };
            var check = sut.CreateCheck(checkDefinition, new FieldDefinition {
                Key = "key1"
            });

            check.Should().NotBeNull();
            check.Should().BeOfType(checkType);
        }
예제 #10
0
        public void ShouldResolveUnresolvedCheckForUnregisteredType()
        {
            // assert
            var cache         = new Mock <IMemoryCache>();
            var logger        = new Mock <ILogger <Check> >();
            var recorder      = new Mock <IAvailabilityRecorder>();
            var configuration = new Mock <IConfiguration>();
            var sp            = serviceCollection.BuildServiceProvider();
            var factory       = new CheckFactory(cache.Object, logger.Object, recorder.Object, sp, configuration.Object);

            factory.RegisterCheck("foo", typeof(HealthCheck));

            // act
            var config = new CheckConfiguration()
            {
                Name = "foo", Type = "foo"
            };
            var check = factory.Create(config);

            // assert
            check.Should().NotBeNull();
            check.Should().BeOfType(typeof(UnresolvedCheck));
        }
예제 #11
0
        /// <summary>
        /// 工厂代码存在Check
        /// </summary>
        private void ruleFactoryExit_CustomValidationMethod(object sender, CustomValidationEventArgs e)
        {
            CheckFactory check = new CheckFactory();

            e.IsValid = check.Check01Bool(this.txtFactory.Text);
        }