2013年1月28日 星期一

AttributeRouting

Define your routes directly on actions and controllers in:
ASP.NET MVC OR ASP.NET/Self-Hosted Web API

RESTful

WEB API ROUTING 網址路由

  • Web API 使用HTTP 方法的名稱慣例(naming convention)來替代。你也能明確在 action 方法上指定使用 HttpGet, HttpPost, HttpPut, HttpDelete 屬性。

     如果說我們使用的方法名稱不是 Get/Post/Put/Delete 的規則時,我們就一定要宣告它的接受動詞 (Accept Verb)。

    AccecptVerb 內寫入需對應的 HttpMthod


     
  • 在一個 RESTful API,你應該避免在 URI 使用動詞(verbs),因為 URI 應該是定義資源而不是action。
  • 如果要預防一個 action 被呼叫,可以使用 NonAction 屬性。這是一個信號跟 Framework 說此方法不是一個 action 方法。
參考資料:

2013年1月20日 星期日

iOS delegate

iPhone 地圖 app

Objective-C的記憶體管理

Objective-C VS C#

Xcode:開發IDE,像是 Visual Studio 或 Netbeans 或者 ShareDevelop。
Cocoa:函式庫,像是 MFC、.NET、Swing


  • 減號 ( 或加號 )

    C#
  • private void hello(bool ishello)
    {
       //OOXX
    }
    
    Objective-C
    -(void) hello:(BOOL)ishello
    {
       //OOXX
    }
    
    在 Objective-C 中沒有 public 和 private 的概念,可以認為全是 public。
    加號的意思在於其他函數可以調用這個類中的這個函數,而不用創建這個類的實例。

  • 中括號

    中括號可以認為如何調用你剛才寫的方法,通常在 Objective-C裡叫做「消息」。

    C#
      this.hello(true);
    
    Objective-C
      [self hello:YES];
    
  • NS****
    Jobs被Apple公司的CEO史考利趕出Apple後,建立的公司叫 NextStep,後來 Apple 買下 NextStep,就有了後來的 Mac OS X。
    NextStep 除了變身為 Mac OS X 也變成現在 iPod、iPhone、iPad 上的 iOS

    這些開發NextStep的人們比較自戀地把函數庫裡面所有的類都用NextStep的縮寫打頭命名,也就是NS****了。比較常見的比如:
  •   NSLog
      NSString
      NSInteger
      NSURL
      NSImage
    
      NSLog (@"%d",myInt);
    
    NSLog 主要是在 console 裡追蹤使用。

    還有一些其他開頭的類別
    CF:Core Foundation
    CA:Core Admination
    CG:Core Graphics
    UI :User Interface
    等...

    2013年1月8日 星期二

    檢查頁面否有輸入特殊字元

      
        
        String strReturnPageUrl ="www.google.com";
    
        protected void Page_Error(object sender, EventArgs e)
        {
            Exception ex = Server.GetLastError();
            if (ex is HttpRequestValidationException)
            {
                Session.Clear();
                JSUtil.AlertSussTranscation("請勿輸入特殊字元!", strReturnPageUrl);
            }
        }
     

    2013年1月6日 星期日

    中止操作被 WSACancelBlockingCall 呼叫打斷

    • WSACancelBlockingCall呼叫打斷 --> 最簡單的方式, 攔截 (Try Catch), 然後不理它, 因為處在 Receive 的狀態, 另一方斷線一定會引發這個 Execption。
    • 在同步Accept的等待狀況下, 一旦被打斷就會出現這個Execption. 一般是可以攔截此例外做處理就好。

    資料來源

    dynaTrace應用程式效能監控

    聚碩科技
    dynaTrace應用程式效能監控

    PA & Spotlight


    Spotlight 

    資料庫即時監控模組

    PA ( Performance Analysis )

    資料庫效能分析工具

    參考資料
    ( PDF ) Performance Analysis for Oracle

    2013年1月5日 星期六

    免費圖示網站 Glyphish


     Glyphish


    使用此網站的免費版圖示完全不需付費,只需記得在你的軟體介紹裡提及圖片是從 glyphish 而來即可。

    2013年1月4日 星期五

    Objective-C 基本教學

    Objective-C 的 Nil、nil 與 NULL
    The difference is that while NULL represents zero for any pointer, nil is specific to objects (e.g., id) and Nil is specific to class pointers.
    • nil : 正常來說,它所指的是一個物件對象,而這個對象的指標指向空 Empty。
    • Nil : 用來區別所指向的對象是一個類別 Class 而非物件。
    • NULL : 任何指向空值的指標 ( 可以想成當成一個數值來使用 )。

    Objective-C 基礎筆記

    • NULL 是使用 nil ,且 nil 是能夠傳遞訊息的,例: [nil Message];
    • BOOL 在 Object-C 型態為 YES 跟 NO;
    • 盡量使用 #improt 不使用 #include
    • 使用 NS 為型別的前輟名,例: NSString, NSNumber
    • ARC(Automatic Reference Counting) 支援 iOS 4.0 以上SDK
    • 在方法中開頭為 「+」號的是靜態方法,「-」號的是實例方法,例: +(void) helloWold; -(NSString) helloWorld;
    • .h 為標頭檔,做為宣告屬性及方法使用, .m 為Objective-C檔,做為實際編寫屬性值及方法內容使用。
    • 屬性宣告需要在 .h檔的 @interface { ........ } 之中
    • 方法宣告需要在 .h檔的 @interface {} .............. @end 之中
    • 方法實作需要在 .m檔的 @implementation {} ......................... @end 之中
    • 如宣告屬性需要在 .h檔加入 @property ,並且在 .m檔加入 @synthesize,例:
      .h > @property (nonatomic, retain) NSString userName;
      .m > @synthesize userName = _userName;
      使用 self.userName = @"Arvin"; 方式操作
    • 如宣告型別為 NSInteger, CGFloat, int, float, double, char 時,@property 需使用 assign
    • retain:保留, release:釋放, alloc(Allocation):分配, dealloc(Destruction):銷毀
    • 呼叫方法的方式為
      .h > -(void) MethodName;
      .m > -(void) MethodName {  ....... };
      呼叫使用 [self MethodName];
    • 呼叫帶參數方法為
      .h > -(void) MethodName:(NSString*) arg1 withAge:(int) arg2;
      .m > -(void) MethodName:(NSString*) arg1 withAge:(int) arg2 { ......... };
      呼叫使用 [self MethodName: @"Arvin" withAge: 27];
    • Sleep 的方法為 [NSThread sleepForTimeInterval:1];
    • #pragma mark - 可以標註區塊,例如: #pragma mark - 更新方法
    資料來源:

    Objective-C 教學網站


    分享 NB Wi-Fi


    2013年1月1日 星期二

    Xcode 使用


    教學網站


    使用Objective C 創造類別

    類別的宣告

    @Interface + 類別名稱 + @end
    ex:
    @Interface Dog
    @end

    類別的繼承

    @Interface + 類別名稱  + :+ 父類別名稱 + @end
    ex:
    @Interface Dog : Animal
    @end

    • Objective-C 不予許多重繼承。

    類別的 member

    @Interface + 類別名稱  + :+ 父類別名稱 + {
            member 1 的type + member 1 的大名 + ;
            member 2 的type + member 2 的大名 + ;
    }
    @end
    ex:
    @interface MyController : UIViewController {
       SString *name;
       BOutlet UIButton *myButton;
    }
    @end
    

    • NSString 是類別名稱,name 是個物件,在 Objective-C裡,宣告物件時必須加上星號。
    • NSObject 是所有類別的祖先。
    • NSString 為 iOS SDK 的 Foundation Framework 裡定義專門處理字串的類別。
    • Objective-C 的程式碼裡,也可以參雜 C 和 C++ 的語法和 API
    • 在 iOS SDK裡,隨處都可以看到以 NS 開頭的型別,NSNumber 即是處理數字的類別,NSArray 即是處理陣列的類別。





    Java Queue