Ejemplo n.º 1
0
        private void RaiseEventForChange([NotNull] FakeFileSystemVersionedChange change)
        {
            string rootDirectory = change.RootDirectory.GetText();

            switch (change.ChangeType)
            {
            case WatcherChangeTypes.Created:
            {
                Created?.Invoke(this, new FileSystemEventArgs(change.ChangeType, rootDirectory, change.RelativePath));
                break;
            }

            case WatcherChangeTypes.Deleted:
            {
                Deleted?.Invoke(this, new FileSystemEventArgs(change.ChangeType, rootDirectory, change.RelativePath));
                break;
            }

            case WatcherChangeTypes.Changed:
            {
                Changed?.Invoke(this, new FileSystemEventArgs(change.ChangeType, rootDirectory, change.RelativePath));
                break;
            }

            case WatcherChangeTypes.Renamed:
            {
                Renamed?.Invoke(this,
                                new RenamedEventArgs(change.ChangeType, rootDirectory, change.RelativePath,
                                                     change.PreviousRelativePathInRename));
                break;
            }
            }
        }
Ejemplo n.º 2
0
        internal void HandleGuildCreate(GatewayGuild data)
        {
            if (!_guilds.TryGetValue(data.Id.RawValue, out var guild))
            {
                guild = new CachedGuild {
                    Id = data.Id
                };
                guild.Update(data);
                _guilds[data.Id.RawValue] = guild;
                Created?.Invoke(guild);

                guild.Unavailable = data.Unavailable;
                if (guild.Unavailable != true)
                {
                    Available?.Invoke(guild);
                }
            }
            else
            {
                if (data.Unavailable == false && guild.Unavailable != false)
                {
                    guild.Unavailable = false;
                    Available?.Invoke(guild);
                }
                else if (data.Unavailable == true && guild.Unavailable != true)
                {
                    guild.Unavailable = true;
                    Unavailable?.Invoke(guild);
                }
                guild.Update(data);
            }
        }
Ejemplo n.º 3
0
        public ObjectPool(T template, List <T> list, Func <T, T> builder = null)
        {
            this.builder = builder;

            Template    = template;
            originCount = list.Count;
            itemList    = new List <PoolItem>(list.Count);
            for (int index = 0; index < list.Count; ++index)
            {
                if (list[index] == null)
                {
                    continue;
                }

                PoolItem item = new PoolItem(list[index]);

                ++residueCount;
                itemList.Add(item);

                item.poolItem?.OnCreated(this);
                Created?.Invoke(item.instance);
            }

            version++;

            Builded?.Invoke();
        }
Ejemplo n.º 4
0
 public virtual void Open()
 {
     AssertValidState(AccountState.Created);
     _state = AccountState.Opened;
     IncrementDays();
     Created?.Invoke("Account created. On your account {_amount}");
 }
Ejemplo n.º 5
0
        public async Task ListenCreations(Channel channel)
        {
            var client = CreateClient(channel);

            try
            {
                using (var call = GetCreationCall(client, channel.ShutdownToken))
                using (var creationsStream = call.ResponseStream)
                {
                    while (await creationsStream.MoveNext(channel.ShutdownToken))
                    {
                        channel.ShutdownToken.ThrowIfCancellationRequested();

                        var createdState = creationsStream.Current;
                        var info = new TInfo();
                        info.State.MergeFrom(createdState);

                        var orders = CreateOrders(client, info.ID);
                        
                        await mSyncContext.Execute(() => Created?.Invoke(orders, info));
                        var t = ListenStateUpdates(info, client, channel.ShutdownToken);
                    }
                }
            }
            catch (Exception e)
            {
                Debug.LogError(e);
                throw;
            }
        }
Ejemplo n.º 6
0
        private void OnCreateBullet(Ship ship)
        {
            var bullet = new Bullet(ship.Position, (ship.Heading * _bulletSpeed) + ship.Velocity, _bulletTTL);

            _bullets.Add(bullet);
            Created?.Invoke(bullet);
        }
