static IRoutine GetRoutine(IServiceProvider serviceProvider) { IConfigurationManager configurationManager = serviceProvider.GetService <IConfigurationManager>(); IRoutine routine = null; switch (smartDeviceState.Mode) { case SmartDeviceMode.Inactive: routine = new InactiveRoutine(configurationManager); break; case SmartDeviceMode.Active: if (smartDeviceState.IsTurnedOn) { routine = new ActiveRoutine( serviceProvider, fileCache, cvAdsAPIClient, geoLocationAPIClient, smartDeviceState); } else { routine = new ActiveTurnedOffRoutine(configurationManager); } break; case SmartDeviceMode.Blocked: routine = new BlockedRoutine(configurationManager); break; } return(routine); }
/// <summary> /// Resolves the routine target of the invocation within the give context. /// </summary> /// <param name="context">The query context used to resolve the routine.</param> /// <remarks> /// <para> /// If the given <paramref name="context"/> is <c>null</c> this method will /// try to resolve the routine towards the /// </para> /// </remarks> /// <returns> /// Returns an instance of <see cref="IRoutine"/> that is the target of the invocation. /// </returns> /// <exception cref="InvalidOperationException"> /// If the routine could not be resolved for this call. /// </exception> public IRoutine ResolveRoutine(IRequest context) { if (cached != null) { return(cached); } if (context == null) { cached = SystemFunctions.Provider.ResolveFunction(this, null); } else { var resolvedName = context.Access().ResolveObjectName(DbObjectType.Routine, RoutineName); var invoke = new Invoke(resolvedName, Arguments); cached = context.Query.Access().ResolveRoutine(invoke, context); } if (cached == null) { throw new InvalidOperationException(String.Format("Unable to resolve the call {0} to a function", this)); } return(cached); }
public void Construct(IRoutine routine) { routine.WakeUp(); routine.GoToSchool(); routine.ListenToMusic(); routine.Sleep(); }
private void BuildControl(IRoutine routine) { if (routine == null) { return; } DataContext = routine.RoutineSettings?.GetDataContext(); if (routine.RoutineSettings == null) { ErrorMessage = "No settings were found for this routine"; return; } var control = routine.RoutineSettings.GetControl(); if (control == null) { ErrorMessage = "No settings control was found for this routine"; return; } Control = new UserControl { Content = control, DataContext = this }; }
/// <summary> /// Constructs a new viewport with the given width/height. /// </summary> /// <param name="routine">Routine to view.</param> /// <param name="width">Viewport width.</param> /// <param name="height">Viewport height.</param> public RoutineViewport(IRoutine routine, int width, int height) { _routine = routine; // Validate that routines defined views the way we expect if (_routine.Views.Count == 0) { throw new Exception($"{_routine.GetType().Name} defines 0 views."); } for (int i = 1; i < _routine.Views.Count; i++) { var curView = _routine.Views[i].view; var prevView = _routine.Views[i - 1].view; if (curView.Width != prevView.Width || curView.Height != prevView.Height) { throw new Exception($"{_routine.GetType().Name} defines views that are not the same size."); } } // Initialize initial views _viewIndex = 0; (CurrentViewName, CurrentView) = _routine.Views[_viewIndex]; // Initialize initial viewport CurrentViewport = new Viewport <char>(CurrentView, (0, 0, width, height)); CurrentViewport.SetViewArea( CurrentViewport.ViewArea.WithCenter((CurrentView.Width / 2, CurrentView.Height / 2))); }
public void Execute(IRoutine routine) { for (int i = 0; i < this.count; i++) { routine.Execute(); } }
public RoutinesQueue Enqueue(IRoutine routine) { Assert.IsNotNull(routine); Assert.IsTrue(!_queue.Contains(routine)); // при добавлении рутины дважды, произойдёт не то, что ожидалось. _queue.Enqueue(routine); return(this); }
public static void Start(this MonoBehaviour behaviour, IEnumerator routine, out IRoutine controller) { InternalController c = new InternalController(); c.Start(routine); controller = c; behaviour.StartCoroutine(c.Run()); }
public static InvokeResult Execute(this IRoutine routine, InvokeArgument[] args, IRequest request, IVariableResolver resolver, IGroupResolver group) { var invoke = new Invoke(routine.ObjectInfo.FullName, args); var executeContext = new InvokeContext(invoke, routine, resolver, group, request); return(routine.Execute(executeContext)); }
/// <summary> /// 构造函数注入 /// </summary> /// <param name="routine"></param> /// <param name="sys"></param> /// <param name="token"></param> /// <param name="user"></param> /// <param name="biz"></param> /// <param name="gameKey"></param> public RoutineController(IRoutine routine, ISystems sys, IToken token, IUser user, IBiz biz, IOptions <GameKeySetting> gameKey) { _routine = routine; _sys = sys; _token = token; _user = user; _biz = biz; _gameKey = gameKey.Value; _log = _log = LogManager.GetLogger(Startup.repository.Name, typeof(RoutineController)); }
private static void PushRoutineToHeap(IRoutine routine) { try { Routines.Add(routine); } catch (Exception e) { throw; } }
/// <summary> /// 构造函数注入 /// </summary> /// <param name="mag"></param> /// <param name="sys"></param> /// <param name="user"></param> /// <param name="token"></param> /// <param name="biz"></param> /// <param name="accout"></param> public UserController(IPhoneMessage mag, ISystems sys, IUser user, IToken token, IRoutine routine, IBiz biz, IAccout accout) { _mag = mag; _sys = sys; _user = user; _token = token; _biz = biz; _accout = accout; _log = LogManager.GetLogger(Startup.repository.Name, typeof(UserController)); _routine = routine; }
private void OnRoutineChanged(IRoutine newRoutine) { var routineViewModel = AllRoutines.FirstOrDefault(r => r.DisplayName == newRoutine.DisplayName); if (routineViewModel != null) { CurrentRoutine = routineViewModel; SelectedRoutine = routineViewModel; UpdateRoutineLists(); } }
public virtual TrinityPower GetPowerForTarget(TrinityActor target) { IRoutine routine = TrinityCombat.Routines.Current; if (target == null) { return(null); } switch (target.Type) { case TrinityObjectType.BloodShard: case TrinityObjectType.Gold: case TrinityObjectType.HealthGlobe: case TrinityObjectType.PowerGlobe: case TrinityObjectType.ProgressionGlobe: return(routine.GetMovementPower(target.Position)); case TrinityObjectType.Door: case TrinityObjectType.HealthWell: case TrinityObjectType.Shrine: case TrinityObjectType.Interactable: case TrinityObjectType.CursedShrine: return(InteractPower(target, 100, 250)); case TrinityObjectType.CursedChest: case TrinityObjectType.Container: return(InteractPower(target, 100, 1200)); case TrinityObjectType.Item: return(InteractPower(target, 15, 15, 6f)); case TrinityObjectType.Destructible: case TrinityObjectType.Barricade: Core.PlayerMover.MoveTowards(target.Position); return(routine.GetDestructiblePower()); } if (target.IsQuestGiver) { Core.PlayerMover.MoveTowards(target.Position); return(InteractPower(target, 100, 250)); } if (!TrinityCombat.IsInCombat) { return(null); } TrinityPower routinePower = routine.GetOffensivePower(); return(TryKamakaziPower(target, routinePower, out TrinityPower kamakaziPower) ? kamakaziPower : routinePower); }
/// <summary> /// 构造函数注入 /// </summary> /// <param name="user"></param> /// <param name="token"></param> /// <param name="sys"></param> /// <param name="recharge"></param> /// <param name="routine"></param> /// <param name="biz"></param> public RechargeController(IUser user, IToken token, IOptions <WeChatPaySetting> weChatPay, IOptions <LqhnWeChatPaySetting> lqhnweChatPay, ISystems sys, IRecharge recharge, IRoutine routine, IBiz biz, IAccout accout) { _sys = sys; _user = user; _token = token; _recharge = recharge; _routine = routine; _biz = biz; _accout = accout; _weChatPay = weChatPay.Value; _lqhnweChatPay = lqhnweChatPay.Value; }
private static void CreateRoutine(IRoutine routine) { try { PushRoutineToHeap(routine); routine.Start().Wait(); } catch (Exception e) { throw e; } }
internal InvokeContext(Invoke invoke, IRoutine routine, IVariableResolver resolver, IGroupResolver group, IRequest request) { if (invoke == null) throw new ArgumentNullException("invoke"); if (routine == null) throw new ArgumentNullException("routine"); Request = request; GroupResolver = group; VariableResolver = resolver; Invoke = invoke; Routine = routine; }
/// <summary> /// Initializes a new instance of the <see cref="T:ZsqApp.Core.WebApi.Controllers.H5Controllres.WebBetsController"/> class. /// </summary> /// <param name="token"></param> /// <param name="biz"></param> /// <param name="gameKey"></param> /// <param name="user"></param> /// <param name="systems"></param> /// <param name="userTask"></param> /// <param name="currencyKey"></param> /// <param name="accout"></param> public WebBetsController(IToken token, IBiz biz, IOptions <GameKeySetting> gameKey, IUser user, ISystems systems, IUserTask userTask, IRoutine routine, IOptions <CurrencyKeySetting> currencyKey, IAccout accout) { _token = token; _biz = biz; _gameKey = gameKey.Value; _user = user; _sys = systems; _userTask = userTask; _currencyKey = currencyKey.Value; _log = _log = LogManager.GetLogger(Startup.repository.Name, typeof(WebBetsController)); _accout = accout; _routine = routine; }
/// <summary> /// Проолжить выполнение корутины. Возвращает false и обнуляет routine, если корутина завершилась. /// </summary> public static bool Execute(ref IRoutine routine) { if (routine == null) { return(false); } if (!routine.MoveNext()) { routine = null; return(false); } return(true); }
public RoutineViewModel(IRoutine routine) { _routine = routine; RoutineTypeName = routine.GetType().Name; DisplayName = routine.DisplayName; Description = routine.Description; RequiredBuild = routine.BuildRequirements; Author = routine.Author; Version = routine.Version; Class = routine.Class; Url = routine.Url; BuildControl(routine); }
public static void Tick(IRoutine routine) { smethod_0(routine, routineEvent_2); try { routine.Tick(); } catch (Exception exception) { ilog_0.Error("Exception during routine Tick.", exception); } smethod_0(routine, routineEvent_3); }
public static void Stop(IRoutine routine) { smethod_0(routine, routineEvent_4); try { routine.Stop(); } catch (Exception exception) { ilog_0.Error("Exception during routine Stop.", exception); } smethod_0(routine, routineEvent_5); }
internal ExecuteContext(Invoke invoke, IRoutine routine, IVariableResolver resolver, IGroupResolver group, IQueryContext queryContext) { if (invoke == null) throw new ArgumentNullException("invoke"); if (routine == null) throw new ArgumentNullException("routine"); QueryContext = queryContext; GroupResolver = group; VariableResolver = resolver; Invoke = invoke; Routine = routine; }
public static InvokeResult Execute(this IRoutine routine, SqlExpression[] args, IQuery query, IVariableResolver resolver, IGroupResolver group) { var request = new Invoke(routine.FullName, args); if (query != null && !query.UserCanExecuteFunction(request)) { throw new InvalidOperationException(); } var executeContext = new InvokeContext(request, routine, resolver, group, query); return(routine.Execute(executeContext)); }
private static void smethod_0(IRoutine iroutine_1, RoutineEvent routineEvent_6) { if (routineEvent_6 != null) { try { routineEvent_6(iroutine_1); } catch (Exception exception) { ilog_0.Error("[Invoke] Error during execution:", exception); } } }
public static InvokeResult Execute(this IRoutine routine, Field[] args) { var invokeArgs = new InvokeArgument[0]; if (args != null && args.Length > 0) { invokeArgs = new InvokeArgument[args.Length]; for (int i = 0; i < args.Length; i++) { invokeArgs[i] = new InvokeArgument(SqlExpression.Constant(args[i])); } } return(routine.Execute(invokeArgs)); }
/// <summary> /// Select the routine and initialize it. /// </summary> public static void Init() { // Initialize NCurses _window = NCurses.InitScreen(); NCurses.CBreak(); NCurses.NoEcho(); NCurses.Keypad(_window, true); // Pick routine, and generate its map and views _routine = PickRoutine(); _routine.GenerateMap(); _routine.CreateViews(); // Set up viewport, defaulting to first item in views list _mapView = new RoutineViewport(_routine, Console.WindowWidth - 1, Console.WindowHeight - 1); }
public static InvokeResult Execute(this IRoutine routine, DataObject[] args) { var exps = new SqlExpression[0]; if (args != null && args.Length > 0) { exps = new SqlExpression[args.Length]; for (int i = 0; i < args.Length; i++) { exps[i] = SqlExpression.Constant(args[i]); } } return(routine.Execute(exps)); }
internal InvokeContext(Invoke invoke, IRoutine routine, IVariableResolver resolver, IGroupResolver group, IRequest request) { if (invoke == null) { throw new ArgumentNullException("invoke"); } if (routine == null) { throw new ArgumentNullException("routine"); } Request = request; GroupResolver = group; VariableResolver = resolver; Invoke = invoke; Routine = routine; }
/// <summary> /// Update routine parameters /// </summary> /// <param name="routines">routine collection</param> protected void UpdateRoutineParameters(IReadOnlyDictionary <string, IRoutine> routines) { this.ExecuteReader <object>( "GetRoutineParameters", reader => { IRoutine routine = null; List <IParameter> parameters = null; var resolver = this.ResolverFactory.GetResolver <IParameter>(); while (reader.Read()) { var routineSchema = GetData <string>(reader, "ROUTINE_SCHEMA"); var routineName = GetData <string>(reader, "ROUTINE_NAME"); if ((routine == null) || !routine.SchemaName.Equals(routineSchema, StringComparison.OrdinalIgnoreCase) || !routine.RoutineName.Equals(routineName, StringComparison.OrdinalIgnoreCase)) { var routineDisplayName = GetDisplayName(routineSchema, routineName); if (!routines.TryGetValue(routineDisplayName, out routine)) { var errorMessage = string.Format( CultureInfo.InvariantCulture, "Could not found routine \"{0}\" while process parameters", routineDisplayName); throw new ApplicationException(errorMessage); } parameters = new List <IParameter>(); routine.Parameters = parameters; } var parameter = resolver.Resolve(); parameter.ParameterName = GetData <string>(reader, "PARAMETER_NAME"); parameter.Mode = GetData <string>(reader, "PARAMETER_MODE"); parameter.DataTypeName = GetData <string>(reader, "DATA_TYPE"); parameter.StringSize = GetData <int?>(reader, "CHARACTER_MAXIMUM_LENGTH"); parameter.NumericPrecision = GetData <int?>(reader, "NUMERIC_PRECISION"); parameter.NumericScale = GetData <int?>(reader, "NUMERIC_SCALE"); parameters.Add(parameter); } return(null); }); }
/// <summary> /// Initialize script here. This is essentially "free" computing, and wont affect the program average runtime... /// </summary> public Program() { //Compile core variables manualProgram = new ManualProgram(this); gridAnalyser = new GridAnalyser(this); output = new Output(this, programTag); timer = gridAnalyser.GetTimer(programTag); diagnostics = new Diagnostics(this, diagnosticTag); diagnostics.Start(); //Add routines here routines.Add(new Logistics(this, logisticsTag)); routines.Add(new Hangar(this, hangarTag)); routines.Add(new Factory(this, factoryTag)); //routines.Add(new AirlockManager(this, airlockTag)); InitRoutines(); //Set how often this runs Runtime.UpdateFrequency = UpdateFrequency.Update1; }
static async Task Main() { using var serviceProvider = GetServiceProvider(); InitializeServices(serviceProvider); await LoginAsync(serviceProvider); ConfigureShutDownBehaviour(); await ConnectToHubAsync(serviceProvider); while (!shutDownWasEmmited.WaitOne(0)) { if (reloginWasEmmited.WaitOne(0)) { Logger.StartNewSection(); await LoginAsync(serviceProvider); } IRoutine routine = GetRoutine(serviceProvider); await routine.RunAsync(); } DisposeResources(); }
/// <summary> /// Resolves the routine target of the invocation within the give context. /// </summary> /// <param name="context">The query context used to resolve the routine.</param> /// <remarks> /// <para> /// If the given <paramref name="context"/> is <c>null</c> this method will /// try to resolve the routine towards the /// </para> /// </remarks> /// <returns> /// Returns an instance of <see cref="IRoutine"/> that is the target of the invocation. /// </returns> /// <exception cref="InvalidOperationException"> /// If the routine could not be resolved for this call. /// </exception> public IRoutine ResolveRoutine(IRequest context) { if (cached != null) return cached; if (context == null) { cached = SystemFunctions.Provider.ResolveFunction(this, null); } else { var resolvedName = context.Access().ResolveObjectName(DbObjectType.Routine, RoutineName); var invoke = new Invoke(resolvedName, Arguments); cached = context.Query.Access().ResolveRoutine(invoke, context); } if (cached == null) throw new InvalidOperationException(String.Format("Unable to resolve the call {0} to a function", this)); return cached; }
/// <summary> /// Resolves the routine target of the invocation within the give context. /// </summary> /// <param name="context">The query context used to resolve the routine.</param> /// <remarks> /// <para> /// If the given <paramref name="context"/> is <c>null</c> this method will /// try to resolve the routine towards the /// </para> /// </remarks> /// <returns> /// Returns an instance of <see cref="IRoutine"/> that is the target of the invocation. /// </returns> /// <exception cref="InvalidOperationException"> /// If the routine could not be resolved for this call. /// </exception> public IRoutine ResolveRoutine(IRequest context) { if (cached != null) return cached; if (context == null) { cached = SystemFunctions.Provider.ResolveFunction(this, null); } else { cached = context.Query.ResolveRoutine(this); } if (cached == null) throw new InvalidOperationException(String.Format("Unable to resolve the call {0} to a function", this)); return cached; }