Beispiel #1
0
 public SMInstance(PipedAlgaeTerrarium master)
     : base(master)
 {
     this.operational = master.GetComponent <Operational>();
     this.converter   = master.GetComponent <ElementConverter>();
     this.dispenser   = master.GetComponent <ConduitDispenser>();
 }
Beispiel #2
0
        public void TestWhenBirthdayNotYetThenSubstract1Year()
        {
            var result   = Operational.GetDateFromText("17 декабря", 11);
            var expected = new DateTime(2005, 12, 17);

            Assert.AreEqual(result, expected);
        }
Beispiel #3
0
            public void TestSwitchCDeferredLoop()
            {
                CellStreamSink <IReadOnlyList <TestObject> > streamSink = Cell.CreateStreamSink <IReadOnlyList <TestObject> >();
                Cell <IReadOnlyList <TestObject> >           cell       = Transaction.Run(() =>
                {
                    CellLoop <IReadOnlyList <TestObject> > cellLoop = new CellLoop <IReadOnlyList <TestObject> >();
                    Cell <IReadOnlyList <TestObject> > cellLocal    = streamSink
                                                                      .OrElse(Operational.Defer(cellLoop.Map(oo => oo.Select(o => o.Output).Lift(vv => vv.Sum())).SwitchC().Values()).Filter(sum => sum < 50).Snapshot(cellLoop, (_, items) => (IReadOnlyList <TestObject>)items.Concat(new[] { new TestObject() }).ToArray()))
                                                                      .Hold(Enumerable.Range(1, 10).Select(_ => new TestObject()).ToArray());
                    cellLoop.Loop(cellLocal);
                    return(cellLocal);
                });

                List <int> objectCounts = new List <int>();

                objectCounts.Add(-1);
                cell.Listen(vv => objectCounts.Add(vv.Count));
                objectCounts.Add(-1);
                cell.Sample()[2].Input1.Send(1);
                objectCounts.Add(-1);
                cell.Sample()[1].Input1.Send(-20);
                objectCounts.Add(-1);
                streamSink.Send(new TestObject[0]);
                objectCounts.Add(-1);

                // Ideal result, likely not achievable.
                //CollectionAssert.AreEquivalent(new[] { -1, 10, -1, 11, -1, 15, -1, 10, -1 }, objectCounts);

                // Glitchy result, but correct otherwise.
                CollectionAssert.AreEquivalent(new[] { -1, 10, -1, 11, -1, 12, 13, 14, 15, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1 }, objectCounts);
            }
Beispiel #4
0
        public void TestGetDateFromText()
        {
            var result   = Operational.GetDateFromText("17 января", 11);
            var expected = new DateTime(2006, 1, 17);

            Assert.AreEqual(result, expected);
        }
Beispiel #5
0
 public Instance(Shower master)
     : base(master)
 {
     operational = master.GetComponent <Operational>();
     consumer    = master.GetComponent <ConduitConsumer>();
     dispenser   = master.GetComponent <ConduitDispenser>();
 }
        /// <summary>
        /// 保存用户角色关系
        /// </summary>
        /// <param name="accountId">用户Id</param>
        /// <param name="roleIds">角色Id集合</param>
        /// <param name="operational">操作信息</param>
        /// <returns>结果</returns>
        public static Result SavePermissionRole(Guid accountId, List <Guid> roleIds, Operational operational)
        {
            Result result = new Result();

            try
            {
                using (IPowerUnitOfWork unit = DbContext.CreateIPowerUnitOfWork())
                {
                    IRoleUserRelationshipRepository roleUserRelationshipRepository = DbContext.CreateIRoleUserRelationshipRepository(unit);
                    roleUserRelationshipRepository.RemoveByAccountId(accountId);
                    var content = PermissionBuilder.ToMRoleUserRelationship(accountId, roleIds);
                    roleUserRelationshipRepository.Add(content);
                    unit.Complete();
                }

                result.IsSucceed = true;
                result.Message   = "保存成功";
            }
            catch (Exception ex)
            {
                result.IsSucceed = false;
                result.Message   = Const.ErrorMessage;
                LogService.WriteLog(ex, "保存用户角色关系");
            }
            return(result);
        }
