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


C# JsExpression.Member方法代码示例

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


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

示例1: CreateObject

        public JsExpression CreateObject(JsExpression containingType, IMethodSymbol constructor, params JsExpression[] arguments)
        {
            var constructorReference = containingType.Member("prototype").Member(constructor.GetMemberName());

            if (constructor.IsBuiltIn())
            {
                // If the constructor is built-in, then we don't want it invoked at all, since it's just a shim for the built-in
                // version.  Therefore, just call the types constructor passing in the arguments as usual for a normal JS new.
                return Js.New(containingType, arguments);
            }
            else
            {
                // Object creation gets transformed into:
                // new T(T.prototype.ctor, arg1, arg2, arg3...)
                return constructorReference.Member(SpecialNames.New).Invoke(arguments);
            }
        }
开发者ID:x335,项目名称:WootzJs,代码行数:17,代码来源:Idioms.cs

示例2: Invoke

 public JsInvocationExpression Invoke(JsExpression target, IMethodSymbol method, params JsExpression[] arguments)
 {
     return target.Member(method.GetMemberName()).Invoke(arguments);
 }
开发者ID:x335,项目名称:WootzJs,代码行数:4,代码来源:Idioms.cs

示例3: CreatePrototype

 public JsExpressionStatement CreatePrototype(JsExpression type, JsExpression baseType)
 {
     return type.Member("prototype").Assign(Js.New(baseType)).Express();
 }
开发者ID:x335,项目名称:WootzJs,代码行数:4,代码来源:Idioms.cs

示例4: Get

 public JsInvocationExpression Get(JsExpression target, IPropertySymbol property, params JsExpression[] arguments)
 {
     return target.Member(property.GetMethod.GetMemberName()).Invoke(arguments);
 }
开发者ID:x335,项目名称:WootzJs,代码行数:4,代码来源:Idioms.cs

示例5: MapInterfaceMethod

 public JsStatement MapInterfaceMethod(JsExpression assignee, IMethodSymbol interfaceMethod, JsExpression implementation)
 {
     return assignee.Member(interfaceMethod.GetMemberName()).Assign(implementation).Express();
 }
开发者ID:x335,项目名称:WootzJs,代码行数:4,代码来源:Idioms.cs

示例6: TryCharBinaryExpression

 public bool TryCharBinaryExpression(SyntaxKind type, TypeInfo leftSymbol, TypeInfo rightSymbol, JsExpression left, JsExpression right, out JsExpression result)
 {
     if (Equals(leftSymbol.Type, Context.Instance.Char) || Equals(rightSymbol.Type, Context.Instance.Char))
     {
         switch (type)
         {
             case SyntaxKind.SubtractExpression:
             case SyntaxKind.AddExpression:
             case SyntaxKind.MultiplyExpression:
             case SyntaxKind.DivideExpression:
             case SyntaxKind.ModuloExpression:
             case SyntaxKind.BitwiseAndExpression:
             case SyntaxKind.BitwiseOrExpression:
             case SyntaxKind.LessThanExpression:
             case SyntaxKind.LessThanOrEqualExpression:
             case SyntaxKind.GreaterThanExpression:
             case SyntaxKind.GreaterThanOrEqualExpression:
             case SyntaxKind.LeftShiftExpression:
             case SyntaxKind.RightShiftExpression:
             case SyntaxKind.ExclusiveOrExpression:
             case SyntaxKind.AddAssignmentExpression:
             case SyntaxKind.SubtractAssignmentExpression:
             case SyntaxKind.MultiplyAssignmentExpression:
             case SyntaxKind.DivideAssignmentExpression:
             case SyntaxKind.ModuloAssignmentExpression:
                 result = Js.Binary(
                     ToBinaryOperator(type).Value,
                     !Equals(leftSymbol.Type, Context.Instance.Char) || Equals(rightSymbol.Type, Context.Instance.String) ? left : left.Member("charCodeAt").Invoke(Js.Primitive(0)),
                     !Equals(rightSymbol.Type, Context.Instance.Char) || Equals(leftSymbol.Type, Context.Instance.String) ? right : right.Member("charCodeAt").Invoke(Js.Primitive(0))
                 );
                 switch (type)
                 {
                     case SyntaxKind.AddAssignmentExpression:
                     case SyntaxKind.SubtractAssignmentExpression:
                     case SyntaxKind.MultiplyAssignmentExpression:
                     case SyntaxKind.DivideAssignmentExpression:
                     case SyntaxKind.ModuloAssignmentExpression:
                         result = left.Assign(Js.Reference("String").Member("fromCharCode").Invoke(result));
                         break;
                 }
                 return true;
         }                
     }
     result = null;
     return false;
 }
开发者ID:x335,项目名称:WootzJs,代码行数:46,代码来源:Idioms.cs

