public static void ExposedFunctions_AddData1(Data1 e) { if (e == null) { new IHTMLDiv { innerText = "yay, no data..." }.AttachTo(instructions); return; } Func <string> GetString = () => new { e.text, e.index }.ToString(); // this function can now be used by external API e.GetString = IFunction.OfDelegate(GetString); var div = new IHTMLDiv { // using a real anonymous type, we get a nice key value string for display innerText = GetString() }; #region attach events if (e.onclick != null) { div.style.cursor = IStyle.CursorEnum.pointer; div.onclick += delegate { e.onclick.apply(e, div); }; } if (e.onmouseover != null) { div.style.cursor = IStyle.CursorEnum.pointer; div.onmouseover += delegate { e.onmouseover.apply(e, div); }; } if (e.onmouseout != null) { div.style.cursor = IStyle.CursorEnum.pointer; div.onmouseout += delegate { e.onmouseout.apply(e, div); }; } #endregion div.AttachTo(instructions); }
public static void ExposedFunctions_AddData1(Data1 e) { if (e == null) { new IHTMLDiv { innerText = "yay, no data..." }.AttachTo(instructions); return; } Func<string> GetString = () => new { e.text, e.index }.ToString(); // this function can now be used by external API e.GetString = IFunction.OfDelegate(GetString); var div = new IHTMLDiv { // using a real anonymous type, we get a nice key value string for display innerText = GetString() }; #region attach events if (e.onclick != null) { div.style.cursor = IStyle.CursorEnum.pointer; div.onclick += delegate { e.onclick.apply(e, div); }; } if (e.onmouseover != null) { div.style.cursor = IStyle.CursorEnum.pointer; div.onmouseover += delegate { e.onmouseover.apply(e, div); }; } if (e.onmouseout != null) { div.style.cursor = IStyle.CursorEnum.pointer; div.onmouseout += delegate { e.onmouseout.apply(e, div); }; } #endregion div.AttachTo(instructions); }