コード例 #1
0
        private static void ParsePersistentState(string content)
        {
            string[] Lines = content.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string Line in Lines)
            {
                string[] Splitted = Line.Split('=');
                if (Splitted.Length < 2)
                {
                    continue;
                }

                string Key   = Splitted[0].Trim().ToLower();
                string Value = Splitted[1];
                for (int i = 2; i < Splitted.Length; i++)
                {
                    Value += "=" + Splitted[i];
                }
                Value = Value.Trim();

                StateTable.Add(Key, Value);

                if (DebugTrace)
                {
                    Debug.WriteLine($"{Key}={Value}");
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Reduces an existing node. Opposite of Expand.
        /// </summary>
        /// <param name="reducedIndex">Index of the reduced node.</param>
        /// <param name="isChanged">True upon return if the node was changed. False if the node was already reduced.</param>
        public virtual void Reduce(IWriteableNodeIndex reducedIndex, out bool isChanged)
        {
            Contract.RequireNotNull(reducedIndex, out IWriteableNodeIndex ReducedIndex);
            Debug.Assert(StateTable.ContainsKey(ReducedIndex));
            Debug.Assert(StateTable[ReducedIndex] is IWriteablePlaceholderNodeState);

            WriteableOperationList OperationList = CreateOperationList();

            Reduce(ReducedIndex, OperationList, isNested: false);

            if (OperationList.Count > 0)
            {
                WriteableOperationReadOnlyList OperationReadOnlyList = OperationList.ToReadOnly();
                WriteableOperationGroup        OperationGroup        = CreateOperationGroup(OperationReadOnlyList, null);

                SetLastOperation(OperationGroup);
                CheckInvariant();

                isChanged = true;
            }
            else
            {
                isChanged = false;
            }
        }
コード例 #3
0
        public static string GetValue(string key, string defaultValue)
        {
            if (StateTable == null)
            {
                LoadPersistentState();
            }

            string Result;

            if (StateTable.ContainsKey(key) && !string.IsNullOrEmpty(StateTable[key]))
            {
                Result = StateTable[key];
            }
            else
            {
                Result = defaultValue;
            }

            if (DebugTrace)
            {
                Debug.WriteLine($"GetValue(\"{key}\") <- {Result}");
            }

            return(Result);
        }
コード例 #4
0
        public static void SetValue(string key, string value)
        {
            if (StateTable == null)
            {
                LoadPersistentState();
            }

            if (StateTable.ContainsKey(key))
            {
                if (DebugTrace)
                {
                    Debug.WriteLine($"SetValue(\"{key}\") -> {value}");
                }

                StateTable[key] = value;
            }
            else
            {
                if (DebugTrace)
                {
                    Debug.WriteLine($"[{key}, {value}] added");
                }

                StateTable.Add(key, value);
            }

            Commit();
        }
コード例 #5
0
        public void disp_StateTable()
        {
            //Creates a command for the SQL query
            SqlCommand cmd = con.CreateCommand();

            cmd.CommandType = CommandType.Text;

            string query = " SELECT processing_date AS 'Processing Date' ," +
                           " CONCAT('$', amount) AS Amount ," +
                           " CONCAT('$', balance) AS Balance ," +
                           " Action ," +
                           " Description ," +
                           " State FROM CustomerData" +
                           " WHERE STATE IN ( SELECT Description" +
                           "                    FROM TRIGGERS ); ";

            cmd.CommandText = query;

            //Executes the SQL query
            cmd.ExecuteNonQuery();

            //Data Table Read from sql server
            DataTable dt = new DataTable();

            SqlDataAdapter da = new SqlDataAdapter(cmd);

            //Fills the SQL Data by the Data Table
            da.Fill(dt);

            //Gets the Data from the data table and places it into the HTML
            StateTable.DataSource = dt;
            StateTable.DataBind();
        }
コード例 #6
0
        private void UpdateList(Node root, StateTable inputs, List <DataEntry> aviable)
        {
            var booleans = inputs.BooleanEntries;
            var integers = inputs.IntegerEntries;

            int neededCount = booleans.Count + integers.Count;

            for (int i = aviable.Count; i < neededCount; i++)
            {
                var entry = _dataEntryScene.Instance <DataEntry>();
                root.AddChild(entry);
                aviable.Add(entry);
            }
            for (int i = aviable.Count; i > neededCount; i--)
            {
                aviable[i - 1].QueueFree();
                aviable.RemoveAt(i - 1);
            }
            int state = 0;

            foreach (var entry in booleans)
            {
                aviable[state].UpdateText(entry);
                state++;
            }
            foreach (var entry in integers)
            {
                aviable[state].UpdateText(entry);
                state++;
            }
        }
コード例 #7
0
        public Input_AI_Expand(Input_AI input, IBattleField battlefield, CharController_Direct _self, FB.FFSM.AI_StateTable table, AILevel aiLevel)
        {
            this.selfCC      = _self;
            this.battlefield = battlefield;
            this.input       = input;
            this.aiLevel     = aiLevel;
            this.ai_table    = table;
            //ai改变属性
            AILevelChange();

            vIdlePos = (battlefield as BattleField).GetRealChar(selfCC.idCare).transform.position;

            enemyCC = battlefield.GetAllCCBySide(1)[0] as CharController_Direct;
            //enemyCC.SetCCLife(0);
            stateTable = (battlefield as BattleField).GetRealChar(selfCC.idCare).transform.GetComponent <FB.FFSM.com_FightFSM>().stateTable;
            Start();
            ChangeState(StateMachine.idle);

            ai_attackstate_map = new Dictionary <int, List <AI_StateItem> >();
            for (int i = 0; i <= 3; i++)
            {
                ai_attackstate_map[i] = new List <AI_StateItem>();//0 移动系列
            }
            if (ai_table == null || ai_table.allstates == null)
            {
                return;
            }
            foreach (var a in ai_table.allstates)
            {
                ai_attackstate_map[a.attacktype].Add(a);
            }
        }
コード例 #8
0
 void Awake()
 {
     fightfsm = transform.GetComponent <com_FightFSM>();
     ap       = transform.GetComponent <AniPlayer>();
     ai_table = fightfsm.aiStateTable;
     table    = fightfsm.stateTable;
 }
コード例 #9
0
        public void BooleanIO(string iBKey, string bTest, bool iBValid, string iAKey, string assignment, bool iAValid)
        {
            var inputBoolKeys = new List <StateEntry <bool> >()
            {
                { new StateEntry <bool>(iBKey, true, "", "") }
            };
            var outputBoolKeys = new List <StateEntry <bool> >()
            {
                { new StateEntry <bool>(iAKey, true, "", "") }
            };
            var inputRegisters             = new StateTable(inputBoolKeys, new List <StateEntry <int> >());
            var outputRegisters            = new StateTable(outputBoolKeys, new List <StateEntry <int> >());
            ProcessingUnitMock pu          = new ProcessingUnitMock(inputRegisters, outputRegisters);
            BooleanExpression  expressionA = Interpreter.AsBooleanExpression(bTest, pu);

            if (iBValid)
            {
                Assert.IsTrue(expressionA.IsValid());
                Assert.IsEqual(expressionA.Result(pu), true);
            }
            else
            {
                Assert.IsTrue(expressionA == null || !expressionA.IsValid());
            }
            var ae = Osls.St.Assignment.Interpreter.AsAssignmentExpression(assignment, pu);

            if (iAValid)
            {
                Assert.IsTrue(ae.IsValid());
            }
            else
            {
                Assert.IsTrue(ae == null || !ae.IsValid());
            }
        }
コード例 #10
0
        /// <summary>
        /// Unassign the optional node.
        /// </summary>
        /// <param name="nodeIndex">Index of the optional node.</param>
        /// <param name="isChanged">True upon return if the node was changed. False if the node was already not assigned.</param>
        public virtual void Unassign(IWriteableBrowsingOptionalNodeIndex nodeIndex, out bool isChanged)
        {
            Contract.RequireNotNull(nodeIndex, out IWriteableBrowsingOptionalNodeIndex NodeIndex);
            Debug.Assert(StateTable.ContainsKey(NodeIndex));

            IWriteableOptionalNodeState State = StateTable[NodeIndex] as IWriteableOptionalNodeState;

            Debug.Assert(State != null);

            IWriteableOptionalInner <IWriteableBrowsingOptionalNodeIndex> Inner = State.ParentInner as IWriteableOptionalInner <IWriteableBrowsingOptionalNodeIndex>;

            Debug.Assert(Inner != null);

            if (Inner.IsAssigned)
            {
                Action <IWriteableOperation> HandlerRedo = (IWriteableOperation operation) => RedoUnassign(operation);
                Action <IWriteableOperation> HandlerUndo = (IWriteableOperation operation) => UndoUnassign(operation);
                WriteableAssignmentOperation Operation   = CreateAssignmentOperation(Inner.Owner.Node, Inner.PropertyName, HandlerRedo, HandlerUndo, isNested: false);

                Operation.Redo();
                SetLastOperation(Operation);
                CheckInvariant();

                isChanged = true;
            }
            else
            {
                isChanged = false;
            }
        }
コード例 #11
0
        public void Test_StateTable_GetStateOfDefinitelyOccupied_2()
        {
            var input = Permutator.Run_v2_withoutConsideringWeekNumber(TestData
                                                                       .GetSlotsByName(TestData.Subjects.HighwayAndTransportation).ToArray());
            var expected = StateTable.ParseString_AsStateOfDefinitelyOccupied(
                "00000000000000000000001100000000~" +
                "00000000000000000000000000000000~" +
                "00000011110000000000000000000000~" +
                "00000000000000000000000000000000~" +
                "00000000000000000000000000000000~" +
                "00000000000000000000000000000000~" +
                "00000000000000000000000000000000"
                );
            var actual = StateTable.GetStateOfDefinitelyOccupied(input);

            for (int i = 0; i < 7; i++)
            {
                if (expected[i] != actual[i])
                {
                    string errorMessage = "Error at day = " + i + "\n";
                    errorMessage += "Expected = " + Convert.ToString(expected[i], 2) + "\n";
                    errorMessage += "Actual   = " + Convert.ToString(actual[i], 2);
                    Assert.Fail(errorMessage);
                }
            }
            Assert.Pass();
        }
コード例 #12
0
ファイル: StateWindow.cs プロジェクト: z3nth10n/unity-themes
        public void CheckTarget()
        {
            var target = Selection.activeGameObject;

            if (!target.IsNull())
            {
                var  table   = target.GetComponent <StateTable>();
                bool changed = table != this.target || this.target.IsNull();
                if (changed && !table.IsNull())
                {
                    if (!this.target.IsNull())
                    {
                        Events.Remove("On State Updated", this.Repaint, this.target);
                        Events.Remove("On State Refreshed", this.BuildTable, this.target);
                        Events.Remove("On Components Changed", this.BuildTable, this.target.gameObject);
                    }
                    Events.Add("On Components Changed", this.BuildTable, table.gameObject);
                    this.target     = table;
                    this.tableIndex = 0;
                    this.BuildTable();
                }
            }
            if (this.tableGUI.rows.Count < 1)
            {
                this.target = null;
            }
        }
コード例 #13
0
        /// <summary>
        /// Expands an existing node. In the node:
        /// * All optional children are assigned if they aren't
        /// * If the node is a feature call, with no arguments, an empty argument is inserted.
        /// </summary>
        /// <param name="expandedIndex">Index of the expanded node.</param>
        /// <param name="isChanged">True upon return if the node was changed. False if the node was already expanded.</param>
        public virtual void Expand(IWriteableNodeIndex expandedIndex, out bool isChanged)
        {
            Contract.RequireNotNull(expandedIndex, out IWriteableNodeIndex ExpandedIndex);
            Debug.Assert(StateTable.ContainsKey(ExpandedIndex));
            Debug.Assert(StateTable[ExpandedIndex] is IWriteablePlaceholderNodeState);

            WriteableOperationList OperationList = CreateOperationList();

            DebugObjects.AddReference(OperationList);

            Expand(ExpandedIndex, OperationList);

            if (OperationList.Count > 0)
            {
                WriteableOperationReadOnlyList OperationReadOnlyList = OperationList.ToReadOnly();
                WriteableOperationGroup        OperationGroup        = CreateOperationGroup(OperationReadOnlyList, null);

                SetLastOperation(OperationGroup);
                CheckInvariant();

                isChanged = true;
            }
            else
            {
                isChanged = false;
            }
        }
コード例 #14
0
        public List <List <Slot> > GetPossibleTimetables(Slot[] inputSlots)
        {
            var subjects = SubjectModel.Parse(inputSlots.ToList());
            Func <Slot[], List <List <Slot> > > permutator = Permutator.Run_v2_withoutConsideringWeekNumber;

            subjects = SortBySlotCount(subjects);
            var currentSlots        = subjects[0].Slots;
            var possibleCombination = permutator.Invoke(currentSlots.ToArray());
            var state = StateTable.GetStateOfDefinitelyOccupied(possibleCombination);
            int last  = subjects.Count - 1;

            for (int i = 1; i < subjects.Count; i++)
            {
                var originalSchema = new SubjectSchema(subjects[i].Slots);
                var filtrate       = StateTable.Filter(subjects[i].Slots, state);
                var newSchema      = new SubjectSchema(filtrate);
                if (!originalSchema.Equals(newSchema))
                {
                    return(null);
                }
                currentSlots.AddRange(filtrate);
                possibleCombination = permutator.Invoke(currentSlots.ToArray());
                if (i != last)
                {
                    state = StateTable.GetStateOfDefinitelyOccupied(possibleCombination);
                }
            }
            return(possibleCombination);
        }
コード例 #15
0
ファイル: StateManager.cs プロジェクト: acmercyj/Framework
    /// <summary>
    /// 根据状态表和移动回调创建移动结构
    /// </summary>
    private MoveFunc CreateMoveFunc(StateTable table, Action moveFunc)
    {
        var mf = new MoveFunc();

        mf.mode     = (EMoveMode)table.moveMode;
        mf.priority = table.movePriority;
        mf.func     = moveFunc;
        return(mf);
    }
コード例 #16
0
ファイル: StateTable.cs プロジェクト: biru100/TeamIdentity
    public static StateTable Load(string[] parts)
    {
        int        i = 0;
        StateTable p = new StateTable();

        p._Index         = int.Parse(parts[i++]);
        p._Name          = parts[i++];
        p._IconStatePath = parts[i++];

        return(p);
    }
コード例 #17
0
ファイル: Switch.cs プロジェクト: MarcoDorantes/switch
 public SimpleCommandLineParser(string input)
 {
     this.input           = input;
     result               = new List <string>();
     currently__build_arg = new System.Text.StringBuilder();
     state = new ParseState()
     {
         StateID = 0
     };
     state_table = StateTableSingleton.Instance;
 }
コード例 #18
0
        public static StateFromTableDto Map(StateTable stateTableLink)
        {
            var state = stateTableLink.State;

            return(new StateFromTableDto
            {
                Id = state.Id,
                Name = state.Name,

                Index = stateTableLink.IndexInTable,
                TableId = stateTableLink.TableId
            });
        }
コード例 #19
0
        /// <summary>
        /// Changes the value of a comment.
        /// </summary>
        /// <param name="nodeIndex">Index of the state with the comment to change.</param>
        /// <param name="text">The new text.</param>
        /// <param name="oldCaretPosition">The old caret position.</param>
        /// <param name="newCaretPosition">The new caret position.</param>
        /// <param name="changeCaretBeforeText">True if the caret should be changed before the text, to preserve the caret invariant.</param>
        public virtual void ChangeCommentAndCaretPosition(IFocusIndex nodeIndex, string text, int oldCaretPosition, int newCaretPosition, bool changeCaretBeforeText)
        {
            Debug.Assert(nodeIndex != null);
            Debug.Assert(StateTable.ContainsKey(nodeIndex));
            Debug.Assert(text != null);

            Action <IWriteableOperation> HandlerRedo = (IWriteableOperation operation) => RedoChangeComment(operation);
            Action <IWriteableOperation> HandlerUndo = (IWriteableOperation operation) => UndoChangeComment(operation);
            IFocusNodeState State = StateTable[nodeIndex];
            IFocusChangeCommentOperation Operation = CreateChangeCommentOperation(State.Node, text, oldCaretPosition, newCaretPosition, changeCaretBeforeText, HandlerRedo, HandlerUndo, isNested: false);

            Operation.Redo();
            SetLastOperation(Operation);
            CheckInvariant();
        }
コード例 #20
0
        /// <summary>
        /// Changes the value of a comment.
        /// </summary>
        /// <param name="nodeIndex">Index of the state with the comment to change.</param>
        /// <param name="text">The new text.</param>
        /// <param name="oldCaretPosition">The old caret position.</param>
        /// <param name="newCaretPosition">The new caret position.</param>
        /// <param name="changeCaretBeforeText">True if the caret should be changed before the text, to preserve the caret invariant.</param>
        public virtual void ChangeCommentAndCaretPosition(IFocusIndex nodeIndex, string text, int oldCaretPosition, int newCaretPosition, bool changeCaretBeforeText)
        {
            Contract.RequireNotNull(nodeIndex, out IFocusIndex NodeIndex);
            Contract.RequireNotNull(text, out string Text);
            Debug.Assert(StateTable.ContainsKey(NodeIndex));

            System.Action <IWriteableOperation> HandlerRedo = (IWriteableOperation operation) => RedoChangeComment(operation);
            System.Action <IWriteableOperation> HandlerUndo = (IWriteableOperation operation) => UndoChangeComment(operation);
            IFocusNodeState             State     = (IFocusNodeState)StateTable[NodeIndex];
            FocusChangeCommentOperation Operation = CreateChangeCommentOperation(State.Node, Text, oldCaretPosition, newCaretPosition, changeCaretBeforeText, HandlerRedo, HandlerUndo, isNested: false);

            Operation.Redo();
            SetLastOperation(Operation);
            CheckInvariant();
        }
コード例 #21
0
        /// <summary>
        /// Changes the value of a text.
        /// </summary>
        /// <param name="nodeIndex">Index of the state with the comment to change.</param>
        /// <param name="text">The new comment.</param>
        public virtual void ChangeComment(IWriteableIndex nodeIndex, string text)
        {
            Contract.RequireNotNull(nodeIndex, out IWriteableIndex NodeIndex);
            Debug.Assert(StateTable.ContainsKey(NodeIndex));
            Contract.RequireNotNull(text, out string Text);

            System.Action <IWriteableOperation> HandlerRedo = (IWriteableOperation operation) => RedoChangeComment(operation);
            System.Action <IWriteableOperation> HandlerUndo = (IWriteableOperation operation) => UndoChangeComment(operation);
            IWriteableNodeState             State           = (IWriteableNodeState)StateTable[NodeIndex];
            WriteableChangeCommentOperation Operation       = CreateChangeCommentOperation(State.Node, Text, HandlerRedo, HandlerUndo, isNested: false);

            Operation.Redo();
            SetLastOperation(Operation);
            CheckInvariant();
        }
コード例 #22
0
        /// <summary>
        /// Changes the value of an enum or boolean.
        /// If the value exceeds allowed values, it is rounded to fit.
        /// </summary>
        /// <param name="nodeIndex">Index of the state with the enum to change.</param>
        /// <param name="propertyName">Name of the property to change.</param>
        /// <param name="value">The new value.</param>
        public virtual void ChangeDiscreteValue(IWriteableIndex nodeIndex, string propertyName, int value)
        {
            Contract.RequireNotNull(nodeIndex, out IWriteableIndex NodeIndex);
            Debug.Assert(StateTable.ContainsKey(NodeIndex));
            Debug.Assert(value >= 0);

            System.Action <IWriteableOperation> HandlerRedo = (IWriteableOperation operation) => RedoChangeDiscreteValue(operation);
            System.Action <IWriteableOperation> HandlerUndo = (IWriteableOperation operation) => UndoChangeDiscreteValue(operation);
            IWriteableNodeState State = (IWriteableNodeState)StateTable[NodeIndex];
            WriteableChangeDiscreteValueOperation Operation = CreateChangeDiscreteValueOperation(State.Node, propertyName, value, HandlerRedo, HandlerUndo, isNested: false);

            Operation.Redo();
            SetLastOperation(Operation);
            CheckInvariant();
        }
コード例 #23
0
        public void Test_StateTable_ParseString_2()
        {
            string input =
                "10000000000000000000000000000000~" +
                "10000000000000000000000000000000~" +
                "10000000000000000000000000000000~" +
                "10000000000000000000000000000000~" +
                "10000000000000000000000000000000~" +
                "10000000000000000000000000000000~" +
                "10000000000000000000000000000000";
            var expected = new int[7] {
                1, 1, 1, 1, 1, 1, 1
            };
            var actual = StateTable.ParseString_AsStateOfDefinitelyOccupied(input);

            Assert.IsTrue(actual.SequenceEqual(expected));
        }
コード例 #24
0
        public void Test_StateTable_GetStateOfDefinitelyOccupied_1()
        {
            var input = Permutator.Run_v2_withoutConsideringWeekNumber(TestData
                                                                       .GetSlotsByName(TestData.Subjects.AdvancedStructuralSteelDesign).ToArray());
            var expected = StateTable.ParseString_AsStateOfDefinitelyOccupied(
                "00000000000000111100000000000000~" +
                "00110000000000000000000000000000~" +
                "00000000000000000000000000000000~" +
                "00000000000000000000000000000000~" +
                "00000000000000000000000000000000~" +
                "00000000000000000000000000000000~" +
                "00000000000000000000000000000000"
                );
            var actual = StateTable.GetStateOfDefinitelyOccupied(input);

            Assert.IsTrue(actual.SequenceEqual(expected));
        }
コード例 #25
0
        public void Test_StateTable_Filter_1()
        {
            var input      = TestData.GetSlotsByName(TestData.Subjects.AdvancedStructuralSteelDesign);
            var inputState = StateTable.ParseString_AsStateOfDefinitelyOccupied(
                "11111111111111111111111111111111~" +
                "11111111111111111111111111111111~" +
                "11111111111111111111111111111111~" +
                "11111111111111111111111111111111~" +
                "11111111111111111111111111111111~" +
                "11111111111111111111111111111111~" +
                "11111111111111111111111111111111"
                );
            var expectedCount = 0;
            var actualCount   = StateTable.Filter(input, inputState).Count;

            Assert.AreEqual(expectedCount, actualCount);
        }
コード例 #26
0
        public static (StateTable, StateEntity) Map(StateFromTableDto dto)
        {
            var stateTable = new StateTable
            {
                TableId      = dto.TableId,
                IndexInTable = dto.Index,
                StateId      = dto.Id
            };

            var state = new StateEntity
            {
                Id   = dto.Id,
                Name = dto.Name
            };

            return(stateTable, state);
        }
コード例 #27
0
        public void NumericalIO()
        {
            var intKeys = new List <StateEntry <int> >
            {
                { new StateEntry <int>("testInt", 1, "", "") }
            };
            var inputRegisters              = new StateTable(new List <StateEntry <bool> >(), intKeys);
            var outputRegisters             = new StateTable(new List <StateEntry <bool> >(), new List <StateEntry <int> >());
            ProcessingUnitMock  pu          = new ProcessingUnitMock(inputRegisters, outputRegisters);
            NumericalExpression expressionA = Interpreter.AsNumericalExpression("testInt", pu);

            Assert.IsTrue(expressionA.IsValid());
            Assert.IsEqual(expressionA.Result(pu), 1);
            NumericalExpression expressionB = Interpreter.AsNumericalExpression("invalidInt", pu);

            Assert.IsFalse(expressionB.IsValid());
        }
コード例 #28
0
        public void Test_StateTable_Filter_ShouldRemoveRelatedSlots()
        {
            var input = new List <Slot> {
                TestData.GetSlot(309), TestData.GetSlot(311)
            };
            var inputState = StateTable.ParseString_AsStateOfDefinitelyOccupied(
                "00000011110000000000000000000000~" +
                "00000000000000000000000000000000~" +
                "00000000000000000000000000000000~" +
                "00000000000000000000000000000000~" +
                "00000000000000000000000000000000~" +
                "00000000000000000000000000000000~" +
                "00000000000000000000000000000000"
                );
            var expectedCount = 0;
            var actualCount   = StateTable.Filter(input, inputState).Count;

            Assert.AreEqual(expectedCount, actualCount);
        }
コード例 #29
0
        /// <summary>
        /// Set the value of the designer property for this model item.
        /// </summary>
        /// <typeparam name="T">Property value type.</typeparam>
        /// <param name="item">Model item.</param>
        /// <param name="property">Designer property.</param>
        /// <param name="value">Designer property value.</param>
        public static void SetDesignerProperty <T>(this ModelItem item, DesignerProperty <T> property, T value)
        {
            DesignerStateDictionary dictionary = item.Context.Services.GetService <DesignerStateDictionary>();

            if (dictionary == null)
            {
                dictionary = new DesignerStateDictionary();
                item.Context.Services.Publish <DesignerStateDictionary>(dictionary);
            }

            StateTable table;

            if (!dictionary.TryGetValue(item, out table))
            {
                table            = new StateTable();
                dictionary[item] = table;
            }

            table[property] = value;
        }
コード例 #30
0
 /// <summary>
 /// Creates the text for the plant info panel according to the given inputs and outputs
 /// </summary>
 public void UpdateText(StateTable inputs, StateTable outputs)
 {
     if (inputs == null || outputs == null)
     {
         foreach (var entry in _aviableInputs)
         {
             entry.QueueFree();
         }
         _aviableInputs.Clear();
         foreach (var entry in _aviableOutputs)
         {
             entry.QueueFree();
         }
         _aviableOutputs.Clear();
     }
     else
     {
         Node inputNode  = GetNode <VBoxContainer>("ScrollContainer/VBox/Inputs");
         Node outputNode = GetNode <VBoxContainer>("ScrollContainer/VBox/Outputs");
         UpdateList(inputNode, inputs, _aviableInputs);
         UpdateList(outputNode, outputs, _aviableOutputs);
     }
 }
コード例 #31
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="options">The options to assist when configuring the state machine.</param>
        /// <param name="commandFactory">The SMTP command factory.</param>
        public SmtpStateMachine(ISmtpServerOptions options, SmtpCommandFactory commandFactory)
        {
            _stateTable = new StateTable
            {
                new State(SmtpState.Initialized)
                {
#if DEBUG
                    { "DBUG", commandFactory.TryMakeDbug },
#endif
                    { "NOOP", commandFactory.TryMakeNoop },
                    { "RSET", commandFactory.TryMakeRset },
                    { "QUIT", commandFactory.TryMakeQuit },
                    { "HELO", commandFactory.TryMakeHelo, SmtpState.WaitingForMail },
                    { "EHLO", commandFactory.TryMakeEhlo, SmtpState.WaitingForMail },
                },
                new State(SmtpState.WaitingForMail)
                {
#if DEBUG
                    { "DBUG", commandFactory.TryMakeDbug },
#endif
                    { "NOOP", commandFactory.TryMakeNoop },
                    { "RSET", commandFactory.TryMakeRset },
                    { "QUIT", commandFactory.TryMakeQuit },
                    { "HELO", commandFactory.TryMakeHelo, SmtpState.WaitingForMail },
                    { "EHLO", commandFactory.TryMakeEhlo, SmtpState.WaitingForMail },
                    { "MAIL", commandFactory.TryMakeMail, SmtpState.WithinTransaction },
                    { "STARTTLS", commandFactory.TryMakeStartTls, SmtpState.WaitingForMailSecure },
                },
                new State(SmtpState.WaitingForMailSecure)
                {
#if DEBUG
                    { "DBUG", commandFactory.TryMakeDbug },
#endif
                    { "NOOP", commandFactory.TryMakeNoop },
                    { "RSET", commandFactory.TryMakeRset },
                    { "QUIT", commandFactory.TryMakeQuit },
                    { "AUTH", commandFactory.TryMakeAuth },
                    { "HELO", commandFactory.TryMakeHelo, SmtpState.WaitingForMailSecure },
                    { "EHLO", commandFactory.TryMakeEhlo, SmtpState.WaitingForMailSecure },
                    { "MAIL", commandFactory.TryMakeMail, SmtpState.WithinTransaction }
                },
                new State(SmtpState.WithinTransaction)
                {
#if DEBUG
                    { "DBUG", commandFactory.TryMakeDbug },
#endif
                    { "NOOP", commandFactory.TryMakeNoop },
                    { "RSET", commandFactory.TryMakeRset },
                    { "QUIT", commandFactory.TryMakeQuit },
                    { "RCPT", commandFactory.TryMakeRcpt, SmtpState.CanAcceptData },
                },
                new State(SmtpState.CanAcceptData)
                {
#if DEBUG
                    { "DBUG", commandFactory.TryMakeDbug },
#endif
                    { "NOOP", commandFactory.TryMakeNoop },
                    { "RSET", commandFactory.TryMakeRset },
                    { "QUIT", commandFactory.TryMakeQuit },
                    { "RCPT", commandFactory.TryMakeRcpt },
                    { "DATA", commandFactory.TryMakeData, SmtpState.WaitingForMail },
                }
            };

            if (options.AllowUnsecureAuthentication)
            {
                _stateTable[SmtpState.WaitingForMail].Add("AUTH", commandFactory.TryMakeAuth);
            }

            _stateTable.Initialize(SmtpState.Initialized);
        }
コード例 #32
0
ファイル: State.cs プロジェクト: groov0v/edriven-gui
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="name"></param>
 /// <param name="properties"></param>
 public State(string name, StateTable properties)
 {
     Name = name;
     _properties = properties;
 }