Ejemplo n.º 7
0
 private void HandleFiles()
 {
     // change tracking
     files.TrackChanges(GetFtpFiles(), true, out var changed, out var added, out var removed);
     foreach (var change in changed)
     {
         if (EnableRaisingEvents)
         {
             Changed?.Invoke(this, new FtpFileSystemEventArgs {
                 ChangeType = FtpWatcherChangeTypes.Changed, FullPath = change.Key, Name = change.Key
             });
         }
     }
     foreach (var add in added)
     {
         if (EnableRaisingEvents)
         {
             Created?.Invoke(this, new FtpFileSystemEventArgs {
                 ChangeType = FtpWatcherChangeTypes.Created, FullPath = add.Key, Name = add.Key
             });
         }
     }
     foreach (var remove in removed)
     {
         if (EnableRaisingEvents)
         {
             Deleted?.Invoke(this, new FtpFileSystemEventArgs {
                 ChangeType = FtpWatcherChangeTypes.Deleted, FullPath = remove.Key, Name = remove.Key
             });
         }
     }
 }
 void IVirtualDesktopNotification.VirtualDesktopCreated(IVirtualDesktop pDesktop)
 {
     if (Created != null)
     {
         Created.Invoke(this, FromComObject(pDesktop));
     }
 }
Ejemplo n.º 9
0
        internal void OnCreated(CefBrowser browser)
        {
            m_created = true;
            m_browser = browser;

            Created?.Invoke(this, EventArgs.Empty);
        }
Ejemplo n.º 10
0
        public Attempt <IValueSet> Create(
            string name,
            IValueSetMeta meta,
            IReadOnlyCollection <ICodeSystemCode> codeSetCodes)
        {
            if (!this.NameIsUnique(name))
            {
                return(Attempt <IValueSet> .Failed(new ArgumentException($"A value set named '{name}' already exists.")));
            }

            if (!this.ValidateValueSetMeta(meta, out var msg))
            {
                return(Attempt <IValueSet> .Failed(new ArgumentException(msg)));
            }

            var setCodes = codeSetCodes as IValueSetCode[] ?? codeSetCodes.ToArray();

            var valueSet = new ValueSet(name, meta, setCodes)
            {
                StatusCode      = ValueSetStatus.Draft,
                IsCustom        = true,
                IsLatestVersion = true
            };

            Created?.Invoke(this, valueSet);
            return(Attempt <IValueSet> .Successful(valueSet));
        }
Ejemplo n.º 11
0
        public void Create(string name, string fontFamily, int fontSize)
        {
            name = name.Trim();

            if (name.Length == 0)
            {
                throw new ValidationException("Name is required.");
            }

            if (_nameForbiddenChars.Any(x => name.Contains(x)))
            {
                throw new ValidationException("Name cannot contain any of the following characters: /, \\, <, >, :, \", |, ?, *");
            }

            if (_notesRepository.Exists(name))
            {
                throw new ValidationException("A note with the same name already exists.");
            }

            _notesRepository.Create(name);

            var note = new Note(name, string.Empty, DateTime.Now, new NoteMetadata(fontFamily, fontSize));

            _notesMetadataService.Add(note.Name, note.Metadata);
            _notesMetadataService.Save();

            Created.Invoke(this, new CreatedNoteEventArgs
            {
                CreatedNote = note
            });
        }
Ejemplo n.º 12
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            try
            {
                if (Creating != null)
                {
                    Creating.Invoke(this, EventArgs.Empty);
                }

                //ToolMobile.log("set form [" + this.GetType().FullName + "] layout");

                base.OnCreate(savedInstanceState);

                //   setEnvironment(ToolMobile.getEnvironment());

                if (designId >= 0)
                {
                    SetContentView(designId == 0 ? Resource.Layout.form : designId);
                }

                if (Created != null)
                {
                    Created.Invoke(this, EventArgs.Empty);
                }

                this.Window.SetSoftInputMode(SoftInput.StateAlwaysHidden);
                //   (WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
            }
            catch (Exception exc)
            {
                ToolMobile.setException(exc);
            }
        }