Beispiel #7
0
        /// <summary>
        /// 添加角色
        /// </summary>
        /// <param name="tRole">角色信息</param>
        /// <param name="operational">操作信息</param>
        /// <returns>结果</returns>
        public static Result AddRole(TRole tRole, Operational operational)
        {
            Result result = new Result();

            try
            {
                using (var roleRepository = DbContext.CreateIRoleRepository())
                {
                    if (tRole.Id == Guid.Empty)
                    {
                        tRole.Id = Guid.NewGuid();
                    }
                    var mRole = tRole.ToMRole();
                    roleRepository.Add(mRole);
                }

                result.IsSucceed = true;
                result.Message   = "添加成功";
            }
            catch (Exception ex)
            {
                result.IsSucceed = false;
                result.Message   = Const.ErrorMessage;
                LogService.WriteLog(ex, "添加角色");
            }
            return(result);
        }
        /// <summary>
        /// 保存权限菜单
        /// </summary>
        /// <param name="roleId">角色Id</param>
        /// <param name="menuIds">菜单Id集合</param>
        /// <param name="operational">操作信息</param>
        /// <returns>结果</returns>
        public static Result SavePermissionMenu(Guid roleId, List <Guid> menuIds, Operational operational)
        {
            Result result = new Result();

            try
            {
                PermissionValidate.ValidateMenuIds(menuIds);
                using (IPowerUnitOfWork unit = DbContext.CreateIPowerUnitOfWork())
                {
                    IRolePermissionsRepository rolePermissionsRepository = DbContext.CreateIRolePermissionsRepository(unit);
                    rolePermissionsRepository.RemoveByRoleId(roleId);
                    var content = PermissionBuilder.ToMRolePermissions(roleId, menuIds);
                    rolePermissionsRepository.Add(content);
                    unit.Complete();
                }

                result.IsSucceed = true;
                result.Message   = "保存成功";
            }
            catch (CustomException ex)
            {
                result.IsSucceed = false;
                result.Message   = ex.Message;
            }
            catch (Exception ex)
            {
                result.IsSucceed = false;
                result.Message   = Const.ErrorMessage;
                LogService.WriteLog(ex, "保存权限菜单");
            }
            return(result);
        }
Beispiel #9
0
        /// <summary>
        /// 添加菜单
        /// </summary>
        /// <param name="tMenu">菜单信息</param>
        /// <param name="operational">操作信息</param>
        /// <returns>结果</returns>
        public static Result AddMenu(TMenu tMenu, Operational operational)
        {
            Result result = new Result();

            try
            {
                using (var menuRepository = DbContext.CreateIMenuRepository())
                {
                    if (tMenu.Id == Guid.Empty)
                    {
                        tMenu.Id = Guid.NewGuid();
                    }
                    var mMenu = tMenu.ToMMenu();
                    menuRepository.Add(mMenu);
                }

                result.IsSucceed = true;
                result.Message   = "添加成功";
            }
            catch (Exception ex)
            {
                result.IsSucceed = false;
                result.Message   = Const.ErrorMessage;
                LogService.WriteLog(ex, "添加菜单");
            }
            return(result);
        }
Beispiel #10
0
    public void Refresh()
    {
        UnregisterLight();
        Operational component = GetComponent <Operational>();

        if ((!((Object)component != (Object)null) || component.IsOperational) && base.isActiveAndEnabled)
        {
            Vector3 position = base.transform.GetPosition();
            position = new Vector3(position.x + Offset.x, position.y + Offset.y, position.z);
            int num = Grid.PosToCell(position);
            if (Grid.IsValidCell(num))
            {
                Vector2I vector2I = Grid.CellToXY(num);
                int      num2     = (int)Range;
                if (shape == LightShape.Circle)
                {
                    Vector2I vector2I2 = new Vector2I(vector2I.x - num2, vector2I.y - num2);
                    solidPartitionerEntry  = GameScenePartitioner.Instance.Add("Radiator", base.gameObject, vector2I2.x, vector2I2.y, 2 * num2, 2 * num2, GameScenePartitioner.Instance.solidChangedLayer, TriggerRefresh);
                    liquidPartitionerEntry = GameScenePartitioner.Instance.Add("Radiator", base.gameObject, vector2I2.x, vector2I2.y, 2 * num2, 2 * num2, GameScenePartitioner.Instance.liquidChangedLayer, TriggerRefresh);
                }
                else if (shape == LightShape.Cone)
                {
                    Vector2I vector2I3 = new Vector2I(vector2I.x - num2, vector2I.y - num2);
                    solidPartitionerEntry  = GameScenePartitioner.Instance.Add("Radiator", base.gameObject, vector2I3.x, vector2I3.y, 2 * num2, num2, GameScenePartitioner.Instance.solidChangedLayer, TriggerRefresh);
                    liquidPartitionerEntry = GameScenePartitioner.Instance.Add("Radiator", base.gameObject, vector2I3.x, vector2I3.y, 2 * num2, num2, GameScenePartitioner.Instance.liquidChangedLayer, TriggerRefresh);
                }
                cell = num;
                litCells.Clear();
                emitter = new RadiationGridEmitter(cell, litCells, Lux, Range, shape, 0.5f);
                emitter.Add();
                isRegistered = true;
            }
        }
    }
