/*============================================================================*/
        /* Private Functions                                                           */
        /*============================================================================*/

        private void HandleContextView(object contextView)
        {
            if (_contextView != null)
            {
                return;
            }
            IContextView castContextView = contextView as IContextView;

            if (castContextView == null)
            {
                return;
            }

            _contextView = castContextView;

            if (_contextViewStateWatcher != null)
            {
                _logger.Warn("A IViewStateWatcher on the context view has already been set");
                return;
            }

            if (!_context.injector.HasDirectMapping(typeof(IViewStateWatcher)))
            {
                _logger.Info("No ViewStateWatcherExtension has been found yet. We will check again at the end of the contextview Configuration");
                _context.AddConfigHandler(new InstanceOfMatcher(typeof(IContextView)), HandleViewStateWatcher);
                return;
            }
            else
            {
                HandleViewStateWatcher(_context.injector.GetInstance(typeof(IViewStateWatcher)));
            }
        }
示例#2
0
        private Stream ProcessRanges(IResponse rangedResponse, ref HttpCode status)
        {
            var responseBody  = rangedResponse.Body;
            var contentLength = GetContentLengthFromStream(responseBody);

            try {
                string ar;
                if (status != HttpCode.Ok && contentLength > 0 ||
                    !headers.TryGetValue("Range", out ar))
                {
                    return(responseBody);
                }
                var m = bytes.Match(ar);
                if (!m.Success)
                {
                    throw new InvalidDataException("Not parsed!");
                }
                var totalLength = contentLength;
                var start       = 0L;
                var end         = totalLength - 1;
                if (!long.TryParse(m.Groups[1].Value, out start) || start < 0)
                {
                    throw new InvalidDataException("Not parsed");
                }
                if (m.Groups.Count != 3 ||
                    !long.TryParse(m.Groups[2].Value, out end) ||
                    end <= start || end >= totalLength)
                {
                    end = totalLength - 1;
                }
                if (start >= end)
                {
                    responseBody.Close();
                    rangedResponse = Error416.HandleRequest(this);
                    return(rangedResponse.Body);
                }

                if (start > 0)
                {
                    responseBody.Seek(start, SeekOrigin.Current);
                }
                contentLength = end - start + 1;
                rangedResponse.Headers["Content-Length"] = contentLength.ToString();
                rangedResponse.Headers.Add(
                    "Content-Range",
                    String.Format("bytes {0}-{1}/{2}", start, end, totalLength)
                    );
                status = HttpCode.Partial;
            }
            catch (Exception ex) {
                _logger.Warn(String.Format(
                                 "{0} - Failed to process range request!", this), ex);
            }
            return(responseBody);
        }
示例#3
0
 public SoundVO GetSoundEffect(string name)
 {
     foreach (SoundVO sound in soundEffects)
     {
         if (sound.name == name)
         {
             return(sound);
         }
     }
     logger.Warn("Could not find sound effect: '{0}'", name);
     return(NULL_SOUND);
 }
        /*============================================================================*/
        /* Private Functions                                                           */
        /*============================================================================*/

        private void HandleContextView(object contextView)
        {
            if (_contextView != null)
            {
                return;
            }
            IContextView castContextView = contextView as IContextView;

            if (castContextView == null)
            {
                return;
            }
            _contextView = castContextView;

            if (_injector.HasDirectMapping(typeof(IViewStateWatcher)))
            {
                return;
            }
            IViewStateWatcher viewStateWatcher = GetViewStateWatcher(_contextView.view);

            if (viewStateWatcher == null)
            {
                _logger.Warn("Unable to create View State Watcher.");
                return;
            }
            _injector.Map(typeof(IViewStateWatcher)).ToValue(viewStateWatcher);
        }
示例#5
0
        public async Task DeleteRoles()
        {
            var _rowsAffected = 0;
            var _errorTitle   = "UserManagementApi:DeleteRoles";

            try
            {
                await Task.Run(() =>
                {
                    using (IDbConnection db = new SqlConnection(ConnectionString))
                    {
                        if (db.State == ConnectionState.Closed)
                        {
                            db.Open();
                        }

                        _rowsAffected = db.Execute(SqlQueries.DeleteRoles_Sql, null);
                        if (_rowsAffected <= 0)
                        {
                            _logging.Warn(_errorTitle, "no rows were affected during roles deletion");
                        }
                    }
                });
            }
            catch (Exception ex)
            {
                _logging.Error(_errorTitle, ex.ToString());
            }
        }
示例#6
0
        public async Task Execute(BundleInfo info)
        {
            var path = Path.Combine(settings.BasePath, info.Path);

            if (bundles.Has(info.Id))
            {
                return;
            }

            var request = UnityWebRequestAssetBundle.GetAssetBundle(path);

            //log.Trace("REQUEST " + path);

            await request.SendWebRequest();

            var hasError = request.isHttpError || request.isNetworkError;

            if (hasError)
            {
                log.Warn("no bundle at " + path);
                return;
            }

            var bundle = DownloadHandlerAssetBundle.GetContent(request);

            bundles.Store(info.Id, bundle);

            info.Scenes?.Each(name => scenes.Load(name));
        }
