本文整理汇总了C#中System.Xml.XmlNode.CreateNavigator方法的典型用法代码示例。如果您正苦于以下问题:C# XmlNode.CreateNavigator方法的具体用法?C# XmlNode.CreateNavigator怎么用?C# XmlNode.CreateNavigator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlNode
的用法示例。
在下文中一共展示了XmlNode.CreateNavigator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
/// <summary>
/// Creates the object representing the configuration section. The section will
/// be serialized into the type specified by the type attribute in the xml.
///
/// This method is called by the framework, for example when ConfiguratinManager.GetSection()
/// is called. It should not be called directly by client code.
/// </summary>
/// <param name="parent">Parent object</param>
/// <param name="configContext">Configuration context object</param>
/// <param name="section">Section XML node</param>
/// <returns></returns>
public object Create(object parent, object configContext, XmlNode section)
{
XPathNavigator nav = section.CreateNavigator();
string typename = (string)nav.Evaluate("string(@type)");
Type type = Type.GetType(typename);
if (type == null)
{
throw new ConfigurationErrorsException(
string.Format("Type '{0}' specified with the XmlSerializerSectionHandler could not be resolved.", typename)
);
}
try
{
using (XmlNodeReader xmlNodeReader = new XmlNodeReader(section))
{
XmlSerializer xmlSerializer = new XmlSerializer(type);
return xmlSerializer.Deserialize(xmlNodeReader);
}
}
catch (InvalidOperationException ex)
{
// Unwrap any exception
if (ex.InnerException != null)
throw ex.InnerException;
throw;
}
}
示例2: TransformNode
public static void TransformNode(XmlNode element, XmlReader xslTemplate)
{
XmlReader reader = new XmlNodeReader(element);
XmlReader transformResultReader = TransformXml(reader, xslTemplate, null);
element.CreateNavigator().ReplaceSelf(transformResultReader);
}
示例3: Create
public object Create( object parent, object configContext, XmlNode section )
{
XPathNavigator navigator = section.CreateNavigator();
string typeName = ( string )navigator.Evaluate( "string(@type)" );
if( string.IsNullOrEmpty( typeName ) )
throw new ConfigurationErrorsException( string.Format( MISSING_TYPE_MSG, section.Name ), section );
Type type = Type.GetType( typeName );
if( type == null )
throw new ConfigurationErrorsException( string.Format( NULL_TYPE_MSG, typeName, section.Name ), section );
XmlSerializer serializer = new XmlSerializer( type );
XmlNodeReader reader = new XmlNodeReader( section );
try
{
return serializer.Deserialize( reader );
}
catch( Exception ex )
{
throw new ConfigurationErrorsException(
string.Format( FAILED_DESERIALIZE_MSG, typeName, section.Name, FormattedInnerExceptions( ex ) ),
ex, section );
}
}
示例4: Create
public object Create(object parent, object configContext, XmlNode section)
{
XPathNavigator nav = section.CreateNavigator();
var typename = (string)nav.Evaluate("string(@type)");
Type t = Type.GetType(typename);
var ser = new XmlSerializer(t);
return ser.Deserialize(new XmlNodeReader(section));
}
示例5: Create
/// <summary>
/// Creates a configuration section handler.
/// </summary>
/// <returns>
/// The created section handler object.
/// </returns>
/// <param name="parent">Parent object.</param><param name="configContext">Configuration context object.</param><param name="section">Section XML node.</param><filterpriority>2</filterpriority>
public object Create(object parent, object configContext, XmlNode section)
{
var navigator = section.CreateNavigator();
var typeOfObject = (string)navigator.Evaluate("string(@type)");
var type = Type.GetType(typeOfObject);
var xmlSerializer = new XmlSerializer(type);
var nodeReader = new XmlNodeReader(section);
return xmlSerializer.Deserialize(nodeReader);
}
示例6: Create
public object Create(object parent, object configContext, XmlNode section)
{
if (section == null)
{
return null;
}
_config = section.CreateNavigator();
return this;
}
示例7: XmlSerializer
//������ض�����ǰ���ýڵķ���
object IConfigurationSectionHandler.Create(object parent, object configContext, XmlNode section)
{
//XPathNavigator��ʹ���α�ģ�ʹ��������ݴ洢����ȡ���ݡ�
XPathNavigator navigator = section.CreateNavigator();
string text = (string)navigator.Evaluate("string(@type)");
Type type = Type.GetType(text);
XmlSerializer serializer = new XmlSerializer(type);
return serializer.Deserialize(new XmlNodeReader(section));
}
开发者ID:alloevil,项目名称:A-embedded-image-processing-platform--,代码行数:11,代码来源:XmlSerializerSectionHandler.cs
示例8: Create
/// <summary>
/// Create the configuration section.
/// </summary>
/// <param name="parent"></param>
/// <param name="configContext"></param>
/// <param name="section"></param>
/// <returns></returns>
public object Create(object parent,
object configContext,
XmlNode section) {
XPathNavigator nav = section.CreateNavigator();
String typename = (String) nav.Evaluate("string(@type)");
Type type = Type.GetType(typename);
object theObject = this.GetConfigObject (type,
section.SelectSingleNode ("//" + SharpCvsLibConfig.SUB_SECTION));
return theObject;
}
示例9: ApplyChanges
public XmlDocument ApplyChanges(BaseDiffResultObjectList results, XmlNode originalDocument)
{
XmlDocument resultDocument = new XmlDocument();
XPathNavigator navigator = originalDocument.CreateNavigator();
foreach (var item in results.Items)
{
GetCommonNode(item, ref navigator);
}
resultDocument.LoadXml(navigator.OuterXml);
return resultDocument;
}
示例10: DoPostMerge
private static void DoPostMerge(string outputPath, XmlNode mergedNode)
{
foreach (XmlNode partNode in mergedNode.SafeSelectNodes("layout/generate"))
{
partNode.Attributes.Remove(partNode.Attributes["combinedkey"]);
}
using (var writer = XmlWriter.Create(outputPath, CanonicalXmlSettings.CreateXmlWriterSettings()))
{
writer.WriteNode(mergedNode.CreateNavigator(), true);
}
}
示例11: Create
public object Create(object parent, object configContext, XmlNode section)
{
XPathNavigator nav = section.CreateNavigator();
string typeName = (string)nav.Evaluate("string(@type)");
Type t = Type.GetType(typeName);
XmlSerializer ser = new XmlSerializer(t);
XmlNodeReader xnr = new XmlNodeReader(section);
object deSerialised = null;
deSerialised = ser.Deserialize(xnr);
return deSerialised;
}
示例12: DeserializeSection
/// <summary>
/// Returns an object deserialized from an Xml Configuration Section.
/// </summary>
/// <param name="section">The configuration section containing the settings.</param>
/// <param name="settingsTarget">The existing settings object to copy the new settings to.</param>
/// <returns></returns>
static object DeserializeSection(XmlNode section)
{
XPathNavigator navigator = section.CreateNavigator();
string typename = (string)navigator.Evaluate("string(@type)");
Type type = Type.GetType(typename);
if(type == null)
throw new ConfigurationException("The type '" + typename + "' is not a valid type. Double check the type parameter.");
XmlSerializer serializer = new XmlSerializer(type);
return serializer.Deserialize(new XmlNodeReader(section));
}
示例13: Create
public object Create(object parent, object configContext, XmlNode section)
{
try
{
string typeName = (string)section.CreateNavigator().Evaluate("string(@type)");
string configSouce = (string)section.CreateNavigator().Evaluate("string(@configSouce)");
XmlSerializer serializer = new XmlSerializer(Type.GetType(typeName), new XmlRootAttribute(section.Name));
if (!string.IsNullOrEmpty(configSouce))
{
using (XmlTextReader tr = new XmlTextReader(Config.BasePath + configSouce))
{
return serializer.Deserialize(tr);
}
}
return serializer.Deserialize(new XmlNodeReader(section));
}
catch (Exception e)
{
Log.Error("ReadServiceConfig.Create;" + e.Message);
}
return null;
}
示例14: Create
public object Create(object parent, object configContext, XmlNode section)
{
try
{
string typeName = (string) section.CreateNavigator().Evaluate("string(@type)");
XmlSerializer serializer = new XmlSerializer(Type.GetType(typeName));
return serializer.Deserialize(new XmlNodeReader(section));
}
catch(Exception e)
{
Log.Error("WriteServiceConfig.Create;" + e.Message);
}
return null;
}
示例15: ReisDeel
public ReisDeel(XmlNode node)
{
var navigator = node.CreateNavigator();
Vervoerder = navigator.Evaluate("string(Vervoerder)").ToString();
VervoerType = navigator.Evaluate("string(VervoerType)").ToString();
RitNummer = Convert.ToInt32(navigator.Evaluate("number(RitNummer)").ToString());
GeplandeSoringId = navigator.Evaluate("string(GeplandeSoringId)").ToString();
OngeplandeStoringId = navigator.Evaluate("string(OngeplandeStoringId)").ToString();
ReisStops = new List<ReisStop>();
foreach (XmlNode n in node.SelectNodes("ReisStop"))
{
ReisStops.Add(new ReisStop(n));
}
}