示例#1
0
        /// <summary>
        /// Finds all P# machines in the project.
        /// </summary>
        private static void FindAllMachines()
        {
            // Iterate the syntax trees for each project file.
            foreach (var tree in AnalysisContext.Compilation.SyntaxTrees)
            {
                if (!AnalysisContext.IsProgramSyntaxTree(tree))
                {
                    continue;
                }

                // Get the tree's semantic model.
                var model = AnalysisContext.Compilation.GetSemanticModel(tree);

                // Get the tree's root node compilation unit.
                var root = (CompilationUnitSyntax)tree.GetRoot();

                // Iterate the class declerations only if they are machines.
                foreach (var classDecl in root.DescendantNodes().OfType <ClassDeclarationSyntax>())
                {
                    if (Querying.IsMachine(AnalysisContext.Compilation, classDecl))
                    {
                        AnalysisContext.Machines.Add(classDecl);
                    }
                }
            }
        }
        /// <summary>
        /// Summarizes the state-machines in the project.
        /// </summary>
        /// <param name="machines">StateMachines</param>
        private void SummarizeStateMachines(ISet <StateMachine> machines)
        {
            // Iterate the syntax trees for each project file.
            foreach (var tree in base.AnalysisContext.Compilation.SyntaxTrees)
            {
                // Get the tree's semantic model.
                var model = base.AnalysisContext.Compilation.GetSemanticModel(tree);

                // Get the tree's root node compilation unit.
                var root = (CompilationUnitSyntax)tree.GetRoot();

                // Iterate the class declerations only if they are machines.
                foreach (var classDecl in root.DescendantNodes().OfType <ClassDeclarationSyntax>())
                {
                    if (Querying.IsMachine(base.AnalysisContext.Compilation, classDecl))
                    {
                        StateMachine stateMachine = new StateMachine(classDecl, base.AnalysisContext);
                        if (this.Configuration.AnalyzeDataFlow)
                        {
                            stateMachine.Summarize();
                        }

                        machines.Add(stateMachine);
                    }
                }
            }
        }
示例#3
0
文件: Program.cs 项目: ml054/ravendb
        public static void Main(string[] args)
        {
#if !DNXCORE50
            for (int i = 0; i < 10; i++)
            {
                Console.WriteLine("i = " + i);
                using (var testServerFixture = new TestServerFixture())
                {
                    for (int j = 0; j < 10; j++)
                    {
                        Console.WriteLine("j = " + j);
                        using (var querying = new Querying())
                        {
                            querying.SetFixture(testServerFixture);
                            querying.CanStreamQueryResult();
                        }
                        using (var querying = new Querying())
                        {
                            querying.SetFixture(testServerFixture);
                            querying.CanGetFacets();
                        }
                    }
                }
            }
#endif
        }
示例#4
0
        private void Internal_FillContentsWithImage(BookViewModel book)
        {
            int currentCount = Querying.BookContentsCount(book.ID);

            if (currentCount != book.Contents.Count() || !book.Contents.All(b => b.IsLoaded))
            {
                ContentsLoadTask.FillContentsWithImage(this, book);
            }
        }
示例#5
0
 /// <summary>
 /// Finds all states in the machine.
 /// </summary>
 private void FindAllStates()
 {
     foreach (var classDecl in this.Declaration.DescendantNodes().OfType <ClassDeclarationSyntax>())
     {
         if (Querying.IsMachineState(this.AnalysisContext.Compilation, classDecl))
         {
             this.MachineStates.Add(new MachineState(classDecl, this, this.AnalysisContext));
         }
     }
 }
示例#6
0
        private static void GenerateNewCoverBitmap(PageViewModel _page, CoverSideCandidate CoverLeftSide, CoverSideCandidate CoverRightSide, CoverSegmenting cs, DataOperationUnit dataOpUnit)
        {
            int count = Querying.BookContentsCount(_page.BookID, dataOpUnit);
            var dir   = Path.GetDirectoryName(_page.Image.AbsoluteMasterPath);

            cs._masterPath = $"{dir}\\XC{(count + 1)}.jpg";
            var newBitmap = CopyBitmap(_page, CoverLeftSide, CoverRightSide);

            SaveBitmap(newBitmap, cs._masterPath);
        }
示例#7
0
        private void Internal_FillContents(BookViewModel book)
        {
            int currentCount = Querying.BookContentsCount(book.ID);

            InsertContentsObjIf(book);
            var countIsNotFull   = currentCount != book.Contents.Count();
            var allPagesIsLoaded = book.Contents.All(b => b.IsLoaded);

            if (countIsNotFull || !allPagesIsLoaded)
            {
                ContentsLoadTask.FillContents(this, book);
            }
        }
