///////////////////////////////////////////////////////// #region initialize protected override void Initialize() { var netRef = DotNetObjectRef.Create(this); var events = GetEventNames(); _jsRef = Invoke <string>("initCollectionView", netRef, _host, _props, events); }
public static Task <T> Init <T>(IJSRuntime jsRuntime, DotNetObjectRef <object> helper) { // Implemented in exampleJsInterop.js return(jsRuntime.InvokeAsync <T>( "comp.init", helper)); }
/// <summary> /// Show picker popup /// </summary> public void Open() { OldStartValue = StartDate; OldEndValue = EndDate; var selectedRange = Ranges?.FirstOrDefault(r => r.Value.Start.Date == StartDate?.Date && r.Value.End.Date == EndDate?.Date); if (selectedRange != null) { ChosenLabel = selectedRange.Value.Key; } else { ChosenLabel = CustomRangeLabel; ShowCalendars(); } Visible = true; Issue11159 fixer = new Issue11159(JSRuntime); DotNetObjectRef <DatePickerComponentBase> reference = fixer.CreateDotNetObjectRef(this); JSRuntime.InvokeAsync <object>("clickAndPositionHandler.addClickOutsideEvent", Id, ParentId, reference); JSRuntime.InvokeAsync <object>("clickAndPositionHandler.getPickerPosition", Id, ParentId, Enum.GetName(typeof(DropsType), Drops).ToLower(), Enum.GetName(typeof(SideType), Opens).ToLower()); OnOpened.InvokeAsync(null); }
public static object[] EchoThreeParameters( ComplexParameter parameter1, byte parameter2, DotNetObjectRef <TestDTO> parameter3) { return(new object[] { parameter1, parameter2, parameter3.Value.GetNonSerializedValue() }); }
public void RegisterJsEvents() { foreach (var item in listDragTarget) { BvgJsInterop.HandleDrop(item.ElementID, item.ID, DotNetObjectRef.Create(classForJS)); } }
public Task CallHelloHelperSayHello(string name) { // sayHello is implemented in wwwroot/exampleJsInterop.js return(_jsRuntime.InvokeAsync <object>( "exampleJsFunctions.sayHello", DotNetObjectRef.Create(new HelloHelper(name)))); }
public void OnClose(Func <Exception, Task> callback) { this.closeCallback = new HubCloseCallback(callback); this.runtime.InvokeSync <object>(ON_CLOSE_METHOD, this.InternalConnectionId, DotNetObjectRef.Create(this.closeCallback)); }
public InfoBox(Geocoordinate center, InfoboxOptions options, string id) { Id = Guid.NewGuid().ToString(); Center = center; JSRuntime.Current.InvokeAsync <object>(_infoboxRegister, Id, center, options); thisRef = new DotNetObjectRef(this); }
public void SerializesDotNetObjectWrappersInKnownFormat() { // Arrange var runtime = new TestJSRuntime(); var obj1 = new object(); var obj2 = new object(); var obj3 = new object(); // Act // Showing we can pass the DotNetObject either as top-level args or nested var obj1Ref = new DotNetObjectRef(obj1); var obj1DifferentRef = new DotNetObjectRef(obj1); runtime.InvokeAsync <object>("test identifier", obj1Ref, new Dictionary <string, object> { { "obj2", new DotNetObjectRef(obj2) }, { "obj3", new DotNetObjectRef(obj3) }, { "obj1SameRef", obj1Ref }, { "obj1DifferentRef", obj1DifferentRef }, }); // Assert: Serialized as expected var call = runtime.BeginInvokeCalls.Single(); Assert.Equal("test identifier", call.Identifier); Assert.Equal("[\"__dotNetObject:1\",{\"obj2\":\"__dotNetObject:2\",\"obj3\":\"__dotNetObject:3\",\"obj1SameRef\":\"__dotNetObject:1\",\"obj1DifferentRef\":\"__dotNetObject:4\"}]", call.ArgsJson); // Assert: Objects were tracked Assert.Same(obj1, runtime.ArgSerializerStrategy.FindDotNetObject(1)); Assert.Same(obj2, runtime.ArgSerializerStrategy.FindDotNetObject(2)); Assert.Same(obj3, runtime.ArgSerializerStrategy.FindDotNetObject(3)); Assert.Same(obj1, runtime.ArgSerializerStrategy.FindDotNetObject(4)); }
/// <summary> /// Creates a new instance of <see cref="DotNetStaticClickHandler"/> /// </summary> /// <param name="clickHandler">The delegate for a click handler.</param> public DotNetInstanceClickHandler(InstanceClickHandler clickHandler) { if (clickHandler == null) { throw new ArgumentNullException(nameof(clickHandler)); } // the method needs to be public if (!clickHandler.Method.IsPublic) { throw new ArgumentException("The click handler needs to be public", nameof(clickHandler)); } // the method needs to have the attribute JSInvokable var isJsInvokable = clickHandler .Method .CustomAttributes.Any(data => data.AttributeType == typeof(JSInvokableAttribute)); if (!isJsInvokable) { throw new ArgumentException("The passed in method must have the 'JSInvokable' attribute", nameof(clickHandler)); } //AssemblyName = assembly.GetName().Name; // clickHandler.Method.DeclaringType.Assembly.GetName().Name; InstanceRef = DotNetObjectRef.Create(clickHandler.Target); MethodName = clickHandler.Method.Name; }
public static void VoidWithThreeParameters( ComplexParameter parameter1, byte parameter2, DotNetObjectRef <TestDTO> parameter3) { Invocations[nameof(VoidWithThreeParameters)] = new object[] { parameter1, parameter2, parameter3.Value.GetNonSerializedValue() }; }
public static Dictionary <string, DotNetObjectRef <TestDTO> > ReturnDotNetObjectByRef() { return(new Dictionary <string, DotNetObjectRef <TestDTO> > { { "Some sync instance", DotNetObjectRef.Create(new TestDTO(1000)) } }); }
protected string _propName; // name of the property in the parent control protected override void Initialize() { var netRef = DotNetObjectRef.Create(this); var events = GetEventNames(); _jsRef = Invoke <string>("initMarkupProperty", netRef, _host, _propName, _className, _props, events); }
public static Task <object[]> EchoThreeParametersAsync( ComplexParameter parameter1, byte parameter2, DotNetObjectRef <TestDTO> parameter3) { return(Task.FromResult(new object[] { parameter1, parameter2, parameter3.Value.GetNonSerializedValue() })); }
protected override async Task OnFirstAfterRenderAsync() { dotNetObjectRef = dotNetObjectRef ?? JSRunner.CreateDotNetObjectRef(new NumericEditAdapter(this)); await JSRunner.InitializeNumericEdit(dotNetObjectRef, ElementId, ElementRef, Decimals, DecimalsSeparator, Step); await base.OnFirstAfterRenderAsync(); }
public override async Task InitAsync(string mapId) { thisRef = new DotNetObjectRef(this); var param = new { InputPanelId, ItineraryPanelId, ModuleRef = thisRef }; await InitModuleAsync(mapId, ModuleId, InitFunctionName, param); }
public static Task VoidWithThreeParametersAsync( ComplexParameter parameter1, byte parameter2, DotNetObjectRef <TestDTO> parameter3) { Invocations[nameof(VoidWithThreeParametersAsync)] = new object[] { parameter1, parameter2, parameter3.Value.GetNonSerializedValue() }; return(Task.CompletedTask); }
protected DotNetObjectRef <T> CreateDotNetObjectRef <T>(T value) where T : class { lock (CreateDotNetObjectRefSyncObj) { JSRuntime.SetCurrentJSRuntime(jsRuntime); return(DotNetObjectRef.Create(value)); } }
public void CanAssociateWithSameRuntimeMultipleTimes() { var objRef = new DotNetObjectRef(new object()); var jsRuntime = new TestJsRuntime(); objRef.EnsureAttachedToJsRuntime(jsRuntime); objRef.EnsureAttachedToJsRuntime(jsRuntime); }
private DotNetObjectRef <SpeechSynthesis> GetObjectRef() { if (_ObjectRefOfThis == null) { _ObjectRefOfThis = DotNetObjectRef.Create(this); } return(_ObjectRefOfThis); }
public static object[] EchoSixParameters(ComplexParameter parameter1, byte parameter2, DotNetObjectRef <TestDTO> parameter3, int parameter4, long parameter5, float parameter6) { return(new object[] { parameter1, parameter2, parameter3.Value.GetNonSerializedValue(), parameter4, parameter5, parameter6 }); }
public static Task <object[]> EchoSixParametersAsync(ComplexParameter parameter1, byte parameter2, DotNetObjectRef <TestDTO> parameter3, int parameter4, long parameter5, float parameter6) { return(Task.FromResult(new object[] { parameter1, parameter2, parameter3.Value.GetNonSerializedValue(), parameter4, parameter5, parameter6 })); }
public async Task InitAsync() { Logger.LogDebug("Init JsonRequestHandler"); const string InitializeJavaScriptInteropName = "InitializeJavaScriptInterop"; Logger.LogDebug(InitializeJavaScriptInteropName); Microsoft.JSInterop.JSRuntime.SetCurrentJSRuntime(JSRuntime); await JSRuntime.InvokeAsync <object>(InitializeJavaScriptInteropName, DotNetObjectRef.Create(this)); }
public static async Task <Dictionary <string, DotNetObjectRef <TestDTO> > > ReturnDotNetObjectByRefAsync() { await Task.Yield(); return(new Dictionary <string, DotNetObjectRef <TestDTO> > { { "Some async instance", DotNetObjectRef.Create(new TestDTO(1001)) } }); }
public static void VoidWithFiveParameters( ComplexParameter parameter1, byte parameter2, DotNetObjectRef <TestDTO> parameter3, int parameter4, long parameter5) { Invocations[nameof(VoidWithFiveParameters)] = new object[] { parameter1, parameter2, parameter3.Value.GetNonSerializedValue(), parameter4, parameter5 }; }
internal DotNetObjectRef <SpeechSynthesisUtterance> GetObjectRef() { _ObjectRefCounter++; if (_ObjectRefCounter == 1) { _ObjectRef = DotNetObjectRef.Create(this); } return(_ObjectRef); }
// TODO: Find out a more smart way to register to global connect/disconnect events from the WebUSB API regardless if there are subscribers to the events. public async Task Initialize() { if (!this._initialized) { await this.JSRuntime.InvokeAsync <object>(REGISTER_USB_METHOD, DotNetObjectRef.Create(this)); this._initialized = true; } }
private void ReleaseObjectRef() { _ObjectRefCounter--; if (_ObjectRefCounter == 0) { _ObjectRef.Dispose(); _ObjectRef = null; } }
public HubConnection(IJSRuntime runtime, HttpConnectionOptions options) { this.runtime = runtime; this.Options = options; this.InternalConnectionId = Guid.NewGuid().ToString(); runtime.InvokeSync <object>(CREATE_CONNECTION_METHOD, this.InternalConnectionId, DotNetObjectRef.Create(this.Options)); }
public BaseMatHidden() { CallAfterRender(async() => { dotNetObjectRef = dotNetObjectRef ?? CreateDotNetObjectRef(this); await Js.InvokeAsync <object>("matBlazor.matHidden.init", Id, dotNetObjectRef); await UpdateVisible(); }); }