Ejemplo n.º 13
0
        public Version AddNew(string jsonPath)
        {
            _logService.Info(nameof(VersionService), "Adding new version");

            var newVersion = Load(jsonPath);

            if (newVersion != null)
            {
                if (newVersion.InheritsFrom != null)
                {
                    InheritParentProperties(newVersion);
                }

                _versions.Add(newVersion.ID, newVersion);
                Created?.Invoke(newVersion);
            }
            else
            {
                // This version is invalid, cleanup
                File.Delete(jsonPath);
                Directory.Delete(Path.GetDirectoryName(jsonPath));
            }

            return(newVersion);
        }
Ejemplo n.º 14
0
 private void UnsubscribeOnEvents(FileSystemWatcher watcher)
 {
     watcher.Created -= (o, e) => LogEvent?.Invoke($"File: {e.Name} {e.ChangeType}");
     watcher.Changed -= (o, e) => LogEvent?.Invoke($"File: {e.Name} {e.ChangeType}");
     watcher.Deleted -= (o, e) => LogEvent?.Invoke($"File: {e.Name} {e.ChangeType}");
     watcher.Renamed -= (o, e) => LogEvent?.Invoke($"File: {e.OldName} renamed to {e.Name}");
     watcher.Deleted -= (o, e) => Created?.Invoke(e.FullPath);
 }
Ejemplo n.º 15
0
        private void OnRealized(IntPtr window)
        {
            _xid = GetNativeHandle();
            var createdEvent = new CreatedEventArgs(IntPtr.Zero, window, _xid);

            Created?.Invoke(this, createdEvent);
            _isInitialized = true;
        }
Ejemplo n.º 16
0
        private void _fileSystemWatcher_Created(object sender, FileSystemEventArgs e)
        {
            Console.WriteLine($"Processing {e.FullPath}...");

            FileHelper.WaitForFileToUnlock(e.FullPath);

            Created?.Invoke(this, e);
        }
Ejemplo n.º 17
0
 protected void OnCreated(CreatedEventArgs e)
 {
     ThreadPool.QueueUserWorkItem(s =>
     {
         Created?.Invoke(this, e);
     });
     //Created?.Invoke(this, e);
 }
Ejemplo n.º 18
0
        private void CreateAsteroidAt(Vector3 position, int breakdowns)
        {
            var velocity = new Vector3(Random.Range(-3f, 3f), Random.Range(-3f, 3f), 0f);
            var asteroid = new Asteroid(position, velocity, breakdowns);

            Add(asteroid);
            Created?.Invoke(asteroid);
        }
Ejemplo n.º 19
0
 private void watcher_Created(object sender, FileSystemEventArgs e)
 {
     if (reIgnore.IsMatch(e.FullPath))
     {
         return;
     }
     Created?.Invoke(this, e);
 }
