本文整理汇总了C#中System.Data.Services.Providers.ResourceType.Epm方法的典型用法代码示例。如果您正苦于以下问题:C# ResourceType.Epm方法的具体用法?C# ResourceType.Epm怎么用?C# ResourceType.Epm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.Services.Providers.ResourceType
的用法示例。
在下文中一共展示了ResourceType.Epm方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildEpm
/// <summary>
/// Initializes the EPM internal information for the specified resource type and all its base types.
/// </summary>
/// <param name="resourceType">The resource type to build the EPM information for.</param>
/// <remarks>If the type in question has no EPM attributes anywhere in its hierarchy this method will do nothing.</remarks>
internal static void BuildEpm(ResourceType resourceType)
{
DebugUtils.CheckNoExternalCallers();
Debug.Assert(resourceType != null, "resourceType != null");
// Walk the base types and determine if there's EPM anywhere in there.
bool hasEpm = false;
ResourceType resourceTypeToTest = resourceType;
while (resourceTypeToTest != null)
{
if (resourceTypeToTest.Epm() != null)
{
hasEpm = true;
break;
}
resourceTypeToTest = resourceTypeToTest.BaseType;
}
// If there is build the EPM information for this type and add it as annotation.
if (hasEpm)
{
EpmResourceTypeAnnotation epm = resourceType.Epm();
if (epm == null)
{
epm = new EpmResourceTypeAnnotation();
// resourceType.SetAnnotation(epm);
}
epm.BuildEpmForType(resourceType, resourceType);
}
}
示例2: BuildEpmForType
/// <summary>
/// Initializes the EPM annotation with EPM information from the specified resource type.
/// </summary>
/// <param name="definingResourceType">Resource type to use the EPM infromation from.</param>
/// <param name="affectedResourceType">Resource type for this the EPM information is being built.</param>
private void BuildEpmForType(ResourceType definingResourceType, ResourceType affectedResourceType)
{
Debug.Assert(definingResourceType != null, "definingResourceType != null");
Debug.Assert(affectedResourceType != null, "affectedResourceType != null");
if (definingResourceType.BaseType != null)
{
this.BuildEpmForType(definingResourceType.BaseType, affectedResourceType);
}
EpmResourceTypeAnnotation epm = definingResourceType.Epm();
if (epm != null)
{
foreach (EntityPropertyMappingAttribute epmAttribute in epm.AllEpmAttributes.ToList())
{
this.epmSourceTree.Add(new EntityPropertyMappingInfo(epmAttribute, definingResourceType, affectedResourceType));
if (definingResourceType == affectedResourceType)
{
if (!PropertyExistsOnType(affectedResourceType, epmAttribute))
{
this.InheritedEpmAttributes.Add(epmAttribute);
this.OwnEpmAttributes.Remove(epmAttribute);
}
else
{
Debug.Assert(
this.OwnEpmAttributes.SingleOrDefault(attr => Object.ReferenceEquals(epmAttribute, attr)) != null,
"Own epmInfo should already have the given instance");
}
}
}
}
}
示例3: CheckEntityPropertyMapping
/// <summary>
/// Check whether the EPM on the specified resource type is supported in the specified version.
/// </summary>
/// <param name="version">The version to check.</param>
/// <param name="resourceType">The entity resoure type to check.</param>
internal static void CheckEntityPropertyMapping(ODataVersion version, ResourceType resourceType)
{
DebugUtils.CheckNoExternalCallers();
Debug.Assert(resourceType != null, "resourceType != null");
EpmResourceTypeAnnotation epmAnnotation = resourceType.Epm();
if (epmAnnotation != null)
{
Debug.Assert(epmAnnotation.EpmTargetTree != null, "If the EPM annotation is present the EPM tree must already be initialized.");
if (version < epmAnnotation.EpmTargetTree.MinimumODataProtocolVersion)
{
throw new ODataException(
Strings.ODataVersionChecker_EpmVersionNotSupported(
resourceType.FullName,
epmAnnotation.EpmTargetTree.MinimumODataProtocolVersion.VersionString(),
version.VersionString()));
}
}
}