Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-generic signal Declare method. #636

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,17 @@ public static class SignalExtensions
{
public static SignalDeclarationBindInfo CreateDefaultSignalDeclarationBindInfo(DiContainer container, Type signalType)
{
var signalBindInfo = new SignalDeclarationBindInfo(signalType);

signalBindInfo.RunAsync = container.Settings.Signals.DefaultSyncMode == SignalDefaultSyncModes.Asynchronous;
signalBindInfo.MissingHandlerResponse = container.Settings.Signals.MissingHandlerDefaultResponse;
signalBindInfo.TickPriority = container.Settings.Signals.DefaultAsyncTickPriority;

return signalBindInfo;
return new SignalDeclarationBindInfo(signalType)
{
RunAsync = container.Settings.Signals.DefaultSyncMode == SignalDefaultSyncModes.Asynchronous,
MissingHandlerResponse = container.Settings.Signals.MissingHandlerDefaultResponse,
TickPriority = container.Settings.Signals.DefaultAsyncTickPriority
};
}

public static DeclareSignalIdRequireHandlerAsyncTickPriorityCopyBinder DeclareSignal<TSignal>(this DiContainer container)
public static DeclareSignalIdRequireHandlerAsyncTickPriorityCopyBinder DeclareSignal(this DiContainer container, Type type)
{
var signalBindInfo = CreateDefaultSignalDeclarationBindInfo(container, typeof(TSignal));
var signalBindInfo = CreateDefaultSignalDeclarationBindInfo(container, type);

var bindInfo = container.Bind<SignalDeclaration>().AsCached()
.WithArguments(signalBindInfo).WhenInjectedInto(typeof(SignalBus), typeof(SignalDeclarationAsyncInitializer)).BindInfo;
Expand All @@ -26,6 +25,11 @@ public static DeclareSignalIdRequireHandlerAsyncTickPriorityCopyBinder DeclareSi
return signalBinder;
}

public static DeclareSignalIdRequireHandlerAsyncTickPriorityCopyBinder DeclareSignal<TSignal>(this DiContainer container)
{
return container.DeclareSignal(typeof(TSignal));
}

public static BindSignalIdToBinder<TSignal> BindSignal<TSignal>(this DiContainer container)
{
var signalBindInfo = new SignalBindingBindInfo(typeof(TSignal));
Expand All @@ -34,3 +38,4 @@ public static BindSignalIdToBinder<TSignal> BindSignal<TSignal>(this DiContainer
}
}
}