示例#7
0
        private void ReceiveCallback(IAsyncResult result)
        {
            try {
                var endpoint = new IPEndPoint(IPAddress.None, SSDP_PORT);
                var received = client.EndReceive(result, ref endpoint);
                if (received == null)
                {
                    throw new IOException("Didn't receive anything");
                }
                if (received.Length == 0)
                {
                    throw new IOException("Didn't receive any bytes");
                }
#if DUMP_ALL_SSDP
                DebugFormat("{0} - SSDP Received a datagram", endpoint);
#endif
                using (var reader = new StreamReader(
                           new MemoryStream(received), Encoding.ASCII)) {
                    var proto = reader.ReadLine();
                    if (proto == null)
                    {
                        throw new IOException("Couldn't read protocol line");
                    }
                    proto = proto.Trim();
                    if (string.IsNullOrEmpty(proto))
                    {
                        throw new IOException("Invalid protocol line");
                    }
                    var method  = proto.Split(new char[] { ' ' }, 2)[0];
                    var headers = new Headers();
                    for (var line = reader.ReadLine(); line != null;
                         line = reader.ReadLine())
                    {
                        line = line.Trim();
                        if (string.IsNullOrEmpty(line))
                        {
                            break;
                        }
                        var parts = line.Split(new char[] { ':' }, 2);
                        headers[parts[0]] = parts[1].Trim();
                    }
#if DUMP_ALL_SSDP
                    DebugFormat("{0} - Datagram method: {1}", endpoint, method);
                    Debug(headers);
#endif
                    if (method == "M-SEARCH")
                    {
                        RespondToSearch(endpoint, headers["st"]);
                    }
                }
            }
            catch (IOException ex) {
                _logger.Debug("Failed to read SSDP message", ex);
            }
            catch (Exception ex) {
                _logger.Warn("Failed to read SSDP message", ex);
            }
            Receive();
        }
示例#8
0
 public void extension_throws_for_WARNING()
 {
     Assert.Throws(typeof(VigilantException), new TestDelegate(() =>
     {
         logger.Warn("");
     }
                                                               ));
 }
        /*============================================================================*/
        /* Public Functions                                                           */
        /*============================================================================*/

        public void Configure()
        {
            if (registry.FallbackBinding != null)
            {
                logger.Warn("The fallback container has already been set in the registry");
            }

            viewManager.SetFallbackContainer(new object());
        }
        /*============================================================================*/
        /* Private Functions                                                          */
        /*============================================================================*/

        private void AddContextView(object contextViewObject)
        {
            IContextView contextView = contextViewObject as IContextView;

            if (!(contextView.view is UnityEngine.Transform))
            {
                _logger.Warn("Cannot map {0} as Transform for the ContextViewTransformExtension to work. Try to configure with 'new TransformContextView(transform)'", contextView.view);
                return;
            }

            if (_injector.HasDirectMapping(typeof(UnityEngine.Transform)))
            {
                _logger.Warn("A Transform has already been mapped, ignoring {0}", contextView.view);
                return;
            }

            _logger.Debug("Mapping {0} as Transform", contextView.view);
            _injector.Map(typeof(UnityEngine.Transform)).ToValue(contextView.view);
        }
示例#11
0
        public bool DeleteJob(Guid jobCorrelationId)
        {
            if (jobCorrelationId == Guid.Empty)
            {
                throw new ArgumentOutOfRangeException(nameof(jobCorrelationId), "Specified jobCorrelationId is invalid");
            }

            var res = _repository.DeleteJob(jobCorrelationId);

            if (res)
            {
                _logging.Info($"Job {jobCorrelationId} deleted");
            }
            else
            {
                _logging.Warn($"Failed to delete job {jobCorrelationId}");
            }
            return(res);
        }
 public IContext AddChild(IContext child)
 {
     if (!_children.Contains(child))
     {
         _logger.Info("Adding child context {0}", new object[] { child });
         if (!child.Uninitialized)
         {
             _logger.Warn("Child context {0} must be uninitialized", new object[] { child });
         }
         if (child.injector.parent != null)
         {
             _logger.Warn("Child context {0} must not have a parent Injector", new object[] { child });
         }
         _children.Add(child);
         child.injector.parent = injector;
         child.POST_DESTROY   += OnChildDestroy;
     }
     return(this);
 }
        public void ReadCommands()
        {
            if (!FileExits())
            {
                loggingService.Warn($"FileCommandParser->ReadCommands() : {filePath} does not exists.");
                return;
            }

            var lineCommands = new string[] { };

            try
            {
                lineCommands = File.ReadAllLines(filePath);
            }
            catch (IOException ex)
            {
                loggingService.Warn($"FileCommandParser->ReadCommands() : {ex.Message}");
            }

            ParseCommands(lineCommands);
        }
