コード例 #1
0
 protected override void OnMarshalInfoSet()
 {
     if (MarshalInfo == null)
     {
         IndirectDelegate = null;
     }
     else
     {
         // Create a delegate to the StartNew instance method.
         IndirectDelegate = (StartNew)Delegate.CreateDelegate(typeof(StartNew), MarshalInfo.Marshaller, MarshalInfo.MarshalMethod);
     }
 }
コード例 #2
0
        public Analyze Analyze(string host, Publish publish, StartNew startNew, FromCache fromCache, int?maxHours, All all, IgnoreMismatch ignoreMismatch)
        {
            var analyzeModel = new Analyze();

            // Checking host is valid before continuing
            if (!_urlValidation.IsValid(host))
            {
                analyzeModel.HasErrorOccurred = true;
                analyzeModel.Errors.Add(new Error {
                    message = "Host does not pass preflight validation. No Api call has been made."
                });
                return(analyzeModel);
            }

            // Building request model
            var requestModel = _requestModelFactory.NewAnalyzeRequestModel(ApiUrl, "analyze", host, publish.ToString().ToLower(), startNew.ToString().ToLower(),
                                                                           fromCache.ToString().ToLower(), maxHours, all.ToString().ToLower(), ignoreMismatch.ToString().ToLower());

            try
            {
                var webResponse = _apiProvider.MakeGetRequest(requestModel);
                analyzeModel = _responsePopulation.AnalyzeModel(webResponse, analyzeModel);
            }
            catch (Exception ex)
            {
                analyzeModel.HasErrorOccurred = true;
                analyzeModel.Errors.Add(new Error {
                    message = ex.ToString()
                });
            }

            // Checking if errors have occoured either from ethier api or wrapper
            if (analyzeModel.Errors.Count != 0 && !analyzeModel.HasErrorOccurred)
            {
                analyzeModel.HasErrorOccurred = true;
            }

            return(analyzeModel);
        }
コード例 #3
0
        public Analyze AutomaticAnalyze(string host, Publish publish, StartNew startNew, FromCache fromCache, int?maxHours, All all, IgnoreMismatch ignoreMismatch,
                                        int maxWaitInterval, int sleepInterval)
        {
            var startTime = DateTime.UtcNow;
            var sleepIntervalMilliseconds = sleepInterval * 1000;
            var apiPassCount = 1;
            var analyzeModel = Analyze(host, publish, startNew, fromCache, maxHours, all, ignoreMismatch);

            // Ignoring cache settings after first request to prevent loop
            startNew = StartNew.Ignore;

            // Shouldn't have to check status header as HasErrorOccurred should be enough
            while (analyzeModel.HasErrorOccurred == false && analyzeModel.status != "READY" && (DateTime.UtcNow - startTime).TotalSeconds < maxWaitInterval)
            {
                Thread.Sleep(sleepIntervalMilliseconds);
                apiPassCount++;
                analyzeModel = Analyze(host, publish, startNew, fromCache, null, all, ignoreMismatch);
            }

            analyzeModel.Wrapper.ApiPassCount = apiPassCount;

            return(analyzeModel);
        }
コード例 #4
0
        public Analyze Analyze(string host, Publish publish, StartNew startNew, FromCache fromCache, int? maxHours, All all, IgnoreMismatch ignoreMismatch)
        {
            var analyzeModel = new Analyze();

            // Checking host is valid before continuing
            if (!_urlValidation.IsValid(host))
            {
                analyzeModel.HasErrorOccurred = true;
                analyzeModel.Errors.Add(new Error { message = "Host does not pass preflight validation. No Api call has been made." });
                return analyzeModel;
            }

            // Building request model
            var requestModel = _requestModelFactory.NewAnalyzeRequestModel(ApiUrl, "analyze", host, publish.ToString().ToLower(), startNew.ToString().ToLower(),
                fromCache.ToString().ToLower(), maxHours, all.ToString().ToLower(), ignoreMismatch.ToString().ToLower());

            try
            {
                var webResponse = _apiProvider.MakeGetRequest(requestModel);
                analyzeModel = _responsePopulation.AnalyzeModel(webResponse, analyzeModel);
            }
            catch (Exception ex)
            {
                analyzeModel.HasErrorOccurred = true;
                analyzeModel.Errors.Add(new Error { message = ex.ToString() });
            }

            // Checking if errors have occoured either from ethier api or wrapper
            if (analyzeModel.Errors.Count != 0 && !analyzeModel.HasErrorOccurred) { analyzeModel.HasErrorOccurred = true; }

            return analyzeModel;
        }
コード例 #5
0
        public Analyze AutomaticAnalyze(string host, Publish publish, StartNew startNew, FromCache fromCache, int? maxHours, All all, IgnoreMismatch ignoreMismatch,
			int maxWaitInterval, int sleepInterval)
        {
            var startTime = DateTime.UtcNow;
            var sleepIntervalMilliseconds = sleepInterval * 1000;
            var apiPassCount = 1;
            var analyzeModel = Analyze(host, publish, startNew, fromCache, maxHours, all, ignoreMismatch);

            // Ignoring cache settings after first request to prevent loop
            startNew = StartNew.Ignore;

            // Shouldn't have to check status header as HasErrorOccurred should be enough
            while (analyzeModel.HasErrorOccurred == false && analyzeModel.status != "READY" && (DateTime.UtcNow - startTime).TotalSeconds < maxWaitInterval)
            {
                Thread.Sleep(sleepIntervalMilliseconds);
                apiPassCount++;
                analyzeModel = Analyze(host, publish, startNew, fromCache, null, all, ignoreMismatch);
            }

            analyzeModel.Wrapper.ApiPassCount = apiPassCount;

            return analyzeModel;
        }