Пример #1
0
        private void ProcessLifecycleEventMethod(MethodDeclarationSyntax methodDeclaration, WebFormsPageLifecycleEvent lifecycleEvent)
        {
            var statements = (IEnumerable <StatementSyntax>)methodDeclaration.Body.Statements;

            // Dont do anything if the method is empty, no reason to move over nothing
            if (statements.Any())
            {
                statements = statements.AddComment(string.Format(Constants.NewEventRepresentationCommentTemplate, lifecycleEvent.ToString()));

                var blazorLifecycleEvent = LifecycleManagerService.GetEquivalentComponentLifecycleEvent(lifecycleEvent);

                if (_newLifecycleLines.ContainsKey(blazorLifecycleEvent))
                {
                    // Add spacing between last added method
                    statements = statements.Prepend(CodeSyntaxHelper.GetBlankLine());
                    _newLifecycleLines[blazorLifecycleEvent] = _newLifecycleLines[blazorLifecycleEvent].Concat(statements);
                }
                else
                {
                    _newLifecycleLines.Add(blazorLifecycleEvent, statements);
                }
            }
        }
Пример #2
0
 public void GetEquivalentComponentLifecycleEvent_Returns_Correct_Dispose_Events()
 {
     Assert.AreEqual(BlazorComponentLifecycleEvent.Dispose, LifecycleManagerService.GetEquivalentComponentLifecycleEvent(WebFormsPageLifecycleEvent.Unload));
 }
Пример #3
0
 public void GetEquivalentComponentLifecycleEvent_Returns_Correct_OnAfterRender_Events()
 {
     Assert.AreEqual(BlazorComponentLifecycleEvent.OnAfterRender, LifecycleManagerService.GetEquivalentComponentLifecycleEvent(WebFormsPageLifecycleEvent.SaveStateComplete));
 }
Пример #4
0
 public void GetEquivalentComponentLifecycleEvent_Returns_Correct_OnParametersSet_Events()
 {
     Assert.AreEqual(BlazorComponentLifecycleEvent.OnParametersSet, LifecycleManagerService.GetEquivalentComponentLifecycleEvent(WebFormsPageLifecycleEvent.PreRender));
     Assert.AreEqual(BlazorComponentLifecycleEvent.OnParametersSet, LifecycleManagerService.GetEquivalentComponentLifecycleEvent(WebFormsPageLifecycleEvent.PreRenderComplete));
 }
Пример #5
0
 public void GetEquivalentComponentLifecycleEvent_Returns_Correct_OnInitialized_Events()
 {
     Assert.AreEqual(BlazorComponentLifecycleEvent.OnInitialized, LifecycleManagerService.GetEquivalentComponentLifecycleEvent(WebFormsPageLifecycleEvent.InitComplete));
     Assert.AreEqual(BlazorComponentLifecycleEvent.OnInitialized, LifecycleManagerService.GetEquivalentComponentLifecycleEvent(WebFormsPageLifecycleEvent.LoadComplete));
 }
Пример #6
0
 public void GetEquivalentComponentLifecycleEvent_Returns_Correct_SetParametersAsync_Events()
 {
     Assert.AreEqual(BlazorComponentLifecycleEvent.SetParametersAsync, LifecycleManagerService.GetEquivalentComponentLifecycleEvent(WebFormsPageLifecycleEvent.PreInit));
     Assert.AreEqual(BlazorComponentLifecycleEvent.SetParametersAsync, LifecycleManagerService.GetEquivalentComponentLifecycleEvent(WebFormsPageLifecycleEvent.Init));
 }