Skip to content

Instantly share code, notes, and snippets.

View fatihdumanli's full-sized avatar
🎯
Focusing

Fatih fatihdumanli

🎯
Focusing
View GitHub Profile
@fatihdumanli
fatihdumanli / IRabbitMQAdapter.cs
Last active November 3, 2020 20:15
IRabbitMQAdapter interface
namespace EventTower
{
public delegate void MessageReceived(MessageReceivedEventArgs args);
public interface IRabbitMQAdapter
{
event MessageReceived MessageReceived;
void TryConnect();
void BasicPublish(ICommand command, string destination);
void BasicPublish(IEvent @event);
@fatihdumanli
fatihdumanli / MyService.cs
Created November 3, 2020 06:45
Secured service
[Route("/user/{UserId}/set/email", "POST")]
[Authenticate]
public class SetEmail : IReturn<bool>
{
public Guid UserId { get; set; }
public string Email { get; set; }
}
@fatihdumanli
fatihdumanli / IEvent.cs
Last active November 3, 2020 20:14
IEvent interface
namespace EventTower
{
//Marker interface for events
public interface IEvent : IMessage
{
}
}
@fatihdumanli
fatihdumanli / ICommand.cs
Last active November 3, 2020 20:14
ICommand interfae
namespace EventTower
{
//Marker interface for commands
public interface ICommand : IMessage
{
}
}
@fatihdumanli
fatihdumanli / IMessage.cs
Last active November 3, 2020 20:15
IMessage interface
namespace EventTower
{
//Marker interface for messages
public interface IMessage
{
}
}
@fatihdumanli
fatihdumanli / Startup.cs
Created October 31, 2020 21:18
Registering CustomAuthRepository to built-in IoC container.
public override void Configure(Container container)
{
var userRepo = new SiteAuthRepository();
container.Register<IUserAuthRepository>(userRepo);
}
@fatihdumanli
fatihdumanli / CustomAuthRepository.cs
Last active October 31, 2020 21:02
CustomAuthRepository - fills the gap between persistance and our CustomAuthProvider
public class CustomAuthRepository : IUserAuthRepository
{
private readonly SiteInformationDbContext _context;
public CustomAuthRepository()
{
_context = new SiteInformationDbContext();
}
public IUserAuthDetails CreateOrMergeAuthSession(IAuthSession authSession, IAuthTokens tokens)
@fatihdumanli
fatihdumanli / cs
Last active October 31, 2020 19:27
Startup.cs
Plugins.Add(new AuthFeature(() => new AuthUserSession(),
new IAuthProvider[] {
new CustomAuthProvider()
}));
@fatihdumanli
fatihdumanli / cs
Last active October 31, 2020 19:21
CustomAuthProvider.cs
public class CustomAuthProvider : ServiceStack.Auth.CredentialsAuthProvider
{
}
int kactane = 0;
int i = 0;
for (i = 0; i < sizeof(dizi); i++)
{
if (dizi[i] == '.')
{
while (dizi[i] != '\0')