ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
§º§Ñ§Ò§Ý§à§ß§í §á§â§à§Ö§Ü§ä§Ú§â§à§Ó§Ñ§ß§Ú§ñ §¹§Ñ§ã§ä§î §Ó§ä§à§â§Ñ§ñ
§±§à§â§à§Ø§Õ§Ñ§ð§ë§Ú§Ö §ê§Ñ§Ò§Ý§à§ß§í ¡ª  Factory ( §æ§Ñ§Ò§â§Ú§Ü§Ñ, §æ§Ñ§Ò§â§Ú§é§ß§í§Û §Þ§Ö§ä§à§Õ) ¡ª  Abstract Factory  (§Ñ§Ò§ã§ä§â§Ñ§Ü§ä§ß§Ñ§ñ §æ§Ñ§Ò§â§Ú§Ü§Ñ) ¡ª  Singleton ( §à§Õ§Ú§ß§à§é§Ü§Ñ) ¡ª  Lazy Load ( §Ù§Ñ§Ô§â§å§Ù§Ü§Ñ §á§à §ä§â§Ö§Ò§à§Ó§Ñ§ß§Ú§ð)
Fa?ade  (§æ§Ñ§ã§Ñ§Õ)
Fa?ade  (§æ§Ñ§ã§Ñ§Õ) class TreeNode { } class SearchResult { } static class ACAlgoritm { public static TreeNode BuildTree(string[] a_Keywords) { ¡­ } public static SearchResult[] FindAll(TreeNode a_Root, string a_Text) { ¡­ } } class SearchAlgoritm { TreeNode m_Root; public SearchAlgoritm(string[] a_Keywords) { m_Root = ACAlgoritm.BuildTree(a_Keywords); } public SearchResult[] FindAll(string a_Text) { return ACAlgoritm.FindAll(m_Root, a_Text); } public static SearchResult[] FindAll( string[] a_Keywords, string a_Text) { return ACAlgoritm.FindAll( ACAlgoritm.BuildTree(a_Keywords),  a_Text); } }
Fa?ade  (§æ§Ñ§ã§Ñ§Õ) ¡ª  §±§â§Ö§Õ§à§ã§ä§Ñ§Ó§Ú§ä§î §Ò§à§Ý§Ö§Ö §å§Õ§à§Ò§ß§í§Û §Ú§ß§ä§Ö§â§æ§Ö§Û§ã §Õ§Ý§ñ §Ú§ã§á§à§Ý§î§Ù§à§Ó§Ñ§ß§Ú§ñ §Ò§Ú§Ò§Ý§Ú§à§ä§Ö§Ü§Ú, §Ù§Ñ §ã§é§Ö§ä §ß§Ñ§Ý§Ú§é§Ú§ñ §ã§á§Ö§è§Ú§Ñ§Ý§î§ß§í§ç §å§Õ§à§Ò§ß§í§ç §Þ§Ö§ä§à§Õ§à§Ó ¡ª  §±§à§Ó§í§ã§Ú§ä§î §é§Ú§ä§Ñ§Ö§Þ§à§ã§ä§î §Ü§Ý§Ú§Ö§ß§ä§ã§Ü§à§Ô§à §Ü§à§Õ§Ñ (§á§à§Ó§í§ê§Ö§ß§Ú§Ö §å§â§à§Ó§ß§ñ §Ñ§Ò§ã§ä§â§Ñ§Ü§è§Ú§Ú) ¡ª  §³§ß§Ú§Ù§Ú§ä§î §ã§Ó§ñ§Ù§Ñ§ß§ß§à§ã§ä§î §Þ§Ö§Ø§Õ§å §Ü§Ý§Ú§Ö§ß§ä§ã§Ü§Ú§Þ §Ü§à§Õ§à§Þ §Ú §Ü§à§Õ§à§Þ §Þ§à§Õ§å§Ý§ñ ¡ª  §³§à§Ù§Õ§Ñ§ä§î §ã§à§Ò§ã§ä§Ó§Ö§ß§ß§í§Û §ç§à§â§à§ê§à §ã§á§â§à§Ö§Ü§ä§Ú§â§à§Ó§Ñ§ß§ß§í§Û  API  §Õ§Ý§ñ §ã§ä§à§â§à§ß§ß§Ö§Û §Ò§Ú§Ò§Ý§Ú§à§ä§Ö§Ü§Ú, §å §Ü§à§ä§à§â§à§Û §ã§Ó§à§Û  API  §á§Ý§à§ç§à §ã§á§â§à§Ö§Ü§ä§Ú§â§à§Ó§Ñ§ß
Composite ( §Ü§à§Þ§á§à§ß§à§Ó§ë§Ú§Ü)
Composite ( §Ü§à§Þ§á§à§ß§à§Ó§ë§Ú§Ü) select  *  from  Companies  where  (IsClient = 1  or  IsFormerClient = 1)  and  IsDeleted = 0  and  id_Object = 103
Composite ( §Ü§à§Þ§á§à§ß§à§Ó§ë§Ú§Ü) IsClient = 1  or  IsFormerClient = 1)  and  IsDeleted = 0  and  id_Object = 103
Composite ( §Ü§à§Þ§á§à§ß§à§Ó§ë§Ú§Ü) interface IFilter { string GetSql(); } interface ICompositeFilter : IFilter { void AddFilter(IFilter a_Filter); }
Composite ( §Ü§à§Þ§á§à§ß§à§Ó§ë§Ú§Ü) class ScalarFilter : IFilter { string m_Sql; public ScalarFilter(string a_Field, string a_Relation, object a_Value) { m_Sql = string.Format("{0} {1} {2}", a_Field, a_Relation, a_Value); } public ScalarFilter(string a_Field, object a_Value) : this (a_Field, "=", a_Value) {} public string GetSql() { return m_Sql; } }
Composite ( §Ü§à§Þ§á§à§ß§à§Ó§ë§Ú§Ü) class AndFilter : ICompositeFilter { List<IFilter> m_Filters = new List<IFilter>(); public void AddFilter(IFilter a_Filter) { m_Filters.Add(a_Filter); } public string GetSql() { string result = string.Empty; foreach (IFilter filter in m_Filters) { if (result != &quot;&quot;) result += &quot; and &quot;; result += filter.GetSql(); } return result; } }
Composite ( §Ü§à§Þ§á§à§ß§à§Ó§ë§Ú§Ü) protected IFilter GetFilterInternal() {  XAndFilter result = new XAndFilter(); if (ObjectsItemSelection.HasSelectedItems) { XOrFilter objectFilter = new XOrFilter(); foreach (XObject obj in ObjectsItemSelection.SelectedItems)  objectFilter.Add(new XScalarFilter(&quot;id_Object&quot;, obj.Id));  result.Add(objectFilter); } if (OperatorCheckBox.Checked || ClientCheckBox.Checked || FormerClientCheckBox.Checked) { XAndFilter categoryFilter = new XAndFilter(); if (OperatorCheckBox.Checked) categoryFilter.Add(new XScalarFilter(&quot;IsOperator&quot;, 1)); if (ClientCheckBox.Checked) categoryFilter.Add(new XScalarFilter(&quot;IsClient&quot;, 1)); ¡­ result.Add(categoryFilter); } if (HoldingComboBox.Text.Trim() != &quot;&quot;) { result.Add(DB.Companies.HoldingFilter(HoldingComboBox.Text.Trim())); } ¡­ return result; }
Composite ( §Ü§à§Þ§á§à§ß§à§Ó§ë§Ú§Ü) §¬§à§Þ§á§à§ß§à§Ó§ë§Ú§Ü ¡ª §ï§ä§à §Ü§â§å§ä§à!
§¡§ç§ä§å§ß§Ô! public class XScalarFilter : IFilter { string m_Command; IDataParameter m_Parameter; public XScalarFilter(string a_Field, string a_Relation, object a_Value) {  int counter = XFilter.Counter; m_Command = string.Format(&quot;{0} {1} @p{2}&quot;, a_Field, a_Relation, counter); m_Parameter = new SqlParameter(); m_Parameter.Value = a_Value; m_Parameter.ParameterName = &quot;@p&quot; + counter; } public XScalarFilter(string a_Field, object a_Value) : this(a_Field, &quot;=&quot;, a_Value)   {} public string SqlText { get { return m_Command; } } public IList<IDataParameter> Parameters { get { return new IDataParameter[] { m_Parameter }; } } }
§©§Ñ§Õ§Ñ§é§Ñ
Command ( §Ü§à§Þ§Ñ§ß§Õ§Ñ) interface ICommand { void Run(); } interface ICommand { void Do(); void UnDo(); } foreach(ICommand command in GetCommands()) { command.Do(); }
Command ( §Ü§à§Þ§Ñ§ß§Õ§Ñ) <?xml version='1.0' encoding='windows-1251'?> <template> <parts> <part type=&quot;Cell&quot; cell=&quot;Contract&quot;> <sql>select ContractNumber from CompanyClients where id_Company = @id_Company</sql> </part> <part type=&quot;Cell&quot; cell=&quot;CompName&quot;> <sql>select FullName from Companies where id = @id_Company</sql> </part> <part type=&quot;Cell&quot; cell=&quot;SmallCompName&quot;> <sql>select FullName from Companies where id = @id_Company</sql> </part> <part type=&quot;Cell&quot; cell=&quot;Month&quot;> <sql>select @DateFrom</sql> </part> <part type=&quot;Table&quot; cell=&quot;AbonTable&quot; groupBy=&quot;BService&quot;> <sql> select ... </sql>  </part> </parts> </template>
Command ( §Ü§à§Þ§Ñ§ß§Õ§Ñ)
§±§Ý§Ñ§Ô§Ú§ß§í [TemplateItem(TemplateKind.ExcelSpreadsheet, &quot;Cell&quot;)] public class XCellTemplateItem : XTemplateItem { public override void Apply() { XExcelWorkDesk wd = (XExcelWorkDesk)WorkDesk; ¡­ } } [TemplateItem(TemplateKind.ExcelSpreadsheet, &quot;Table&quot;)] class XTableTemplateItem : XTemplateItem { }
§±§Ý§Ñ§Ô§Ú§ß§í Type FindTypeByName(string a_Name) { foreach (Type type in GetType().Assembly.GetTypes()) { if (!type.IsSubclassOf(typeof(XTemplateItem))) { continue; } if (!type.IsDefined(typeof(TemplateItemAttribute), false)) { continue; } TemplateItemAttribute attr = (TemplateItemAttribute)type.GetCustomAttributes(typeof(TemplateItemAttribute), false)[0]; if (attr.TemplateKind == m_Template.TemplateKind && attr.Name == a_Name) { return type; } } return null; }
Template Method  ( §ê§Ñ§Ò§Ý§à§ß§ß§í§Û §Þ§Ö§ä§à§Õ) abstract class Game  {  protected int playersCount;  protected  abstract void initializeGame();  protected  abstract void makePlay(int player);  protected  abstract bool endOfGame();  protected  abstract void printWinner(); /* A template method : */ public  void playOneGame(int playersCount) { this.playersCount = playersCount; initializeGame(); int j = 0; while (!endOfGame()) { makePlay(j); j = (j + 1) % playersCount; } printWinner(); } }
Template Method  ( §ê§Ñ§Ò§Ý§à§ß§ß§í§Û §Þ§Ö§ä§à§Õ) abstract public class XParser { public XCallInformation ParseAndProcess(XBillingString a_BillingString) { a_BillingString.SetParser(this); XCallInformation result = DoParse(a_BillingString); if (result == null) { XBilling.RegisterError(a_BillingString); } return result; } public XCallInformation Parse(XBillingString a_BillingString) { a_BillingString.SetParser(this); return DoParse(a_BillingString); } }
Strategy ( §ã§ä§â§Ñ§ä§Ö§Ô§Ú§ñ) class XDocumentConflictManager { public XDocumentConflict FindConflict( XDocument a_Document, bool a_ForRegisteration) { XDocumentConflictFindingStrategy strategy =  XDocumentConflictFindingStrategy.Create(a_Document, a_ForRegisteration); return new XDocumentConflict( a_Document,  strategy.FindSameDocuments(),  strategy); } }
Strategy ( §ã§ä§â§Ñ§ä§Ö§Ô§Ú§ñ) public abstract class XDocumentConflictFindingStrategy { XDocument m_Document; protected XDocumentConflictFindingStrategy(XDocument a_Document) { m_Document = a_Document; } public static XDocumentConflictFindingStrategy Create(XDocument a_Document, bool a_ForRegistration) { ¡­ } public IList<XDocument> FindSameDocuments() { return XDocumentRepository.Instance.Find(GetSameDocumentsFilter()); } protected abstract IFilter GetSameDocumentsFilter(); public abstract string GetConflictDefinition(); }
Strategy ( §ã§ä§â§Ñ§ä§Ö§Ô§Ú§ñ) public class XBillingConflictFindingStrategy : XDocumentConflictFindingStrategy { internal XBillingConflictFindingStrategy(XDocument a_Document) : base(a_Document) { } protected override IFilter GetSameDocumentsFilter() { return new XAndFilter( DB.vDocuments.idFilter(&quot;!=&quot;, Document.Id), DB.vDocuments.id_CompanyFilter(Document.Company.Id), DB.vDocuments.DocumentDateFilter(Document.DocumentDate), DB.vDocuments.id_TemplateFilter(Document.Template.Id) ); } public override string GetConflictDefinition() { return string.Format(&quot;§¬§à§Þ§á§Ñ§ß§Ú§ñ ?{0}? §å§Ø§Ö §Ú§Þ§Ö§Ö§ä §â§Ñ§ã§ê§Ú§æ§â§à§Ó§Ü§å ?{1}? §Ù§Ñ ?{2:MMMM yyyy}?.&quot;, Document.Company.Alias, Document.Template.Name, Document.DocumentDate); } }

