Beispiel #1
0
        private async void GetSlideMarkdown(Action <string> action)
        {
            using (var service = ApiServiceFactory.CreateService <string>(Services.SettingsServices.SettingsService.Instance.CodeServicesUrl, useJson: false))
            {
                var parser   = ParserFactory.CreateSlideParser(service);
                var markDown = await parser.Parse(_currentSlide);

                if (!string.IsNullOrEmpty(markDown))
                {
                    markDown = XElement.Parse(markDown).Value;
                }
                if (action != null)
                {
                    action.Invoke(markDown);
                }
            }
        }
Beispiel #2
0
        public void Markdown_Generated_WhenValidSlideProvided()
        {
            #region vars

            var xml = @"<?xml version='1.0' encoding='utf-8' ?>
  <Slide Title='Dependency Injection with Windsor Castle' Margin='-200,0,0,0'>
      <RichTextBlock FontSize='20' FontWeight='DemiBold'>     
           <Paragraph>     
             <Bold>Windsor Castle Container</Bold>        
           </Paragraph>
           <Paragraph>
            <Run>Dependency Injection</Run>
           </Paragraph>
           </RichTextBlock>
        
           <Component Id='94928827-5412-4BC8-A279-EB88E21AC64F' Name='Windsor Castle' IsBrowsable='true' Action='View' TargetFile='IoC\ServiceInstaller.cs' TargetProject='Code.Service' Language='csharp'>
                   
             <Code>
                   <![CDATA[ using Castle.Windsor;
            using Castle.Windsor.Installer;
            using Castle.MicroKernel.Registration;
            using Castle.MicroKernel.SubSystems.Configuration;

            var container = new WindsorContainer();
            container.Install(FromAssembly.This());
            //usage:
            var codeServices = container.Resolve<ICodeServices>();

  public class ServiceInstaller : IWindsorInstaller
        {
            public void Install(IWindsorContainer container, IConfigurationStore store)
            {
                container.Register(
                    Component.For<IGenericServices<domain.Presentation>>()
                        .ImplementedBy<GenericServices<domain.Presentation>>()
                        .DependsOn(Dependency.OnAppSettingsValue('path'),
                          Dependency.OnAppSettingsValue('pattern'))
                        .LifestyleSingleton(),

                    Classes.FromThisAssembly()
                        .BasedOn<ApiController>()
                        .LifestyleScoped()
                    );
            }
        }]]>
      </Code>
    </Component>
  </Slide>".Trim().Replace("'", "\"");

            var expectedMarkdown = @"
    #Dependency Injection with Windsor Castle#
    
      *Windsor Castle Container*
  Dependency Injection
    ```csharp
 using Castle.Windsor;
            using Castle.Windsor.Installer;
            using Castle.MicroKernel.Registration;
            using Castle.MicroKernel.SubSystems.Configuration;

            var container = new WindsorContainer();
            container.Install(FromAssembly.This());
            //usage:
            var codeServices = container.Resolve<ICodeServices>();

  public class ServiceInstaller : IWindsorInstaller
        {
            public void Install(IWindsorContainer container, IConfigurationStore store)
            {
                container.Register(
                    Component.For<IGenericServices<domain.Presentation>>()
                        .ImplementedBy<GenericServices<domain.Presentation>>()
                        .DependsOn(Dependency.OnAppSettingsValue('path'),
                          Dependency.OnAppSettingsValue('pattern'))
                        .LifestyleSingleton(),

                    Classes.FromThisAssembly()
                        .BasedOn<ApiController>()
                        .LifestyleScoped()
                    );
            }
        }
      
    ```
  ".Replace("'", "\"");

            #endregion

            var parser = ParserFactory.CreateSlideParser(new MockApiServiceString());
            Assert.IsNotNull(parser);

            var markdown = parser.Parse(XmlHelper2 <Slide> .LoadFromString(xml)).GetAwaiter().GetResult();

            TextHelper.SaveFileContent("expected-markdown.txt", expectedMarkdown);
            TextHelper.SaveFileContent("actual-markdown.txt", markdown);
            Assert.AreEqual(expectedMarkdown.Trim(), markdown.Trim());
        }