コード例 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MachineState"/> class.
 /// </summary>
 internal MachineState(ClassDeclarationSyntax classDecl, StateMachine machine, AnalysisContext context)
 {
     this.AnalysisContext  = context;
     this.Machine          = machine;
     this.Name             = AnalysisContext.GetFullClassName(classDecl);
     this.Declaration      = classDecl;
     this.StateTransitions = new List <StateTransition>();
     this.MachineActions   = new List <MachineAction>();
     this.IsStart          = this.IsStartState();
 }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="StateMachine"/> class.
        /// </summary>
        internal StateMachine(ClassDeclarationSyntax classDecl, AnalysisContext context)
        {
            this.AnalysisContext = context;
            this.Name            = AnalysisContext.GetFullClassName(classDecl);
            this.Declaration     = classDecl;
            this.BaseMachines    = new HashSet <StateMachine>();
            this.MachineStates   = new HashSet <MachineState>();
            this.MethodSummaries = new Dictionary <BaseMethodDeclarationSyntax, MethodSummary>();

            if (this.Declaration.Modifiers.Any(SyntaxKind.AbstractKeyword))
            {
                this.IsAbstract = true;
            }

            this.FindAllStates();
            this.AnalyzeAllStates();
        }
コード例 #3
0
        /// <summary>
        /// Computes the state-machine inheritance information for all
        /// state-machines in the project.
        /// </summary>
        private void ComputeStateMachineInheritanceInformation(ISet <StateMachine> machines)
        {
            foreach (var machine in machines)
            {
                IList <INamedTypeSymbol> baseTypes = this.AnalysisContext.GetBaseTypes(machine.Declaration);
                foreach (var type in baseTypes)
                {
                    if (type.ToString().Equals(typeof(Machine).FullName))
                    {
                        break;
                    }

                    var availableMachines = new List <StateMachine>(machines);
                    var inheritedMachine  = availableMachines.FirstOrDefault(
                        m => AnalysisContext.GetFullClassName(m.Declaration).Equals(type.ToString()));
                    if (inheritedMachine is null)
                    {
                        break;
                    }

                    machine.BaseMachines.Add(inheritedMachine);
                }
            }
        }