本文整理匯總了C#中System.Xml.Linq.XText類的典型用法代碼示例。如果您正苦於以下問題:C# XText類的具體用法?C# XText怎麽用?C# XText使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
XText類屬於System.Xml.Linq命名空間,在下文中一共展示了XText類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: MakeWrapper
public static XObjectWrapper MakeWrapper(XText obj)
{
if (obj is XCData)
return MakeWrapper((XCData)obj);
else
return new XTextWrapper(obj);
}
示例2: CalibrateText
private static XText CalibrateText(XText n)
{
if (n.parent == null)
{
return n;
}
XNode content = (XNode) n.parent.content;
while (true)
{
content = content.next;
XText text = content as XText;
if (text != null)
{
do
{
if (content == n)
{
return text;
}
content = content.next;
}
while (content is XText);
}
}
}
示例3: ProcessXText
private void ProcessXText(XText xtext, StringBuilder sb, bool performReplacements)
{
//.NET likes to just drop out some of the formatting, specially the " which becomes normal old double quotes.
var correctedText = XmlTextEncoder.Encode(xtext.Value);
var newvalue = performReplacements ? Replace(correctedText) : correctedText;
sb.Append(newvalue);
}
示例4: Service
public Service(XElement baseElement, Product parent)
{
_nameAndRev = baseElement.Elements(_ns + "span").Nodes().OfType<XText>().FirstOrDefault();
_amountSpan = baseElement.Elements(_ns + "span").Elements(_ns + "span").Nodes().OfType<XText>().ToList();
_options = new List<Option>();
Product = parent;
}
示例5: AdjacentTextNodes2
//[Variation(Priority = 3, Desc = "Adjacent text nodes II. (sanity)")]
public void AdjacentTextNodes2()
{
XText t1 = new XText("a");
XElement e = new XElement("root", "hello");
e.Add(t1);
VerifyOrder(e.FirstNode, t1, -1);
}
示例6: AdjacentTextNodes1
//[Variation(Priority = 3, Desc = "Adjacent text nodes I. (sanity)")]
public void AdjacentTextNodes1()
{
XText t1 = new XText("a");
XText t2 = new XText("");
XElement e = new XElement("root", t1, t2);
VerifyOrder(t1, t2, -1);
}
示例7: XText
public XText(XText other)
{
if (other == null)
{
throw new ArgumentNullException("other");
}
this.text = other.text;
}
示例8: Test_text_node
public void Test_text_node()
{
var tx = new XText("This is some text");
var e1 = new XElement("Root", tx);
var d1 = new XDocument(e1);
var di = d1.GetObjectId();
var id = e1.GetObjectId();
var ti = tx.GetObjectId();
var d2 = XNodeAnnotationSerializer.Serialize(d1);
var d3 = XNodeAnnotationSerializer.Deserialize(d2);
Assert.IsTrue(d3.Root.FirstNode.GetObjectId() == ti);
}
示例9: ReplaceFields
private void ReplaceFields()
{
var elements = DocumentContent.XPathSelectElements( @"//text:text-input[ @text:description = 'Template']",
Manager );
var nodes = elements.ToList();
foreach( var element in nodes )
{
var attribute = element.Value;
var preparedAttribute = attribute.Replace( "U+10FFFD", "@" );
var text = new XText( preparedAttribute );
element.ReplaceWith( text );
}
}
示例10: CreateControlFlowFromComment
private void CreateControlFlowFromComment( XElement comment )
{
var row = comment.XPathSelectElement( "./ancestor::table:table-row", Manager );
var commentValue = comment.Value.Replace( "U+10FFFD", "@" );
var beforeNode = new XText( commentValue + "{" );
var afterNode = new XText( "}" );
row.AddBeforeSelf( beforeNode );
row.AddAfterSelf( afterNode );
comment.Remove();
}
示例11: XmlEncode
/// <summary>
/// Encodes a string for use in an XML element or attribute.
/// </summary>
/// <param name="value" this="true">The value to encode in XML compatible way.</param>
/// <returns>The XML encoded string.</returns>
public static string XmlEncode(this string value)
{
Guard.NotNull(() => value, value);
var output = new StringBuilder();
var text = new XText(value);
using (var writer = XmlWriter.Create(output, new XmlWriterSettings { ConformanceLevel = ConformanceLevel.Fragment }))
{
text.WriteTo(writer);
writer.Flush();
return output.ToString();
}
}
示例12: NodeTypes
//[Variation(Desc = "NodeTypes")]
public void NodeTypes()
{
XDocument document = new XDocument();
XElement element = new XElement("x");
XText text = new XText("text-value");
XComment comment = new XComment("comment");
XProcessingInstruction processingInstruction = new XProcessingInstruction("target", "data");
Validate.IsEqual(document.NodeType, XmlNodeType.Document);
Validate.IsEqual(element.NodeType, XmlNodeType.Element);
Validate.IsEqual(text.NodeType, XmlNodeType.Text);
Validate.IsEqual(comment.NodeType, XmlNodeType.Comment);
Validate.IsEqual(processingInstruction.NodeType, XmlNodeType.ProcessingInstruction);
}
示例13: WriteAsCode
/// <summary>
/// Write as C# code.
/// </summary>
private static void WriteAsCode(XText text, CommentSection section, bool inCode)
{
var lineNo = 0;
var content = text.Value;
if (string.IsNullOrEmpty(content))
return;
foreach (var part in content.Split('\n'))
{
if ((lineNo > 0) && inCode)
section.WriteLine();
section.Write(part.Replace("&", "&").Replace("<", "<").Replace(">", ">"));
lineNo++;
}
}
示例14: NodeTypes
public void NodeTypes()
{
XDocument document = new XDocument();
XElement element = new XElement("x");
XText text = new XText("text-value");
XComment comment = new XComment("comment");
XProcessingInstruction processingInstruction = new XProcessingInstruction("target", "data");
Assert.Equal(XmlNodeType.Document, document.NodeType);
Assert.Equal(XmlNodeType.Element, element.NodeType);
Assert.Equal(XmlNodeType.Text, text.NodeType);
Assert.Equal(XmlNodeType.Comment, comment.NodeType);
Assert.Equal(XmlNodeType.ProcessingInstruction, processingInstruction.NodeType);
}
示例15: CollectText
private static string CollectText(XText n)
{
string str = n.Value;
if (n.parent != null)
{
while (n != n.parent.content)
{
n = n.next as XText;
if (n == null)
{
return str;
}
str = str + n.Value;
}
}
return str;
}