Beispiel #11
0
        public FrView(Window window, Fridget fr, IListener l)
        {
            StreamSink <MouseEvent> sMouse = new StreamSink <MouseEvent>();
            StreamSink <KeyEvent>   sKey   = new StreamSink <KeyEvent>();

            this.MouseDown += (sender, args) => sMouse.Send(new MouseEvent(args, () => args.GetPosition(this)));
            this.MouseUp   += (sender, args) => sMouse.Send(new MouseEvent(args, () => args.GetPosition(this)));
            this.MouseMove += (sender, args) => sMouse.Send(new MouseEvent(args, () => args.GetPosition(this)));
            CellSink <IMaybe <Size> > size = new CellSink <IMaybe <Size> >(Maybe.Nothing <Size>());

            this.SizeChanged += (sender, args) => size.Send(Maybe.Just(args.NewSize));
            window.KeyDown   += (sender, args) =>
            {
                Key key = args.Key == Key.System ? args.SystemKey : args.Key;
                if (key == Key.Back)
                {
                    sKey.Send(new BackspaceKeyEvent());
                }
            };
            window.TextInput += (sender, args) => sKey.Send(new StringKeyEvent(args.Text));
            CellLoop <long> focus = new CellLoop <long>();

            Fridget.Output fo = fr.Reify(size, sMouse, sKey, focus, new Supply());
            focus.Loop(fo.SChangeFocus.Hold(-1));
            this.drawable = fo.Drawable;
            this.l        = new ImmutableCompositeListener(new[] { l, Operational.Updates(this.drawable).Listen(d => this.InvalidateVisual()) });
        }
Beispiel #12
0
            public Renderer(CompositionTargetSecondsTimerSystem timerSystem, Cell <DrawableDelegate> drawable, Size size, Animate animation, Cell <bool> isStarted)
            {
                this.drawable = drawable;
                this.size     = size;

                Transaction.Run(() => Operational.Value(isStarted).Filter(s => s).ListenOnce(_ => timerSystem.AddAnimation(animation)));
            }
        public MainWindow()
        {
            this.InitializeComponent();

            Transaction.RunVoid(() =>
            {
                STextBox word           = new STextBox(string.Empty);
                CellLoop <bool> enabled = new CellLoop <bool>();
                SButton button          = new SButton(enabled)
                {
                    Content = "look up"
                };
                Stream <string> sWord = button.SClicked.Snapshot(word.Text);
                IsBusy <string, IMaybe <string> > ib = new IsBusy <string, IMaybe <string> >(Lookup, sWord);
                Stream <string> sDefinition          = ib.SOut.Map(o => o.Match(v => v, () => "ERROR!"));
                Cell <string> definition             = sDefinition.Hold(string.Empty);
                Cell <string> output = definition.Lift(ib.Busy, (def, bsy) => bsy ? "Looking up..." : def);
                enabled.Loop(ib.Busy.Map(b => !b));
                STextBox outputArea = new STextBox(Operational.Value(output), string.Empty, enabled)
                {
                    TextWrapping = TextWrapping.Wrap, AcceptsReturn = true
                };
                this.TextBoxPlaceholder.Child = word;
                this.ButtonPlaceholder.Child  = button;
                this.OutputPlaceholder.Child  = outputArea;
            });
        }
Beispiel #14
0
    private static string ResolveInfoStatusItemString(string format_str, object data)
    {
        LogicOperationalController logicOperationalController = (LogicOperationalController)data;
        Operational component = logicOperationalController.GetComponent <Operational>();

        return((!component.GetFlag(logicOperationalFlag)) ? BUILDING.STATUSITEMS.LOGIC.LOGIC_CONTROLLED_DISABLED : BUILDING.STATUSITEMS.LOGIC.LOGIC_CONTROLLED_ENABLED);
    }
    protected override void OnSpawn()
    {
        Operational component = GetComponent <Operational>();

        component.SetActive(component.IsOperational, false);
        filteredStorage.FilterChanged();
    }
 public override void Update()
 {
     for (int i = 0; i < slots.Length; i++)
     {
         SlotEntry slotEntry         = slots[i];
         AssignableSlotInstance slot = slotEntry.slot;
         if (slot.IsAssigned())
         {
             bool        flag      = slot.assignable.GetNavigationCost(navigator) != -1;
             Operational component = slot.assignable.GetComponent <Operational>();
             if ((Object)component != (Object)null)
             {
                 flag = (flag && component.IsOperational);
             }
             if (flag != slotEntry.isReachable)
             {
                 slotEntry.isReachable = flag;
                 slots[i] = slotEntry;
                 Trigger(334784980, slotEntry);
             }
         }
         else if (slotEntry.isReachable)
         {
             slotEntry.isReachable = false;
             slots[i] = slotEntry;
             Trigger(334784980, slotEntry);
         }
     }
 }
