This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ApiActor : ReceiveActor | |
{ | |
private readonly IActorRef _watchedVideoActor; | |
private readonly IActorRef _videoActor; | |
private readonly IActorRef _recommandationActor; | |
public ApiActor(IActorRef watchedVideoActor) | |
{ | |
_watchedVideoActor = watchedVideoActor; | |
_recommandationActor = Context.ActorOf(Props.Create<RecommandationActor>(watchedVideoActor)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FooActor : UntypedActor | |
{ | |
protected override void OnReceive(object message) | |
{ | |
} | |
protected override void PreStart() | |
{ | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected override SupervisorStrategy SupervisorStrategy() | |
{ | |
return new OneForOneStrategy(// or AllForOneStrategy | |
maxNumberOfRetries: 10, // opsiyonel | |
duration: TimeSpan.FromSeconds(30), // opsiyonel | |
decider: x => | |
{ | |
// ArithmeticException Actor durduracak kadar kritik bir hata değil | |
// dolayısıyla devam etmesinde bir sakınca yok. | |
if (x is ArithmeticException) return Directive.Resume; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Tuple<int, string, string, string> GetUserById(int userId) | |
{ | |
// TODO : verilerin datareader veya datatable'da geldiğini ve sonrasında Tuple nesnesini oluşturduğumuzu düşünün. | |
// (Evet ORM kullanılmadığımız bir projeydi) | |
var user = new Tuple<int, string, string, string>(1, "Deniz", "İrgin", "deniz@denizirgin.com"); | |
return user; | |
} | |
// -------- Kullanımı | |
Tuple<int, string, string, string> user = GetUserById(1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public (int, string, string, string) GetUserById(int userId) // Tuple Type | |
{ | |
// verilerin bir datasource'dan geldiğini düşünelim | |
int id = 1; | |
string firstName = "Deniz"; | |
string lastName = "İrgin"; | |
string email = "deniz@denizirgin.com"; | |
return (id, firstName, lastName, email); // Tuple Literal | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public (int Id, string FirstName, string LastName, string Email) GetUserById(int userId) // Tuple Type | |
{ | |
// verilerin bir datasource'dan geldiğini düşünelim | |
int id = 1; | |
string firstName = "Deniz"; | |
string lastName = "İrgin"; | |
string email = "deniz@denizirgin.com"; | |
return (id, firstName, lastName, email); // Tuple Literal | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void UpdateUserBalance(int userId, string balance) // harici bir sistemden gelen string data | |
{ | |
decimal userBalance; | |
if(decimal.TryParse(balance, out userBalance)) | |
{ | |
Console.WriteLine($"{userId} id'li kullanıcının bakiyesi {userBalance}"); | |
} | |
else | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void UpdateUserBalance(int userId, string balance) // harici bir sistemden gelen string data | |
{ | |
if (decimal.TryParse(balance, out decimal userBalance)) // decimal yerine var'da kullanabiliriz | |
{ | |
Console.WriteLine($"{userId} id'li kullanıcının bakiyesi {userBalance}"); | |
} | |
else | |
{ | |
Console.WriteLine("Geçerisiz bir değer girildi"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var city = "İstanbul"; | |
using (var context = CreateContext()) | |
{ | |
context.Customers.FromSql($@" | |
SELECT * | |
FROM Customers | |
WHERE City = {city}"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void ShowUserBalance(object balance) | |
{ | |
if (balance is null) // constant pattern "null" | |
{ | |
return; | |
} | |
if (balance is decimal userBalance) // type pattern "decimal userBalance" | |
{ | |
Console.WriteLine($"Kullanıcının bakiyesi {userBalance}"); |
OlderNewer