Esempio n. 1
0
        public void LogInfo(string message)
        {
            ReflectedInfo srcInfo = Reflect();

            _logger.Log(LogLevel.Info, string.Format("Machine ({0}) AssemblyName ({1}) :{2}.{3}.{4} says '{5}'",
                                                     srcInfo.MachineName,
                                                     srcInfo.AssemblyName,
                                                     srcInfo.Namespace,
                                                     srcInfo.ClassName,
                                                     srcInfo.MethodName,
                                                     message));
        }
        private void BuildFromInfo()
        {
            outputPorts.Clear();
            if (eventType == null)
            {
                return;
            }

            Info = ReflectedInfo.For(eventType);
            foreach (var field in Info.reflectedFields)
            {
                outputPorts.Add(ValueOutput(field.Value.FieldType, field.Value.Name));
            }

            foreach (var property in Info.reflectedProperties)
            {
                outputPorts.Add(ValueOutput(property.Value.PropertyType, property.Value.Name));
            }
        }
        private void BuildFromInfo()
        {
            inputPorts.Clear();
            if (_eventType == null)
            {
                return;
            }

            Info = ReflectedInfo.For(_eventType);
            foreach (var field in Info.reflectedFields)
            {
                if (field.Value.FieldType == typeof(bool))
                {
                    inputPorts.Add(ValueInput <bool>(field.Value.Name, false));
                }
                else if (field.Value.FieldType == typeof(int))
                {
                    inputPorts.Add(ValueInput <int>(field.Value.Name, 0));
                }
                else if (field.Value.FieldType == typeof(float))
                {
                    inputPorts.Add(ValueInput <float>(field.Value.Name, 0.0f));
                }
                else if (field.Value.FieldType == typeof(string))
                {
                    inputPorts.Add(ValueInput <string>(field.Value.Name, ""));
                }
                else if (field.Value.FieldType == typeof(GameObject))
                {
                    inputPorts.Add(ValueInput <GameObject>(field.Value.Name, null).NullMeansSelf());
                }
                else
                {
                    inputPorts.Add(ValueInput(field.Value.FieldType, field.Value.Name));
                }
            }


            foreach (var property in Info.reflectedProperties)
            {
                if (property.Value.PropertyType == typeof(bool))
                {
                    inputPorts.Add(ValueInput <bool>(property.Value.Name, false));
                }
                else if (property.Value.PropertyType == typeof(int))
                {
                    inputPorts.Add(ValueInput <int>(property.Value.Name, 0));
                }
                else if (property.Value.PropertyType == typeof(float))
                {
                    inputPorts.Add(ValueInput <float>(property.Value.Name, 0.0f));
                }
                else if (property.Value.PropertyType == typeof(string))
                {
                    inputPorts.Add(ValueInput <string>(property.Value.Name, ""));
                }
                else if (property.Value.PropertyType == typeof(GameObject))
                {
                    inputPorts.Add(ValueInput <GameObject>(property.Value.Name, null).NullMeansSelf());
                }
                else
                {
                    inputPorts.Add(ValueInput(property.Value.PropertyType, property.Value.Name));
                }
            }
        }
Esempio n. 4
0
        public string GetExceptionInfo(Exception ex)
        {
            ReflectedInfo srcInfo = Reflect();
            string        exInfo  = null;
            var           strInfo = new StringBuilder();

            if (HttpContext.Current != null && HttpContext.Current.User != null)
            {
                strInfo.AppendFormat("User: {0}{1}", HttpContext.Current.User.Identity.Name, Environment.NewLine);
            }

            strInfo.AppendFormat(string.Format("Machine ({0}) AssemblyName ({1}) :{2}.{3}.{4} says '{5}'",
                                               srcInfo.MachineName,
                                               srcInfo.AssemblyName,
                                               srcInfo.Namespace,
                                               srcInfo.ClassName,
                                               srcInfo.MethodName,
                                               Regex.Replace(ex.Message, @"[^\d\w\s]", "-")));

            strInfo.AppendFormat(string.Format(
                                     "RequestedUrl : {0}, SessionID = {1}, UserAddress = {2}, UserAgent = {3}", RequestedUrl, SessionId,
                                     UserAddress, UserAgent));

            Exception currentException = ex;
            int       exceptionCount   = 1;

            do
            {
                // Write title information for the exception object.
                strInfo.AppendFormat("{0}{0}{1}) Exception Information{0}{2}", Environment.NewLine,
                                     exceptionCount.ToString(), "*********************************************");
                strInfo.AppendFormat("{0}Exception Type: {1}", Environment.NewLine, currentException.GetType().FullName);

                #region Loop through the public properties of the exception object and record their value

                // Loop through the public properties of the exception object and record their value.
                PropertyInfo[] aryPublicProperties = currentException.GetType().GetProperties();
                foreach (PropertyInfo p in aryPublicProperties)
                {
                    // Do not log information for the InnerException or StackTrace. This information is captured later in the process.
                    if (p.Name != "InnerException" && p.Name != "StackTrace")
                    {
                        if (p.GetValue(currentException, null) == null)
                        {
                            strInfo.AppendFormat("{0}{1}: NULL", Environment.NewLine, p.Name);
                        }
                        else
                        {
                            // Loop through the collection of AdditionalInformation if the exception type is a BaseApplicationException.
                            strInfo.AppendFormat("{0}{1}: {2}", Environment.NewLine, p.Name,
                                                 p.GetValue(currentException, null));
                        }
                    }
                }

                #endregion

                #region Record the Exception StackTrace

                // Record the StackTrace with separate label.
                if (currentException.StackTrace != null)
                {
                    strInfo.AppendFormat("{0}{0}StackTrace Information{0}{1}", Environment.NewLine,
                                         "*********************************************");
                    strInfo.AppendFormat("{0}{1}", Environment.NewLine, currentException.StackTrace);
                }

                #endregion

                // Reset the temp exception object and iterate the counter.
                currentException = currentException.InnerException;
                exceptionCount++;
            } while (currentException != null);

            exInfo = strInfo.ToString();

            return(exInfo);
        }