More Related Content

§º§Ñ§Ò§Ý§à§ß§í §á§â§à§Ö§Ü§ä§Ú§â§à§Ó§Ñ§ß§Ú§ñ 2

  • 2. §±§à§â§à§Ø§Õ§Ñ§ð§ë§Ú§Ö §ê§Ñ§Ò§Ý§à§ß§í ¡ª Factory ( §æ§Ñ§Ò§â§Ú§Ü§Ñ, §æ§Ñ§Ò§â§Ú§é§ß§í§Û §Þ§Ö§ä§à§Õ) ¡ª Abstract Factory (§Ñ§Ò§ã§ä§â§Ñ§Ü§ä§ß§Ñ§ñ §æ§Ñ§Ò§â§Ú§Ü§Ñ) ¡ª Singleton ( §à§Õ§Ú§ß§à§é§Ü§Ñ) ¡ª Lazy Load ( §Ù§Ñ§Ô§â§å§Ù§Ü§Ñ §á§à §ä§â§Ö§Ò§à§Ó§Ñ§ß§Ú§ð)
  • 4. Fa?ade (§æ§Ñ§ã§Ñ§Õ) class TreeNode { } class SearchResult { } static class ACAlgoritm { public static TreeNode BuildTree(string[] a_Keywords) { ¡­ } public static SearchResult[] FindAll(TreeNode a_Root, string a_Text) { ¡­ } } class SearchAlgoritm { TreeNode m_Root; public SearchAlgoritm(string[] a_Keywords) { m_Root = ACAlgoritm.BuildTree(a_Keywords); } public SearchResult[] FindAll(string a_Text) { return ACAlgoritm.FindAll(m_Root, a_Text); } public static SearchResult[] FindAll( string[] a_Keywords, string a_Text) { return ACAlgoritm.FindAll( ACAlgoritm.BuildTree(a_Keywords), a_Text); } }
  • 5. Fa?ade (§æ§Ñ§ã§Ñ§Õ) ¡ª §±§â§Ö§Õ§à§ã§ä§Ñ§Ó§Ú§ä§î §Ò§à§Ý§Ö§Ö §å§Õ§à§Ò§ß§í§Û §Ú§ß§ä§Ö§â§æ§Ö§Û§ã §Õ§Ý§ñ §Ú§ã§á§à§Ý§î§Ù§à§Ó§Ñ§ß§Ú§ñ §Ò§Ú§Ò§Ý§Ú§à§ä§Ö§Ü§Ú, §Ù§Ñ §ã§é§Ö§ä §ß§Ñ§Ý§Ú§é§Ú§ñ §ã§á§Ö§è§Ú§Ñ§Ý§î§ß§í§ç §å§Õ§à§Ò§ß§í§ç §Þ§Ö§ä§à§Õ§à§Ó ¡ª §±§à§Ó§í§ã§Ú§ä§î §é§Ú§ä§Ñ§Ö§Þ§à§ã§ä§î §Ü§Ý§Ú§Ö§ß§ä§ã§Ü§à§Ô§à §Ü§à§Õ§Ñ (§á§à§Ó§í§ê§Ö§ß§Ú§Ö §å§â§à§Ó§ß§ñ §Ñ§Ò§ã§ä§â§Ñ§Ü§è§Ú§Ú) ¡ª §³§ß§Ú§Ù§Ú§ä§î §ã§Ó§ñ§Ù§Ñ§ß§ß§à§ã§ä§î §Þ§Ö§Ø§Õ§å §Ü§Ý§Ú§Ö§ß§ä§ã§Ü§Ú§Þ §Ü§à§Õ§à§Þ §Ú §Ü§à§Õ§à§Þ §Þ§à§Õ§å§Ý§ñ ¡ª §³§à§Ù§Õ§Ñ§ä§î §ã§à§Ò§ã§ä§Ó§Ö§ß§ß§í§Û §ç§à§â§à§ê§à §ã§á§â§à§Ö§Ü§ä§Ú§â§à§Ó§Ñ§ß§ß§í§Û API §Õ§Ý§ñ §ã§ä§à§â§à§ß§ß§Ö§Û §Ò§Ú§Ò§Ý§Ú§à§ä§Ö§Ü§Ú, §å §Ü§à§ä§à§â§à§Û §ã§Ó§à§Û API §á§Ý§à§ç§à §ã§á§â§à§Ö§Ü§ä§Ú§â§à§Ó§Ñ§ß
  • 7. Composite ( §Ü§à§Þ§á§à§ß§à§Ó§ë§Ú§Ü) select * from Companies where (IsClient = 1 or IsFormerClient = 1) and IsDeleted = 0 and id_Object = 103
  • 8. Composite ( §Ü§à§Þ§á§à§ß§à§Ó§ë§Ú§Ü) IsClient = 1 or IsFormerClient = 1) and IsDeleted = 0 and id_Object = 103
  • 9. Composite ( §Ü§à§Þ§á§à§ß§à§Ó§ë§Ú§Ü) interface IFilter { string GetSql(); } interface ICompositeFilter : IFilter { void AddFilter(IFilter a_Filter); }
  • 10. Composite ( §Ü§à§Þ§á§à§ß§à§Ó§ë§Ú§Ü) class ScalarFilter : IFilter { string m_Sql; public ScalarFilter(string a_Field, string a_Relation, object a_Value) { m_Sql = string.Format(&quot;{0} {1} {2}&quot;, a_Field, a_Relation, a_Value); } public ScalarFilter(string a_Field, object a_Value) : this (a_Field, &quot;=&quot;, a_Value) {} public string GetSql() { return m_Sql; } }
  • 11. Composite ( §Ü§à§Þ§á§à§ß§à§Ó§ë§Ú§Ü) class AndFilter : ICompositeFilter { List<IFilter> m_Filters = new List<IFilter>(); public void AddFilter(IFilter a_Filter) { m_Filters.Add(a_Filter); } public string GetSql() { string result = string.Empty; foreach (IFilter filter in m_Filters) { if (result != &quot;&quot;) result += &quot; and &quot;; result += filter.GetSql(); } return result; } }
  • 12. Composite ( §Ü§à§Þ§á§à§ß§à§Ó§ë§Ú§Ü) protected IFilter GetFilterInternal() { XAndFilter result = new XAndFilter(); if (ObjectsItemSelection.HasSelectedItems) { XOrFilter objectFilter = new XOrFilter(); foreach (XObject obj in ObjectsItemSelection.SelectedItems) objectFilter.Add(new XScalarFilter(&quot;id_Object&quot;, obj.Id)); result.Add(objectFilter); } if (OperatorCheckBox.Checked || ClientCheckBox.Checked || FormerClientCheckBox.Checked) { XAndFilter categoryFilter = new XAndFilter(); if (OperatorCheckBox.Checked) categoryFilter.Add(new XScalarFilter(&quot;IsOperator&quot;, 1)); if (ClientCheckBox.Checked) categoryFilter.Add(new XScalarFilter(&quot;IsClient&quot;, 1)); ¡­ result.Add(categoryFilter); } if (HoldingComboBox.Text.Trim() != &quot;&quot;) { result.Add(DB.Companies.HoldingFilter(HoldingComboBox.Text.Trim())); } ¡­ return result; }
  • 13. Composite ( §Ü§à§Þ§á§à§ß§à§Ó§ë§Ú§Ü) §¬§à§Þ§á§à§ß§à§Ó§ë§Ú§Ü ¡ª §ï§ä§à §Ü§â§å§ä§à!
  • 14. §¡§ç§ä§å§ß§Ô! public class XScalarFilter : IFilter { string m_Command; IDataParameter m_Parameter; public XScalarFilter(string a_Field, string a_Relation, object a_Value) { int counter = XFilter.Counter; m_Command = string.Format(&quot;{0} {1} @p{2}&quot;, a_Field, a_Relation, counter); m_Parameter = new SqlParameter(); m_Parameter.Value = a_Value; m_Parameter.ParameterName = &quot;@p&quot; + counter; } public XScalarFilter(string a_Field, object a_Value) : this(a_Field, &quot;=&quot;, a_Value) {} public string SqlText { get { return m_Command; } } public IList<IDataParameter> Parameters { get { return new IDataParameter[] { m_Parameter }; } } }
  • 16. Command ( §Ü§à§Þ§Ñ§ß§Õ§Ñ) interface ICommand { void Run(); } interface ICommand { void Do(); void UnDo(); } foreach(ICommand command in GetCommands()) { command.Do(); }
  • 17. Command ( §Ü§à§Þ§Ñ§ß§Õ§Ñ) <?xml version='1.0' encoding='windows-1251'?> <template> <parts> <part type=&quot;Cell&quot; cell=&quot;Contract&quot;> <sql>select ContractNumber from CompanyClients where id_Company = @id_Company</sql> </part> <part type=&quot;Cell&quot; cell=&quot;CompName&quot;> <sql>select FullName from Companies where id = @id_Company</sql> </part> <part type=&quot;Cell&quot; cell=&quot;SmallCompName&quot;> <sql>select FullName from Companies where id = @id_Company</sql> </part> <part type=&quot;Cell&quot; cell=&quot;Month&quot;> <sql>select @DateFrom</sql> </part> <part type=&quot;Table&quot; cell=&quot;AbonTable&quot; groupBy=&quot;BService&quot;> <sql> select ... </sql> </part> </parts> </template>
  • 19. §±§Ý§Ñ§Ô§Ú§ß§í [TemplateItem(TemplateKind.ExcelSpreadsheet, &quot;Cell&quot;)] public class XCellTemplateItem : XTemplateItem { public override void Apply() { XExcelWorkDesk wd = (XExcelWorkDesk)WorkDesk; ¡­ } } [TemplateItem(TemplateKind.ExcelSpreadsheet, &quot;Table&quot;)] class XTableTemplateItem : XTemplateItem { }
  • 20. §±§Ý§Ñ§Ô§Ú§ß§í Type FindTypeByName(string a_Name) { foreach (Type type in GetType().Assembly.GetTypes()) { if (!type.IsSubclassOf(typeof(XTemplateItem))) { continue; } if (!type.IsDefined(typeof(TemplateItemAttribute), false)) { continue; } TemplateItemAttribute attr = (TemplateItemAttribute)type.GetCustomAttributes(typeof(TemplateItemAttribute), false)[0]; if (attr.TemplateKind == m_Template.TemplateKind && attr.Name == a_Name) { return type; } } return null; }
  • 21. Template Method ( §ê§Ñ§Ò§Ý§à§ß§ß§í§Û §Þ§Ö§ä§à§Õ) abstract class Game { protected int playersCount; protected abstract void initializeGame(); protected abstract void makePlay(int player); protected abstract bool endOfGame(); protected abstract void printWinner(); /* A template method : */ public void playOneGame(int playersCount) { this.playersCount = playersCount; initializeGame(); int j = 0; while (!endOfGame()) { makePlay(j); j = (j + 1) % playersCount; } printWinner(); } }
  • 22. Template Method ( §ê§Ñ§Ò§Ý§à§ß§ß§í§Û §Þ§Ö§ä§à§Õ) abstract public class XParser { public XCallInformation ParseAndProcess(XBillingString a_BillingString) { a_BillingString.SetParser(this); XCallInformation result = DoParse(a_BillingString); if (result == null) { XBilling.RegisterError(a_BillingString); } return result; } public XCallInformation Parse(XBillingString a_BillingString) { a_BillingString.SetParser(this); return DoParse(a_BillingString); } }
  • 23. Strategy ( §ã§ä§â§Ñ§ä§Ö§Ô§Ú§ñ) class XDocumentConflictManager { public XDocumentConflict FindConflict( XDocument a_Document, bool a_ForRegisteration) { XDocumentConflictFindingStrategy strategy = XDocumentConflictFindingStrategy.Create(a_Document, a_ForRegisteration); return new XDocumentConflict( a_Document, strategy.FindSameDocuments(), strategy); } }
  • 24. Strategy ( §ã§ä§â§Ñ§ä§Ö§Ô§Ú§ñ) public abstract class XDocumentConflictFindingStrategy { XDocument m_Document; protected XDocumentConflictFindingStrategy(XDocument a_Document) { m_Document = a_Document; } public static XDocumentConflictFindingStrategy Create(XDocument a_Document, bool a_ForRegistration) { ¡­ } public IList<XDocument> FindSameDocuments() { return XDocumentRepository.Instance.Find(GetSameDocumentsFilter()); } protected abstract IFilter GetSameDocumentsFilter(); public abstract string GetConflictDefinition(); }
  • 25. Strategy ( §ã§ä§â§Ñ§ä§Ö§Ô§Ú§ñ) public class XBillingConflictFindingStrategy : XDocumentConflictFindingStrategy { internal XBillingConflictFindingStrategy(XDocument a_Document) : base(a_Document) { } protected override IFilter GetSameDocumentsFilter() { return new XAndFilter( DB.vDocuments.idFilter(&quot;!=&quot;, Document.Id), DB.vDocuments.id_CompanyFilter(Document.Company.Id), DB.vDocuments.DocumentDateFilter(Document.DocumentDate), DB.vDocuments.id_TemplateFilter(Document.Template.Id) ); } public override string GetConflictDefinition() { return string.Format(&quot;§¬§à§Þ§á§Ñ§ß§Ú§ñ ?{0}? §å§Ø§Ö §Ú§Þ§Ö§Ö§ä §â§Ñ§ã§ê§Ú§æ§â§à§Ó§Ü§å ?{1}? §Ù§Ñ ?{2:MMMM yyyy}?.&quot;, Document.Company.Alias, Document.Template.Name, Document.DocumentDate); } }