/** <inheritDoc /> */ public void Inject(Ignite grid) { // ReSharper disable once InconsistentlySynchronizedField _ignite = grid; ResourceProcessor.Inject(_filter, grid); }
private void Execute0(bool cancel, out object res, out bool success) { // 1. Inject resources. IComputeResourceInjector injector = _job as IComputeResourceInjector; if (injector != null) { injector.Inject(_ignite); } else { ResourceProcessor.Inject(_job, _ignite); } // 2. Execute. try { if (cancel) { _job.Cancel(); } res = _job.Execute(); success = true; } catch (Exception e) { res = e; success = false; } }
public void Process(ResourceProcessor resProc) { foreach (var resource in resources.Keys) { resProc(this, resource); } }
/// <summary> /// Start execution. /// </summary> /// <param name="grid">Ignite instance.</param> /// <param name="writer">Writer.</param> /// <param name="cb">Callback invoked when all necessary data is written to stream.</param> /// <param name="qry">Query.</param> public void Start(Ignite grid, PortableWriterImpl writer, Func <IUnmanagedTarget> cb, ContinuousQuery <TK, TV> qry) { // 1. Inject resources. ResourceProcessor.Inject(_lsnr, grid); ResourceProcessor.Inject(_filter, grid); // 2. Allocate handle. _hnd = grid.HandleRegistry.Allocate(this); // 3. Write data to stream. writer.WriteLong(_hnd); writer.WriteBoolean(qry.Local); writer.WriteBoolean(_filter != null); ContinuousQueryFilterHolder filterHolder = _filter == null || qry.Local ? null : new ContinuousQueryFilterHolder(typeof(TK), typeof(TV), _filter, _keepPortable); writer.WriteObject(filterHolder); writer.WriteInt(qry.BufferSize); writer.WriteLong((long)qry.TimeInterval.TotalMilliseconds); writer.WriteBoolean(qry.AutoUnsubscribe); // 4. Call Java. _nativeQry = cb(); // 5. Initial query. var nativeInitialQryCur = UU.ContinuousQueryGetInitialQueryCursor(_nativeQry); _initialQueryCursor = nativeInitialQryCur == null ? null : new QueryCursor <TK, TV>(nativeInitialQryCur, _marsh, _keepPortable); }
private void InitializeMainForm() { var version = Assembly.GetExecutingAssembly().GetName().Version; this.Text = $"PassBerry {version.Major}.{version.Minor} - Press Shift + F2 to paste username and password"; this.MinimumSize = new Size(700, 500); var dataGrid = this.dataGridViewMain; dataGrid.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dataGrid.BackgroundColor = Color.White; dataGrid.BorderStyle = BorderStyle.None; dataGrid.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None; dataGrid.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.None; dataGrid.AllowDrop = false; dataGrid.AllowUserToResizeColumns = false; dataGrid.AllowUserToResizeRows = false; dataGrid.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dataGrid.MultiSelect = false; dataGrid.RowHeadersVisible = false; dataGrid.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.None; dataGrid.RowHeadersBorderStyle = DataGridViewHeaderBorderStyle.None; dataGrid.CellBorderStyle = DataGridViewCellBorderStyle.None; dataGrid.DefaultCellStyle.SelectionBackColor = Color.Black; dataGrid.DefaultCellStyle.SelectionForeColor = Color.White; dataGrid.RowTemplate.Height = 50; dataGrid.RowTemplate.DefaultCellStyle.Padding = new Padding(10); allDataCache = ResourceProcessor.GetInstance().GetAll(); this.LoadData(allDataCache); }
/// <summary> /// Grid start callback. /// </summary> /// <param name="grid">Ignite instance.</param> internal void OnStart(Ignite grid) { ResourceProcessor.Inject(_target, grid); if (_startEvt) { _target.OnLifecycleEvent(LifecycleEventType.AfterNodeStart); } }
/// <summary> /// Initializes a new instance of the <see cref="MessageListenerHolder"/> class. /// </summary> /// <param name="reader">The reader.</param> public MessageListenerHolder(BinaryReader reader) { _filter = reader.ReadObject <object>(); _invoker = GetInvoker(_filter); _ignite = reader.Marshaller.Ignite; ResourceProcessor.Inject(_filter, _ignite); }
private void buttonAdd_Click(object sender, EventArgs e) { var result = new Edit(null).ShowDialog(); if (result == DialogResult.OK) { allDataCache = ResourceProcessor.GetInstance().GetAll(); this.LoadData(allDataCache); } }
/// <summary> /// Initializes a new instance of the <see cref="MessageFilterHolder"/> class. /// </summary> /// <param name="reader">The reader.</param> public MessageFilterHolder(IPortableReader reader) { var reader0 = (PortableReaderImpl)reader.RawReader(); _filter = PortableUtils.ReadPortableOrSerializable <object>(reader0); _invoker = GetInvoker(_filter); _ignite = reader0.Marshaller.Ignite; ResourceProcessor.Inject(_filter, _ignite); }
/** * Attach new processor to the manager in order to start working on the content, * each processor will be assigned to identity from type string. */ public void attachProcessor(String procId, ResourceProcessor proc) { if (procId == null || proc == null) { throw new NullReferenceException(); } if (resourceProcessors.ContainsKey(procId) == true) { throw new InvalidOperationException(); } resourceProcessors.Add(procId, proc); }
/// <summary> /// Initializes a new instance of the <see cref="CacheStoreInternal{TK,TV}"/> class. /// </summary> public CacheStoreInternal(ICacheStore <TK, TV> store, bool convertBinary) { Debug.Assert(store != null); _store = store; _convertBinary = convertBinary; _sesProxy = new CacheStoreSessionProxy(); ResourceProcessor.InjectStoreSession(store, _sesProxy); }
/// <summary> /// Performs compute-specific resource injection. /// </summary> public static void InjectResources(IIgniteInternal ignite, object job) { var injector = job as IComputeResourceInjector; if (injector != null) { injector.Inject(ignite); } else { ResourceProcessor.Inject(job, ignite); } }
/// <summary> /// Initializes a new instance of the <see cref="CacheStore" /> class. /// </summary> /// <param name="store">Store.</param> /// <param name="convertBinary">Whether to convert binary objects.</param> /// <param name="registry">The handle registry.</param> private CacheStore(ICacheStore store, bool convertBinary, HandleRegistry registry) { Debug.Assert(store != null); _store = store; _convertBinary = convertBinary; _sesProxy = new CacheStoreSessionProxy(); ResourceProcessor.InjectStoreSession(store, _sesProxy); _handle = registry.AllocateCritical(this); }
public String GetPhotoThumbnail(String nickname, String password, Int32 photoID) { if (String.IsNullOrEmpty(nickname)) { throw new ArgumentNullException("nickname"); } if (String.IsNullOrEmpty(password)) { throw new ArgumentNullException("password"); } var member = data.Member.GetMemberViaNicknamePassword(nickname, password); var photo = data.Photo.GetPhotoByPhotoIDWithJoin(photoID); return(ResourceProcessor.GetThumbnailBase64String(photo.ThumbnailResourceFile.SavePath)); }
private long ServiceInit(long memPtr) { using (var stream = IgniteManager.Memory.Get(memPtr).GetStream()) { var reader = _ignite.Marshaller.StartUnmarshal(stream); bool srvKeepBinary = reader.ReadBoolean(); var svc = reader.ReadObject <IService>(); ResourceProcessor.Inject(svc, _ignite); svc.Init(new ServiceContext(_ignite.Marshaller.StartUnmarshal(stream, srvKeepBinary))); return(_handleRegistry.Allocate(svc)); } }
private void buttonDelete_Click(object sender, EventArgs e) { if (this.dataGridViewMain.SelectedRows.Count < 1) { return; } var currentSelectedItem = (Guid)this.dataGridViewMain.SelectedRows[0].Cells["Id"].Value; var confirmResult = MessageBox.Show("Are you sure to delete the current item?", "Delete Item", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk); if (confirmResult == DialogResult.Yes) { ResourceProcessor.GetInstance().Delete(currentSelectedItem); allDataCache = ResourceProcessor.GetInstance().GetAll(); this.LoadData(allDataCache); } }
private void buttonEdit_Click(object sender, EventArgs e) { if (this.dataGridViewMain.SelectedRows.Count < 1) { return; } var currentSelectedItem = (Guid)this.dataGridViewMain.SelectedRows[0].Cells["Id"].Value; var record = allDataCache.Find(i => i.Id == currentSelectedItem); var result = new Edit(record).ShowDialog(); if (result == DialogResult.OK) { allDataCache = ResourceProcessor.GetInstance().GetAll(); this.LoadData(allDataCache); } }
/// <summary> /// Initializes this instance with grid. /// </summary> /// <param name="grid">Grid.</param> public void Initialize(Ignite grid) { Debug.Assert(grid != null); _ignite = grid; lock (_initActions) { _initActions.ForEach(x => x(grid)); _initActions.Clear(); } _initEvent.Set(); ResourceProcessor.Inject(_log, grid); }
/// <summary> /// Initializes a new instance of the <see cref="MessageListenerHolder" /> class. /// </summary> /// <param name="grid">Grid.</param> /// <param name="filter">The <see cref="IMessageListener{T}" /> to wrap.</param> /// <param name="invoker">The invoker func that takes key and value and invokes wrapped IMessageListener.</param> private MessageListenerHolder(Ignite grid, object filter, Func <Guid, object, bool> invoker) { Debug.Assert(filter != null); Debug.Assert(invoker != null); _invoker = invoker; _filter = filter; // 1. Set fields. Debug.Assert(grid != null); _ignite = grid; _invoker = invoker; // 2. Perform injections. ResourceProcessor.Inject(filter, grid); }
/// <summary> /// Start execution. /// </summary> /// <param name="grid">Ignite instance.</param> /// <param name="writer">Writer.</param> /// <param name="cb">Callback invoked when all necessary data is written to stream.</param> /// <param name="qry">Query.</param> public void Start(Ignite grid, BinaryWriter writer, Func <IUnmanagedTarget> cb, ContinuousQuery <TK, TV> qry) { // 1. Inject resources. ResourceProcessor.Inject(_lsnr, grid); ResourceProcessor.Inject(_filter, grid); // 2. Allocate handle. _hnd = grid.HandleRegistry.Allocate(this); // 3. Write data to stream. writer.WriteLong(_hnd); writer.WriteBoolean(qry.Local); writer.WriteBoolean(_filter != null); var javaFilter = _filter as PlatformJavaObjectFactoryProxy; if (javaFilter != null) { writer.WriteObject(javaFilter.GetRawProxy()); } else { var filterHolder = _filter == null || qry.Local ? null : new ContinuousQueryFilterHolder(_filter, _keepBinary); writer.WriteObject(filterHolder); } writer.WriteInt(qry.BufferSize); writer.WriteLong((long)qry.TimeInterval.TotalMilliseconds); writer.WriteBoolean(qry.AutoUnsubscribe); // 4. Call Java. _nativeQry = cb(); // 5. Initial query. var nativeInitialQryCur = UU.ContinuousQueryGetInitialQueryCursor(_nativeQry); _initialQueryCursor = nativeInitialQryCur == null ? null : new QueryCursor <TK, TV>(nativeInitialQryCur, _marsh, _keepBinary); }
/// <summary> /// Get the SiteDirectory containment response from the request path. /// </summary> /// <param name="transaction"> /// The current transaction to the database. /// </param> /// <param name="partition"> /// The database partition (schema) where the requested resource is stored. /// </param> /// <param name="routeParams"> /// The route Parameters. /// </param> /// <returns> /// The list of containment <see cref="Thing"/>. /// </returns> private IEnumerable <Thing> GetContainmentResponse( NpgsqlTransaction transaction, string partition, dynamic routeParams) { var processor = new ResourceProcessor( this.ServiceProvider, transaction, this.RequestUtils); if (routeParams.Count == 0) { // sitedirectory singleton resource request (IncludeReferenceData is handled in the sitedirectory service logic) foreach (var thing in processor.GetResource(TopContainer, partition, null, new RequestSecurityContext { ContainerReadAllowed = true })) { yield return(thing); } } else { // process containment path var routeSegments = HttpRequestHelper.ParseRouteSegments(routeParams, TopContainer); List <Thing> resolvedResourcePath; foreach (var thing in this.ProcessRequestPath(processor, TopContainer, partition, routeSegments, out resolvedResourcePath)) { yield return(thing); } if (resolvedResourcePath.Count() > 1 && this.RequestUtils.QueryParameters.IncludeReferenceData) { // add reference data information if the resource is a model reference data library if (resolvedResourcePath.Last().GetType() == typeof(ModelReferenceDataLibrary)) { foreach (var thing in this.CollectReferenceDataLibraryChain(processor, (ModelReferenceDataLibrary)resolvedResourcePath.Last())) { yield return(thing); } } } } }
private void buttonSave_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(this.textBoxName.Text)) { MessageBox.Show("Please select a valid name for current item.", "Save Item", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Image logo = null; var logoFilePath = this.textBoxLogoFilePath.Text; if (!string.IsNullOrWhiteSpace(logoFilePath)) { try { logo = Image.FromFile(logoFilePath); logo = ImageHelper.ZoomPicture(logo, 100, 50); } catch { MessageBox.Show("Please select a valid image for Logo.", "Save Item", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } if (this.record == null) { this.record = new RecordForDisplay { Id = Guid.NewGuid() }; } this.record.Name = this.textBoxName.Text; var image = this.textBoxLogoFilePath.Text; this.record.PictureForLogo = logo; this.record.Username = this.textBoxUsername.Text; this.record.Password = SecureStringHelper.GetSecureStringFromString(this.textBoxPassword.Text); this.record.Keywords = this.textBoxKeywords.Text; this.record.Remarks = this.textBoxRemarks.Text; ResourceProcessor.GetInstance().Save(this.record); this.DialogResult = DialogResult.OK; this.Close(); }
public CacheEntryProcessorResultHolder Process(object key, object value, bool exists, Ignite grid) { ResourceProcessor.Inject(_proc, grid); var entry = _entryCtor(key, value, exists); try { return(new CacheEntryProcessorResultHolder(entry, _processFunc(entry, _arg), null)); } catch (TargetInvocationException ex) { return(new CacheEntryProcessorResultHolder(null, null, ex.InnerException)); } catch (Exception ex) { return(new CacheEntryProcessorResultHolder(null, null, ex)); } }
internal void PrepareFiltersAndProcesses() { if (Filters.Count <= 0 && Processes.Count <= 0) { List <string> processes = new List <string>(); ResourceProcessor.ReadFiltersAndAssetProcessors(DslPath, Filters, processes); var enumNames = Enum.GetNames(typeof(AssetProcessorEnum)); var enumValues = Enum.GetValues(typeof(AssetProcessorEnum)); foreach (string processor in processes) { int ix = Array.IndexOf <string>(enumNames, processor); if (ix >= 0) { var e = (AssetProcessorEnum)enumValues.GetValue(ix); Processes.Add(e); } } } }
private long ServiceInit(void *target, long memPtr) { return(SafeCall(() => { using (var stream = IgniteManager.Memory.Get(memPtr).Stream()) { var reader = _ignite.Marshaller.StartUnmarshal(stream); bool srvKeepPortable = reader.ReadBoolean(); var svc = reader.ReadObject <IService>(); ResourceProcessor.Inject(svc, _ignite); svc.Init(new ServiceContext(_ignite.Marshaller.StartUnmarshal(stream, srvKeepPortable))); return _handleRegistry.Allocate(svc); } })); }
/// <summary> /// Creates an instance of this class from a stream. /// </summary> /// <param name="memPtr">Memory pointer.</param> /// <param name="grid">Grid</param> /// <returns>Deserialized instance of <see cref="RemoteListenEventFilter"/></returns> public static RemoteListenEventFilter CreateInstance(long memPtr, Ignite grid) { Debug.Assert(grid != null); using (var stream = IgniteManager.Memory.Get(memPtr).GetStream()) { var marsh = grid.Marshaller; var reader = marsh.StartUnmarshal(stream); var pred = reader.ReadObject <object>(); ResourceProcessor.Inject(pred, grid); var func = DelegateTypeDescriptor.GetEventFilter(pred.GetType()); return(new RemoteListenEventFilter(grid, evt => func(pred, evt))); } }
public AskResponse GetResponse(String nickname, String password, Int32 questionID) { if (String.IsNullOrEmpty(nickname)) { throw new ArgumentNullException("nickname"); } if (String.IsNullOrEmpty(password)) { throw new ArgumentNullException("password"); } var member = Member.GetMemberViaNicknamePassword(nickname, password); var question = AskAFriend.GetAskAFriendByAskAFriendIDWithJoin(questionID); var response = new AskResponse() { AskQuestionID = question.AskAFriendID, Question = Text2Mobile.Filter(question.Question), PhotoBase64Binary = ResourceProcessor.GetThumbnailBase64String(question.DefaultPhotoResourceFile.SavePath), ResponseValues = AskAFriend.GetAskAFriendResult(question).ToArray(), ResponseType = question.ResponseType, Average = 0, CustomResponses = new String[2] }; /* Set the average value (only applicable if the ResponseType is Rate1To10). */ for (var i = 0; i < response.ResponseValues.Length; i++) { response.Average += response.ResponseValues[i]; } response.Average = response.Average / Convert.ToDouble(response.ResponseValues.Length); /* Custom responses will be blank strings if not applicable. */ response.CustomResponses[0] = Text2Mobile.Filter(question.ResponseA); response.CustomResponses[1] = Text2Mobile.Filter(question.ResponseB); return(response); }
/// <summary> /// Constructor. /// </summary> /// <param name="grid">Grid.</param> /// <param name="compute">Compute.</param> /// <param name="task">Task.</param> /// <param name="arg">Argument.</param> public ComputeTaskHolder(Ignite grid, ComputeImpl compute, IComputeTask <TA, T, TR> task, TA arg) { _compute = compute; _arg = arg; _task = task; ResourceTypeDescriptor resDesc = ResourceProcessor.Descriptor(task.GetType()); IComputeResourceInjector injector = task as IComputeResourceInjector; if (injector != null) { injector.Inject(grid); } else { resDesc.InjectIgnite(task, grid); } _resCache = !resDesc.TaskNoResultCache; }
/** <inheritdoc /> */ public void LocalListen <T>(IMessageListener <T> listener, object topic = null) { IgniteArgumentCheck.NotNull(listener, "filter"); ResourceProcessor.Inject(listener, _ignite); lock (_funcMap) { var key = GetKey(listener, topic); MessageListenerHolder filter0 = MessageListenerHolder.CreateLocal(_ignite, listener); var filterHnd = _ignite.HandleRegistry.Allocate(filter0); filter0.DestroyAction = () => { lock (_funcMap) { _funcMap.Remove(key, filterHnd); } }; try { DoOutOp((int)Op.LocalListen, writer => { writer.WriteLong(filterHnd); writer.Write(topic); }); } catch (Exception) { _ignite.HandleRegistry.Release(filterHnd); throw; } _funcMap.Add(key, filterHnd); } }
private long ServiceInit(long memPtr) { using (var stream = IgniteManager.Memory.Get(memPtr).GetStream()) { try { var reader = _ignite.Marshaller.StartUnmarshal(stream); var srvKeepBinary = reader.ReadBoolean(); var svc = reader.ReadObject <IService>(); ResourceProcessor.Inject(svc, _ignite); svc.Init(new ServiceContext(_ignite.Marshaller.StartUnmarshal(stream, srvKeepBinary))); stream.Reset(); stream.WriteBool(true); // Success. stream.SynchronizeOutput(); return(_handleRegistry.Allocate(svc)); } catch (Exception e) { stream.Reset(); var writer = _ignite.Marshaller.StartMarshal(stream); BinaryUtils.WriteInvocationResult(writer, false, e); _ignite.Marshaller.FinishMarshal(writer); stream.SynchronizeOutput(); return(0); } } }
public void Process (ResourceProcessor resProc) { foreach (var resource in resources.Keys) { resProc (this, resource); } }
/** * Attach new processor to the manager in order to start working on the content, * each processor will be assigned to identity from type string. */ public void attachProcessor(String procId, ResourceProcessor proc) { if(procId == null || proc == null) throw new NullReferenceException(); if (resourceProcessors.ContainsKey(procId) == true) throw new InvalidOperationException(); resourceProcessors.Add(procId,proc); }