private static string GegerateMessageClassCode(SourceSection section, string classnameprefix) { return ($@"internal sealed class {section.ClassName}CollectSourceMessage : CollectSourceMessage {{ public override Uri Source => {classnameprefix}SupportedSource.{section.ShortClassName}.Url; }}" ); }
private static string GegerateSupportedSourceClassCode(SourceSection section) { return ($@" public static readonly SupportedSource {section.ShortClassName} = new SupportedSource {{ Url = new Uri(""{section.Url}"", UriKind.Absolute), Description = ""СМИ: {section.Description}"" }};" ); }
private static string GegerateMessageRegistrationCode(SourceSection section, string classnameprefix) { return($@" Component .For<IMaterialBinder>() .ImplementedBy<{classnameprefix}MaterialBinder>() .AsMaterialBinderFor({classnameprefix}SupportedSource.{section.ShortClassName}) .LifeStyle.Singleton, Component .For<INewsBoardParser>() .ImplementedBy<{classnameprefix}BoardParser>() .AsNewsBoardParserFor({classnameprefix}SupportedSource.{section.ShortClassName}) .LifeStyle.Singleton, Component .For<ISagaControl>() .ImplementedBy<SagaControl<{section.ClassName}CollectSourceMessage>>() .AsSagaControlFor({classnameprefix}SupportedSource.{section.ShortClassName}) .LifeStyle.Singleton" ); }
private async Task <SourceSection> GenerateSource(string url) { var uri = url.AddUrlScheme(); var section = new SourceSection { Url = uri, ClassName = uri.ConvertToClassName(), }; var shortNameString = uri.StripPrefix(RootUri).Trim(StringExtensions.AllowedExtraCharacters.ToArray()); section.ShortClassName = !string.IsNullOrEmpty(shortNameString) ? shortNameString.ConvertToClassName() : "All"; if (needDescription.Checked) { section.Description = await DescriptionLoader.TryLoadDescriptionFromTitle(section.Url); } else { section.Description = section.Url; } return(section); }