コード例 #1
0
        /// <summary>
        /// Finds object by name.
        /// </summary>
        /// <typeparam name="T">Type of object (TexturedObject, GameObject etc.)</typeparam>
        public static T Get <T>(string name) where T : RenderableObject
        {
            lock (All)
                foreach (RenderableObject o in All)
                {
                    if (o.Name == name && o is T)
                    {
                        return((T)o);
                    }
                }
            Exception ex = new ObjectException("Could not find object \"" + name + "\" with type \"" + typeof(T).FullName + "\"");

            Log.Exception(ex);
            throw ex;
        }
コード例 #2
0
        /// <summary>
        /// Finds object by name
        /// </summary>
        public static RenderableObject Get(string name)
        {
            lock (All)
                foreach (RenderableObject o in All)
                {
                    if (o.Name == name)
                    {
                        return(o);
                    }
                }
            Exception ex = new ObjectException("Could not find object \"" + name + "\"");

            Log.Exception(ex);
            throw ex;
        }
コード例 #3
0
        private RenderableObject findByID(uint id)
        {
            lock (All)
                foreach (RenderableObject o in All)
                {
                    if (o.ID == id)
                    {
                        return(o);
                    }
                }
            Exception ex = new ObjectException("Could not find object with ID " + id);

            Log.Exception(ex);
            throw ex;
        }
コード例 #4
0
ファイル: AbstractHttpAction.cs プロジェクト: liuguiyou/FclEx
        protected override async ValueTask <ActionEvent> ExecuteInternalAsync(CancellationToken token)
        {
            if (token.IsCancellationRequested)
            {
                return(await NotifyCancelEventAsync().DonotCapture());
            }

            HttpReq req = null;

            try
            {
                req = BuildRequest();
                var response = await HttpService.ExecuteAsync(req, token).DonotCapture();

                PreCheckResponse(response);
                var result = await HandleResponse(response).DonotCapture();

                return(result);
            }
            catch (TaskCanceledException)
            {
                return(await NotifyCancelEventAsync().DonotCapture());
            }
            catch (Exception ex)
            {
                if (Logger.IsEnabled(LogLevel.Trace) && req != null)
                {
                    // 此处用于生成请求信息,然后用fiddler等工具测试
                    var url    = req.GetUrl();
                    var header = req.GetRequestHeader(HttpService.GetCookies(req.Uri));
                    Logger.LogTrace(ex.ToString());
                    Logger.LogTrace(url);
                    Logger.LogTrace(header);
                }
                return(await HandleExceptionAsync(ObjectException.Create(req, ex.Message, ex))
                       .DonotCapture());
            }
            finally
            {
                ++ExcuteTimes;
            }
        }
コード例 #5
0
ファイル: AbstractAction.cs プロジェクト: liuguiyou/FclEx
 protected ValueTask <ActionEvent> NotifyObjectErrorAsync <T>(T obj, string msg = null, Exception innerException = null)
 => NotifyErrorAsync(ObjectException.Create(obj, msg, innerException));
コード例 #6
0
 public HappenedException(ObjectException exception)
 {
     Type        = exception.GetType().ToString();
     Description = exception.Message;
 }