本文整理汇总了C#中XDoc.NavigateToList方法的典型用法代码示例。如果您正苦于以下问题:C# XDoc.NavigateToList方法的具体用法?C# XDoc.NavigateToList怎么用?C# XDoc.NavigateToList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XDoc
的用法示例。
在下文中一共展示了XDoc.NavigateToList方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Load
private void Load(XDoc doc)
{
Assertion.AreEqual("ormap", doc.Node.Name, "Root element should be [ormap].");
foreach (XAccessor x in doc.Attributes)
{
Assertion.AreEqual("xmlns", x.Prefix, "Only xmlns attributes allowed in root element.");
string tag = x.LocalName;
string target = x.GetStringValue();
if (target.StartsWith(DbPath.DB_SCHEMA))
{
DbPath dbPath = target.RemoveBegin(DbPath.DB_SCHEMA);
Assertion.IsTrue(ORMConfig.ORMConfiguration.ExistDatabase(dbPath.DatabaseId), "Database [{0}] is not defined.", dbPath.DatabaseId);
_dbDict.Add(tag, dbPath);
}
else if (target.StartsWith(ClrClassPath.CLR_SCHEME))
{
ClrClassPath path = target.RemoveBegin(ClrClassPath.CLR_SCHEME);
_clrDict.Add(tag, path);
}
else
{
Assertion.Fail("Unknown schema of uri [{0}].", target);
}
}
var mapList = doc.NavigateToList("object-table-map");
foreach (var xMap in mapList)
{
PrefixedName c = new PrefixedName(xMap.GetStringValue("@class"));
PrefixedName t = new PrefixedName(xMap.GetStringValue("@table"));
string primaryKey = xMap.GetStringValue("@primaryKey");
string pkGenerate = xMap.GetStringValue("@primaryKeyGenerate");
Assertion.IsTrue(_clrDict.ContainsKey(c.Prefix), "Prefix [{0}] is not defined.", c.Prefix);
Type entityType = _clrDict[c.Prefix].MakeType(c.LocalName);
if (entityType == null)
MappingInfoExceptionHelper.ThrowLoadEntityTypeFail(c.Prefix, c.LocalName);
var fields = xMap.NavigateToList("field");
List<IPropertyMapInfo> list = new List<IPropertyMapInfo>();
foreach (var xField in fields)
{
string property = xField.GetStringValue("@property");
string column = xField.GetStringValue("@column");
int length = xField.GetValue<int>("@length") ?? 0;
bool nullable = xField.GetValue<bool>("@nullable") ?? true;
IPropertyMapInfo pInfo = new PropertyMapInfo(property, column, length, nullable);
list.Add(pInfo);
}
IObjectMapInfo info = new ObjectMapInfo(t, entityType, primaryKey, pkGenerate, list);
_cache.SetMapInfo(entityType, info);
}
}