示例#1
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);
            }
        }
示例#2
0
        /// <summary />
        internal static OpenStackNetConfigurationOptions Create()
        {
            var createEvent = new CreateEvent();

            Creating?.Invoke(createEvent);
            return(createEvent.Result);
        }
示例#3
0
        /// <summary>
        /// ctor
        /// </summary>
        /// <param name="названиеи задачи"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="content"></param>
        /// <param name="priority"></param>
        /// <param name="type"></param>
        public Task([NotNull] string name, int argument1, int argument2, [NotNull] Expression <Func <int, int, bool> > content, TaskType type = TaskType.Type1, TaskPriority priority = TaskPriority.VeryLow)
        {
            Name         = name;
            _contentFunc = content ?? throw new ArgumentNullException(nameof(content));
            _argument1   = argument1;
            _argument2   = argument2;

            Priority = priority;
            Type     = type;
            Creating?.Invoke(this, new TaskEventArgs($"Задача {Name} Priority:{Priority} Type:{Type} Создание"));
        }
示例#4
0
文件: Pool.cs 项目: GF47/GRT
        /// <summary>
        /// 池初始化,根据传入的实例化方法来生成新的实例
        /// </summary>
        /// <param name="count">初始数量</param>
        /// <param name="createNewFunc">生成一个新实例的方法</param>
        public void Initialize(int count, Func <T> createNewFunc)
        {
            _queue         = new Queue <T>(count);
            _createNewFunc = createNewFunc;
            for (int i = 0; i < count; i++)
            {
                T item = _createNewFunc();
                _queue.Enqueue(item);

                Creating?.Invoke(item);
            }
        }
示例#5
0
        /// <summary>
        /// Jaffaフレームワークにページ開始を通知します。
        /// InitializeComponentの前に実行する必要があります。
        /// </summary>
        /// <param name="win">Jaffaフレームワークを利用するページのインスタンスを指定します。</param>
        public static void Start(Windows.UI.Xaml.Controls.Page page)
        {
            // ページ生成完了通知イベント
            Creating?.Invoke(page, new EventArgs());

            // カルチャに合わせてリソースを切り替え
            if (Jaffa.Application.WaitingChangeCulture == true)
            {
                Jaffa.Application.Current.Resources    = Internal.Core.MakeChangedResources(Jaffa.Application.Current.Resources, Jaffa.International.GetAvailableLanguageCodeList(), Jaffa.International.CurrentCulture);
                Jaffa.Application.WaitingChangeCulture = false;
            }
            page.Resources = Internal.Core.MakeChangedResources(page.Resources, Jaffa.International.GetAvailableLanguageCodeList(), Jaffa.International.CurrentCulture);
        }
示例#6
0
 public void Create(CancellationToken cancellationToken)
 {
     if (!IsCreated)
     {
         m_Element = m_Creator.Invoke(cancellationToken);
         Creating?.Invoke(m_Element);
         IsCreated = true;
     }
     else
     {
         throw new ElementAlreadyCommittedException();
     }
 }
示例#7
0
 public virtual void OnCreating(EntityReplyEventArgs <TModel> e)
 {
     Creating?.Invoke(this, e);
 }
示例#8
0
 protected virtual void OnCreating(EntityEventArgs <TModel> e)
 {
     Creating?.Invoke(this, e);
 }
示例#9
0
        public async Task <ICommandResult <TReply> > CreateAsync(TReply reply)
        {
            // Validate
            if (reply == null)
            {
                throw new ArgumentNullException(nameof(reply));
            }

            if (reply.Id > 0)
            {
                throw new ArgumentOutOfRangeException(nameof(reply.Id));
            }

            if (reply.EntityId <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(reply.EntityId));
            }

            if (String.IsNullOrWhiteSpace(reply.Message))
            {
                throw new ArgumentNullException(nameof(reply.Message));
            }

            if (reply.CreatedDate == null)
            {
                throw new ArgumentNullException(nameof(reply.CreatedDate));
            }

            var result = new CommandResult <TReply>();

            // Ensure the entity exists
            var entity = await _entityStore.GetByIdAsync(reply.EntityId);

            if (entity == null)
            {
                return(result.Failed(new CommandError($"An entity with the Id '{reply.EntityId}' could not be found")));
            }

            // Parse Html and abstract
            reply.Html = await ParseEntityHtml(reply.Message);

            reply.Abstract = await ParseEntityAbstract(reply.Message);

            reply.Urls = await ParseEntityUrls(reply.Html);

            // Raise creating event
            Creating?.Invoke(this, new EntityReplyEventArgs <TReply>(entity, reply));

            // Invoke EntityReplyCreating subscriptions
            foreach (var handler in _broker.Pub <TReply>(this, "EntityReplyCreating"))
            {
                reply = await handler.Invoke(new Message <TReply>(reply, this));
            }

            var newReply = await _entityReplyStore.CreateAsync(reply);

            if (newReply != null)
            {
                // Raise created event
                Created?.Invoke(this, new EntityReplyEventArgs <TReply>(entity, newReply));

                // Invoke EntityReplyCreated subscriptions
                foreach (var handler in _broker.Pub <TReply>(this, "EntityReplyCreated"))
                {
                    newReply = await handler.Invoke(new Message <TReply>(newReply, this));
                }

                return(result.Success(newReply));
            }

            return(result.Failed(new CommandError("An unknown error occurred whilst attempting to create the reply")));
        }
