Esempio n. 1
0
        public TemplatePersistor(ITemplateContainer container, string path)
        {
            LOGGER.Debug($"Creating template persistor for path '{path}'");

            Path      = path;
            Container = container;
        }
Esempio n. 2
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="ParserOptions" /> class.
 /// </summary>
 /// <param name="template">The template.</param>
 /// <param name="sourceStream">The source stream.</param>
 /// <param name="encoding">The encoding.</param>
 /// <param name="disableContentEscaping">if set to <c>true</c> [disable content escaping].</param>
 public ParserOptions(ITemplateContainer template,
                      Func <Stream> sourceStream,
                      Encoding encoding,
                      bool disableContentEscaping = false)
     : this(template, sourceStream, encoding, 0, disableContentEscaping)
 {
 }
Esempio n. 3
0
        public static void AssertDocumentItemIsSameAsTemplate(ITemplateContainer textContainer,
                                                              IDocumentItem documentItem,
                                                              ParserOptions options)
        {
            var text = ((textContainer as StringTemplateContainer).Template as StringTemplateResource).ToString();

            AssertDocumentItemIsSameAsTemplate(text, documentItem, options);
        }
Esempio n. 4
0
        /// <summary>
        ///		Runs the Tokenizer and returns all errors in the template if present
        /// </summary>
        /// <param name="template"></param>
        /// <returns></returns>
        public static async Task <IEnumerable <IMorestachioError> > Validate(ITemplateContainer template)
        {
            var options          = new ParserOptions(template);
            var tokenzierContext = new TokenzierContext(new List <int>(), null);
            await Tokenizer.Tokenize(options, tokenzierContext);

            return(tokenzierContext.Errors);
        }
Esempio n. 5
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="ParserOptions" /> class.
 /// </summary>
 /// <param name="template">The template.</param>
 /// <param name="sourceStream">The source stream.</param>
 /// <param name="encoding">The encoding.</param>
 /// <param name="maxSize">The maximum size.</param>
 /// <param name="disableContentEscaping">if set to <c>true</c> [disable content escaping].</param>
 public ParserOptions(ITemplateContainer template,
                      Func <Stream> sourceStream,
                      Encoding encoding,
                      long maxSize,
                      bool disableContentEscaping = false)
     : this(template, sourceStream, encoding)
 {
     MaxSize = maxSize;
     DisableContentEscaping = disableContentEscaping;
 }
Esempio n. 6
0
        public PathForm(IPathContainer pathContainer, ITemplateContainer templateContainer, IYoutubeJobContainer queueContainer, IYoutubeJobContainer archiveContainer, IYoutubeAccountContainer accountContainer)
        {
            LOGGER.Info($"Initializing new instance of PathForm");

            InitializeComponent();

            this.pathContainer     = pathContainer;
            this.templateContainer = templateContainer;

            this.queueContainer   = queueContainer;
            this.archiveContainer = archiveContainer;
            this.accountContainer = accountContainer;
        }
Esempio n. 7
0
        public async Task <T> MatchAsync(Uri @namespace, IRequest request, CancellationToken token)
        {
            ITemplateContainer <T> templateContainer = await _templateStore.GetTemplateContainerAsync(@namespace, token);

            if (templateContainer?.Templates?.Any() ?? false)
            {
                var result = GetClosestMatchingTemplate(templateContainer.Templates, request);
                if (result == null)
                {
                    return(default(T));
                }
                return(result.Template);
            }

            return(default(T));
        }
Esempio n. 8
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="ParserOptions" /> class.
 /// </summary>
 /// <param name="template">The template.</param>
 /// <param name="sourceStream">The source stream.</param>
 /// <param name="encoding">The encoding.</param>
 public ParserOptions(ITemplateContainer template,
                      Func <ParserOptions, IByteCounterStream> sourceStream,
                      Encoding encoding)
 {
     Template                     = template ?? new StringTemplateContainer("");
     StreamFactory                = new ByteCounterFactory(sourceStream);
     Encoding                     = encoding ?? Encoding.UTF8;
     _formatters                  = new MorestachioFormatterService();
     Null                         = string.Empty;
     MaxSize                      = 0;
     DisableContentEscaping       = false;
     Timeout                      = TimeSpan.Zero;
     PartialStackSize             = 255;
     _customDocumentItemProviders = new CustomDocumentList();
     CultureInfo                  = CultureInfo.CurrentCulture;
     UnmatchedTagBehavior         = UnmatchedTagBehavior.ThrowError | UnmatchedTagBehavior.LogWarning;
 }
