CommunityServer学习之旅(一)

http://code.communityserver.org
代码片段1:~/CS Tree/CS 2.1/Forums/Forums.cs
24       public sealed class Forums {
25   
26           #region CreateUpdateDelete
27           public static int Update(Forum f)
28           {
29               return Sections.UpdateSection(f);
30           }

31   
32           public static int Add(Forum f)
33           {
34               return Sections.AddSection(f);
35           }

36   
37           public static void Delete(Forum f)
38           {
39               Sections.DeleteSection(f);
40   
41               ForumAttachmentSettings fas = ForumConfiguration.Instance().AttachmentSettings;
42   
43               try
44               {
45                   fas.DeleteSectionFromDisk(f.SectionID);
46               }

47               catch(IOException ex)
48               
49                   new CSException(CSExceptionType.AccessDenied, "Delete: Permission to delete file on filesystem denied.", ex).Log(); 
50               }

51               catch(SecurityException ex)
52               
53                   new CSException(CSExceptionType.AccessDenied, "Delete: Permission to delete file on filesystem denied.", ex).Log(); 
54               }

55               catch { }
56           }

57           #endregion


代码片段2:~/CS Tree/CS 2.1/Components/Sections.cs
16       public class Sections
17       {
18           private Sections()
19           {
20           }

21   
22           /// <summary>
23           /// Adds a new Sections
24           /// </summary>
25           public static int AddSection (Section section) 
26           {
27               CSEvents.BeforeSection(section,ObjectState.Create,section.ApplicationType);
28   
29               section.SectionID = CreateUpdateDeleteSection(section, DataProviderAction.Create);
30               EventLogs.Write(string.Format("Section {0} ({1}) in application {2} was created",section.Name,section.SectionID,section.ApplicationType),"Data"204,EventType.Information, CSContext.Current.SettingsID);
31               CSEvents.AfterSection(section,ObjectState.Create,section.ApplicationType);
32               
33               return section.SectionID;
34           }

35   

代码片段3:~/CS Tree/CS 2.1/Components/Components/CSEvents.cs
9        public class CSEvents
10       {
11           private CSEvents(){}
12   
123          Sections

代码片段4:~/CS Tree/CS 2.1/Components/Components/CSApplication.cs
83           cnstr
183  

556          Section Events
至此为止,代码进入了我不熟悉的领域——委托和事件。所以,充电先……^_^

posted on 2006-09-14 10:19  DannyNew  阅读(257)  评论(0)    收藏  举报

导航