public JsClrClientSerializer() { ObjInfos = new Dictionary<object, ObjInfo>(); IgnoreFields = new JsObject<bool>(); IgnoreFields["_type"] = true; IgnoreFields["_hashKey"] = true; }
public jQuery renderTemplateClone(JsObject data ) { JsString token; JsString field; dynamic dereferencedValue; var keyRegex = new JsRegExp(@"\{[\w\W]+?\}", "g"); var foundKeys = templateAsString.match(keyRegex); var output = templateAsString; if (foundKeys != null) { for ( int j = 0; j < foundKeys.length; j++ ) { token = foundKeys[ j ]; field = returnFieldName( token ); if (field.indexOf(".") != -1) { dereferencedValue = resolveComplexName(data, field); } else if (field != "*") { dereferencedValue = data[field]; } else { dereferencedValue = data; } output = output.replace(token, dereferencedValue); } } jQuery fragmentJquery = jQueryContext.J("<div></div>"); fragmentJquery.append(output); return fragmentJquery; }
private void SendInternal(string httpMethod, string type, JsString url, object data, JsAction<object, JsString, jqXHR> success, JsAction<JsError, JsString, jqXHR> failed) { url = addTimeToUrl(url); JsObject headers = new JsObject(); AjaxSettings ajaxSettings = new AjaxSettings { type = httpMethod, dataType = type, data = data, url = jsUtils.inst.getLocation() + "/" + url, headers = headers, success = delegate(object o, JsString s, jqXHR arg3) { success(o, s, arg3); }, error = delegate(jqXHR xhr, JsString s, JsError arg3) { failed(arg3, s, xhr); } }; bool isString = data.As<JsObject>()["toLowerCase"] != null; if (isString) { ajaxSettings.processData = true; ajaxSettings.contentType = (type.As<JsString>().toLowerCase() == "xml") ? "application/xml" : "application/json"; } jQuery.ajax( ajaxSettings); }
public void ObjectPropertiesAreEqual() { var obj1 = new { prop1 = "test", prop2 = 2 }; dynamic obj2 = new JsObject(); obj2.prop1 = "test"; obj2.prop2 = 2; AssertEx.ObjectPropertiesAreEqual(obj1, obj2); obj2.prop2 = 5; AssertEx.ObjectPropertiesAreNotEqual(obj1, obj2); obj2.prop2 = 2; obj2.thirdProp = "some other property"; AssertEx.ObjectPropertiesAreNotEqual(obj1, obj2); ((IDictionary<string, object>)obj2).Remove("thirdProp"); AssertEx.ObjectPropertiesAreEqual(obj1, obj2); // make sure it fails correctly too Assert.Throws<AssertionException>(() => { AssertEx.ObjectPropertiesAreNotEqual(obj1, obj2); }); }
public void Querystring(JsString qs = null) { // optionally pass a querystring to parse this.parameters = new JsObject<JsString>(); JsCode("this.get = Querystring_get"); if (qs == null) qs = location.search.Substring(1, location.search.length); if (qs.length == 0) return; // Turn <plus> back to <space> // See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1 qs = qs.Replace(new JsRegExp("\\+", "g"), " "); JsArray<JsString> args = qs.Split('&'); // parse out name/value pairs separated via & // split out each name=value pair for (int i = 0; i < args.length; i++) { JsString value; JsArray<JsString> pair = args[i].Split('='); JsString name = Unescape(pair[0]); if (pair.length == 2) value = Unescape(pair[1]); else value = name; this.parameters[name] = value; } }
void foo() { dynamic arrivingViewProps = new JsObject(); arrivingViewProps.left = 0; arrivingViewProps.leaveTransforms = true; animate(arrivingViewProps, HOW_LONG); }
public override object filter(JsObject obj, JsObject arg) { int day = arg["day"].As<int>(); JsArray<JsArray<ngHistoryEntry>> allPropousals = obj.As<JsArray<JsArray<ngHistoryEntry>>>(); JsArray<ngHistoryEntry> res = allPropousals[day]; return res; }
public void NullableDateTime() { var o = new JsObject(); o["MyDate"] = "2015-11-02T23:00:54.237".As<JsObject>(); var obj = o.FromJsonObject<NullableDateTimeClass>(); AssertEquals(54, obj.MyDate.Value.Second); }
public LocalizationProvider(AbstractTranslator translator ) { this.translator = translator; translator.translationResult += provideTranslation; timer = new Timer( 10, 1 ); timer.timerComplete += sendTranslationRequest; pendingTranslations = new JsObject<JsArray<Node>>(); }
public void BreakPoint(JsObject instance) { if (InvokeRequired) { this.Invoke(new MethodInvoker(() => { debugControl.InspectObject(instance); })); } }
public void FromDynamic() { var div = CQ.Create("<div></div>"); dynamic dict = new JsObject(); dict.width = "10px"; dict.height = 20; div.CssSet(dict); Assert.AreEqual("10px", div.Css("width")); Assert.AreEqual("20px", div.Css("height")); }
public static Delegate MarshalJsFunction(JintRuntime runtime, JsObject function, JsObject that, Type delegateType) { if (runtime == null) throw new ArgumentNullException("runtime"); if (function == null) throw new ArgumentNullException("function"); if (delegateType == null) throw new ArgumentNullException("delegateType"); if (!typeof(Delegate).IsAssignableFrom(delegateType)) throw new ArgumentException("A delegate type is required", "delegateType"); var invokeMethod = delegateType.GetMethod("Invoke"); var parameters = invokeMethod .GetParameters() .Select(p => Expression.Parameter(p.ParameterType, p.Name)) .ToList(); Expression call = Expression.Call( Expression.Constant(function), typeof(JsObject).GetMethod("Execute"), Expression.Constant(runtime), Expression.Constant(that), MakeArrayInit( parameters.Select(p => Expression.Call( Expression.Constant(runtime.Global.Marshaller), typeof(Marshaller).GetMethod("MarshalClrValue").MakeGenericMethod(p.Type), p )), typeof(object), false ) ); if (invokeMethod.ReturnType != typeof(void)) { call = Expression.Call( Expression.Constant(runtime.Global.Marshaller), typeof(Marshaller).GetMethod("MarshalJsValue").MakeGenericMethod(invokeMethod.ReturnType), call ); } var lambda = Expression.Lambda( delegateType, Expression.Block( invokeMethod.ReturnType, call ), parameters ); return lambda.Compile(); }
public void Stop() { if (timeoutHandle != null) { Jsni.clearTimeout(timeoutHandle); timeoutHandle = null; } if (intervalHandle != null) { Jsni.clearInterval(intervalHandle); intervalHandle = null; } }
void foo2() { FakeQuery arrivingView = null; dynamic arrivingViewProps = new JsObject(); arrivingViewProps.left = 0; arrivingViewProps.leaveTransforms = true; var newLeftSide = 7; arrivingView.show(); arrivingView.css("left", newLeftSide); arrivingView.animate(arrivingViewProps, HOW_LONG); }
static void OnReady() { var fields = new JsObject<FieldConfig>(); fields["OrderID"] = new FieldConfig { type = "number" }; fields["ShipCountry"] = new FieldConfig { type = "string" }; fields["ShipName"] = new FieldConfig { type = "string" }; fields["ShipAddress"] = new FieldConfig { type = "string" }; new jQuery("#grid").kendoGrid(new GridConfiguration { dataSourceObject = new DataSourceConfiguration { type = "odata", transport = new DataSourceTransportConfiguration { readString = "http://demos.kendoui.com/service/Northwind.svc/Orders" }, schema = new DataSourceSchemaConfiguration { model = new ModelObjectOptions { fields = fields } }, pageSize = 10, serverPaging = true, serverFiltering = true, serverSorting = true }, height = 250, sortableBoolean = true, filterable = true, columnMenu = true, pageableBoolean = true, columns = new JsArray<GridColumnConfiguration> { new GridColumnConfiguration{ field = "OrderID" }, new GridColumnConfiguration{ field = "ShipCountry" }, new GridColumnConfiguration{ field = "ShipName" }, new GridColumnConfiguration { field = "ShipAddress", filterable = false } } }); }
public StaticTranslator() { this.translations = new JsObject<JsObject<JsString>>(); var labels = new JsObject<JsString>(); labels["Greetings"] = "Howdy There"; labels["Whatever"] = "Blah"; var messages = new JsObject<JsString>(); labels["ERROR"] = "There has been a rather large error"; labels["LEAVE"] = "It would be best if you left now"; translations["labels"] = labels; translations["messages"] = labels; }
public void Save() { try { JsObject data = new JsObject(); data.str["main"] = MainFormPosition; data.str["fullscreen"] = FullscreenPosition; data.str["monitor"] = MonitorFormPosition; data.str["options"] = OptionsFormPosition; data.str["hivemind_submit"] = HivemindSubmitFormPosition; File.WriteAllText(cfgFile, data.Serialize()); } catch (Exception) { } }
public void SendGet(string type, JsString url, JsAction<object, JsString, jqXHR> success, JsAction<JsError, JsString, jqXHR> failed) { url = addTimeToUrl(url); JsObject headers = new JsObject(); jQuery.ajax(new AjaxSettings { type = "GET", dataType = type, url = jsUtils.inst.getLocation() + "/" + url, headers = headers, success = delegate(object o, JsString s, jqXHR arg3) { success(o, s, arg3); }, error = delegate(jqXHR xhr, JsString s, JsError arg3) { failed(arg3, s, xhr); } }); }
// run the currently selected effect static void runEffect() { // get effect type from var selectedEffect = new jQuery("#effectTypes").val().As<EffectType>(); // most effect types need no options passed by default var options = new JsObject { }; if (selectedEffect.ExactEquals("scale")) { options = new { percent = 0 }.As<JsObject>(); } else if (selectedEffect.ExactEquals("size")) { options = new { to = new { width = 200, height = 60 } }.As<JsObject>(); } // run the effect new jQuery("#effect").hide(selectedEffect, options, 1000, callback); }
public void ExtendPocoFromDynamic() { TestClass1 t1 = new TestClass1(); t1.Prop1 = "value1"; t1.Prop2 = "value2"; dynamic t2 = new JsObject(); t2.Prop2 = "class2value2"; t2.Prop3 = "class2vlaue3"; CQ.Extend(t1, t2); Assert.AreEqual("value1", t1.Prop1, "Target prop1 unchanged"); Assert.AreEqual("class2value2", t1.Prop2, "Target prop2 updated"); }
public override object filter(JsObject obj, JsObject arg) { JsArray<ngFoodItem> res = new JsArray<ngFoodItem>(); string category = arg["category"].As<JsString>(); int day = arg["day"].As<int>(); JsArray<JsArray<ngFoodItem>> allFoods = obj.As<JsArray<JsArray<ngFoodItem>>>(); JsArray<ngFoodItem> items = allFoods[day]; if (null != items) { foreach (ngFoodItem item in items) { if ((item.Category == category) && !item.isContainer) { res.Add(item); } } } return res; }
public override object filter(JsObject obj, JsObject arg) { JsArray<ngOrderEntry> res = new JsArray<ngOrderEntry>(); int day = arg["day"].As<int>(); JsArray<JsArray<ngOrderEntry>> allOrders = obj.As<JsArray<JsArray<ngOrderEntry>>>(); JsArray<ngOrderEntry> tmp = allOrders[day]; if (tmp != null && tmp.length > 0) { foreach (ngOrderEntry order in tmp) { ngFoodItem foodItem = ngFoodController.inst.findFoodById(order.FoodId); if (null != foodItem && !foodItem.isContainer) { res.Add(order); } } } return res; }
// run the currently selected effect static void runEffect() { // get effect type from var selectedEffect = new jQuery("#effectTypes").val().As<EffectType>(); var options = new JsObject { }; if (selectedEffect.ExactEquals("scale")) { options = new { percent = 0 }.As<JsObject>(); } else if (selectedEffect.ExactEquals("transfer")) { options = new { to = "#button", className = "ui-effects-transfer" }.As<JsObject>(); } else if (selectedEffect.ExactEquals("size")) { options = new { to = new Size { width = 200, height = 60 } }.As<JsObject>(); } // run the effect new jQuery("#effect").effect(selectedEffect, options, 500, callback); }
public object Execute(JintRuntime runtime, object @this, JsObject callee, object[] arguments) { var genericArguments = JintRuntime.ExtractGenericArguments(ref arguments); if ( _generics.Count == 0 && genericArguments != null && genericArguments.Length > 0 ) throw new InvalidOperationException("Method cannot be called without generic arguments"); var implementation = _overloads.ResolveOverload( arguments, runtime.Global.Marshaller.MarshalGenericArguments(genericArguments) ); if (implementation == null) throw new JintException(String.Format("No matching overload found {0}<{1}>", callee.Delegate.Name, genericArguments)); return implementation(runtime, @this, callee, arguments); }
public static object clone(object obj) { if ( ( obj == null) || ( JsContext.@typeof( obj ) != "object" ) ) { return obj; } //Dates if ( obj is JsDate ) { var copy = new JsDate(); copy.setTime( obj.As<JsDate>().getTime() ); return copy; } //Array if (obj is JsArray) { var copy = new JsArray(); var current = obj.As<JsArray>(); for (var i = 0; i < current.length; i++ ) { copy[ i ] = clone( current[ i ] ); } return copy; } //Object if (obj is JsObject) { var copy = new JsObject(); var current = obj.As<JsObject>(); foreach (var key in current ) { if ( current.hasOwnProperty( key )) { copy[ key ] = clone( current[ key ] ); } } return copy; } return null; }
public void Change(TimeSpan dueTime, TimeSpan period) { // Clear any existing timers Stop(); // Set up a timeout to fire the timer if (dueTime.TotalMilliseconds == 0) { intervalHandle = Jsni.setInterval(OnTimeout, (int)period.TotalMilliseconds); } else { timeoutHandle = Jsni.setTimeout( () => { callback(state); timeoutHandle = null; intervalHandle = Jsni.setInterval(OnTimeout, (int)period.TotalMilliseconds); }, (int)dueTime.TotalMilliseconds); } }
public NativePropertyStore(JsObject owner, MethodInfo[] getters, MethodInfo[] setters) : base((DictionaryPropertyStore)owner.PropertyStore) { if (getters == null) throw new ArgumentNullException("getters"); if (setters == null) throw new ArgumentNullException("setters"); _global = owner.Global; _getOverload = new NativeOverloadImpl<MethodInfo, WrappedIndexerGetter>( _global, (genericArgs, length) => Array.FindAll(getters, mi => mi.GetParameters().Length == length), ProxyHelper.WrapIndexerGetter ); _setOverload = new NativeOverloadImpl<MethodInfo, WrappedIndexerSetter>( _global, (genericArgs, length) => Array.FindAll(setters, mi => mi.GetParameters().Length == length), ProxyHelper.WrapIndexerSetter ); }
static void OnReady() { var fields = new JsObject<FieldConfig>(); fields["FirstName"] = new FieldConfig { type = "string" }; fields["LastName"] = new FieldConfig { type = "string" }; fields["City"] = new FieldConfig { type = "string" }; fields["Title"] = new FieldConfig { type = "string" }; fields["BirthDate"] = new FieldConfig { type = "date" }; fields["Age"] = new FieldConfig { type = "number" }; new jQuery("#grid").kendoGrid(new GridConfiguration { dataSourceObject = new DataSourceConfiguration { data = People.createRandomData(50), schema = new DataSourceSchemaConfiguration { model = new ModelObjectOptions { fields = fields, } }, pageSize = 10 }, height = 250, scrollable = true, sortableBoolean = true, filterable = true, pageableBoolean = true, columns = new JsArray<GridColumnConfiguration> { new GridColumnConfiguration { field = "FirstName", title = "First Name", widthNumber = 100}, new GridColumnConfiguration { field = "LastName", title = "LastName", widthNumber = 100}, new GridColumnConfiguration { field = "City", widthNumber = 100}, new GridColumnConfiguration { field = "Title"}, new GridColumnConfiguration { field = "BirthDate", title = "Birth Date", template = "#= kendo.toString(BirthDate,'MM/dd/yyyy') #"}, new GridColumnConfiguration { field = " Age", widthNumber = 50 } } }); }
/// <summary> /// Set up bindings on a single node without binding any of its descendents. /// </summary> /// <param name="node">The node to bind to.</param> /// <param name="bindings">An optional dictionary of bindings, pass null to let Knockout gather them from the element.</param> /// <param name="viewModel">The view model instance.</param> /// <param name="bindingAttributeName">The name of the attribute which has the binding definitions.</param> public static void applyBindingsToNode(HtmlElement node, JsObject bindings, object viewModel, JsString bindingAttributeName) { }
public extern JsObject apply(JsObject thisInstance, JsArray args);
public PropertyFileTranslator(JsString url, bool forceReload) { this.url = url; this.forceReload = forceReload; keyValuePairs = new JsObject(); }
static void OnReady() { var fields = new JsObject <FieldConfig>(); fields["FirstName"] = new FieldConfig { type = "string" }; fields["LastName"] = new FieldConfig { type = "string" }; fields["City"] = new FieldConfig { type = "string" }; fields["Title"] = new FieldConfig { type = "string" }; fields["BirthDate"] = new FieldConfig { type = "date" }; fields["Age"] = new FieldConfig { type = "number" }; new jQuery("#grid").kendoGrid(new GridConfiguration { dataSourceObject = new DataSourceConfiguration { data = People.createRandomData(50), schema = new DataSourceSchemaConfiguration { model = new ModelObjectOptions { fields = fields, } }, pageSize = 10 }, height = 250, scrollable = true, sortableBoolean = true, filterable = true, pageableBoolean = true, columns = new JsArray <GridColumnConfiguration> { new GridColumnConfiguration { field = "FirstName", title = "First Name", widthNumber = 100 }, new GridColumnConfiguration { field = "LastName", title = "LastName", widthNumber = 100 }, new GridColumnConfiguration { field = "City", widthNumber = 100 }, new GridColumnConfiguration { field = "Title" }, new GridColumnConfiguration { field = "BirthDate", title = "Birth Date", template = "#= kendo.toString(BirthDate,'MM/dd/yyyy') #" }, new GridColumnConfiguration { field = " Age", widthNumber = 50 } } }); }
public MainView(DClient client, Settings mainSetting) { client.GetData += Client_GetData; _client = client; _mainSetting = mainSetting; LoadData(); InitializeChrome(); InitializeComponent(); CreatePlayer(); if (mainSetting.IsDoubleButton) { BtnDouble.Visibility = Visibility.Visible; } job1 = new JsObject(); job2 = new JsObject(); BrowserTab1.Browser.RegisterJsObject("jsobject", job1); BrowserTab2.Browser.RegisterJsObject("jsobject", job2); job1.CoeffChanged += Job1_CoeffChanged; job2.CoeffChanged += Job2_CoeffChanged; job1.LoginChange += LoginChange; job2.LoginChange += LoginChange; job1.Stop += Job_Stop; job2.Stop += Job_Stop; job1.MaxBetChanged += Job1_MaxBetChanged; job2.MaxBetChanged += Job2_MaxBetChanged; //Показываем список активных БК Test.ItemsSource = _bookmakers.Where(x => x.IsShow).ToList(); //Инициализируем нужных менеджеров _managers.Add(BookmakerType.Zenit, new ZenitManager(BrowserTab1.Browser)); _managers.Add(BookmakerType.Fonbet, new FonbetManager(BrowserTab1.Browser)); _managers.Add(BookmakerType.Olimp, new OlimpManager(BrowserTab2.Browser)); _managers.Add(BookmakerType.Marafon, new MarafonManager(BrowserTab2.Browser)); _managers.Add(BookmakerType.Parimatch, new PariMatchManager(BrowserTab2.Browser)); //Инстализируем отдельный поток для обновления вилок _thForksUpdate = new Thread(ForksUpdate); _thForksUpdate.IsBackground = true; _thForksUpdate.Start(); LbFilters.ItemsSource = mainSetting.Sports; Loaded += MainView_Loaded; Closing += MainView_Closing; //Задаем настройки внешнего вида if (mainSetting.WinSet == null) { mainSetting.WinSet = new WindowsSettings(); } _minPercent = mainSetting.WinSet.MinPercent; _maxPercent = mainSetting.WinSet.MaxPercent; if (_minPercent != 0) { TxtMinPercent.Text = _minPercent.ToString("#"); } else { TxtMinPercent.Text = 0.ToString(); } TxtMaxPercent.Text = _maxPercent.ToString("#"); Height = mainSetting.WinSet.WindowsHeight; Width = mainSetting.WinSet.WindowsWidth; SpliterOne.Height = new GridLength(mainSetting.WinSet.SpliterOne); SpliterTwo.Width = new GridLength(mainSetting.WinSet.SpliterTwo); if (mainSetting.WinSet.ColumnsWidth != null) { var gridview = Forks.View as GridView; if (gridview == null) { MessageBox.Show($"Не удалось загрузить настройки столбцов. Будут заданы настройки по умолчанию."); return; } for (int i = 0; i < mainSetting.WinSet.ColumnsWidth.Count; i++) { try { gridview.Columns[i].Width = mainSetting.WinSet.ColumnsWidth[i]; } catch (Exception ex) { Debug.WriteLine($"Ошибка задания размеров {nameof(gridview)}. {ex.Message}"); } } } }
public JsProperty(JsObject @this) { This = @this; }
public JsImplDictionary() { this._table = new JsObject(); this._keys = new JsObject(); this._version = 0; }
/// <summary> /// Constructor. /// </summary> /// <param name="headers">A map of header name/header values. Use an array to specify more than one value.</param> public FileDownloadOptions(JsObject headers = null) { }
protected override RavenJObject ConvertReturnValue(JsObject jsObject) { return(null); // we don't use / need the return value }
public void Clear() { Hashtable = new JsObject <T>(); _Count = 0; }
// TODO: asAdmin public object callSvc(string ac, JsObject param = null, JsObject postParam = null, CallSvcOpt opt = null) { Match m = Regex.Match(ac, @"(\w+)(?:\.(\w+))?$"); string ac1 = null; string table = null; string clsName = null; string methodName = null; if (m.Groups[2].Length > 0) { table = m.Groups[1].Value; ac1 = m.Groups[2].Value; clsName = onCreateAC(table); methodName = "api_" + ac1; } else { clsName = "Global"; methodName = "api_" + m.Groups[1].Value; } JDApiBase api = null; Assembly asm = JDEnvBase.getAsmembly(); api = asm.CreateInstance("JDApi." + clsName) as JDApiBase; if (api == null) { if (table == null) { throw new MyException(JDApiBase.E_PARAM, "bad ac=`" + ac + "` (no Global)"); } int code = !this.api.hasPerm(JDApiBase.AUTH_LOGIN)? JDApiBase.E_NOAUTH : JDApiBase.E_FORBIDDEN; throw new MyException(code, string.Format("Operation is not allowed for current user on object `{0}`", table)); } Type t = api.GetType(); MethodInfo mi = t.GetMethod(methodName); if (mi == null) { throw new MyException(JDApiBase.E_PARAM, "bad ac=`" + ac + "` (no method)"); } api.env = this; NameValueCollection[] bak = null; if (opt != null) { if (opt.backupEnv) { bak = new NameValueCollection[] { this._GET, this._POST } } ; if (opt.isCleanCall) { this._GET = new NameValueCollection(); this._POST = new NameValueCollection(); } } if (param != null) { foreach (var kv in param) { this._GET[kv.Key] = kv.Value.ToString(); } } if (postParam != null) { foreach (var kv in postParam) { this._POST[kv.Key] = kv.Value.ToString(); } } object ret = null; if (clsName == "Global") { ret = mi.Invoke(api, null); } else if (t.IsSubclassOf(typeof(AccessControl))) { AccessControl accessCtl = api as AccessControl; accessCtl.init(table, ac1); accessCtl.before(); object rv = mi.Invoke(api, null); //ret[1] = t.InvokeMember(methodName, BindingFlags.InvokeMethod, null, api, null); accessCtl.after(ref rv); ret = rv; } else { throw new MyException(JDApiBase.E_SERVER, "misconfigured ac=`" + ac + "`"); } if (ret == null) { ret = "OK"; } if (bak != null) { this._GET = bak[0] as NameValueCollection; this._POST = bak[1] as NameValueCollection; } return(ret); }
public extern string Stringify(JsObject o);
internal static void _SafeCopyObject(JsObject source, JsObject target) { }
void ICustomSuperClass.SetJsHandle(IntPtr handle) { mJsObject = handle; Entry.Object.MakePersistent(mJsObject); }
static void OnReady() { var fields = new JsObject <FieldConfig>(); fields["ProductID"] = new FieldConfig { editable = false, nullable = true }; fields["ProductName"] = "ProductName".As <FieldConfig>(); fields["UnitPrice"] = new FieldConfig { type = "number" }; fields["Discontinued"] = new FieldConfig { type = "boolean" }; fields["UnitsInStock"] = new FieldConfig { type = "number" }; var crudServiceBaseUrl = "http://demos.kendoui.com/service"; var dataSource = new DataSource(new DataSourceConfiguration { transport = new DataSourceTransportConfiguration { read = new DataSourceTransportReadConfiguration { url = crudServiceBaseUrl + "/Products/Update", dataType = "jsonp" }, update = new DataSourceTransportUpdateConfiguration { url = crudServiceBaseUrl + "/Products/Update", dataType = "jsonp" }, destroy = new DataSourceTransportDestroyConfiguration { url = crudServiceBaseUrl + "/Products/Destroy", dataType = "jsonp" }, create = new DataSourceTransportCreateConfiguration { url = crudServiceBaseUrl + "/Products/Create", data = "jsonp" }, parameterMap = (options, operation) => { if (operation.ExactNotEquals("read") && options.As <JsObject>()["models"].As <bool>()) { //TODO: return {models: kendo.stringify(options.models)}; JsContext.JsCode("return {models: kendo.stringify(options.models)};"); return(null); } return(null); } }, batch = true, pageSize = 4, schema = new DataSourceSchemaConfiguration { model = new ModelObjectOptions { id = "ProductID", fields = fields } } }); new jQuery("#pager").kendoPager(new PagerConfiguration { dataSource = dataSource }); var listView = new jQuery("#listView").kendoListView(new ListViewConfiguration { dataSource = dataSource, template = Kendo.template(new jQuery("#template").html()), editTemplate = Kendo.template(new jQuery("#editTemplate").html()), }).data("kendoListView").As <ListView>(); new jQuery(".k-add-button").click(e => { listView.add(); e.preventDefault(); }); }
public void Extend() { dynamic settings = CQ.ParseJSON("{ 'xnumber1': 5, 'xnumber2': 7, 'xstring1': 'peter', 'xstring2': 'pan' }"); dynamic options = CQ.ParseJSON("{ 'xnumber2': 1, 'xstring2': 'x', 'xxx': 'newstring'}"); dynamic optionsCopy = CQ.ParseJSON("{ 'xnumber2': 1, 'xstring2': 'x', 'xxx': 'newstring' }"); dynamic merged = CQ.ParseJSON("{ 'xnumber1': 5, 'xnumber2': 1, 'xstring1': 'peter', 'xstring2': 'x', 'xxx': 'newstring' }"); dynamic deep1 = CQ.ParseJSON("{ 'foo': { 'bar': true } }"); dynamic deep1copy = CQ.ParseJSON("{ 'foo': { 'bar': true } }"); dynamic deep2 = CQ.ParseJSON("{ 'foo': { 'baz': true }, 'foo2': 'document' }"); dynamic deep2copy = CQ.ParseJSON("{ 'foo': { 'baz': true }, 'foo2': 'document' }"); dynamic deepmerged = CQ.ParseJSON("{ 'foo': { 'bar': true, 'baz': true }, 'foo2': 'document' }"); var arr = new int[] { 1, 2, 3 }; dynamic nestedarray = new ExpandoObject(); nestedarray.arr = arr; CQ.Extend(settings, options); Assert.AreEqual(merged, settings, "Check if extended: settings must be extended"); Assert.AreEqual(optionsCopy, options, "Check if not modified: options must not be modified"); CQ.Extend(settings, null, options); Assert.AreEqual(settings, merged, "Check if extended: settings must be extended"); Assert.AreEqual(optionsCopy, options, "Check if not modified: options must not be modified"); // Test deep copying CQ.Extend(true, deep1, deep2); Assert.AreEqual(deepmerged.foo, deep1.foo, "Check if foo: settings must be extended"); Assert.AreEqual(deep2copy.foo, deep2.foo, "Check if not deep2: options must not be modified"); // n/a //Assert.AreEqual(document, deep1.foo2, "Make sure that a deep clone was not attempted on the document"); var nullUndef = CQ.Extend(null, options, CQ.ParseJSON("{ 'xnumber2': null }")); Assert.IsTrue(nullUndef.xnumber2 == null, "Check to make sure null values are copied"); nullUndef = CQ.Extend(null, options, CQ.ParseJSON("{ 'xnumber0': null }")); Assert.IsTrue(nullUndef.xnumber0 == null, "Check to make sure null values are inserted"); // Test nested arrays dynamic extendedArr = CQ.Extend(true, null, nestedarray); Assert.AreNotSame(extendedArr.arr, arr, "Deep extend of object must clone child array"); Assert.AreNotSame(extendedArr.arr, arr, "Deep extend of object must clone child array"); // #5991 dynamic emptyArrObj = CQ.ParseJSON("{ arr: {} }"); dynamic extendedArr2 = CQ.Extend(true, emptyArrObj, nestedarray); Assert.IsTrue(extendedArr2.arr is IEnumerable, "Cloned array heve to be an Array"); dynamic simpleArrObj = new ExpandoObject(); simpleArrObj.arr = arr; emptyArrObj = CQ.ParseJSON("{ arr: {} }"); dynamic result = CQ.Extend(true, simpleArrObj, emptyArrObj); Assert.IsTrue(!(result.arr is Array), "Cloned object heve to be an plain object"); dynamic empty = new JsObject(); dynamic optionsWithLength = CQ.ParseJSON("{ 'foo': { 'length': -1 } }"); CQ.Extend(true, empty, optionsWithLength); Assert.AreEqual(empty.foo, optionsWithLength.foo, "The length property must copy correctly"); //? not really relevant empty = new JsObject(); dynamic optionsWithDate = new JsObject(); optionsWithDate.foo = new JsObject(); optionsWithDate.foo.date = new DateTime(); CQ.Extend(true, empty, optionsWithDate); Assert.AreEqual(empty.foo, optionsWithDate.foo, "Dates copy correctly"); var customObject = DateTime.Now; dynamic optionsWithCustomObject = new { foo = new { date = customObject } }; empty = CQ.Extend(true, null, optionsWithCustomObject); Assert.IsTrue(empty.foo != null && empty.foo.date == customObject, "Custom objects copy correctly (no methods)"); //// Makes the class a little more realistic //myKlass.prototype = { someMethod: function(){} }; //empty = {}; //jQuery.extend(true, empty, optionsWithCustomObject); //ok( empty.foo && empty.foo.date === customObject, "Custom objects copy correctly" ); dynamic ret = CQ.Extend(true, CQ.ParseJSON("{'foo': 4 }"), new { foo = 5 }); Assert.IsTrue(ret.foo == 5, "Wrapped numbers copy correctly"); nullUndef = CQ.Extend(null, options, "{ 'xnumber2': null }"); Assert.IsTrue(nullUndef.xnumber2 == null, "Check to make sure null values are copied"); // nullUndef = jQuery.extend({}, options, { xnumber2: undefined }); // ok( nullUndef.xnumber2 === options.xnumber2, "Check to make sure undefined values are not copied"); nullUndef = CQ.Extend(null, options, "{ 'xnumber0': null }"); Assert.IsTrue(nullUndef.xnumber0 == null, "Check to make sure null values are inserted"); dynamic target = new ExpandoObject(); dynamic recursive = new ExpandoObject(); recursive.bar = 5; recursive.foo = target; CQ.Extend(true, target, recursive); dynamic compare = CQ.ParseJSON("{ 'bar':5 }"); Assert.AreEqual(target, compare, "Check to make sure a recursive obj doesn't go never-ending loop by not copying it over"); // These next checks don't really apply as they are specific to javascript nuances, but can't hurt ret = CQ.Extend(true, CQ.ParseJSON(" { 'foo': [] }"), CQ.ParseJSON("{ 'foo': [0] }")); // 1907 // arrays are returned as List<object> when casting to expando object Assert.AreEqual(1, ret.foo.Count, "Check to make sure a value with coersion 'false' copies over when necessary to fix #1907"); ret = CQ.Extend(true, CQ.ParseJSON("{ 'foo': '1,2,3' }"), CQ.ParseJSON("{ 'foo': [1, 2, 3] }")); Assert.IsTrue(!(ret.foo is string), "Check to make sure values equal with coersion (but not actually equal) overwrite correctly"); dynamic obj = CQ.ParseJSON("{ 'foo':null }"); CQ.Extend(true, obj, CQ.ParseJSON("{ 'foo':'notnull' }")); Assert.AreEqual(obj.foo, "notnull", "Make sure a null value can be overwritten"); // function func() {} // jQuery.extend(func, { key: "value" } ); // equals( func.key, "value", "Verify a function can be extended" ); dynamic defaults = CQ.ParseJSON("{ 'xnumber1': 5, 'xnumber2': 7, 'xstring1': 'peter', 'xstring2': 'pan' }"); dynamic defaultsCopy = CQ.ParseJSON(" { xnumber1: 5, xnumber2: 7, xstring1: 'peter', xstring2: 'pan' }"); dynamic options1 = CQ.ParseJSON("{ xnumber2: 1, xstring2: 'x' }"); dynamic options1Copy = CQ.ParseJSON(" { xnumber2: 1, xstring2: 'x' }"); dynamic options2 = CQ.ParseJSON(" { xstring2: 'xx', xxx: 'newstringx'}"); dynamic options2Copy = CQ.ParseJSON(" { xstring2: 'xx', xxx: 'newstringx'}"); dynamic merged2 = CQ.ParseJSON(" { xnumber1: 5, xnumber2: 1, xstring1: 'peter', xstring2: 'xx', xxx: 'newstringx' }"); ret = CQ.Extend(true, CQ.ParseJSON(" { foo:'bar' }"), CQ.ParseJSON("{ foo:null }")); Assert.IsTrue(ret.foo == null, "Make sure a null value doesn't crash with deep extend, for #1908"); settings = CQ.Extend(null, defaults, options1, options2); Assert.AreEqual(merged2, settings, "Check if extended: settings must be extended"); Assert.AreEqual(defaults, defaultsCopy, "Check if not modified: options1 must not be modified"); Assert.AreEqual(options1, options1Copy, "Check if not modified: options1 must not be modified"); Assert.AreEqual(options2, options2Copy, "Check if not modified: options2 must not be modified"); }
protected JsString getName(JsObject instance) { var dependency = new TypeDefinition(instance["constructor"]); return(dependency.getClassName()); }
/// <summary> /// Constructor. /// </summary> /// <param name="fileKey">The name of the form element. Defaults to "file".</param> /// <param name="fileName">The file name to use when saving the file on the server. Defaults to "image.jpg".</param> /// <param name="mimeType">The mime type of the data to upload. Defaults to "image/jpeg".</param> /// <param name="parameters">A set of optional key/value pairs to pass in the HTTP request.</param> /// <param name="headers">A map of header name/header values. Use an array to specify more than one value.</param> /// <param name="httpMethod">"PUT" or "POST"</param> public FileUploadOptions(JsString fileKey = null, JsString fileName = null, JsString mimeType = null, JsObject parameters = null, JsObject headers = null, FileUploadMethod httpMethod = FileUploadMethod.Post) { }
private static RavenJObject ConvertReturnValue(JsObject jsObject) { return(ToRavenJObject(jsObject)); }
private void listChangedHandler(int index, JsObject data) { if (menuItemSelected != null && data != null) { var menuItem = new MenuItem {name = data[ "name" ].As<string>(), url = data[ "url" ].As<string>()}; menuItemSelected(menuItem); } }
public SymbolInvoker(JsObject @this, string method) => (this.@this, this.method) = (@this, method);
public JsObject GetDependencies() { JsObject ret = new JsObject(UsdCsPINVOKE.PlugPlugin_GetDependencies(swigCPtr), true); return(ret); }
/// <summary> /// Defines an external JsObject value to be available inside the script /// </summary> /// <param name="name">Local name of the Double value during the execution of the script</param> /// <param name="value">Available JsObject value</param> /// <returns>The current JintEngine instance</returns> public JintEngine SetParameter(string name, JsObject value) { Visitor.GlobalScope[name] = value; return(this); }
public HashMap() { entries = new JsObject(); }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(JsObject obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }
/// <summary> /// Set up bindings on a single node without binding any of its descendents. /// </summary> /// <param name="node">The node to bind to.</param> /// <param name="bindings">An optional dictionary of bindings, pass null to let Knockout gather them from the element.</param> /// <param name="viewModel">The view model instance.</param> public static void applyBindingsToNode(HtmlElement node, JsObject bindings, object viewModel) { }
public static IObservable <TResult> switchCase <TValue, TResult>(JsFunc <TValue> selector, JsObject <TValue, IObservable <TResult> > sources, IObservable <TResult> defaultSource) { return(null); }
public StyleExtensionMap() { hashMap = new JsObject <StyleExtensionMapEntry>(); }
JsImplType _MakeGenericType(JsExtendedArray typeArguments) { if (_MakeGenericTypeCache == null) _MakeGenericTypeCache = new JsObject(); var key = ""; for (var i = 0; i < typeArguments.length; i++) { var typeArg = typeArguments[i].As<JsImplType>(); key += typeArg._Name; } var t = _MakeGenericTypeCache[key].As<JsImplType>(); if (t == null) { t = new JsImplType(_JsType); _MakeGenericTypeCache[key] = t; t._Name = _Name; t._GenericTypeDefinition = this; t._TypeArguments = typeArguments; t._Properties = _Properties; t._PropertiesByName = _PropertiesByName; t._Methods = _Methods; t._MethodsByName = _MethodsByName; t._DeclaringType = _DeclaringType; t._CustomAttributes = _CustomAttributes; } return t; }
public static IObservable <TResult> switchCase <TValue, TResult>(JsFunc <TValue> selector, JsObject <TValue, IObservable <TResult> > sources, IScheduler scheduler = null) { return(null); }
protected virtual RavenJObject ConvertReturnValue(JsObject jsObject) { return(ToRavenJObject(jsObject)); }
public JsObject GetMetadata() { JsObject ret = new JsObject(UsdCsPINVOKE.PlugPlugin_GetMetadata(swigCPtr), true); return(ret); }