03.12.2018 - 07.12.2018 arası işler

- Moq kütüphanesi ile çalışmak Link Video
- Mevcut koda unit test yapmak Link Video
- Unit test yaparken xunit kullanmak Link Video
- Klasik olacak lakin dependency injection nedir güzel bir video Link
-  Unit test ile örnek kodlar Link
- Asp.net core web api ile video stream etmek Link
- Redis pub-sub mekanizması Link
- C# fluence builder nasıl yapılır Link
- Excel'de duplicate kayıtları bulmak Link
- C# unix get timestamp Link
- Decorator Pattern c# Link
- Bitcoin online kitap Link

- Swagger Authorization per Endpointn in Asp.net Core
https://docs.microsoft.com/en-us/aspnet/core/tutorials/getting-started-with-swashbuckle?view=aspnetcore-2.1&tabs=visual-studio
https://skalinets.github.io/swagger-authorization.html
https://skalinets.github.io/dotnet-core-swagger.html
https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/603
https://github.com/domaindrivendev/Swashbuckle.AspNetCore
https://www.hanselman.com/blog/ASPNETCoreRESTfulWebAPIVersioningMadeEasy.aspx
https://www.nuget.org/packages/Microsoft.AspNetCore.Mvc.Versioning
https://stackoverflow.com/questions/47919553/azure-app-service-cant-start-because-it-cant-find-swagger-documentation-xml-us
https://www.talkingdotnet.com/add-swagger-to-asp-net-core-2-0-web-api/

- Yeni başlayan birinin 9 ay içindeki maceraları
https://medium.freecodecamp.org/how-i-went-from-newbie-to-software-engineer-in-9-months-while-working-full-time-460bd8485847

- Asp.net core static dosyaların kullanımı
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/static-files?view=aspnetcore-2.2#serving-a-default-document

- Visual studio code extensionları derlemesi güzel bir yazı

https://codeburst.io/top-javascript-vscode-extensions-for-faster-development-c687c39596f5

- Online kurslar ücretsiz
 https://medium.com/quick-code/80-free-online-courses-you-can-start-this-week-fe2514e0596b

- Nodejs kullanılmayan yanları hakkında yazılmış güzel bir yazı, nodejs gerçekte backend js mi, bunu sorgulamışlar

https://edgecoders.com/getting-started-with-node-js-91449a0d03d3

- C# dersler online Link

- Server Sent Events Kütüphane Link , kütüphanenin bug fix link for azure

