本文整理汇总了C#中JsExpression类的典型用法代码示例。如果您正苦于以下问题:C# JsExpression类的具体用法?C# JsExpression怎么用?C# JsExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JsExpression类属于命名空间,在下文中一共展示了JsExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: JsObjectLiteralProperty
public JsObjectLiteralProperty(string name, JsExpression value) {
if (name == null) throw new ArgumentNullException("name");
if (value == null) throw new ArgumentNullException("value");
Name = name;
Value = value;
}
示例2: JsVariableDeclaration
public JsVariableDeclaration(string name, JsExpression initializer)
{
if (name == null) throw new ArgumentNullException("name");
if (!name.IsValidJavaScriptIdentifier()) throw new ArgumentException("name");
Name = name;
Initializer = initializer;
}
示例3: BindBaseCall
public JsExpression BindBaseCall(IType baseType, string methodName, IList<IType> typeArguments, JsExpression @this)
{
JsExpression method = JsExpression.Member(JsExpression.Member(GetScriptType(baseType, TypeContext.BindBaseCall), "prototype"), methodName);
if (typeArguments != null && typeArguments.Count > 0)
method = InstantiateGenericMethod(method, typeArguments);
return JsExpression.Invocation(JsExpression.Member(_createTypeReferenceExpression(KnownTypeReference.Delegate), "mkdel"), @this, method);
}
示例4: CloneDelegate
public JsExpression CloneDelegate(JsExpression source, IType sourceType, IType targetType)
{
if (Equals(sourceType, targetType)) {
// The user does something like "D d1 = F(); var d2 = new D(d1)". Assume he does this for a reason and create a clone of the delegate.
return JsExpression.Invocation(JsExpression.Member(_createTypeReferenceExpression(KnownTypeReference.Delegate), "clone"), source);
}
else {
return source; // The clone is just to convert the delegate to a different type. The risk of anyone comparing the references is small, so just return the original as delegates are immutable anyway.
}
}
示例5: EnsureCanBeEvaluatedMultipleTimes
public static JsExpression EnsureCanBeEvaluatedMultipleTimes(IList<JsStatement> statementList, JsExpression expression, IList<JsExpression> expressionsThatMustBeEvaluatedBefore, Func<string> createTemporaryVariable) {
if (IsJsExpressionComplexEnoughToGetATemporaryVariable.Analyze(expression)) {
CreateTemporariesForAllExpressionsThatHaveToBeEvaluatedBeforeNewExpression(statementList, expressionsThatMustBeEvaluatedBefore, expression, createTemporaryVariable);
var temp = createTemporaryVariable();
statementList.Add(new JsVariableDeclarationStatement(temp, expression));
return JsExpression.Identifier(temp);
}
else
return expression;
}
示例6: JsClass
public JsClass(ITypeDefinition csharpTypeDefinition, string name, ClassTypeEnum classType, IEnumerable<string> typeArgumentNames, JsExpression baseClass, IEnumerable<JsExpression> implementedInterfaces)
: base(csharpTypeDefinition, name)
{
BaseClass = baseClass;
ClassType = classType;
TypeArgumentNames = new List<string>(typeArgumentNames ?? new string[0]);
ImplementedInterfaces = new List<JsExpression>(implementedInterfaces ?? new JsExpression[0]);
NamedConstructors = new List<JsNamedConstructor>();
InstanceMethods = new List<JsMethod>();
StaticMethods = new List<JsMethod>();
StaticInitStatements = new List<JsStatement>();
}
示例7: 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);
}
}
示例8: InitializeField
JsExpression IRuntimeLibrary.InitializeField(JsExpression jsMember, string scriptName, IMember member, JsExpression initialValue, IRuntimeContext context) {
return InitializeField(jsMember, scriptName, member, initialValue, context);
}
示例9: GetExpressionForLocal
JsExpression IRuntimeLibrary.GetExpressionForLocal(string name, JsExpression accessor, IType type, IRuntimeContext context) {
return GetExpressionForLocal(name, accessor, type, context);
}
示例10: ApplyConstructor
JsExpression IRuntimeLibrary.ApplyConstructor(JsExpression constructor, JsExpression argumentsArray, IRuntimeContext context) {
return ApplyConstructor(constructor, argumentsArray, context);
}
示例11: SetAsyncException
JsExpression IRuntimeLibrary.SetAsyncException(JsExpression taskCompletionSource, JsExpression exception, IRuntimeContext context) {
return SetAsyncException(taskCompletionSource, exception, context);
}
示例12: SetMultiDimensionalArrayValue
JsExpression IRuntimeLibrary.SetMultiDimensionalArrayValue(JsExpression array, IEnumerable<JsExpression> indices, JsExpression value, IRuntimeContext context) {
return SetMultiDimensionalArrayValue(array, indices, value, context);
}
示例13: MakeEnumerator
JsExpression IRuntimeLibrary.MakeEnumerator(IType yieldType, JsExpression moveNext, JsExpression getCurrent, JsExpression dispose, IRuntimeContext context) {
return MakeEnumerator(yieldType, moveNext, getCurrent, dispose, context);
}
示例14: IntegerDivision
JsExpression IRuntimeLibrary.IntegerDivision(JsExpression numerator, JsExpression denominator, IRuntimeContext context) {
return IntegerDivision(numerator, denominator, context);
}
示例15: MakeException
JsExpression IRuntimeLibrary.MakeException(JsExpression operand, IRuntimeContext context) {
return MakeException(operand, context);
}