2011-12-14 11 views
0

私はWebパーツでSharePointを勉強しています。このサンプルコードと私のしていることを理解しようとしています。 ここだから、これが意味するか、行うこの [(「cf5f3fd5-1776-4c47-9587-4f6fe4f3d645」)のGuid]は何かということです私は私の最初の質問で働いていているサンプルSharepointコントロールとwebparts C#の説明

using System; 
using System.Runtime.InteropServices; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
using System.Web.UI.WebControls.WebParts; 
using System.Xml.Serialization; 
using Microsoft.SharePoint; 
using Microsoft.SharePoint.WebControls; 
using Microsoft.SharePoint.WebPartPages; 

namespace SampleWebpart1 

    { 
    [Guid("cf5f3fd5-1776-4c47-9587-4f6fe4f3d645")] 

    public class SampleWebpart1 : Microsoft.SharePoint.WebPartPages.WebPart    
     { 

      public SampleWebpart1() { } 

      protected override void CreateChildControls() 
      { 
       base.CreateChildControls(); 
       SharePointCalendar calendar = new SharePointCalendar(); 
       Controls.Add(calendar); 
      } 
     } 

    public class SharePointCalendar : Control 

    { 
     private SPCalendarView _view; 
     /// Create the SharePoint calendar. Uses the SharePoint SPCalendarView object. 
     protected override void CreateChildControls() 
     { 
      base.CreateChildControls(); 
      _view = new SPCalendarView(); 
      _view.EnableViewState = true; 
      _view.Width = Unit.Percentage(100); 
      _view.DataSource = GetCalendarItems(); 
      DataBind(); 
      Controls.Add(_view); 
     } 

     private SPCalendarItemCollection GetCalendarItems() 
     { 

      // Create a new collection for the calendar items 
      // This is an item with a start and end date. 
      SPCalendarItemCollection items = new SPCalendarItemCollection(); 
     // Add the first dummy item 
      SPCalendarItem item = new SPCalendarItem(); 
      item.StartDate = DateTime.Now; 
      item.EndDate = DateTime.Now.AddHours(1); 
      item.hasEndDate = true; 
      item.Title = "First calendar item"; 
      item.DisplayFormUrl = "/News"; 
      item.Location = "USA"; 
      item.Description = "This is the first test item in the calendar rollup"; 
      item.IsAllDayEvent = false; 
      item.IsRecurrence = false; 
      item.CalendarType = Convert.ToInt32(SPCalendarType.Gregorian); 
      items.Add(item); 
     // Add the second item. This is an all day event. 
     SPCalendarItem item2 = new SPCalendarItem(); 
     item2.StartDate = DateTime.Now.AddDays(-1); 
     item.hasEndDate = true; 
     item2.Title = "Second calendar item"; 
     item2.DisplayFormUrl = "/News"; 
     item2.Location = "India"; 
     item2.Description = "This is the second test item in the calendar rollup"; 
     item2.IsAllDayEvent = true; 
     item2.IsRecurrence = false; 
     item2.CalendarType = Convert.ToInt32(SPCalendarType.Gregorian); 
     items.Add(item2); 
     // return the collection 
     return items; 
     } 

     } 

    } 

です。私はXNAのようなものを見てきましたが、それはコンテンツ処理のためのものでした。

この行の意味は次のとおりです。public class SharePointCalendar:Control クラスsharpointcalendarによってコントロールが拡張されているということですか?

これで何ができますか?そしてなぜ前に見えているのですか?これで任意のヘルプ

 _view = new SPCalendarView(); 
     _view.EnableViewState = true; 
     _view.Width = Unit.Percentage(100); 
     _view.DataSource = GetCalendarItems(); 

感謝:)

+2

これはかなり基本的な質問です。 C#を最初に学ぶべきでしょう。 –

答えて

0

は_ダッシュは、変数がプライベートであることを述べることで、これはオプションであり、あなたが好きなようにあなたはそれに名前を付けることができます。しかし、ほとんどのプログラミング言語は、ネーミング規則と呼ばれるこのパターンに従い、SharePointで開発を始める前に知っておくべきだと思います! :)

  • パブリック - 最初の文字が大文字
  • 保護されている - 最初の文字が小文字
  • _privateある - 最初の文字はGUIDである小文字

続くダッシュ問題のクラスを表すCOM識別子。外部のコンポーネントを識別するために使用されます。

この例では、リモートシステムでwebpartを実行したり、外部アセンブリなどでアクセスする場合を除いて、この例ではguidを使用する理由はほとんどありません。

+0

ああ、本当にありがとうございました。 – MNM

1

SharePoint開発に入る前に、C#とASP.NETを学ぶ必要があります。「C#ステップバイステップ」と「ASP.NETステップバイステップ」(Microsoft Press)あなたが始めることができる本の数。最初にC#を学んだ後、ASP.NETに移動してください。その後、SharePoint開発に飛び乗る準備が整いました。良い出発点は、 "Beginning SharePoint 2010 Development"(WROX)Pressのような本です。

GUIDは「Globally Unique IDentifier」の略で、Windowsのリソースにはに割り当てることができる一意のIDです。 GUIDは、「Galactically Unique Identifier」と呼ばれることもあります。これは、2つのGUIDが繰り返される可能性は非常に低いためです。

クラス宣言のコロンは、クラスがコントロールから継承することを意味します。

+0

ああ、それはフォームをコントロールを継承する – MNM