linq做为转换工具不错,代码简洁多了
<?xml version="1.0" encoding="utf-8" ?>
<Modules>
<Module Name="ErpDefault">
<Action Id="000000" MKEntity=""
Handler="MoCoolKaErp.Handlers.CoreHandler,MoCoolKaErp" AccessRule=""
ComponentProcessor="MoCoolKaErp.Components.DefaultComponentProcessor,MoCoolKaErp"
BusinessProcessor="MoCoolKaErp.MKBusinessProcessors.DefaultBusinessProcessor,MoCoolKaErp" />
</Module>
<Module Name="ErpCore">
<Action Id="100101" MKEntity="MoCoolKaCoreErp.Model.Code.MKCodeClassEO,MoCoolKaCoreErp"/>
<Action Id="100102" MKEntity="MoCoolKaCoreErp.Model.Code.MKCodeEO,MoCoolKaCoreErp"/>
<Action Id="100203" MKEntity="MoCoolKaCoreErp.Model.Access.MKConfigEO,MoCoolKaCoreErp"/>
<Action Id="100202" MKEntity="MoCoolKaCoreErp.Model.Access.MKRoleEO,MoCoolKaCoreErp"/>
<Action Id="100201" MKEntity="MoCoolKaCoreErp.Model.Access.MKUserEO,MoCoolKaCoreErp"/>
</Module>
</Modules>
[b]linq xml to entity [/b]
IList<DefaultModule> listModule =new List<DefaultModule>( from pp in configElement.Descendants(Module_Module)
select new DefaultModule(getAttr(pp.Attribute(ServerConfig.Module_Name)), pp));
[b]linq xml to var[/b]
var moduleVar = from pp in module.Content.Descendants(ServerConfig.Module_Action)
select new { Id = getAttr(pp.Attribute(ServerConfig.Module_Id)),
MKEntity = getAttr(pp.Attribute(ServerConfig.Module_MKEntity)) ,
Handler=getAttr(pp.Attribute(ServerConfig.Module_Handler)) ,
AccessRule=getAttr(pp.Attribute(ServerConfig.Module_AccessRule)) ,
ComponentProcessor=getAttr(pp.Attribute(ServerConfig.Module_ComponentProcessor)) ,
BusinessProcessor=getAttr(pp.Attribute(ServerConfig.Module_BusinessProcessor))
};
<?xml version="1.0" encoding="utf-8" ?>
<Modules>
<Module Name="ErpDefault">
<Action Id="000000" MKEntity=""
Handler="MoCoolKaErp.Handlers.CoreHandler,MoCoolKaErp" AccessRule=""
ComponentProcessor="MoCoolKaErp.Components.DefaultComponentProcessor,MoCoolKaErp"
BusinessProcessor="MoCoolKaErp.MKBusinessProcessors.DefaultBusinessProcessor,MoCoolKaErp" />
</Module>
<Module Name="ErpCore">
<Action Id="100101" MKEntity="MoCoolKaCoreErp.Model.Code.MKCodeClassEO,MoCoolKaCoreErp"/>
<Action Id="100102" MKEntity="MoCoolKaCoreErp.Model.Code.MKCodeEO,MoCoolKaCoreErp"/>
<Action Id="100203" MKEntity="MoCoolKaCoreErp.Model.Access.MKConfigEO,MoCoolKaCoreErp"/>
<Action Id="100202" MKEntity="MoCoolKaCoreErp.Model.Access.MKRoleEO,MoCoolKaCoreErp"/>
<Action Id="100201" MKEntity="MoCoolKaCoreErp.Model.Access.MKUserEO,MoCoolKaCoreErp"/>
</Module>
</Modules>
[b]linq xml to entity [/b]
IList<DefaultModule> listModule =new List<DefaultModule>( from pp in configElement.Descendants(Module_Module)
select new DefaultModule(getAttr(pp.Attribute(ServerConfig.Module_Name)), pp));
[b]linq xml to var[/b]
var moduleVar = from pp in module.Content.Descendants(ServerConfig.Module_Action)
select new { Id = getAttr(pp.Attribute(ServerConfig.Module_Id)),
MKEntity = getAttr(pp.Attribute(ServerConfig.Module_MKEntity)) ,
Handler=getAttr(pp.Attribute(ServerConfig.Module_Handler)) ,
AccessRule=getAttr(pp.Attribute(ServerConfig.Module_AccessRule)) ,
ComponentProcessor=getAttr(pp.Attribute(ServerConfig.Module_ComponentProcessor)) ,
BusinessProcessor=getAttr(pp.Attribute(ServerConfig.Module_BusinessProcessor))
};