本文整理汇总了C#中Schema.getText方法的典型用法代码示例。如果您正苦于以下问题:C# Schema.getText方法的具体用法?C# Schema.getText怎么用?C# Schema.getText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Schema
的用法示例。
在下文中一共展示了Schema.getText方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadText
/// <summary>
/// This <c>readText</c> method is used to read the text value
/// from the XML element node specified. This will check the class
/// schema to determine if a <c>Text</c> annotation was
/// specified. If one was specified then the text within the XML
/// element input node is used to populate the contact value.
/// </summary>
/// <param name="node">
/// this is the XML element to acquire the text from
/// </param>
/// <param name="source">
/// the type of the object that is being deserialized
/// </param>
/// <param name="schema">
/// this is used to visit the element contacts
/// </param>
public void ReadText(InputNode node, Object source, Schema schema) {
Label label = schema.getText();
if(label != null) {
Read(node, source, label);
}
}
示例2: ValidateText
/// <summary>
/// This <c>validateText</c> method validates the text value
/// from the XML element node specified. This will check the class
/// schema to determine if a <c>Text</c> annotation was used.
/// If one was specified then the text within the XML element input
/// node is checked to determine if it is a valid entry.
/// </summary>
/// <param name="node">
/// this is the XML element to acquire the text from
/// </param>
/// <param name="schema">
/// this is used to visit the element contacts
/// </param>
public void ValidateText(InputNode node, Schema schema) {
Label label = schema.getText();
if(label != null) {
Validate(node, label);
}
}
示例3: WriteText
/// <summary>
/// This write method is used to write the text contact from the
/// provided source object to the XML element. This takes the text
/// value from the source object and writes it to the single contact
/// marked with the <c>Text</c> annotation. If the value is
/// null and the contact value is required an exception is thrown.
/// </summary>
/// <param name="source">
/// this is the source object to be serialized
/// </param>
/// <param name="node">
/// this is the XML element to write text value to
/// </param>
/// <param name="schema">
/// this is used to track the referenced elements
/// </param>
public void WriteText(OutputNode node, Object source, Schema schema) {
Label label = schema.getText();
if(label != null) {
Contact contact = label.getContact();
Object value = contact.Get(source);
Class type = source.getClass();
if(value == null) {
value = label.getEmpty(context);
}
if(value == null && label.isRequired()) {
throw new TextException("Value for %s is null for %s", label, type);
}
WriteText(node, value, label);
}
}