Saturday, July 27, 2013

Regex

Regex.Match Method (String) ilk kopyayı bulur

 

Regex.Match ("any calor c3olor colour you like", @"colou?r")  colour u bulur ? olabilir de olmayabilirde 0 veya 1

 

Match m1 = Regex.Match ("One color? There are two colours in my head!", @"colou?rs?");
Match m2 = m1.NextMatch();

Excepiton

bool isAttached = Debugger.IsAttached;
         if (!isAttached)
         {
             Application.ThreadException += new ThreadExceptionEventHandler(Program.Application_ThreadException);
         }
         try
         {
             Program.Go(args);
         }
         catch (Exception exception1)
         {
             Exception exception = exception1;
             Program.ProcessException(exception);
         }

BST Binary Search Tree

Solundaki dallar sadece kendinden küçük olanlar sağındakiler büyük olanlar.Sağındaki ve solundaki alt ağaçlarda bir bst olmalı.Duplice node olamaz.

 

AYM3J

Tree search

Delete 1

Delete 3

Delete 4

Linked list

Linked list de her item bir sonrakine pointer tutuyor random access bütün itemları tek tek geçmeyi gerektiriyor çok hızlı ekleme silem yapılabiliyor.Ortaya eklemek daha kolay bütün liste yeniden oluşturulmuyor.

Reg ex

Regular expression

| alternatif mavi | mave  mavi veya mave

mavi madi   ma(v|d)i mavi veya madi

gr[ea]y grey or gray

gra*vy => grvy graaaaavy n tane a 0 d aolabilir 100 de

* 0 tane veya n tane

+ 1 veya n tane

? 0 veya 1 tane

Class vs object

Obje ile class arası fark = class plan obje ise o planı uyguladığın zaman eline geçen şey.Mimarlıktaki gibi class plan bina object.

Pratikte instance ı oluşturulmadan classı kullanmak mümkün static method ile.

Friday, June 14, 2013

Kendo datasource

   1: <div id="form-container">
   2:  
   3:     <div class="form" >
   4:                    <select data-role="dropdownlist" data-value-field="ProductID" data-text-field="ProductName" data-bind="source: productsSource, value: selectedProduct"></select>
   5:         <ul>
   6:             <li>
   7:                 <label>ID</label>
   8:                 <span data-bind=  "source: productsSource, events: { change: change }"></span></li>
   9: @*            <li>
  10:                 <label>Name</label>
  11:                 <input type="text" class="k-textbox" id="products" data-bind="value: selectedProduct.ProductName, events: { change: change }" /></li>
  12:             <li>
  13:                 <label>UnitPrice</label>
  14:                 <input type="text" data-role="numerictextbox" data-bind="value: selectedProduct.UnitPrice, events: { change: change }" /></li>*@
  15:         </ul>
  16:  
  17:         <button data-bind="click: remove">Delete Product</button>
  18:  
  19:     </div>
  20: </div>
  21: <script>
  22:     var crudServiceBaseUrl = "@Url.Action("Index", "Duyuru", new { area = "Ayarlar" })";
  23:  
  24:     $(document).ready(function () {
  25:         //setTimeout(function () {
  26:             alert("hi");
  27:         var uniqId = '@(ViewBag.UniqEkId)'
  28:         var messageId = '@(ViewBag.Id)'
  29:         alert(crudServiceBaseUrl);
  30:         var viewModel = kendo.observable({
  31:             productsSource: new kendo.data.DataSource({
  32:  
  33:                 transport: { 
  34:                     read: {
  35:                         contentType: "application/json; charset=utf-8",
  36:                         type: "POST",
  37:                         url: crudServiceBaseUrl + "/Read",
  38:                         dataType: "json",
  39:                         data: { id: messageId }
  40:                     },
  41:                     update: {
  42:                         contentType: "application/json; charset=utf-8",
  43:                         type: "POST",
  44:                         cache: false,
  45:                         url: crudServiceBaseUrl + "/Update",
  46:                         dataType: "json"
  47:                     },
  48:                     destroy: {
  49:                         contentType: "application/json; charset=utf-8",
  50:                         type: "POST",
  51:                         cache: false,
  52:                         url: crudServiceBaseUrl + "/Delete",
  53:                         dataType: "json"
  54:                     },
  55:                     parameterMap: function (options, operation) {
  56:                         if (operation !== "read" && options.models) {
  57:                             var x = " { models :" + JSON.stringify(options.models) + "}";
  58:                             console.log(x);
  59:                             return x;
  60:                         }
  61:                         return options;
  62:                     }
  63:                 },
  64:                 autoSync:true,
  65:                 batch: true,
  66:                 schema: {
  67:                     model: { id: "KayitNo" },
  68:                     data: function (result) {
  69:                         if ($.isArray(result)) {
  70:                             return result;
  71:                         }
  72:                         else {
  73:                             return [result];
  74:                         }
  75:                     }
  76:                 }
  77:             }),
  78:             selectedProduct: null,
  79:             hasChanges: false,
  80:             save: function () {
  81:                 this.productsSource.sync();
  82:                 this.set("hasChanges", false);
  83:             },
  84:             remove: function () {
  85:                 if (confirm("Silmek istediğinize emin misiniz?")) {
  86:                     this.productsSource.remove(this.selectedProduct);
  87:                     this.save();
  88:                 }
  89:             },
  90:          
  91:             change: function () {
  92:                 this.set("hasChanges", true);
  93:             }
  94:         });
  95:         console.log(viewModel);
  96:         kendo.bind($("#form-container"), viewModel);
  97:         });
  98:  
  99:  
 100:     //}, 1);
 101: </script>