Esempio n. 1
0
        public void OnInvoke(CInjection injection)
        {
            try
            {
                _context = _tracingContext.CreateEntrySegmentContext(injection.Method.Name, new TextCarrierHeaderCollection(new Dictionary <string, string>()));

                _injection = injection;
                _startTime = DateTime.Now;

                if (!Logger.IsDebugEnabled)
                {
                    return;
                }
                if (_injection == null)
                {
                    return;
                }
                if (!File.Exists(FileName))
                {
                    return;
                }
                if (!injection.IsValid())
                {
                    return;
                }

                var objectSearch = CachedSerializer.Deserialize <ObjectSearch>(File.ReadAllText(FileName), Encoding.UTF8);
                if (objectSearch == null || objectSearch.PropertyNames == null)
                {
                    return;
                }

                _context.Span.AddTag("Method", injection.Method.Name);
                foreach (string propertyName in objectSearch.PropertyNames)
                {
                    var dictionary = _injection.GetPropertyValue(propertyName);
                    var method     = "";
                    var value      = "";
                    foreach (var key in dictionary.Keys)
                    {
                        method = string.Format("Method {0} Argument #{1} :{2}= {3}", injection.Method.Name, key, propertyName, dictionary[key] ?? "<null>");
                        Logger.Debug(method);

                        value += propertyName + "=" + dictionary[key] ?? "<null> /r/n ";
                    }

                    _context.Span.AddLog(LogEvent.Event($"{injection.Method.Name} :{value}"));
                }
            }
            catch (Exception ex)
            {
                Logger.Debug("OnInvoke ex:" + ex.Message);
                Logger.Error(ex);
            }
        }
Esempio n. 2
0
 public string GetRefValue(ref string name)
 {
     try
     {
         LogInject  inject    = new LogInject();
         CInjection injection = new CInjection();
         injection.Method            = System.Reflection.MethodBase.GetCurrentMethod();
         injection.ExecutingAssembly = System.Reflection.Assembly.GetExecutingAssembly();
         injection.Arguments         = new object[] { name };
         inject.OnInvoke(injection);
     }
     catch { }
     Sleep();
     name += ".appended";
     return(name);
 }
Esempio n. 3
0
        public void OnInvoke(CInjection injection)
        {
            _injection = injection;


            if (!Logger.IsDebugEnabled)
            {
                return;
            }
            if (_injection == null)
            {
                return;
            }
            if (!File.Exists(FileName))
            {
                return;
            }
            if (!injection.IsValid())
            {
                return;
            }

            var objectSearch = CachedSerializer.Deserialize <ObjectSearch>(File.ReadAllText(FileName), Encoding.UTF8);

            if (objectSearch == null || objectSearch.PropertyNames == null)
            {
                return;
            }

            foreach (string propertyName in objectSearch.PropertyNames)
            {
                var dictionary = _injection.GetPropertyValue(propertyName);

                foreach (var key in dictionary.Keys)
                {
                    Logger.Debug(String.Format("Method {0} Argument #{1} :{2}= {3}", injection.Method.Name, key, propertyName, dictionary[key] ?? "<null>"));
                }
            }
        }
        public void OnInvoke(CInjection injection)
        {
            _injection = injection;

            if (!Logger.IsDebugEnabled) return;
            if (_injection == null) return;
            if (!File.Exists(FileName)) return;
            if (!injection.IsValid()) return;

            var objectSearch = CachedSerializer.Deserialize<ObjectSearch>(File.ReadAllText(FileName), Encoding.UTF8);
            if (objectSearch == null || objectSearch.PropertyNames == null) return;

            foreach (string propertyName in objectSearch.PropertyNames)
            {
                var dictionary = _injection.GetPropertyValue(propertyName);

                foreach (var key in dictionary.Keys)
                {
                    Logger.Debug(String.Format("Method {0} Argument #{1} :{2}= {3}", injection.Method.Name, key, propertyName, dictionary[key] ?? "<null>"));
                }
            }
        }
