是目标始终是一个实体还是它可以是EntityReference? [英] Is Target always an Entity or can it be EntityReference?

查看:171
本文介绍了是目标始终是一个实体还是它可以是EntityReference?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现在我的某些代码中,我具有以下语法来保护插件免受FUBARing的侵害.我不能为了上帝的爱而忘记了为什么我把 EntityReference 的条件作为条件.

I discovered that in some of my code I have the following syntax guarding the plugin from FUBARing. I can't for the love of god not remember why I put the disjuction conditional for EntityReference.

每个 EntityReference Context.InputParameters ["Target"] 吗?

bool goodToGo 
  = Context.InputParameters.Contains("Target")
    && Context.PrimaryEntityName == "email";
    && (
      Context.InputParameters["Target"] is Entity
      || Context.InputParameters["Target"] is EntityReference);

除了实体以外,是否没有其他?

推荐答案

目标也可以是来自MSDN的EntityReference:

Target can be also an EntityReference, from MSDN:

请注意,并非所有请求都包含Entity类型的Target属性,因此您必须查看每个单独的请求或响应.例如,DeleteRequest确实具有Target属性,但其类型为EntityReference.

Note that not all requests contain a Target property that is of type Entity, so you do have to look at each individual request or response. For example, DeleteRequest does have a Target property but its type is EntityReference.

了解传递给插件的数据上下文

因此,根据插件的逻辑,您可能还需要检查 EntityReference 的属性类型.

So depending on the logic of your plugin you may need to check the property type also for EntityReference.

这篇关于是目标始终是一个实体还是它可以是EntityReference?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