Beispiel #17
0
        private void addLabelPointBus(GMapMarker theMarker, Bus theMioBus)
        {
            Line ruta = ((Line)(laVentana.theMio.lineInfo[theMioBus.lineId]));

            if (ruta != null)
            {
                Operational TheOp = ((Operational)(laVentana.theMio.operationalInfo[theMioBus.busId + " " + theMioBus.tripId]));
                if (TheOp != null)
                {
                    int time = TheOp.desviationTime;
                    theMarker.ToolTipText = $"ID: {theMioBus.busId}, \nRuta: {ruta.shortName}, \nDesc: {ruta.description}, \nTiempo de Desviación: {laVentana.theMio.getTimeDeviation(time)}";
                }
                else
                {
                    var rand = new Random();
                    int num  = rand.Next(-20, 20);
                    theMarker.ToolTipText = $"ID: {theMioBus.busId}, \nRuta: {ruta.shortName}, \nDesc: {ruta.description}, \nTiempo de Desviación: {laVentana.theMio.getTimeDeviation(num)}";
                }
            }
            else
            {
                theMarker.ToolTipText = $"ID: {theMioBus.busId}";
            }
            GMapToolTip theTip = new GMapToolTip(theMarker);

            theTip.Fill       = new SolidBrush(Color.White);
            theTip.Foreground = new SolidBrush(Color.Blue);

            theMarker.ToolTip = theTip;
        }
Beispiel #18
0
            private static Cell <T> Calm <T>(Cell <T> a)
            {
                Lazy <T>           initA  = a.SampleLazy();
                Lazy <IMaybe <T> > mInitA = initA.Map(Maybe.Just);

                return(Calm(Operational.Updates(a), mInitA).HoldLazy(initA));
            }
Beispiel #19
0
        public void TestGetDateFromTextWithSingleDigitNumber()
        {
            var result   = Operational.GetDateFromText("2 мая", 10);
            var expected = new DateTime(2006, 5, 2);

            Assert.AreEqual(result, expected);
        }
Beispiel #20
0
        public void TestGetTeacherNameFromLessonWithTeacher()
        {
            var op = new Operational("1");

            var result = op.GetTeacherNameFromLessonWithTeacher("Название урока (Имя учителя)", "Название урока");

            Assert.AreEqual(result, "Имя учителя");
        }
Beispiel #21
0
        public void TestGetLessonNameFromLessonWithTeacherWithoutTeacher()
        {
            var op = new Operational("1");

            var result = op.GetLessonNameFromLessonWithTeacher("Название урока");

            Assert.AreEqual(result, "Название урока");
        }
Beispiel #22
0
    public static Operational <TNewParameter> To <TOldParameter, TNewParameter>(this Operational <TOldParameter> operational, Func <TOldParameter, TNewParameter> converter)
    {
        var oldParameter = operational.Parameter;

        var newParameter = converter(oldParameter);

        return(new Operational <TNewParameter>(newParameter));
    }
			/// <summary>
			/// Applied after SetFlag runs.
			/// </summary>
			internal static void Postfix(Operational __instance, Operational.Flag flag) {
				var obj = __instance.gameObject;
				if (obj != null && obj.HasTag(RoomConstraints.ConstraintTags.RecBuilding) &&
						(flag.FlagType == Operational.Flag.Type.Functional || flag ==
						BuildingEnabledButton.EnabledFlag))
					// Update rooms if rec buildings break down or get disabled
					Game.Instance.roomProber.SolidChangedEvent(Grid.PosToCell(obj), true);
			}
    public Task <OperationalResult> CreateAsync(Operational <UserModel> operational, CancellationToken cancellationToken = default)
    {
        var model = operational.Parameter;

        var password = model.PassWord;

        return(_dalUserService.AddAsync(operational, cancellationToken));
    }