Esempio n. 9
0
        private void RecreateSaved()
        {
            LOGGER.Debug($"Recreating cache of saved tempaltes");
            Saved = new TemplateContainer();
            foreach (var template in Container.RegisteredTemplates)
            {
                LOGGER.Debug($"Recreating cache for template '{template.Name}'");
                var newTemplate = new Template(template.Id, template.Name, template.DefaultLanguage, template.Category, template.PublishTimes, template.PlannedVideos)
                {
                    AutoLevels          = template.AutoLevels,
                    Description         = template.Description,
                    IsEmbeddable        = template.IsEmbeddable,
                    License             = template.License,
                    NotifySubscribers   = template.NotifySubscribers,
                    PlannedVideos       = template.PlannedVideos,
                    Privacy             = template.Privacy,
                    PublicStatsViewable = template.PublicStatsViewable,
                    PublishTimes        = template.PublishTimes,
                    ShouldPublishAt     = template.ShouldPublishAt,
                    Stabilize           = template.Stabilize,
                    Tags                              = template.Tags,
                    ThumbnailPath                     = template.ThumbnailPath,
                    Title                             = template.Title,
                    CSharpCleanUpScript               = template.CSharpCleanUpScript,
                    CSharpPreparationScript           = template.CSharpPreparationScript,
                    EnableExpertMode                  = template.EnableExpertMode,
                    MailTo                            = template.MailTo,
                    NewVideoDesktopNotification       = template.NewVideoDesktopNotification,
                    NewVideoMailNotification          = template.NewVideoMailNotification,
                    NextUploadSuggestion              = template.NextUploadSuggestion,
                    ReferencedAssembliesText          = template.ReferencedAssembliesText,
                    UploadFailedDesktopNotification   = template.UploadFailedDesktopNotification,
                    UploadFailedMailNotification      = template.UploadFailedMailNotification,
                    UploadFinishedDesktopNotification = template.UploadFinishedDesktopNotification,
                    UploadFinishedMailNotification    = template.UploadFinishedMailNotification,
                    UploadStartedDesktopNotification  = template.UploadStartedDesktopNotification,
                    UploadStartedMailNotification     = template.UploadStartedMailNotification
                };

                Saved.RegisterTemplate(newTemplate);
            }
        }
Esempio n. 10
0
        public ChooseStartTimesForm(IPathContainer pathContainer, ITemplateContainer templateContainer)
        {
            LOGGER.Info($"Initializing new instance of ChooseStartTimesForm");

            InitializeComponent();

            this.pathContainer     = pathContainer;
            this.templateContainer = templateContainer;

            foreach (var path in pathContainer.ActivePaths)
            {
                LOGGER.Info($"Adding active path '{path}'");

                publishSettings.Add(new ObservationConfiguration(path, templateContainer.RegisteredTemplates.FirstOrDefault(t => t.Id == path.SelectedTemplateId)));
            }

            chooseCustomTimesControl.AddRange(publishSettings);

            LOGGER.Debug($"Should publish controls be visible: {publishSettings.Any(i => i.Template.ShouldPublishAt)}");
            globalSettingsControl.SetPublishControlsVisibility(publishSettings.Any(i => i.Template.ShouldPublishAt), false);
        }
Esempio n. 11
0
 public void Setup()
 {
     TemplateDalContainer = TemplateFactory.CreateTemplateDalContainer();
     TemplateDalLogic     = TemplateFactory.CreateTemplateDALLogic();
     TemplateLogic        = new TemplateLogic();
 }
Esempio n. 12
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="ParserOptions" /> class.
 /// </summary>
 /// <param name="template">The template.</param>
 /// <param name="sourceStream">The source stream.</param>
 /// <param name="encoding">The encoding.</param>
 public ParserOptions(ITemplateContainer template,
                      Func <Stream> sourceStream,
                      Encoding encoding) : this(template, ByteCounterFactory.GetDefaultByteCounter(sourceStream), encoding)
 {
 }
Esempio n. 13
0
 /// <summary>
 ///     ctor
 /// </summary>
 /// <param name="template"></param>
 /// <param name="sourceStream">The factory that is used for each template generation</param>
 public ParserOptions(ITemplateContainer template,
                      Func <Stream> sourceStream)
     : this(template, sourceStream, null)
 {
 }
Esempio n. 14
0
 /// <summary>
 ///     ctor
 /// </summary>
 /// <param name="template"></param>
 public ParserOptions(ITemplateContainer template)
     : this(template, (Func <Stream>)null)
 {
 }