Esempio n. 5
0
        public void OnInvoke(CInjection injection)
        {
            if (injection == null)
            {
                return;
            }

            _injection = injection;

            try
            {
                if (injection.IsValid())
                {
                    Logger.Info(_injection.GetMessage("Invoked"));
                }

                if (!Logger.IsDebugEnabled)
                {
                    return;
                }

                var parameters = injection.Method.GetParameters();
                if (injection.Arguments != null)
                {
                    Logger.Debug(String.Format(">> Paramerters: {0}", injection.Arguments.Length));
                    for (int i = 0; i < injection.Arguments.Length; i++)
                    {
                        var currentArgument = injection.Arguments[i];
                        if (currentArgument == null)
                        {
                            Logger.Debug(String.Format("    [{0}]: <null>", parameters[i].Name));
                            continue;
                        }

                        if (currentArgument is IDictionary)
                        {
                            var dictionary        = (IDictionary)currentArgument;
                            var dictionaryBuilder = new StringBuilder();
                            foreach (var key in dictionary.Keys)
                            {
                                dictionaryBuilder.AppendFormat("{0}={1}|", key, GetStringValue(dictionary[key]));
                            }

                            Logger.Debug(String.Format("    [{0}]: {1}", parameters[i].Name, dictionaryBuilder.ToString().TrimEnd(new[] { '|' })));
                        }
                        else if (currentArgument is ICollection)
                        {
                            ICollection   collection        = (ICollection)currentArgument;
                            IEnumerator   enumerator        = collection.GetEnumerator();
                            StringBuilder dictionaryBuilder = new StringBuilder();

                            while (enumerator.MoveNext())
                            {
                                dictionaryBuilder.AppendFormat("{0},", GetStringValue(enumerator.Current)).AppendLine();
                            }

                            Logger.Debug(String.Format("    [{0}]: {1}", parameters[i].Name, dictionaryBuilder.ToString().TrimEnd(new[] { ',' })));
                        }
                        else if (currentArgument is IEnumerable)
                        {
                            IEnumerable   enumerator        = (IEnumerable)currentArgument;
                            StringBuilder dictionaryBuilder = new StringBuilder();

                            foreach (var item in enumerator)
                            {
                                dictionaryBuilder.AppendFormat("{0},", GetStringValue(item)).AppendLine();
                            }
                            Logger.Debug(String.Format("    [{0}]: {1}", parameters[i].Name, dictionaryBuilder.ToString().TrimEnd(new[] { ',' })));
                        }
                        else
                        {
                            Logger.Debug(String.Format("    [{0}]: {1}", parameters[i].Name, GetStringValue(currentArgument)));
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                Logger.Error(exception);
            }
        }
Esempio n. 6
0
 private void DestroyObject()
 {
     Logger.Debug(_injection.GetMessage("Destroyed"));
     _injection = null;
 }
Esempio n. 7
0
 public void Dispose()
 {
     _injection = null;
     _disposed  = true;
     GC.SuppressFinalize(this);
 }
Esempio n. 8
0
 private void DestroyObject()
 {
     _injection = null;
 }
Esempio n. 9
0
 public void OnInvoke(CInjection injection)
 {
     _injection = injection;
     _startTime = DateTime.Now;
 }
 private void DestroyObject()
 {
     _injection = null;
 }
 public void OnInvoke(CInjection injection)
 {
     _injection = injection;
     _startTime = DateTime.Now;
 }
 public void Dispose()
 {
     _injection = null;
     _disposed = true;
     GC.SuppressFinalize(this);
 }
Esempio n. 13
0
        public void OnInvoke(CInjection injection)
        {
            if (injection == null) return;

            _injection = injection;

            try
            {
                if (injection.IsValid())
                    Logger.Info(_injection.GetMessage("Invoked"));

                if (!Logger.IsDebugEnabled) return;

                var parameters = injection.Method.GetParameters();
                if (injection.Arguments != null)
                {
                    Logger.Debug(String.Format(">> Paramerters: {0}", injection.Arguments.Length));
                    for (int i = 0; i < injection.Arguments.Length; i++)
                    {
                        var currentArgument = injection.Arguments[i];
                        if (currentArgument == null)
                        {
                            Logger.Debug(String.Format("    [{0}]: <null>", parameters[i].Name));
                            continue;
                        }

                        if (currentArgument is IDictionary)
                        {
                            var dictionary = (IDictionary)currentArgument;
                            var dictionaryBuilder = new StringBuilder();
                            foreach (var key in dictionary.Keys)
                            {
                                dictionaryBuilder.AppendFormat("{0}={1}|", key, GetStringValue(dictionary[key]));
                            }

                            Logger.Debug(String.Format("    [{0}]: {1}", parameters[i].Name, dictionaryBuilder.ToString().TrimEnd(new[] { '|' })));
                        }
                        else if (currentArgument is ICollection)
                        {
                            ICollection collection = (ICollection)currentArgument;
                            IEnumerator enumerator = collection.GetEnumerator();
                            StringBuilder dictionaryBuilder = new StringBuilder();

                            while (enumerator.MoveNext())
                            {
                                dictionaryBuilder.AppendFormat("{0},", GetStringValue(enumerator.Current)).AppendLine();
                            }

                            Logger.Debug(String.Format("    [{0}]: {1}", parameters[i].Name, dictionaryBuilder.ToString().TrimEnd(new[] { ',' })));
                        }
                        else if (currentArgument is IEnumerable)
                        {
                            IEnumerable enumerator = (IEnumerable)currentArgument;
                            StringBuilder dictionaryBuilder = new StringBuilder();

                            foreach (var item in enumerator)
                            {
                                dictionaryBuilder.AppendFormat("{0},", GetStringValue(item)).AppendLine();
                            }
                            Logger.Debug(String.Format("    [{0}]: {1}", parameters[i].Name, dictionaryBuilder.ToString().TrimEnd(new[] { ',' })));
                        }
                        else
                        {
                            Logger.Debug(String.Format("    [{0}]: {1}", parameters[i].Name, GetStringValue(currentArgument)));
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                Logger.Error(exception);
            }
        }
Esempio n. 14
0
 private void DestroyObject()
 {
     Logger.Debug(_injection.GetMessage("Destroyed"));
     _injection = null;
 }