The project allows to use signals in .NET applications.
To get to this concept, you need to take some of the rules:
Code sample
Starting, running search handlers, and the creation of slots.
The first way, the use of assembly:
rtSignalCore.AppendAssembly(Assembly.GetEntryAssembly());
,the second path, the use of class instances of business logic:
rtSignalCore.AppendTypeInstance(new BusinessLogicClass());
Signal:
public enum SomeNameSignals
{
Signal1,
Signal2
}
Business logic class:
[rtSignalParticipator]
class BusinessLogicClass
{
// asynchronous signal processing
[rtSignalAsyncHandler(SomeNameSignals.SignalWithoutArguments)]
void Process_SignalWithoutArguments(string path)
{
...
}
// asynchronous signal processing
[rtSignalAsyncHandler(SomeNameSignals.SignalWithOneArg)]
void Process_SignalWithOneArg(string data)
{
...
}
[rtSignalHandler(SignalIdentifierEnum.SignalWithTwoArgs)]
void Process_SignalWithTwoArgs(string filePath, FileInfo file)
{
...
}
}
Signal generation:
rtSignalCore.Signal(SomeNameSignals.SignalWithoutArguments);
or
rtSignalCore.Signal(SomeNameSignals.SignalWithOneArg, "Hello, world!");
or
rtSignalCore.Signal(SomeNameSignals.SignalWithTwoArgs, filePath, new FileInfo(filePath));
The handler of signal of finished processing the said signal. Including the completion of his asynchronous handlers:
[rtSignalCompletedAsyncHandler(SomeNameSignals.SignalWithoutArguments)]
void CompleteProcessings_SignalWithoutArguments()
{
// ToDo
}
or
[rtSignalCompletedAsyncHandler(SomeNameSignals.SignalWithOneArg)]
void CompleteProcessings_SignalWithOneArg(string data)
{
// ToDo
}
To mark the signal handlers available the following attributes:
22.04.2013
Now we can send signal with one args the next method:
object.SendSignal(SignalEnum.Signal);
Sample:
"Hello, World!".SendSignal(Signals.HelloWorldSignal);
30.05.2013
Add late binding.
We can write next code:
public class ClassA
{
void TestLateBind(string obj)
{
Console.WriteLine(obj);
}
}
//------------------
ClassA a = new ClassA();
rtSignalCore.AppendMethod(SignalMethodType.SignalHandler, a, "TestLateBind", "SignalForTestLateBinding");
"Hello, world".SendSignal("SignalForTestLateBinding");
//------------------
Console output:
Hello, world