示例#14
0
 private void OverwriteMapping(ICommandMapping oldMapping, ICommandMapping newMapping)
 {
     if (_logger != null)
     {
         _logger.Warn("{0} already mapped to {1}\n" +
                      "If you have overridden this mapping intentionally you can use 'unmap()' " +
                      "prior to your replacement mapping in order to avoid seeing this message.\n",
                      new object[] { _trigger, oldMapping });
     }
     DeleteMapping(oldMapping);
     StoreMapping(newMapping);
 }
 private IViewProcessorMappingConfig OverwriteMapping(IViewProcessorMapping mapping, object processClassOrInstance)
 {
     if (_logger != null)
     {
         _logger.Warn("{0} is already mapped to {1}.\n" +
                      "If you have overridden this mapping intentionally you can use 'unmap()' " +
                      "prior to your replacement mapping in order to avoid seeing this message.\n",
                      _matcher, mapping);
     }
     DeleteMapping(mapping);
     return(CreateMapping(processClassOrInstance));
 }
示例#16
0
 private IMediatorConfigurator OverwriteMapping(IMediatorMapping mapping)
 {
     if (_logger != null)
     {
         _logger.Warn("{0} already mapped to {1}\n" +
                      "If you have overridden this mapping intentionally you can use 'unmap()' " +
                      "prior to your replacement mapping in order to avoid seeing this message.\n",
                      _typeFilter, mapping);
     }
     DeleteMapping(mapping);
     return(CreateMapping(mapping.MediatorType));
 }
示例#17
0
        /*============================================================================*/
        /* Private Functions                                                           */
        /*============================================================================*/

        private void AddContextView(object contextViewObject)
        {
            IContextView contextView = contextViewObject as IContextView;

            if (!HasContextBinding())
            {
                _logger.Debug("Mapping {0} as contextView", contextView.view);
                _injector.Map(typeof(IContextView)).ToValue(contextView);
            }
            else
            {
                _logger.Warn("A contextView has already been installed, ignoring {0}", contextView.view);
            }
        }
示例#18
0
        /*============================================================================*/
        /* Private Functions                                                          */
        /*============================================================================*/

        private void AfterInitializing()
        {
            _containerRegistry = _injector.GetInstance(typeof(ContainerRegistry)) as ContainerRegistry;
            if (!_injector.HasDirectMapping(typeof(IStageCrawler)))
            {
                _logger.Warn("No CrawlerConfig configured. Make sure to configure a platform specific stage crawler config, or don't install the StageCrawler extension");
                return;
            }
            if (_injector.HasDirectMapping(typeof(IViewManager)))
            {
                ScanViewManagedContainers();
            }
            else
            {
                ScanContextView();
            }
        }
示例#19
0
        public virtual void TestLoggingLevels()
        {
            IList    methodsCalled = SetRootInterceptor();
            ILogging logger        = Logger.Get(typeof(LoggingTestCase.ITestLogger));

            ((LoggingTestCase.ITestLogger)logger.Trace()).Msg();
            ((LoggingTestCase.ITestLogger)logger.Debug()).Msg();
            ((LoggingTestCase.ITestLogger)logger.Info()).Msg();
            ((LoggingTestCase.ITestLogger)logger.Warn()).Msg();
            ((LoggingTestCase.ITestLogger)logger.Error()).Msg();
            ((LoggingTestCase.ITestLogger)logger.Fatal()).Msg();
            Assert.AreEqual(Pair.Of(Logger.Trace, "msg"), ((Pair)PopFirst(methodsCalled)));
            Assert.AreEqual(Pair.Of(Logger.Debug, "msg"), ((Pair)PopFirst(methodsCalled)));
            Assert.AreEqual(Pair.Of(Logger.Info, "msg"), ((Pair)PopFirst(methodsCalled)));
            Assert.AreEqual(Pair.Of(Logger.Warn, "msg"), ((Pair)PopFirst(methodsCalled)));
            Assert.AreEqual(Pair.Of(Logger.Error, "msg"), ((Pair)PopFirst(methodsCalled)));
            Assert.AreEqual(Pair.Of(Logger.Fatal, "msg"), ((Pair)PopFirst(methodsCalled)));
        }
示例#20
0
        public TranscodingJobState UpdateProgress(TaskProgressModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            if (!ModelState.IsValid)
            {
                throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }
            if (model.Failed)
            {
                _logging.Warn($"Task {model.Id} failed at {model.MachineName}");
            }
            if (model.Done)
            {
                _logging.Info($"Task {model.Id} done at {model.MachineName}");
            }
            return(_repository.SaveProgress(model.Id, model.Failed, model.Done, model.Progress, model.VerifyProgress, model.MachineName));
        }
示例#21
0
 public void extension_throws_for_WARNING()
 {
     logger.Warn("");
 }
示例#22
0
 public void Warn(string message, params object[] args)
 {
     logger?.Warn(string.Format(message, args));
 }