本文整理汇总了C#中System.Xml.XmlNodeType.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# XmlNodeType.ToString方法的具体用法?C# XmlNodeType.ToString怎么用?C# XmlNodeType.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlNodeType
的用法示例。
在下文中一共展示了XmlNodeType.ToString方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestOnInvalidNodeType
protected void TestOnInvalidNodeType(XmlNodeType nt)
{
XmlReader DataReader = GetReader(pBase64Xml);
PositionOnNodeType(DataReader, nt);
if (!DataReader.CanReadBinaryContent) return;
try
{
byte[] buffer = new byte[1];
int nBytes = DataReader.ReadContentAsBase64(buffer, 0, 1);
}
catch (InvalidOperationException ioe)
{
if (ioe.ToString().IndexOf(nt.ToString()) < 0)
TestLog.Compare(false, "Call threw wrong invalid operation exception on " + nt);
else
return;
}
TestLog.Compare(false, "Call succeeded on " + nt);
}
示例2: TestOnInvalidNodeType
protected void TestOnInvalidNodeType(XmlNodeType nt)
{
ReloadSource();
PositionOnNodeType(nt);
if (CheckCanReadBinaryContent()) return;
try
{
byte[] buffer = new byte[1];
int nBytes = DataReader.ReadContentAsBase64(buffer, 0, 1);
}
catch (InvalidOperationException ioe)
{
if (ioe.ToString().IndexOf(nt.ToString()) < 0)
CError.Compare(false, "Call threw wrong invalid operation exception on " + nt);
else
return;
}
CError.Compare(false, "Call succeeded on " + nt);
}
示例3: CreateReadElementContentAsException
internal static Exception CreateReadElementContentAsException(string methodName, XmlNodeType nodeType, IXmlLineInfo lineInfo)
{
return new InvalidOperationException(AddLineInfo(Res.GetString("Xml_InvalidReadElementContentAs", new string[] { methodName, nodeType.ToString() }), lineInfo));
}
示例4: CreateReadElementContentAsException
static internal Exception CreateReadElementContentAsException(string methodName, XmlNodeType nodeType, IXmlLineInfo lineInfo)
{
return new InvalidOperationException(AddLineInfo(SR.Format(SR.Xml_InvalidReadElementContentAs, methodName, nodeType.ToString()), lineInfo));
}
示例5: CreateNode
public virtual XmlNode CreateNode (
XmlNodeType type,
string prefix,
string name,
string namespaceURI)
{
switch (type) {
case XmlNodeType.Attribute: return CreateAttribute (prefix, name, namespaceURI);
case XmlNodeType.CDATA: return CreateCDataSection (null);
case XmlNodeType.Comment: return CreateComment (null);
case XmlNodeType.Document: return new XmlDocument ();
case XmlNodeType.DocumentFragment: return CreateDocumentFragment ();
case XmlNodeType.DocumentType: return CreateDocumentType (null, null, null, null);
case XmlNodeType.Element: return CreateElement (prefix, name, namespaceURI);
case XmlNodeType.EntityReference: return CreateEntityReference (null);
case XmlNodeType.ProcessingInstruction: return CreateProcessingInstruction (null, null);
case XmlNodeType.SignificantWhitespace: return CreateSignificantWhitespace (String.Empty);
case XmlNodeType.Text: return CreateTextNode (null);
case XmlNodeType.Whitespace: return CreateWhitespace (String.Empty);
case XmlNodeType.XmlDeclaration: return CreateXmlDeclaration ("1.0", null, null);
default:
#if NET_2_0
throw new ArgumentException (
#else // makes less sense
throw new ArgumentOutOfRangeException (
#endif
String.Format("{0}\nParameter name: {1}",
"Specified argument was out of the range of valid values", type.ToString ()));
}
}
示例6: InitFragmentReader
private void InitFragmentReader(XmlNodeType fragmentType, XmlParserContext parserContext, bool allowXmlDeclFragment)
{
_fragmentParserContext = parserContext;
if (parserContext != null)
{
if (parserContext.NamespaceManager != null)
{
_namespaceManager = parserContext.NamespaceManager;
_xmlContext.defaultNamespace = _namespaceManager.LookupNamespace(string.Empty);
}
else
{
_namespaceManager = new XmlNamespaceManager(_nameTable);
}
_ps.baseUriStr = parserContext.BaseURI;
_ps.baseUri = null;
_xmlContext.xmlLang = parserContext.XmlLang;
_xmlContext.xmlSpace = parserContext.XmlSpace;
}
else
{
_namespaceManager = new XmlNamespaceManager(_nameTable);
_ps.baseUriStr = string.Empty;
_ps.baseUri = null;
}
_reportedBaseUri = _ps.baseUriStr;
switch (fragmentType)
{
case XmlNodeType.Attribute:
_ps.appendMode = false;
_parsingFunction = ParsingFunction.SwitchToInteractive;
_nextParsingFunction = ParsingFunction.FragmentAttribute;
break;
case XmlNodeType.Element:
Debug.Assert(_parsingFunction == ParsingFunction.SwitchToInteractiveXmlDecl);
_nextParsingFunction = ParsingFunction.DocumentContent;
break;
case XmlNodeType.Document:
Debug.Assert(_parsingFunction == ParsingFunction.SwitchToInteractiveXmlDecl);
Debug.Assert(_nextParsingFunction == ParsingFunction.DocumentContent);
break;
case XmlNodeType.XmlDeclaration:
if (allowXmlDeclFragment)
{
_ps.appendMode = false;
_parsingFunction = ParsingFunction.SwitchToInteractive;
_nextParsingFunction = ParsingFunction.XmlDeclarationFragment;
break;
}
else
{
goto default;
}
default:
Throw(SR.Xml_PartialContentNodeTypeNotSupportedEx, fragmentType.ToString());
return;
}
_fragmentType = fragmentType;
_fragment = true;
}
示例7: UnexpectedNodeType
#pragma warning restore 618
static internal Exception UnexpectedNodeType(XmlNodeType nodetype)
{
return new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, SR.Xml_UnexpectedNodeType, nodetype.ToString()));
}
示例8: PositionOnNodeType
//////////////////////////////////////////
// PositionOnNodeType
//////////////////////////////////////////
public void PositionOnNodeType(XmlNodeType nodeType)
{
CError.WriteLine("Seeking Nodetype : " + nodeType.ToString());
if (NodeType == nodeType)
return;
while (Read() && NodeType != nodeType)
{
if (NodeType == XmlNodeType.EntityReference)
{
if (CanResolveEntity)
ResolveEntity();
}
if (nodeType == XmlNodeType.ProcessingInstruction && NodeType == XmlNodeType.XmlDeclaration)
{
if (String.Compare(Name, 0, ST_XML, 0, 3) != 0)
return;
}
if (NodeType == XmlNodeType.Element && nodeType == XmlNodeType.Attribute)
{
if (MoveToFirstAttribute())
{
return;
};
}
}
if (EOF)
{
throw new CTestException(CTestBase.TEST_FAIL, "Couldn't find XmlNodeType " + nodeType);
}
}
示例9: UnexpectedNodeType
void UnexpectedNodeType(XmlNodeType type)
{
IXmlLineInfo li = (IXmlLineInfo)reader;
throw new XmlException(string.Format(SR.UnexpectedNodeType, type.ToString()), null,
li.LineNumber, li.LinePosition);
}
示例10: CreateReadElementContentAsException
static internal Exception CreateReadElementContentAsException(string methodName, XmlNodeType nodeType)
{
return new InvalidOperationException(Res.GetString(Res.Xml_InvalidReadElementContentAs, new string[] { methodName, nodeType.ToString() }));
}
示例11: UnexpectedNodeType
internal static Exception UnexpectedNodeType(XmlNodeType nodetype)
{
return new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, Res.GetString("Xml_UnexpectedNodeType"), new object[] { nodetype.ToString() }));
}
示例12: CreateXElement
/// <summary>
///
/// </summary>
/// <remarks></remarks>
/// <seealso cref=""/>
/// <param name="name"></param>
/// <param name="type"></param>
/// <returns></returns>
protected XElement CreateXElement(string name, XmlNodeType type)
{
if (_mode.Equals(XmlNodeMode.type))
{
XElement element = new XElement(type.ToString());
element.SetAttributeValue("name", name);
element.SetAttributeValue("type", type.ToString());
return element;
}
if (_mode.Equals(XmlNodeMode.xPath))
{
XElement element = new XElement(name.Replace(" ", ""));
element.SetAttributeValue("type", type.ToString());
return element;
}
return null;
}
示例13: AddCodeProperty
private static void AddCodeProperty(
string nodeName,
XmlNodeType nodeType,
CodeTypeReference propertyType,
CodeTypeDeclaration classType,
bool collection,
string nameSpaceName)
{
string propertyVariableName = CodePrivateNameFromRssName(nodeName);
string propertyName = CodeNameFromRssName(nodeName);
if (collection)
{
propertyVariableName = Pluralizer.ToPlural(propertyVariableName);
propertyName = Pluralizer.ToPlural(propertyName);
propertyType = new CodeTypeReference(
"List",
new CodeTypeReference[1] { propertyType });
}
bool alreadyThere = TypeContainsProperty(classType, propertyVariableName);
if (alreadyThere)
return;
classType.Members.Add(new CodeMemberField(propertyType, propertyVariableName));
CodeMemberProperty property = new CodeMemberProperty();
property.Attributes &= ~MemberAttributes.AccessMask;
property.Attributes |= MemberAttributes.Public;
property.Name = propertyName;
property.Type = propertyType;
// prevent warnings for RssDocumentBase properties
if (propertyName.Equals("Version", StringComparison.Ordinal)
|| propertyName.Equals("Channel", StringComparison.Ordinal))
{
property.Attributes |= MemberAttributes.New;
}
CodeAttributeDeclaration cad;
if (nodeType != XmlNodeType.Text)
{
cad = new CodeAttributeDeclaration(
"Xml" + nodeType.ToString(),
new CodeAttributeArgument(new CodePrimitiveExpression(nodeName)));
}
else
{
cad = new CodeAttributeDeclaration("Xml" + nodeType.ToString());
}
if (!String.IsNullOrEmpty(nameSpaceName))
{
cad.Arguments.Add(new CodeAttributeArgument("Namespace", new CodePrimitiveExpression(nameSpaceName)));
}
property.CustomAttributes.Add(cad);
property.GetStatements.Add(new CodeMethodReturnStatement(new CodeVariableReferenceExpression(propertyVariableName)));
property.SetStatements.Add(new CodeAssignStatement(new CodeVariableReferenceExpression(propertyVariableName), new CodeArgumentReferenceExpression("value")));
classType.Members.Add(property);
}