-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
92 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,54 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Linq.Expressions; | ||
using System.Reflection; | ||
using YantraJS.Core; | ||
|
||
namespace YantraJS.ExpHelper | ||
{ | ||
public class JSPropertyBuilder | ||
{ | ||
private static Type type = typeof(JSProperty); | ||
|
||
private static ConstructorInfo _New = | ||
type.GetConstructors().FirstOrDefault(); | ||
|
||
private static FieldInfo _Attributes = | ||
type.InternalField(nameof(Core.JSProperty.Attributes)); | ||
|
||
private static FieldInfo _Key = | ||
type.InternalField(nameof(Core.JSProperty.key)); | ||
|
||
private static FieldInfo _Get = | ||
type.InternalField(nameof(Core.JSProperty.get)); | ||
|
||
private static FieldInfo _Value = | ||
type.InternalField(nameof(Core.JSProperty.value)); | ||
|
||
public static Expression Value(Expression key, Expression value) | ||
{ | ||
return Expression.MemberInit(Expression.New(typeof(Core.JSProperty)), | ||
Expression.Bind(_Key, key), | ||
Expression.Bind(_Value, value), | ||
Expression.Bind(_Attributes, Expression.Constant(JSPropertyAttributes.EnumerableConfigurableValue)) | ||
); | ||
} | ||
|
||
public static Expression Property(Expression key, Expression getter, Expression setter) | ||
{ | ||
getter = getter == null | ||
? (Expression)Expression.Constant(null, typeof(Core.JSFunction)) | ||
: Expression.Convert(getter, typeof(Core.JSFunction)); | ||
setter = setter == null | ||
? (Expression)Expression.Constant(null, typeof(Core.JSFunction)) | ||
: Expression.Convert(setter, typeof(Core.JSFunction)); | ||
return Expression.MemberInit(Expression.New(typeof(Core.JSProperty)), | ||
Expression.Bind(_Key, key), | ||
Expression.Bind(_Get, getter), | ||
Expression.Bind(_Value, setter), | ||
Expression.Bind(_Attributes, Expression.Constant(JSPropertyAttributes.EnumerableConfigurableReadonlyProperty)) | ||
); | ||
} | ||
|
||
} | ||
} | ||
//using System; | ||
//using System.Linq; | ||
//using System.Linq.Expressions; | ||
//using System.Reflection; | ||
//using YantraJS.Core; | ||
|
||
//namespace YantraJS.ExpHelper | ||
//{ | ||
// public class JSPropertyBuilder | ||
// { | ||
// private static Type type = typeof(JSProperty); | ||
|
||
// private static ConstructorInfo _New = | ||
// type.GetConstructors().FirstOrDefault(); | ||
|
||
// private static FieldInfo _Attributes = | ||
// type.InternalField(nameof(Core.JSProperty.Attributes)); | ||
|
||
// private static FieldInfo _Key = | ||
// type.InternalField(nameof(Core.JSProperty.key)); | ||
|
||
// private static FieldInfo _Get = | ||
// type.InternalField(nameof(Core.JSProperty.get)); | ||
|
||
// private static FieldInfo _Value = | ||
// type.InternalField(nameof(Core.JSProperty.value)); | ||
|
||
// public static Expression Value(Expression key, Expression value) | ||
// { | ||
// return Expression.MemberInit(Expression.New(typeof(Core.JSProperty)), | ||
// Expression.Bind(_Key, key), | ||
// Expression.Bind(_Value, value), | ||
// Expression.Bind(_Attributes, Expression.Constant(JSPropertyAttributes.EnumerableConfigurableValue)) | ||
// ); | ||
// } | ||
|
||
// public static Expression Property(Expression key, Expression getter, Expression setter) | ||
// { | ||
// getter = getter == null | ||
// ? (Expression)Expression.Constant(null, typeof(Core.JSFunction)) | ||
// : Expression.Convert(getter, typeof(Core.JSFunction)); | ||
// setter = setter == null | ||
// ? (Expression)Expression.Constant(null, typeof(Core.JSFunction)) | ||
// : Expression.Convert(setter, typeof(Core.JSFunction)); | ||
// return Expression.MemberInit(Expression.New(typeof(Core.JSProperty)), | ||
// Expression.Bind(_Key, key), | ||
// Expression.Bind(_Get, getter), | ||
// Expression.Bind(_Value, setter), | ||
// Expression.Bind(_Attributes, Expression.Constant(JSPropertyAttributes.EnumerableConfigurableReadonlyProperty)) | ||
// ); | ||
// } | ||
|
||
// } | ||
//} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,45 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq.Expressions; | ||
using System.Reflection; | ||
using System.Text; | ||
using YantraJS.Core.Extensions; | ||
//using System; | ||
//using System.Collections.Generic; | ||
//using System.Linq.Expressions; | ||
//using System.Reflection; | ||
//using System.Text; | ||
//using YantraJS.Core.Extensions; | ||
|
||
using Exp = YantraJS.Expressions.YExpression; | ||
using Expression = YantraJS.Expressions.YExpression; | ||
using ParameterExpression = YantraJS.Expressions.YParameterExpression; | ||
using LambdaExpression = YantraJS.Expressions.YLambdaExpression; | ||
using LabelTarget = YantraJS.Expressions.YLabelTarget; | ||
using SwitchCase = YantraJS.Expressions.YSwitchCaseExpression; | ||
using GotoExpression = YantraJS.Expressions.YGoToExpression; | ||
using TryExpression = YantraJS.Expressions.YTryCatchFinallyExpression; | ||
using YantraJS.Expressions; | ||
using YantraJS.Core.LambdaGen; | ||
//using Exp = YantraJS.Expressions.YExpression; | ||
//using Expression = YantraJS.Expressions.YExpression; | ||
//using ParameterExpression = YantraJS.Expressions.YParameterExpression; | ||
//using LambdaExpression = YantraJS.Expressions.YLambdaExpression; | ||
//using LabelTarget = YantraJS.Expressions.YLabelTarget; | ||
//using SwitchCase = YantraJS.Expressions.YSwitchCaseExpression; | ||
//using GotoExpression = YantraJS.Expressions.YGoToExpression; | ||
//using TryExpression = YantraJS.Expressions.YTryCatchFinallyExpression; | ||
//using YantraJS.Expressions; | ||
//using YantraJS.Core.LambdaGen; | ||
|
||
namespace YantraJS.Core.LinqExpressions | ||
{ | ||
public static class JSTemplateArrayBuilder | ||
{ | ||
//namespace YantraJS.Core.LinqExpressions | ||
//{ | ||
// public static class JSTemplateArrayBuilder | ||
// { | ||
|
||
//public static Type type = typeof(JSTemplateArray); | ||
// //public static Type type = typeof(JSTemplateArray); | ||
|
||
//private static MethodInfo _new = | ||
// type.PublicMethod(nameof(JSTemplateArray.New), typeof(string[]), typeof(string[]), typeof(JSValue[])); | ||
// //private static MethodInfo _new = | ||
// // type.PublicMethod(nameof(JSTemplateArray.New), typeof(string[]), typeof(string[]), typeof(JSValue[])); | ||
|
||
//public static Expression New(IList<Expression> cooked, IList<Expression> raw, IList<Expression> args) | ||
//{ | ||
// //public static Expression New(IList<Expression> cooked, IList<Expression> raw, IList<Expression> args) | ||
// //{ | ||
|
||
// var c = Expression.NewArrayInit(typeof(string), cooked); | ||
// var r = Expression.NewArrayInit(typeof(string), raw); | ||
// var v = Expression.NewArrayInit(typeof(JSValue), args); | ||
// // return Expression.Call(null, _new, c, r, v); | ||
// return NewLambdaExpression.StaticCallExpression<JSValue>( | ||
// () => () => JSTemplateArray.New(null as string[],null as string[], null as JSValue[]) | ||
// ,c | ||
// ,r | ||
// ,v | ||
// ); | ||
//} | ||
// // var c = Expression.NewArrayInit(typeof(string), cooked); | ||
// // var r = Expression.NewArrayInit(typeof(string), raw); | ||
// // var v = Expression.NewArrayInit(typeof(JSValue), args); | ||
// // // return Expression.Call(null, _new, c, r, v); | ||
// // return NewLambdaExpression.StaticCallExpression<JSValue>( | ||
// // () => () => JSTemplateArray.New(null as string[],null as string[], null as JSValue[]) | ||
// // ,c | ||
// // ,r | ||
// // ,v | ||
// // ); | ||
// //} | ||
|
||
} | ||
} | ||
// } | ||
//} |