- Redis hashset kullanımı Link Link Link Link Link
 using System;  
 using System.Collections.Generic;  
 using System.Linq;  
 using System.Reflection;  
 using System.Text;  
 using Newtonsoft.Json;  
 using StackExchange.Redis;  
 namespace TestConsolePlatform.VoteService  
 {  
   public abstract class BaseService<T>  
   {  
     protected string Name => this.Type.Name;  
     protected PropertyInfo[] Properties => this.Type.GetProperties();  
     protected Type Type => typeof(T);  
     /// <summary>  
     /// Generates a key for a Redis Entry , follows the Redis Name Convention of inserting a colon : to identify values  
     /// </summary>  
     /// <param name="key">Redis identifier key</param>  
     /// <returns>concatenates the key with the name of the type</returns>  
     protected string GenerateKey(string key)  
     {  
       return string.Concat(key.ToLower(), ":", this.Name.ToLower());  
     }  
     protected HashEntry[] GenerateHash(T obj)  
     {  
       var props = this.Properties;  
       var hash = new HashEntry[props.Count()];  
       for (var i = 0; i < props.Count(); i++)  
         hash[i] = new HashEntry(props[i].Name, props[i].GetValue(obj).ToString());  
       return hash;  
     }  
     protected HashEntry[] ToHashEntries(object obj)  
     {  
       PropertyInfo[] properties = obj.GetType().GetProperties();  
       return properties  
         .Where(x => x.GetValue(obj) != null) // <-- PREVENT NullReferenceException  
         .Select  
         (  
           property =>  
           {  
             object propertyValue = property.GetValue(obj);  
             string hashValue;  
             // This will detect if given property value is   
             // enumerable, which is a good reason to serialize it  
             // as JSON!  
             if (propertyValue is IEnumerable<object>)  
             {  
               // So you use JSON.NET to serialize the property  
               // value as JSON  
               hashValue = JsonConvert.SerializeObject(propertyValue);  
             }  
             else  
             {  
               hashValue = propertyValue.ToString();  
             }  
             return new HashEntry(property.Name, hashValue);  
           }  
         )  
         .ToArray();  
     }  
     protected T MapFromHash(HashEntry[] hash)  
     {  
       var obj = (T)Activator.CreateInstance(this.Type); // new instance of T  
       var props = this.Properties;  
       for (var i = 0; i < props.Count(); i++)  
       {  
         for (var j = 0; j < hash.Count(); j++)  
         {  
           if (props[i].Name == hash[j].Name)  
           {  
             var val = hash[j].Value;  
             var type = props[i].PropertyType;  
             if (type.IsConstructedGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>))  
               if (string.IsNullOrEmpty(val))  
               {  
                 props[i].SetValue(obj, null);  
               }  
             props[i].SetValue(obj, Convert.ChangeType(val, type));  
           }  
         }  
       }  
       return obj;  
     }  
   }  
 }  
 using System;  
 using System.Collections.Generic;  
 using System.Linq;  
 using System.Reflection;  
 using System.Text;  
 using Newtonsoft.Json;  
 using StackExchange.Redis;  
 namespace TestConsolePlatform.VoteService  
 {  
   public static class LINQExtension  
   {  
     public static HashEntry[] ToHashEntries(this object obj)  
     {  
       PropertyInfo[] properties = obj.GetType().GetProperties();  
       return properties  
         .Where(x => x.GetValue(obj) != null) // <-- PREVENT NullReferenceException  
         .Select  
         (  
           property =>  
           {  
             object propertyValue = property.GetValue(obj);  
             string hashValue;  
             // This will detect if given property value is   
             // enumerable, which is a good reason to serialize it  
             // as JSON!  
             if (propertyValue is IEnumerable<object>)  
             {  
               // So you use JSON.NET to serialize the property  
               // value as JSON  
               hashValue = JsonConvert.SerializeObject(propertyValue);  
             }  
             else  
             {  
               hashValue = propertyValue.ToString();  
             }  
             return new HashEntry(property.Name, hashValue);  
           }  
         )  
         .ToArray();  
     }  
     public static double Median(this IEnumerable<double> source)  
     {  
       if (source.Count() == 0)  
       {  
         throw new InvalidOperationException("Cannot compute median for an empty set.");  
       }  
       var sortedList = from number in source  
         orderby number  
         select number;  
       int itemIndex = (int)sortedList.Count() / 2;  
       if (sortedList.Count() % 2 == 0)  
       {  
         // Even number of items.   
         return (sortedList.ElementAt(itemIndex) + sortedList.ElementAt(itemIndex - 1)) / 2;  
       }  
       else  
       {  
         // Odd number of items.   
         return sortedList.ElementAt(itemIndex);  
       }  
     }  
   }  
 }  
 using System;  
 using System.Collections.Generic;  
 using System.Linq;  
 using System.Reflection;  
 using System.Text;  
 using Newtonsoft.Json;  
 using StackExchange.Redis;  
 namespace TestConsolePlatform.VoteService  
 {  
   public class RedisVoteService<T>:BaseService<T>  
   {  
     private const string connectionString =  
       "<yourconnectionstring>";  
     public void SaveAsHashSet(string key, Vote vote)  
     {  
       var redis = ConnectionMultiplexer.Connect(connectionString);  
       IDatabase db = redis.GetDatabase();        
       db.HashSet(key, vote.ToHashEntries(), CommandFlags.None);        
     }  
     public bool HashExists(string hashkey, string key)  
     {  
       var redis = ConnectionMultiplexer.Connect(connectionString);  
       IDatabase db = redis.GetDatabase();  
       var result = db.HashExists(hashkey, key);  
       return result;  
     }  
     public double HashIncrement(string hashkey, string key, double increment)  
     {  
       var redis = ConnectionMultiplexer.Connect(connectionString);  
       IDatabase db = redis.GetDatabase();  
       return db.HashIncrement(hashkey, key, increment);  
     }  
     public HashEntry[] GetHashSet(string key)  
     {  
       var redis = ConnectionMultiplexer.Connect(connectionString);  
       IDatabase db = redis.GetDatabase();  
       return db.HashGetAll(key);  
     }  
   }  
 }  
 using System;  
 using System.Collections.Generic;  
 using System.Linq;  
 using System.Reflection;  
 using System.Text;  
 using Newtonsoft.Json;  
 using StackExchange.Redis;  
 namespace TestConsolePlatform  
 {  
   public class Vote  
   {  
     public int Yes { get; set; }  
     public int No { get; set; }  
     public int Undecided { get; set; }  
   }  
 }  
 using System;  
 using System.Collections.Generic;  
 using System.Text;  
 namespace TestConsolePlatform.VoteService  
 {  
   class AddThisController  
   {  
     /*  
     public IActionResult Vote(string value)  
     {  
       var redis = new RedisVoteService<Vote>(this._fact);  
       var theVote = new Vote();  
       switch (value)  
       {  
         case "Y":  
           theVote.Yes = 1;  
           break;  
         case "N":  
           theVote.No = 1;  
           break;  
         case "U":  
           theVote.Undecided = 1;  
           break;  
         default: break;  
       }  
       redis.Save("RedisVote", theVote);  
       var model = redis.Get("RedisVote");  
       return this.PartialView("RedisVote", model);  
     }  
     */  
   }  
 }  
  var redis = new RedisVoteService<Vote>();  
       //first init store object in redis  
       /*  
       var theVote = new Vote();  
       string value = "Y";  
       switch (value)  
       {  
         case "Y":  
           theVote.Yes = 1;  
           break;  
         case "N":  
           theVote.No = 1;  
           break;  
         case "U":  
           theVote.Undecided = 1;  
           break;  
         default: break;  
       }  
       redis.SaveAsHashSet("RedisVote", theVote);  
       */  
       if (redis.HashExists("RedisVote", "Yes"))  
       {  
         var yes = redis.HashIncrement("RedisVote", "Yes", 1); //year now becomes 2017  
       }  
       var values = redis.GetHashSet("RedisVote");  
       foreach (var val in values)  
       {  
         Console.WriteLine(val);   
       }  

Yorumlar

Bu blogdaki popüler yayınlar

22.06.2020 - 26.06.2020 arası işler

Asp.net RestSharp ile data post etmek

List Box Item içindeki elemanları aşağı veya yukarı taşımak