当前位置: 首页>>代码示例>>C#>>正文


C# JsExpression.GetLogicalTarget方法代码示例

本文整理汇总了C#中JsExpression.GetLogicalTarget方法的典型用法代码示例。如果您正苦于以下问题:C# JsExpression.GetLogicalTarget方法的具体用法?C# JsExpression.GetLogicalTarget怎么用?C# JsExpression.GetLogicalTarget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JsExpression的用法示例。


在下文中一共展示了JsExpression.GetLogicalTarget方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TryAccessorAssignment

 public bool TryAccessorAssignment(SyntaxKind type, ISymbol leftSymbol, ISymbol rightSymbol, JsExpression left, JsExpression right, out JsExpression result)
 {
     // Special handling for property and event assignments, since those have to be translated to a set/add/remove_PropertyName invocation.
     if ((!(leftSymbol is IPropertySymbol) || !IsMinimizedAutoProperty((IPropertySymbol)leftSymbol)) && (type == SyntaxKind.SimpleAssignmentExpression || type == SyntaxKind.AddAssignmentExpression || type == SyntaxKind.SubtractAssignmentExpression))
     {
         if (leftSymbol is IPropertySymbol || leftSymbol is IEventSymbol)
         {
             var isExported = leftSymbol.IsExported();
             var nameOverride = leftSymbol.GetAttributeValue<string>(Context.Instance.JsAttributeType, "Name");
             var target = left.GetLogicalTarget();
             var arguments = new List<JsExpression>();
             var property = leftSymbol as IPropertySymbol;
             var isCall = false;
             if (left is JsInvocationExpression)
             {
                 var invocationExpression = (JsInvocationExpression)left;
                 if (invocationExpression.Target is JsMemberReferenceExpression)
                 {
                     var innerMemberReference = (JsMemberReferenceExpression)invocationExpression.Target;
                     if (innerMemberReference.Name == "call" && target is JsMemberReferenceExpression && ((JsMemberReferenceExpression)target).Name.StartsWith("get_"))
                     {
                         isCall = true;
                         target = target.GetLogicalTarget();
                     }
                 }
                 
                 arguments.AddRange(invocationExpression.Arguments);
             }
             arguments.Add(right);
             if (leftSymbol is IPropertySymbol)
             {
                 var methodSymbol = ((IPropertySymbol)leftSymbol).SetMethod;
                 JsExpression inline;
                 if (TryInline(methodSymbol, target, arguments.ToArray(), out inline))
                 {
                     result = inline;
                     return true;
                 }
             }
             if (isExported)
             {
                 IMethodSymbol methodSymbol;
                 if (leftSymbol is IPropertySymbol)
                     methodSymbol = ((IPropertySymbol)leftSymbol).SetMethod;
                 else
                 {
                     var @event = (IEventSymbol)leftSymbol;
                     switch (type)
                     {
                         case SyntaxKind.AddAssignmentExpression:
                             methodSymbol = @event.AddMethod;
                             break;
                         default:
                             methodSymbol = @event.RemoveMethod;
                             break;
                     }
                 }
                 target = target.Member(methodSymbol.Name);
                 if (isCall)
                     target = target.Member("call");
                 result = target.Invoke(arguments.ToArray());
                 return true;
             }
             else if (nameOverride != null && property != null && property.SetMethod.Parameters.Count() > 1)
             {
                 result = target.Member(nameOverride).Invoke(arguments.ToArray());
                 return true;
             }
         }
     }
     result = null;
     return false;
 }
开发者ID:x335,项目名称:WootzJs,代码行数:73,代码来源:Idioms.cs


注:本文中的JsExpression.GetLogicalTarget方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。