Beispiel #25
0
        public void Issue151_PoolDoubleSubtraction_Fixed()
        {
            CellSink <int>   threshold   = new CellSink <int>(10);
            StreamSink <int> addPoolSink = new StreamSink <int>();

            (Stream <int> input, Cell <int> pool) = Transaction.Run(() =>
            {
                StreamLoop <int> submitPooledAmount = new StreamLoop <int>();

                // Ways that the pool is modified.
                Stream <Func <int, int> > poolAddByInput    = addPoolSink.Map <Func <int, int> >(i => x => x + i);
                Stream <Func <int, int> > poolRemoveByUsage = Operational.Defer(submitPooledAmount.Map <Func <int, int> >(i => x => x - i));

                // The current level of the pool
                Cell <int> poolLocal = poolAddByInput
                                       .Merge(poolRemoveByUsage, (f, g) => x => g(f(x)))
                                       .Accum(0, (f, x) => f(x));

                // The current input changes combined with the pool as a stream
                Stream <int> inputByAdded =
                    poolAddByInput
                    .Snapshot(
                        poolLocal,
                        threshold,
                        (f, x, t) => f(x) >= t
                                ? Maybe.Some(f(x))
                                : Maybe.None)
                    .FilterMaybe();

                // Simple rising edge on pool threshold satisfaction.
                Stream <int> inputBySatisfaction =
                    poolLocal.Updates
                    .Snapshot(
                        poolLocal,
                        threshold,
                        (neu, alt, t) => neu >= t && alt < t
                                ? Maybe.Some(neu)
                                : Maybe.None)
                    .FilterMaybe();

                submitPooledAmount.Loop(inputByAdded.Merge(inputBySatisfaction, Math.Max));

                return(submitPooledAmount, poolLocal);
            });

            List <int> submissions = new List <int>();

            using (input.Listen(submissions.Add))
            {
                // Add amount which can be immediately used based on threshold.
                // Pool should remain zero after the transaction is complete.
                addPoolSink.Send(10);
            }

            Assert.AreEqual(1, submissions.Count);
            Assert.AreEqual(10, submissions[0]);
            Assert.AreEqual(0, pool.Sample());
        }
Beispiel #26
0
    protected override void OnCompleteWork(Worker worker)
    {
        Operational component = GetComponent <Operational>();

        if ((UnityEngine.Object)component != (UnityEngine.Object)null)
        {
            component.SetFlag(repairedFlag, true);
        }
    }
Beispiel #27
0
        public async Task TestListenOnceAsync()
        {
            CellSink <int> c      = Cell.CreateSink(9);
            int            result = await Transaction.Run(() => Operational.Value(c).ListenOnceAsync());

            c.Send(2);
            c.Send(7);
            Assert.AreEqual(9, result);
        }
Beispiel #28
0
        public async Task TestListenOnceAsync()
        {
            BehaviorSink <int> b = Behavior.CreateSink(9);
            int result           = await Transaction.Run(() => Operational.Value(b).ListenOnceAsync());

            b.Send(2);
            b.Send(7);
            Assert.AreEqual(9, result);
        }
    public async Task <OperationalResult <bool> > IsExist(Operational <UserQueryModel> operational, CancellationToken cancellationToken = default)
    {
        var queryModel = operational.Parameter;

        Expression <Func <User, bool> > expression = p => p.No == queryModel.UserNo;

        var count = await _userStore.CountAsync(expression, cancellationToken);

        return(OperationalResult <bool> .Ok(count > 0));
    }
    public async Task <OperationalResult> DeleteAsync(Operational <string> operational, CancellationToken cancellationToken = default)
    {
        var UserNo = operational.Parameter;

        Expression <Func <User, bool> > expression = p => p.No == UserNo;

        var result = await _userStore.DeleteAsync(expression, cancellationToken);

        return(result ? OperationalResult.Ok() : OperationalResult.Failed(""));
    }
Beispiel #31
0
        public LCD(Cpu.Pin rs, Cpu.Pin enable,
            Cpu.Pin d4, Cpu.Pin d5, Cpu.Pin d6, Cpu.Pin d7,
            byte columns, Operational lineSize, int numberOfRows, Operational dotSize)
        {
            RS = new OutputPort(rs, false);
            Enable = new OutputPort(enable, false);
            D4 = new OutputPort(d4, false);
            D5 = new OutputPort(d5, false);
            D6 = new OutputPort(d6, false);
            D7 = new OutputPort(d7, false);

            Columns = columns;
            DotSize = (byte)dotSize;
            NumberOfLines = (byte)lineSize;
            NumberOfRows = numberOfRows;

            Initialize();
        }