一个简单的基于XML的模块集成框架(3)

2008-02-23 05:50:49来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折


<xs:enumeration value="CtrlShiftI"/>
<xs:enumeration value="CtrlShiftJ"/>
<xs:enumeration value="CtrlShiftK"/>
<xs:enumeration value="CtrlShiftL"/>
<xs:enumeration value="CtrlShiftM"/>
<xs:enumeration value="CtrlShiftN"/>
<xs:enumeration value="CtrlShiftO"/>
<xs:enumeration value="CtrlShiftP"/>
<xs:enumeration value="CtrlShiftQ"/>
<xs:enumeration value="CtrlShiftR"/>
<xs:enumeration value="CtrlShiftS"/>
<xs:enumeration value="CtrlShiftT"/>
<xs:enumeration value="CtrlShiftU"/>
<xs:enumeration value="CtrlShiftV"/>
<xs:enumeration value="CtrlShiftW"/>
<xs:enumeration value="CtrlShiftX"/>
<xs:enumeration value="CtrlShiftY"/>
<xs:enumeration value="CtrlShiftZ"/>
<xs:enumeration value="ShiftIns"/>
<xs:enumeration value="ShiftF1"/>
<xs:enumeration value="ShiftF2"/>
<xs:enumeration value="ShiftF3"/>
<xs:enumeration value="ShiftF4"/>
<xs:enumeration value="ShiftF5"/>
<xs:enumeration value="ShiftF6"/>
<xs:enumeration value="ShiftF7"/>
<xs:enumeration value="ShiftF8"/>
<xs:enumeration value="ShiftF9"/>
<xs:enumeration value="ShiftF10"/>
<xs:enumeration value="ShiftF11"/>
<xs:enumeration value="ShiftF12"/>
<xs:enumeration value=""/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>

3。定义一个类来加载菜单

public class MenuLoad
{
private PluginCollection m_plugins = null;
public MenuBar _menbar = new MenuBar();
public ToolStrip _toolbar = new ToolStrip();
private OutlookBar bar = new OutlookBar();
private ImageList imglist = new ImageList();
private StringBuilder builder = new StringBuilder();

public MenuLoad()
{
bar = _menbar.outlookBar;
}

private TabControl tabCtrl;
public TabControl TabCtrl
{
set
{
tabCtrl = value;
}
}

private void ValidationEventHandler(object sender, ValidationEventArgs e)
{
builder.AppendLine("验证XML文档的时候发生错误:");
builder.AppendLine("严重级别:" e.Severity);
builder.AppendLine("错误信息:" e.Message);
builder.AppendLine("------ -------- ------- ------ -------- ------- ------ -------- ------- ");
builder.AppendLine();
}

/**//// <summary>
/// 验证XML文件是否是合乎规范的文件
/// </summary>
/// <param name="xmlfile">文件名称</param>
/// <returns>是则返回true,否则返回false</returns>
private bool ValidateXml(string xmlfile)
{
bool validXml = false;
string spath = "";

spath = Application.StartupPath "\\configurations\\XMLSMenu.xsd";
if(!System.IO.File.Exists(spath))
{
throw new System.IO.FileNotFoundException(String.Format(Resources.StringFileNotFound, spath));
}

XmlReaderSettings settings = new XmlReaderSettings();
XmlSchemaSet schemaSet = new XmlSchemaSet();
schemaSet.Add(null, spath);
settings.Schemas.Add(schemaSet);
settings.ValidationType = ValidationType.Schema;
settings.ValidationEventHandler = new ValidationEventHandler(ValidationEventHandler);
settings.ValidationFlags = settings.ValidationFlags | XmlSchemaValidationFlags.ReportValidationWarnings;

XmlReader reader = XmlReader.Create(xmlfile, settings);


while(reader.Read())
{

}

if(builder.Length > 0)
{
validXml = false;
}
else
{
validXml = true;

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:读取XML为行记录

下一篇:从XML中读取数据到内存的实例