示例7: TryCharUnaryExpression

        public bool TryCharUnaryExpression(SyntaxKind type, TypeInfo operandType, JsExpression operand, out JsExpression result)
        {
            if (Equals(operandType.Type, Context.Instance.Char))
            {
                switch (type)
                {
                    case SyntaxKind.PostDecrementExpression:
                    case SyntaxKind.PostIncrementExpression:
                    {
                        var old = Js.Variable("$old", operand);

                        var op = type == SyntaxKind.PostDecrementExpression ? JsBinaryOperator.Subtract : JsBinaryOperator.Add;
                        result = Js.Binary(
                            op, 
                            old.GetReference().Member("charCodeAt").Invoke(Js.Primitive(0)),
                            Js.Primitive(1)
                        );
                        result = operand.Assign(Js.Reference("String").Member("fromCharCode").Invoke(result));

                        var block = new JsBlockStatement();
                        block.Local(old);
                        block.Express(result);
                        block.Return(old.GetReference());
                        result = Wrap(block);

                        return true;
                    }
                    case SyntaxKind.PreDecrementExpression:
                    case SyntaxKind.PreIncrementExpression:
                    {
                        var op = type == SyntaxKind.PreDecrementExpression ? JsBinaryOperator.Subtract : JsBinaryOperator.Add;
                        result = Js.Binary(
                            op, 
                            operand.Member("charCodeAt").Invoke(Js.Primitive(0)),
                            Js.Primitive(1)
                        );
                        result = operand.Assign(Js.Reference("String").Member("fromCharCode").Invoke(result));
                        return true;
                    }
                }
            }
            result = null;
            return false;
        }
开发者ID:x335,项目名称:WootzJs,代码行数:44,代码来源:Idioms.cs

示例8: MemberReference

        public JsExpression MemberReference(JsExpression @this, ISymbol symbol, bool isSetter = false, bool isBaseReference = false)
        {
            switch (symbol.Kind)
            {
                case SymbolKind.Field:
                {
                    var field = (IFieldSymbol)symbol;
                    var result = (JsExpression)@this.Member(field.GetMemberName());

                    if (field.Type is IArrayTypeSymbol && !field.IsExported())
                    {
                        result = MakeArray(result, (IArrayTypeSymbol)field.Type);
                    }

                    return result;
                }
                case SymbolKind.Event:
                {
                    var field = (IEventSymbol)symbol;
                    return @this.Member(field.GetBackingFieldName());
                }
                case SymbolKind.Property:
                {
                    var property = (IPropertySymbol)symbol;
                    if (property.ContainingType.IsGenericType && Equals(property.ContainingType.ConstructedFrom, Context.Instance.NullableType))
                    {
                        property = property.OriginalDefinition;
                        if (Equals(property, Context.Instance.NullableHasValue))
                        {
                            return @this.NotEqualTo(Js.Null()).Parenthetical();
                        }
                        else if (Equals(property, Context.Instance.NullableValue))
                        {
                            return Js.Reference(SpecialNames.NullableGetValue).Invoke(@this);
                        }
                    }

                    return GetPropertyValue(@this, property, isSetter, isBaseReference);
                }
                case SymbolKind.Parameter:
                    return transformer.ReferenceDeclarationInScope(symbol).GetReference();
                case SymbolKind.NamedType:
                    var namedTypeSymbol = (INamedTypeSymbol)symbol;
                    var type = Type(namedTypeSymbol);
                    if (!(type is JsInvocationExpression) && namedTypeSymbol.IsExported())
                        type = type.Invoke();
                    return type;
                case SymbolKind.Local:
                    var declaration = transformer.ReferenceDeclarationInScope(symbol);
                    return !isSetter ? declaration.GetReference() : declaration.SetReference();
                case SymbolKind.Method:
                {
                    var method = (IMethodSymbol)symbol;
                    var containingSymbol = symbol.ContainingType;
                    var name = method.GetMemberName();
                    var target = method.IsStatic ? Type(containingSymbol) : @this;
                    if (Equals(method.ContainingType, containingSymbol))
                    {
                        return target.Member(name);
                    }
                    else if (containingSymbol.IsSubclassOf(method.ContainingType))
                    {
                        return target.Member(name);
                    }
                    else 
                    {
                        throw new Exception();
                    }
                }
                case SymbolKind.Namespace:
                    return Js.Reference(symbol.Name);
                case SymbolKind.Label:
                    return Js.Reference(symbol.Name);
                case SymbolKind.TypeParameter:
                    return Js.Reference(symbol.Name);
                default:
                    throw new InvalidOperationException("Unexpected node: " + symbol);
            }
        }
开发者ID:x335,项目名称:WootzJs,代码行数:79,代码来源:Idioms.cs

示例9: GetPropertyValue

        public JsExpression GetPropertyValue(JsExpression target, IPropertySymbol property, bool isSetter, bool isBaseReference)
        {
            bool isExported = property.IsExported();
            var propertyName = property.GetMemberName();

            JsExpression inline;
            if (!isSetter && TryInline(property.GetMethod, target, new JsExpression[0], out inline))
            {
                return inline;
            }

            if (!isExported || IsMinimizedAutoProperty(property))
            {
                return target.Member(propertyName);
            }
            else
            {
                bool isExtension = property.IsExtension();
                if (isExtension || isBaseReference)
                    return InvokeMethodAs(property.GetMethod, target);
                else if (property.GetMethod != null)
                    return target.Member(property.GetMethod.GetMemberName()).Invoke();
                else 
                    return target.Member("get_" + property.GetMemberName()).Invoke();
            }
        }
开发者ID:x335,项目名称:WootzJs,代码行数:26,代码来源:Idioms.cs


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