本文整理汇总了C#中IEdmModel.TryGetODataAnnotation方法的典型用法代码示例。如果您正苦于以下问题:C# IEdmModel.TryGetODataAnnotation方法的具体用法?C# IEdmModel.TryGetODataAnnotation怎么用?C# IEdmModel.TryGetODataAnnotation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEdmModel
的用法示例。
在下文中一共展示了IEdmModel.TryGetODataAnnotation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryGetBooleanAnnotation
/// <summary>
/// Gets a boolean value for the <paramref name="annotationLocalName"/> OData metadata annotation on
/// the <paramref name="annotatable"/>.
/// </summary>
/// <param name="model">The model containing the annotation.</param>
/// <param name="annotatable">The annotatable to get the annotation from.</param>
/// <param name="annotationLocalName">The local name of the annotation to get.</param>
/// <param name="boolValue">true if the annotation exists and has the value 'true'; false if the annotation does not exist or has the value 'false'.</param>
/// <returns>true if the annotation with the specified local names exists; otherwise false.</returns>
/// <remarks>If the annotation exists but does not have a valid boolean value this method wil throw.</remarks>
private static bool TryGetBooleanAnnotation(IEdmModel model, IEdmElement annotatable, string annotationLocalName, out bool boolValue)
{
Debug.Assert(model != null, "model != null");
Debug.Assert(annotatable != null, "annotatable != null");
Debug.Assert(annotationLocalName != null, "annotationLocalName != null");
string stringValue;
if (model.TryGetODataAnnotation(annotatable, annotationLocalName, out stringValue))
{
boolValue = XmlConvert.ToBoolean(stringValue);
return true;
}
// no annotation exists
boolValue = false;
return false;
}
示例2: TryGetBooleanAnnotation
private static bool TryGetBooleanAnnotation(IEdmModel model, IEdmStructuredType structuredType, string annotationLocalName, bool recursive, out bool boolValue)
{
string str = null;
bool flag;
do
{
flag = model.TryGetODataAnnotation(structuredType, annotationLocalName, out str);
if (flag)
{
break;
}
structuredType = structuredType.BaseType;
}
while (recursive && (structuredType != null));
if (!flag)
{
boolValue = false;
return false;
}
boolValue = XmlConvert.ToBoolean(str);
return true;
}