分层访客模式示例

时间:2013-11-10 22:01:46

标签: c# design-patterns software-design

我有一个xml样本结构,如下所示

<ManagementPack ContentReadable="true" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Manifest>
<Identity>
  <ID></ID>
  <Version></Version>
</Identity>
<Name></Name>
<References>
 <Reference Alias="SC">
    <ID></ID>
    <Version></Version>
    <PublicKeyToken></PublicKeyToken>
  </Reference>   
</References>
</Manifest>
<TypeDefinitions>
<EntityTypes>
  <ClassTypes>
    <ClassType ID="" Base="" Accessibility="" Abstract="" Hosted="" Singleton="" />
  </ClassTypes>
<RelationshipTypes>
    <RelationshipType ID="" Accessibility="" Base="" Abstract="">
      <Source></Source>
      <Target></Target>
    </RelationshipType>
   </RelationshipTypes>
</EntityTypes>
  </TypeDefinitions>
  <Monitoring>
<Discoveries>
  <Discovery ID="" Enabled="" Target="" ConfirmDelivery="" Remotable="" Priority="">
    <Category>Discovery</Category>
    <DiscoveryTypes />
    <DataSource ID="" TypeID="">
      <RuleId></RuleId>
      <GroupInstanceId></GroupInstanceId>
      <MembershipRules>
        <MembershipRule>
          <MonitoringClass></MonitoringClass>
          <RelationshipClass></RelationshipClass>
        </MembershipRule>
      </MembershipRules>
    </DataSource>
  </Discovery>
 </Discoveries>

....等 我正在尝试生成此XML结构。看来我可以用访问者模式来管理它,但由于结构包含节点,访问者模式似乎还不够。我在http://c2.com/cgi/wiki?HierarchicalVisitorPattern偶然发现了等级访问者,但我无法创建样本。我的优先级是减少if-else或switch语句。那么有关于分层访问者的C#的示例实现还是带有完整样本的简单解释?

0 个答案:

没有答案