本文整理汇总了C#中IEntity.OfType方法的典型用法代码示例。如果您正苦于以下问题:C# IEntity.OfType方法的具体用法?C# IEntity.OfType怎么用?C# IEntity.OfType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEntity
的用法示例。
在下文中一共展示了IEntity.OfType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPropertyAccessors
private static IEntity[] GetPropertyAccessors(IEntity[] entities, Func<IProperty, IEntity> selector)
{
return entities.OfType<IProperty>().Select(selector).Distinct().ToArray();
}
示例2: EmitCallableResolutionError
private void EmitCallableResolutionError(Node sourceNode, IEntity[] candidates, ExpressionCollection args)
{
//if this is call without arguments and ambiguous contains generic method without arguments
//than emit BCE0164 for readability
var genericMethod = candidates.OfType<IMethod>().FirstOrDefault(m => m.GenericInfo != null && m.GetParameters().Length == 0);
if (args.Count == 0 && genericMethod != null)
{
Error(CompilerErrorFactory.CannotInferGenericMethodArguments(sourceNode, genericMethod));
return;
}
if (CallableResolutionService.ValidCandidates.Count > 1)
{
Error(CompilerErrorFactory.AmbiguousReference(sourceNode, candidates[0].Name, CallableResolutionService.ValidCandidates.Select(c => (IEntity)c.Method)));
return;
}
var candidate = candidates[0];
var constructor = candidate as IConstructor;
if (constructor != null)
{
Error(CompilerErrorFactory.NoApropriateConstructorFound(sourceNode, constructor.DeclaringType, GetSignature(args)));
}
else
{
Error(CompilerErrorFactory.NoApropriateOverloadFound(sourceNode, GetSignature(args), candidate.FullName));
}
}
示例3: RenderPass
private void RenderPass(IGameContext gameContext, IRenderContext renderContext, IRenderPass renderPass, IEntity[] entities)
{
if (!renderPass.SkipWorldRenderBelow)
{
gameContext.World.RenderBelow(gameContext, renderContext);
}
if (!renderPass.SkipEntityRender)
{
foreach (var entity in entities.OfType<IPrerenderableEntity>())
{
entity.Prerender(gameContext, renderContext);
}
foreach (var entity in entities)
{
entity.Render(gameContext, renderContext);
}
}
if (!renderPass.SkipWorldRenderAbove)
{
gameContext.World.RenderAbove(gameContext, renderContext);
}
if (!renderPass.SkipEngineHookRender)
{
foreach (var hook in _engineHooks)
{
hook.Render(gameContext, renderContext);
}
}
}