public override object Invoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture) { if (IsStatic && obj != null) { throw new InvalidOperationException("Static methods cannot have a target"); } if (!IsStatic && obj == null) { throw new InvalidOperationException("Instance methods must have a target"); } var args = new JsArray(); if (typeArguments != null) { foreach (var typeArgument in typeArguments) { args.push(typeArgument.thisType); } } if (parameters != null) { var parametersArray = parameters.As <JsArray>(); for (var i = 0; i < parametersArray.length; i++) { var argument = parametersArray[i].As <JsObject>(); args.push(argument.As <JsObject>()); } } var target = IsStatic ? DeclaringType.thisType : obj; return(Jsni.apply(jsMethod, target.As <JsObject>(), args)); }
public override object Invoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture) { if (IsStatic && obj != null) { throw new InvalidOperationException("Static methods cannot have a target"); } if (!IsStatic && obj == null) { throw new InvalidOperationException("Instance methods must have a target"); } var args = new JsArray(); if (typeArguments != null) { foreach (var typeArgument in typeArguments) { args.push(typeArgument.thisType); } } if (parameters != null) { foreach (var argument in parameters) { args.push(argument.As <JsObject>()); } } return(Jsni.apply(jsMethod, obj.As <JsObject>(), args)); }
public static void AfterCompilation(JsAction func) { if (IsCompiled) { func(); } else { AfterCompilationFunctions.push(func); } }
void foo5(object obj) { //dynamic result = obj; //JsArray data = new JsArray(); JsArray reminders = new JsArray();// DataUtils.toArray(result.PatientReminder); JsObject reminder; JsDate now = new JsDate(); JsDate startOfToday = new JsDate(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0, 0); JsDate dueDate; foreach (dynamic item in reminders) { dueDate = new JsDate(item.DueDate["$t"]); reminder = new JsObject(); reminder["Due"] = item.DueDate["$t"]; reminder["Done"] = item.PrevDate["$t"]; reminder["Subject"] = item.Description["$t"]; reminder["PastDue"] = dueDate.getTime() < startOfToday.getTime() ? "red" : ""; data.push(reminder); } //bool success = true; //if (success != null) //{ // success(data); //} }
private static JsArray <Property> ParseEvents(HtmlTableElement tbl) { var list = new JsArray <Property>(); var trs = tbl.ToJQuery().find("> tbody > tr"); foreach (var tr in trs) { var cells = tr.ToJQuery().children("td"); var sig = cells[0].ToJQuery().text().RemoveWhitespace(); var type = cells[1].ToJQuery().text().RemoveWhitespace(); var desc = cells[2].ToJQuery().text(); if (type.Contains("None")) { type = "JsAction"; } else { type = "JsAction<" + type + ">"; } var name = sig; var me = new Property { Name = name, Type = new Class { Name = type }, Description = desc, }; list.push(me); } return(list); }
private static JsArray <Property> ParseConstants(HtmlTableElement tbl) { var list = new JsArray <Property>(); var trs = tbl.ToJQuery().find("tbody > tr"); foreach (var tr in trs) { var cells = tr.ToJQuery().children("td"); var name = cells[0].ToJQuery().text().RemoveWhitespace(); var type = "object"; var desc = cells[1].ToJQuery().text(); var me = new Property { Name = name, Type = new Class { Name = type }, Description = desc, IsStatic = true, }; list.push(me); } return(list); }
private JsArray <HtmlElement> findChildNodesForSelector(JsArray <HtmlElement> elements, JsArray <JsString> selectorArray) { var selector = selectorArray.shift(); //We need to actually abstract this so we can deal with IE and Opera returning a collection instead of a NodeList var newElements = new JsArray <HtmlElement>(); if (selector.substr(0, 1) == ".") { var className = selector.substring(1); //Lets assume this is a class selector while (elements.length > 0) { var element = elements.pop(); var nodes = element.getElementsByClassName(className); for (var j = 0; j < nodes.length; j++) { newElements.push(nodes[j].As <HtmlElement>()); } } } else { //invalid but going to assume type for now while (elements.length > 0) { var element = elements.pop(); var nodes = element.getElementsByTagName(selector); for (var j = 0; j < nodes.length; j++) { newElements.push(nodes[j].As <HtmlElement>()); } } } //Only recurse if there is another selector if (selectorArray.length > 0) { newElements = findChildNodesForSelector(newElements, selectorArray); } return(newElements); }
public void Reset() { if (IncludeDescendents) { Stack = new JsArray <HtmlElement>(); Stack.push(Root); } _Current = null; }
public IEnumerator <KeyValuePair <TKey, TValue> > GetEnumerator() { var array = new JsArray(); //TODO: foreach (var hashKey in this._table) { array.push(new KeyValuePair <TKey, TValue>(this._keys[hashKey].As <TKey>(), this._table[hashKey].As <TValue>())); } return(array.As <JsExtendedArray>().GetEnumerator().As <IEnumerator <KeyValuePair <TKey, TValue> > >()); }
public JsArray<JsString> getAllRandoriSelectorEntries() { var allEntries = new JsArray<JsString>(); foreach (var cssSelector in hashMap) { allEntries.push(cssSelector); } return allEntries; }
public JsImplIEnumerator <T> GetEnumerator() { var array = new JsArray <T>(); foreach (var hashKey in Hashtable) { array.push(Hashtable[hashKey]); } return(new JsArrayEnumerator <T>(array)); }
public static JsArray <R> JsSelect <T, R>(this JsArray <T> list, JsFunc <T, R> selector) { var list2 = new JsArray <R>(); foreach (var item in list) { list2.push(selector(item)); } return(list2); }
JsImplConstructorInfo[] GetConstructors() { VerifyConstructors(); var arr = new JsArray(); for (var i = 0; i < _Constructors.length; i++) { arr.push(_Constructors[i]); } return(arr.As <JsImplConstructorInfo[]>()); }
public JsArray <JsString> getAllRandoriSelectorEntries() { var allEntries = new JsArray <JsString>(); foreach (var cssSelector in hashMap) { allEntries.push(cssSelector); } return(allEntries); }
public HtmlElementEnumerator(HtmlElement root, bool includeDescendents, bool includeSelf) { IncludeDescendents = includeDescendents; IncludeSelf = includeSelf; Root = root; if (IncludeDescendents) { Stack = new JsArray <HtmlElement>(); Stack.push(Root); } }
public JsImplMethodInfo[] GetMethods() { VerifyMethods(); var arr = new JsArray(); for (var i = 0; i < _Methods.length; i++) { arr.push(_Methods[i]); } return(arr.As <JsImplMethodInfo[]>()); }
private JsArray <HtmlElement> findChildNodesForCompoundSelector(HtmlElement element, JsString selector) { //lets start with simple ones var selectors = selector.split(" "); var ar = new JsArray <HtmlElement>(); ar.push(element); var elements = findChildNodesForSelector(ar, selectors); return(elements); }
private JsArray <Translation> provideTranslations(JsString domain, JsArray <JsString> keys) { JsArray <Translation> translations = new JsArray <Translation>(); Translation translation; for (int i = 0; i < keys.length; i++) { translation = new Translation(); translation.key = keys[i]; translation.value = keyValuePairs[keys[i]]; translations.push(translation); } return(translations); }
void buildSpinner(SpinnerData sd) { spinnerData = sd; var canvas = document.getElementsByTagName("canvas")[0].As<HTMLCanvasElement>(); ctx = canvas.getContext("2d").As<CanvasRenderingContext2D>(); index = 0; degrees = spinnerData.degrees; degreesList = new JsArray<JsNumber>(); for (var x = 0; x < degrees; x++) degreesList.push(x); // reset index = 0; // so I can kill it later canvasTimer = setInterval(draw, 1000 / degrees); }
//[JsMethod(UseNativeOverloads = true)] public void SetValue(object obj, object value, object[] indexes) { if (_Setter == null) throw new Exception("Property " + _Name + " doesn't have a setter"); if (indexes == null || indexes.Length == 0) { _Setter.call(obj, value); } else { var arr = new JsArray(indexes); arr.push(value); _Setter.apply(obj, indexes ?? new JsArray().As<object[]>()); } }
public override JsArray<Translation> synchronousTranslate(JsString domain, JsArray<JsString> keys) { var domainKeys = translations[domain]; var response = new JsArray<Translation>(); if ( domainKeys != null ) { for ( var i=0; i<keys.length;i++) { var translation = new Translation(); translation.key = keys[i]; translation.value = domainKeys[keys[i]]; response.push(translation); } } return response; }
public void SetValue(object obj, object value, object[] indexes) { if (_Setter == null) { throw new Exception("Property " + _Name + " doesn't have a setter"); } if (indexes == null || indexes.Length == 0) { _Setter.call(obj, value); } else { var arr = new JsArray(indexes); arr.push(value); _Setter.apply(obj, indexes ?? new JsArray().As <object[]>()); } }
void buildSpinner(SpinnerData sd) { spinnerData = sd; var canvas = document.getElementsByTagName("canvas")[0].As <HTMLCanvasElement>(); ctx = canvas.getContext("2d").As <CanvasRenderingContext2D>(); index = 0; degrees = spinnerData.degrees; degreesList = new JsArray <JsNumber>(); for (var x = 0; x < degrees; x++) { degreesList.push(x); } // reset index = 0; // so I can kill it later canvasTimer = setInterval(draw, 1000 / degrees); }
public override JsArray <Translation> synchronousTranslate(JsString domain, JsArray <JsString> keys) { var domainKeys = translations[domain]; var response = new JsArray <Translation>(); if (domainKeys != null) { for (var i = 0; i < keys.length; i++) { var translation = new Translation(); translation.key = keys[i]; translation.value = domainKeys[keys[i]]; response.push(translation); } } return(response); }
private object CloneObject(object obj, CloneContext context) { if (obj.instanceof <JsArray>()) { var arr2 = new JsArray(); context.Mappings[obj] = arr2; foreach (var item in arr2) { arr2.push(Clone(item, context)); } return(arr2); } else if (obj is IList) { var list = obj.As <IList>(); var list2 = Activator.CreateInstance(obj.GetType()).As <IList>(); context.Mappings[obj] = list2; foreach (var item in list) { list2.Add(Clone(item, context)); } return(list2); } else if (obj.instanceof <JsDate>()) { return(new JsDate(obj.As <JsDate>().valueOf())); } else { var obj2 = Activator.CreateInstance(obj.GetType()); context.Mappings[obj] = obj2; var json = obj.As <JsObject>(); var json2 = obj2.As <JsObject>(); foreach (var p in json) { json2[p] = Clone(json[p], context); } return(obj2); } }
private static void Compile_Phase2_TmpType(JsType tmpType) { var p = tmpType.fullname; var type = CompileType(tmpType); if (type != null) { bool result = CopyMemberIfNotDefined(type, type.fullname, window); if (result) { _NewJsTypes.push(type); } } if (type.ns != null) { var ns = ResolveNamespace(type.ns); if (type != null) { ns[type.name] = type; } } }
public void moveBall(ball ball, JsAction callback) { finishRightItem self = this; var points = new JsArray<point>(); points.push(new point {x = xMed, y = yMed, inSide = ESlide.center}); for (int x = xMed; x < xMax; x++) { points.push(new point {x = x, y = yMed}); } points.push(new point {x = xMax, y = yMed, inSide = ESlide.right}); HtmlElement div = getDiv(); div.appendChild(ball.getDiv()); _moveBallInternal(ball, points, callback); }
public void moveBall(ball ball, JsAction callback) { startBottomItem self = this; var points = new JsArray<point>(); points.push(new point {x = xMed, y = yMed, inSide = ESlide.center}); for (int y = yMed; y < yMax; ++y) { points.push(new point {x = xMed, y = y}); } points.push(new point {x = xMed, y = yMax, inSide = ESlide.bottom}); points = points.reverse(); HtmlElement div = getDiv(); div.appendChild(ball.getDiv()); _moveBallInternal(ball, points, callback); }
public void moveBall(ball ball, JsAction callback) { startLeftItem self = this; var points = new JsArray<point>(); points.push(new point {x = xMed, y = yMed, inSide = ESlide.center}); for (int x = xMed - 1; x > xMin; x--) { points.push(new point {x = x, y = yMed}); } points.push(new point {x = xMin, y = yMed, inSide = ESlide.left}); points = points.reverse(); HtmlElement div = getDiv(); div.appendChild(ball.getDiv()); _moveBallInternal(ball, points, callback); }
public void moveBall(ball ball, JsAction callback) { topToRightItem self = this; var points = new JsArray<point>(); points.push(new point {x = xMed, y = yMin, inSide = ESlide.top}); for (int y = yMin + 1; y < yMed; ++y) { points.push(new point {x = xMed, y = y}); } for (int x = xMed; x < xMax; ++x) { points.push(new point {x = x, y = yMed}); } points.push(new point {x = xMax, y = yMed, inSide = ESlide.right}); HtmlElement div = getDiv(); if (ball.getInSide() == ESlide.top) { div.appendChild(ball.getDiv()); points = points.reverse(); _moveBallInternal(ball, points, callback); } else if (ball.getInSide() == ESlide.right) { div.appendChild(ball.getDiv()); _moveBallInternal(ball, points, callback); } else { js.assert(false); } }
public override void init(angularScope scope, angularHttp http, angularLocation loc, angularFilter filter) { base.init(scope, http, loc, filter); ngFoods = new JsArray<JsArray<ngFoodItem>>(); ngCategories = new JsArray<string>(); ngCategories.push(CategoryNames.Salat); ngCategories.push(CategoryNames.First); ngCategories.push(CategoryNames.Garnir); ngCategories.push(CategoryNames.MeatOrFish); ngCategories.push(CategoryNames.ComplexDinner); ngCategories.push(CategoryNames.Breat); //eventManager.inst.subscribe(eventManager.dayOfWeekChanged, delegate(int n) { refresh(null); }); //eventManager.inst.subscribe(eventManager.userIdChanged, delegate(int n) { refresh(null); }); eventManager.inst.subscribe(eventManager.settingsLoaded, delegate(int n) { refreshFoods(delegate { JsFunction fn = HtmlContext.window.As<JsObject>()["initMenu"].As<JsFunction>(); fn.call(); }); }); eventManager.inst.subscribe(eventManager.orderListChanged, delegate(int n) { _scope.apply(); }); }
public JsImplMethodInfo[] GetMethods() { VerifyMethods(); var arr = new JsArray(); for (var i = 0; i < _Methods.length; i++) { arr.push(_Methods[i]); } return arr.As<JsImplMethodInfo[]>(); }
public void Write(char s) { Length++; array.push(s.As <string>()); }
private JsArray<HtmlElement> findChildNodesForCompoundSelector(HtmlElement element, JsString selector) { //lets start with simple ones var selectors = selector.split( " " ); var ar = new JsArray<HtmlElement>(); ar.push(element); var elements = findChildNodesForSelector( ar, selectors ); return elements; }
private static JsArray <Method> ParseMethods(HtmlTableElement tbl, bool isCtor) { var list = new JsArray <Method>(); var trs = tbl.ToJQuery().find("> tbody > tr"); foreach (var tr in trs) { var cells = tr.ToJQuery().children("td"); var sig = cells[0].ToJQuery().text().RemoveWhitespace(); JsString type; JsString desc; if (isCtor) { type = ""; desc = cells[1].ToJQuery().text(); } else { type = cells[1].ToJQuery().text().RemoveWhitespace(); desc = cells[2].ToJQuery().text(); } var name = sig.substr(0, sig.indexOf("(")); var me = new Method { Name = name, Type = new Class { Name = type }, Description = desc, IsConstructor = isCtor, }; var prms = sig.substr(sig.indexOf("(") + 1); prms = prms.substr(0, prms.indexOf(")")); if (prms.length > 0) { if (!prms.Contains("function")) { var prms2 = prms.split(","); foreach (var prm in prms2) { var tokens = prm.split(':'); var prmTypeName = (tokens[1] ?? "").trim(); var prmName = tokens[0].trim(); var prm3 = new Parameter { Type = new Class { Name = prmTypeName ?? "object" } }; if (prmName.EndsWith("?")) { prmName = prmName.substr(0, prmName.length - 1); prm3.IsOptional = true; } prm3.Name = prmName; me.Parameters.Add(prm3); } } } list.push(me); } return(list); }
public void Enqueue(T item) { storage.push(item.As <JsObject>()); }
public override void init(angularScope scope, angularHttp http, angularLocation loc, angularFilter filter) { base.init(scope, http, loc, filter); ngFoods = new JsArray<JsArray<ngFoodItem>>(); ngCategories = new JsArray<string>(); ngCategories.push(CategoryNames.Salat); ngCategories.push(CategoryNames.First); ngCategories.push(CategoryNames.Garnir); ngCategories.push(CategoryNames.MeatOrFish); ngCategories.push(CategoryNames.ComplexDinner); ngCategories.push(CategoryNames.Breat); eventManager.inst.subscribe(eventManager.deviceReady, delegate(int n) { refreshFoods(delegate { }); }); eventManager.inst.subscribe(eventManager.orderListChanged, delegate(int n) { _scope.apply(); }); }
private JsArray<Translation> provideTranslations(JsString domain, JsArray<JsString> keys) { JsArray<Translation> translations = new JsArray<Translation>(); Translation translation; for (int i = 0; i < keys.length; i++) { translation = new Translation(); translation.key = keys[i]; translation.value = keyValuePairs[keys[i]]; translations.push(translation); } return translations; }
public static void BeforeCompilation(JsAction func) { BeforeCompilationFunctions.push(func); }
public void removeFromArray(JsArray items, JsObject obj) { JsArray tmpArray = new JsArray(); foreach (JsObject tmp in items) { if (tmp != obj) { tmpArray.push(tmp); } } while (items.length > 0) { items.pop(); } foreach (object tmp in tmpArray) { items.push(tmp); } }
public void Push(T item) { storage.push(item.As <JsObject>()); }
public void Append(string s) { chunks.push(s.As <JsObject>()); length += s.Length; }
public void moveBall(ball ball, JsAction callback) { finishTopItem self = this; var points = new JsArray<point>(); points.push(new point {x = xMed, y = yMed, inSide = ESlide.center}); for (int y = yMed; y > yMin; --y) { points.push(new point {x = xMed, y = y}); } points.push(new point {x = xMed, y = yMin, inSide = ESlide.top}); HtmlElement div = getDiv(); div.appendChild(ball.getDiv()); _moveBallInternal(ball, points, callback); }
private JsArray<HtmlElement> findChildNodesForSelector(JsArray<HtmlElement> elements, JsArray<JsString> selectorArray) { var selector = selectorArray.shift(); //We need to actually abstract this so we can deal with IE and Opera returning a collection instead of a NodeList var newElements = new JsArray<HtmlElement>(); if ( selector.substr( 0, 1 ) == "." ) { var className = selector.substring( 1 ); //Lets assume this is a class selector while ( elements.length > 0 ) { var element = elements.pop(); var nodes = element.getElementsByClassName( className ); for ( var j=0; j<nodes.length; j++) { newElements.push( nodes[ j ].As<HtmlElement>() ); } } } else { //invalid but going to assume type for now while (elements.length > 0) { var element = elements.pop(); var nodes = element.getElementsByTagName(selector); for (var j = 0; j < nodes.length; j++) { newElements.push( nodes[j].As<HtmlElement>() ); } } } //Only recurse if there is another selector if (selectorArray.length > 0) { newElements = findChildNodesForSelector(newElements, selectorArray); } return newElements; }
public void moveBall(ball ball, JsAction callback) { topToBottomItem self = this; var points = new JsArray<point>(); points.push(new point {x = xMed, y = yMin, inSide = ESlide.top}); for (int y = yMin + 1; y < yMax; ++y) { points.push(new point {x = xMed, y = y}); } points.push(new point {x = xMed, y = yMax, inSide = ESlide.bottom}); HtmlElement div = getDiv(); if (ball.getInSide() == ESlide.top) { div.appendChild(ball.getDiv()); points = points.reverse(); _moveBallInternal(ball, points, callback); } else if (ball.getInSide() == ESlide.bottom) { div.appendChild(ball.getDiv()); _moveBallInternal(ball, points, callback); } }
void foo() { var list = new JsArray<object>(); list.push(new object[7]); list.push(new byte[7]); list.push(new short[7]); list.push(new ushort[7]); list.push(new int[7]); list.push(new uint[7]); list.push(new float[7]); list.push(new double[7]); var blubb = new object[] { 7, 8, 9 }; list.push(new object[] { 7, 8, 9 }); list.push(new byte[] { 77, 8, 9 }); list.push(new short[] { 7, 8, 9 }); list.push(new ushort[] { 7, 8, 9 }); list.push(new int[] { 7, 8, 9 }); list.push(new uint[] { 7, 8, 9 }); list.push(new float[] { 7, 8, 9 }); list.push(new double[] { 7, 8, 9 }); list.push(new[] { 7, 8, 9 }); list.push(new[] { 7.7, 8.8, 9.9 }); list.push(new[] { 7d, 8d, 9d }); int[] a = { 0, 2, 4, 6, 8 }; }
void foo() { var list = new JsArray <object>(); list.push(new object[7]); list.push(new byte[7]); list.push(new short[7]); list.push(new ushort[7]); list.push(new int[7]); list.push(new uint[7]); list.push(new float[7]); list.push(new double[7]); var blubb = new object[] { 7, 8, 9 }; list.push(new object[] { 7, 8, 9 }); list.push(new byte[] { 77, 8, 9 }); list.push(new short[] { 7, 8, 9 }); list.push(new ushort[] { 7, 8, 9 }); list.push(new int[] { 7, 8, 9 }); list.push(new uint[] { 7, 8, 9 }); list.push(new float[] { 7, 8, 9 }); list.push(new double[] { 7, 8, 9 }); list.push(new[] { 7, 8, 9 }); list.push(new[] { 7.7, 8.8, 9.9 }); list.push(new[] { 7d, 8d, 9d }); int[] a = { 0, 2, 4, 6, 8 }; }