示例#8
0
        /// <inheritdoc />
        /// <summary>
        ///     Queries the channel with the specified character spawn.
        /// </summary>
        /// <param name="characterSpawn">The character spawn.</param>
        public void Query(ICharacterSpawn characterSpawn)
        {
            QueryingChannelEventArgs queryingChannelEventArgs = new QueryingChannelEventArgs(characterSpawn);

            Querying?.Invoke(this, queryingChannelEventArgs);
            if (queryingChannelEventArgs.Cancel)
            {
                return;
            }

            QueriedChannelEventArgs queriedChannelEventArgs = new QueriedChannelEventArgs(characterSpawn);

            Queried?.Invoke(this, queriedChannelEventArgs);
        }
示例#9
0
        /// <summary>
        /// Checks that no non-state or non-event classes are declared inside the machine.
        /// </summary>
        /// <param name="machine">Machine</param>
        /// <param name="compilation">Compilation</param>
        private void CheckForNonStateNonEventClasses(ClassDeclarationSyntax machine, CodeAnalysis.Compilation compilation)
        {
            var classIdentifiers = machine.DescendantNodes().OfType <ClassDeclarationSyntax>().
                                   Where(val => !this.IsState(compilation, val) && !Querying.IsEventDeclaration(compilation, val)).
                                   Select(val => val.Identifier).
                                   ToList();

            foreach (var identifier in classIdentifiers)
            {
                base.ErrorLog.Add(Tuple.Create(identifier, "Not allowed to declare non-state class '" +
                                               identifier.ValueText + "' inside " + this.GetTypeOfMachine().ToLower() + " '" +
                                               machine.Identifier.ValueText + "'."));
            }
        }
示例#10
0
        /// <summary>
        /// Checks that at least one state or group is declared inside a group.
        /// </summary>
        private void CheckForAtLeastOneStateOrGroup(ClassDeclarationSyntax machine, CodeAnalysis.Compilation compilation)
        {
            var stateGroups = machine.DescendantNodes().OfType <ClassDeclarationSyntax>().
                              Where(val => Querying.IsMachineStateGroup(compilation, val)).
                              ToList();

            foreach (var stateGroup in stateGroups)
            {
                var contents = stateGroup.DescendantNodes().OfType <ClassDeclarationSyntax>().
                               Where(val => Querying.IsMachineState(compilation, val) ||
                                     Querying.IsMachineStateGroup(compilation, val)).
                               ToList();

                if (contents.Count == 0)
                {
                    this.WarningLog.Add(Tuple.Create(stateGroup.Identifier, "State group " +
                                                     $"'{stateGroup.Identifier.ValueText}' must declare at least one state or group."));
                }
            }
        }
示例#11
0
 /// <summary>
 /// Returns true if the given class declaration is a machine.
 /// </summary>
 protected override bool IsMachine(CodeAnalysis.Compilation compilation, ClassDeclarationSyntax classDecl) =>
 Querying.IsMonitor(compilation, classDecl);
 /// <summary>
 /// Returns true if the given class declaration is a state.
 /// </summary>
 /// <param name="compilation">Compilation</param>
 /// <param name="classDecl">Class declaration</param>
 /// <returns>Boolean value</returns>
 protected override bool IsState(CodeAnalysis.Compilation compilation, ClassDeclarationSyntax classDecl)
 {
     return(Querying.IsMonitorState(compilation, classDecl));
 }
示例#13
0
 /// <summary>
 /// Returns true if the given class declaration is a stategroup.
 /// </summary>
 protected override bool IsStateGroup(CodeAnalysis.Compilation compilation, ClassDeclarationSyntax classDecl) =>
 Querying.IsMachineStateGroup(compilation, classDecl);
示例#14
0
 public bool IsDirty(BookViewModel book)
 {
     return(Querying.IsDirty(this, book));
 }
示例#15
0
 public bool SortingSelected(string name)
 {
     return(Querying.SortingSelected(TagManager.Sorting, name));
 }
示例#16
0
 public bool DisplayTypeSelected(string name)
 {
     return(Querying.DisplayTypeSelected(this.BookCabinet.DisplayType, name));
 }
示例#17
0
 public bool SortingSelected(string name)
 {
     return(Querying.SortingSelected(this.BookCabinet.Sorting, name));
 }