CInject - Code Injection with Runtime intelligence
CInject adds more value to your existing applications by injecting runtime intelligence. You can use injectors provided by with CInject, or define your own injector.
This article will highlight some cases where you can directly use CInject
Existing application has no or very little logging
Your application is a 3-tier application and is designed using Dependency Injection and Inversion of Control patterns. Application switches the flow control too frequently and has no logging.
Use LogInjector to inject logs in your application. When you execute the application, LogInjector will create application logs of when a method was invoked and when it was completed. You can also customize or build your own LogInjector by implementing ICInject interface.
OnInvoke method provides you a lot of information such as,
- Executing method and its properties and signature - Complete reflection object is provided to OnInvoke method
- Arguments passed to the injected method - You can use this to debug what was passed to the method. If the argument is an object (not native type), you can use ObjectSearch to find out any value of any property
- Executing assembly - Useful if you want to load assembly later or want to perform some additional tasks on the assembly
Application is performing slower than I expected
Your application is performing slower than you expected and would want to find out which method is taking the most time. However, all third-party tools are paid and expensive.
[1] INFO Sleep executed in 1201.8618 mSec [1] INFO Add executed in 1438.8754 mSec [1] INFO Subtract executed in 0 mSec [1] INFO GetName executed in 0 mSec [1] INFO GetTypeName executed in 0 mSec [1] INFO GetTypeName executed in 0 mSec [1] INFO Sleep executed in 1200.0686 mSec [1] INFO GetRefValue executed in 1200.0686 mSec [1] INFO GetOutValue executed in 0 mSec [1] INFO Create executed in 0 mSec [1] INFO GetArrayCount executed in 0 mSec [1] INFO AddOptional executed in 0 mSec [1] INFO AddOptional executed in 0 mSec [1] INFO DelegateCalled executed in 0 mSec [1] INFO CallDelegate executed in 1.0001 mSec
Don't know what gets passed as arguments to few methods
Method btnChangeValue_Click Argument #0 :Text= Print the Value in label Method btnChangeValue_Click Argument #0 :Name= btnChangeValue Method ChangeValue Argument #0 :Text= a Method ChangeValue Argument #0 :Name= txtInputValue