Ejemplo n.º 20
0
        public ControlBase(string name, IControl parentControl = null)
        {
            ChildControls = new ControlList();

            Name          = name;
            ParentControl = parentControl;

            Created?.Invoke(this, EventArgs.Empty);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// The on created.
        /// </summary>
        /// <param name="browser">
        /// The browser.
        /// </param>
        public void OnBrowserAfterCreated(CefBrowser browser)
        {
            CefBrowser = browser;

            // Register JavaScriptExecutor
            _config.JavaScriptExecutor = new JavaScriptExecutor(CefBrowser);

            Created?.Invoke(this, EventArgs.Empty);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Raises the <see cref="Created"/> event.
        /// </summary>
        /// <param name="args">Arguments for the event.</param>
        public void RaiseCreated(FileChangedEventArgs args)
        {
            if (!ShouldRaiseEvent(args))
            {
                return;
            }

            Created?.Invoke(this, args);
        }
Ejemplo n.º 23
0
        private void CreateCallback(IntPtr window, IntPtr view)
        {
            _windowHandle = window;
            _viewHandle   = view;
            var createdEvent = new CreatedEventArgs(IntPtr.Zero, _windowHandle, _viewHandle);

            Created?.Invoke(this, createdEvent);
            _isInitialized = true;
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Overrides this method if want to handle behavior when the application is launched.
        /// If base.OnCreated() is not called, the event 'Created' will not be emitted.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        protected virtual void OnCreate()
        {
            string locale = ULocale.GetDefaultLocale();

            ChangeCurrentUICultureInfo(locale);
            ChangeCurrentCultureInfo(locale);

            Created?.Invoke(this, EventArgs.Empty);
        }
Ejemplo n.º 25
0
    /// <summary>
    /// Creates a new equipartition tasks.
    /// </summary>
    /// <param name="group">The group identifier.</param>
    /// <param name="jobId">The job identifier.</param>
    /// <param name="count">The task fragment count.</param>
    /// <param name="description">The description.</param>
    /// <param name="autoRemove">true if remove the item all done automatically; otherwise, false.</param>
    /// <returns>A new equipartition tasks created.</returns>
    public virtual EquipartitionTask Create(string group, string jobId, int count, string description, bool autoRemove = true)
    {
        var task = Create(group, new EquipartitionTask(jobId, count)
        {
            Description = description
        }, autoRemove);

        Created?.Invoke(this, new ChangeEventArgs <EquipartitionTask>(null, task, ChangeMethods.Add, group));
        return(task);
    }
Ejemplo n.º 26
0
        /// <summary>
        /// The on created.
        /// </summary>
        /// <param name="browser">
        /// The browser.
        /// </param>
        public virtual void OnBrowserAfterCreated(CefBrowser browser)
        {
            CefBrowser = browser;

            // Register browser
            CefGlueFrameHandler frameHandler = new CefGlueFrameHandler(browser);

            IoC.RegisterInstance(typeof(CefGlueFrameHandler), typeof(CefGlueFrameHandler).FullName, frameHandler);

            Created?.Invoke(this, EventArgs.Empty);
        }
Ejemplo n.º 27
0
 private void RaiseCreatedEvent(IInfoCache cache)
 {
     if (_uiContext == null)
     {
         Created?.Invoke(cache);
     }
     else
     {
         _uiContext.Send(x => Created?.Invoke(cache), null);
     }
 }
Ejemplo n.º 28
0
 public void CreateFrom(string url)
 {
     try
     {
         var habrArticle = HabrParcer(url);
         Created?.Invoke(this, habrArticle);
     }
     catch (Exception)
     {
         Console.WriteLine($"#Error: url - [{url}] is can't parsed");
     }
 }
        public FileSystemWatcherWrapper(string path, string filter = null, bool recursive = false)
        {
            this.path         = path;
            this.filter       = filter;
            fileSystemWatcher = filter == null ? new FileSystemWatcher(path) : new FileSystemWatcher(path, filter);
            fileSystemWatcher.IncludeSubdirectories = recursive;

            fileSystemWatcher.Changed += (sender, args) => Changed?.Invoke(sender, args);
            fileSystemWatcher.Created += (sender, args) => Created?.Invoke(sender, args);
            fileSystemWatcher.Deleted += (sender, args) => Deleted?.Invoke(sender, args);
            fileSystemWatcher.Error   += (sender, args) => Error?.Invoke(sender, args);
            fileSystemWatcher.Renamed += (sender, args) => Renamed?.Invoke(sender, args);
        }
Ejemplo n.º 30
0
        protected override TrackSkinObject CreateAndLoadAcObject(string id, bool enabled, bool withPastLoad = true)
        {
            var result = CreateAcObject(id, enabled);

            result.Load();
            if (withPastLoad)
            {
                Created?.Invoke(this, new AcObjectEventArgs <TrackSkinObject>(result));
                result.PastLoad();
            }

            return(result);
        }