示例#10
0
        public async Task <ICommandResult <TEntity> > CreateAsync(TEntity model)
        {
            var result = new CommandResult <TEntity>();

            // Validate
            if (model.Id > 0)
            {
                return(result.Failed(new CommandError($"{nameof(model.Id)} cannot be greater than zero when creating an entity")));
            }

            if (model.FeatureId == 0)
            {
                throw new ArgumentOutOfRangeException(nameof(model.FeatureId));
            }

            if (String.IsNullOrWhiteSpace(model.Title))
            {
                throw new ArgumentNullException(nameof(model.Title));
            }

            if (String.IsNullOrWhiteSpace(model.Message))
            {
                throw new ArgumentNullException(nameof(model.Message));
            }

            if (model.CreatedDate == null)
            {
                throw new ArgumentNullException(nameof(model.CreatedDate));
            }

            // Parse Html and message abstract
            model.Html = await ParseEntityHtml(model.Message);

            model.Abstract = await ParseEntityAbstract(model.Message);

            model.Urls = await ParseEntityUrls(model.Html);

            model.Alias = await ParseEntityAlias(model.Title);

            // Parse totals
            model.TotalWords = model.Message.TotalWords();

            // Raise creating event
            Creating?.Invoke(this, new EntityEventArgs <TEntity>(model));

            // Invoke EntityCreating subscriptions
            foreach (var handler in _broker.Pub <TEntity>(this, "EntityCreating"))
            {
                model = await handler.Invoke(new Message <TEntity>(model, this));
            }

            var entity = await _entityStore.CreateAsync(model);

            if (entity != null)
            {
                // Raise created event
                Created?.Invoke(this, new EntityEventArgs <TEntity>(entity));

                // Invoke EntityCreated subscriptions
                foreach (var handler in _broker.Pub <TEntity>(this, "EntityCreated"))
                {
                    entity = await handler.Invoke(new Message <TEntity>(entity, this));
                }

                // Return success
                return(result.Success(entity));
            }

            return(result.Failed(new CommandError("An unknown error occurred whilst attempting to create an eneity")));
        }
示例#11
0
        protected Session()
        {
            This_ = this;
            State = SessionState.STARTING;

            Config.Reload();

            Dir = FileSystemRoutines.CreateDirectory(Log.RootDir + "\\Data");
            Directory.SetLastWriteTime(Dir, DateTime.Now);//to avoid cleaning up
            ConfigFile = Dir + "\\" + ConfigFileName;

            Restored = false;
            Storage  = new SessionStorage();
            DateTime     old_start_time;
            string       old_time_mark;
            SessionState old_state = Storage.ReadLastState(out old_start_time, out old_time_mark);

            switch (old_state)
            {
            case SessionState.NULL:
                break;

            case SessionState.STARTING:
            case SessionState.COMPLETED:
            case SessionState.FATAL_ERROR:
                break;

            case SessionState.RESTORING:
            case SessionState.RUNNING:
            case SessionState.CLOSING:
            case SessionState.UNCOMPLETED:
            case SessionState.BROKEN:
            case SessionState.NONFATAL_ERROR:
                if (Settings.Engine.RestoreBrokenSession && !CommandLine.IsParameterSet(CommandLineParameters.NOT_RESTORE_SESSION))
                {
                    if (LogMessage.AskYesNo("Previous session " + old_time_mark + " is not completed. Restore it?", true))
                    {
                        StartTime = old_start_time;
                        TimeMark  = old_time_mark;
                        Storage.WriteState(SessionState.RESTORING, new { restoring_time = RestoreTime, restoring_session_time_mark = get_time_mark(RestoreTime) });
                        Log.Main.Inform("Loading configuration from " + ConfigFile);
                        Config.Reload(ConfigFile);
                        Storage.RestoreSession();
                        Restored = true;
                    }
                }
                break;

            default:
                throw new Exception("Unknown option: " + old_state);
            }

            if (!Restored)
            {
                if (old_state != SessionState.NULL)
                {
                    string old_dir_new_path = Log.RootDir + "\\Data" + "_" + old_time_mark + "_" + old_state;
                    Log.Main.Write("The old session folder moved to " + old_dir_new_path);
                    Storage.Close();
                    if (Directory.Exists(Dir))
                    {
                        Directory.Move(Dir, old_dir_new_path);
                    }
                    FileSystemRoutines.CreateDirectory(Dir);
                    Storage = new SessionStorage();
                }

                StartTime = Log.Head.CreatedTime;// DateTime.Now;
                TimeMark  = get_time_mark(StartTime);
                Storage.WriteState(SessionState.STARTING, new { session_start_time = StartTime, session_time_mark = TimeMark });
                read_input_file();
                Config.Save(ConfigFile);
            }

            Creating?.Invoke();

            __Creating();
        }