Aylık Arşiv: Eylül 2016

YAGNI: You ain’t gonna need it

YAGNI: You ain’t gonna need it

YAGNI (Buna ihtiyacın olmayacak) Eğer bir API yazmıyorsanız ileride şuna da ihtiyacım olur diyerek hayali kodlar üretmeyin. Bu kodlar test süreçlerini de düşünürsek size tahmininizden fazla zaman kaybettirecektir. Ayrıca programınız olması gerekenden daha karmaşık...

DRY: Don’t Repeat Yourself

DRY: Don’t Repeat Yourself

DRY (Kendizi tekrar etmeyin) Eğer aynı kodu ikiden fazla yerde tekrarlıyorsanız durup bir düşünün. Mümkünse tekrar eden kodları içeren fonksiyonlar/metotlar oluşturun ve başkalarının da kolayca kullanabilmesi için bu fonksiyonları/metotları uygun şekilde belgelendirin.

Online Pdf, Excel v.s. Download

<html> <head> <meta http-equiv=”content-type” content=”text/html; charset=UTF-8″> <meta name=”robots” content=”noindex, nofollow”> <meta name=”googlebot” content=”noindex, nofollow”> <script type=”text/javascript” src=”http://code.jquery.com/jquery-2.1.3.js”></script> <link rel=”stylesheet” type=”text/css” href=”/css/result-light.css”> <script type=”text/javascript” src=”http://www.cloudformatter.com/Resources/Pages/CSS2Pdf/Script/xepOnline.jqPlugin.js”></script> <style type=”text/css”></style> <title>@cloudformatter template</title> </head> <body> <div id=”buttons”> <button onclick=”return...

sealed Keyword’ü Nedir? Ne İşe Yarar?

sealed keywordü bir class ve metod modifier(niteleyici)dır. Eğer bir class sealed komutuyla işaretlenmişse o classtan kalıtım yapılamaz. Yani o class başka bir sınıfın base classı olamaz. Ayriyetten bir metod sealed komutuyla işaretleniyorsa o metodtan...

MVC içindeki filtreler

Filter  Interface  Default Implementation  Authorization Filter  IAuthorizationFilter AuthorizeAttribute  Action Filter  IActionFilter ActionFilterAttribute  Result Filter  IResultFilter ActionFilterAttribute  Exception Filter  IExceptionFilter HandleErrorAttribute Authorization : Diğer filtreler ve Action metodlardan önce çalışmaktadır.Controller ya da Controller içindeki Action metoda...

MVC Get Attributes

Assembly assembly = Assembly.GetExecutingAssembly(); IEnumerable<Type> types = assembly.GetTypes() .Where( type => typeof(Controller).IsAssignableFrom(type) && type.Name.Replace("Controller", "") == controllerName) .OrderBy(x => x.Name); foreach (Type cls in types) { HelpAttribute helpAttribute = Attribute.GetCustomAttribute(cls, typeof(HelpAttribute)) as HelpAttribute; url...

MVC Get – Controllers, Actions, Attributes and Return Types – 2

Assembly assembly = Assembly.LoadFrom(sAssemblyFileName) IEnumerable<Type> types = assembly.GetTypes().Where(type => typeof(Controller).IsAssignableFrom(type)).OrderBy(x => x.Name); foreach (Type cls in types) { list.Add(cls.Name.Replace("Controller", "")); IEnumerable<MemberInfo> memberInfo = cls.GetMethods(BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public).Where(m => !m.GetCustomAttributes(typeof(System.Runtime.CompilerServices.CompilerGeneratedAttribute), true).Any()).OrderBy(x => x.Name); foreach...

MVC Get – Controllers, Actions, Attributes and Return Types

Assembly asm = Assembly.GetAssembly(typeof(MyWebDll.MvcApplication)); var controlleractionlist = asm.GetTypes() .Where(type=> typeof(System.Web.Mvc.Controller).IsAssignableFrom(type)) .SelectMany(type => type.GetMethods(BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public)) .Where(m => !m.GetCustomAttributes(typeof( System.Runtime.CompilerServices.CompilerGeneratedAttribute), true).Any()) .Select(x => new {Controller = x.DeclaringType.Name, Action = x.Name, ReturnType = x.ReturnType.Name,...

c# Mapping Class

public static class TypeExtensions { public static void MapTo<T, S>(this S source, T target) { Type sourceType = source.GetType(); Type targetType = target.GetType(); var sourceProperties = sourceType.GetProperties(); var targetProperties = targetType.GetProperties(); for (int i...

FileSaver.js

FileSaver.js

<script src="FileSaver.js"></script> var blob = new Blob([“Hello, world!”], {type: "text/plain;charset=utf-8"}); saveAs(blob, "hello world.txt"); Detaylı bilgi ve örneklere https://github.com/eligrey/FileSaver.js sayfasından ulaşabilirsiniz.

Javascript base64encode(input)

Javascript base64encode(input)

function base64encode(input) { var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; var output = ""; var chr1, chr2, chr3, enc1, enc2, enc3, enc4; var i = 0; input = utf8Encode(input); while (i < input.length) { chr1 = input.charCodeAt(i++);...

html2canvas

Ekrandaki verilerin “screenshots” almak için kullanılır. http://html2canvas.hertzen.com/

Export HTML Table to CSV TXT JSON XML SQL XLS DOC PNG PDF

Installation To save the generated export files on client side, include: <script type=”text/javascript” src=”libs/FileSaver/FileSaver.min.js”></script> To export the table as a PDF file the following includes are required: <script type=”text/javascript” src=”libs/jsPDF/jspdf.min.js”></script> <script type=”text/javascript” src=”libs/jsPDF-AutoTable/jspdf.plugin.autotable.js”></script> To...

Xml veriyi Class’a Atama

public static T SetXmlDataToViewModel&amp;lt;T&amp;gt;(T oViewModel, string xmlData) { if (string.IsNullOrEmpty(xmlData)) { return oViewModel; } XDocument dataXmlDoc = XDocument.Parse(xmlData); foreach (var prop in typeof(T).GetProperties()) { if (dataXmlDoc.Descendants().SingleOrDefault(p =&amp;gt; p.Name.LocalName == prop.Name) != null) prop.SetValue(oViewModel, Convert.ChangeType(dataXmlDoc.Descendants().SingleOrDefault(p...

ASP.NET Core 1.0 ve ASP.NET’in Geleceği

ASP.NET Core 1.0 ve ASP.NET’in Geleceği

ASP.NET Core yakın zamana kadar ASP.NET 5 ismiyle anılıyordu. Geçtiğimiz haftalarda yayınlanan resmi bir yazı ile artık ASP.NET 5 yerine ASP.NET Core olarak isimlendirileceği belirtildi. http://devnot.com/2016/asp-net-core-1-0-ve-asp-netin-gelecegi/ https://yazilimda.com/2016/04/asp-net-core-1-0-neler-sunuyor/ https://www.microsoft.com/net/core#windows