/// <summary> /// Loads and retrieves the bundled transformation messages. /// </summary> /// <param name="this">The content service.</param> /// <returns>A retrieval result which may or may not have succeeded.</returns> public static RetrieveEntityResult <TransformationText> GetTransformationMessages ( [NotNull] this ContentService @this ) { if ([email protected](TransformationMessagesPath)) { return(RetrieveEntityResult <TransformationText> .FromError("Transformation messages not found.")); } using ( var reader = new StreamReader ( @this.FileSystem.OpenFile ( TransformationMessagesPath, FileMode.Open, FileAccess.Read, FileShare.Read ) ) ) { var content = reader.ReadToEnd(); if (!TransformationText.TryDeserialize(content, out var text)) { return(RetrieveEntityResult <TransformationText> .FromError("Failed to parse the messages.")); } return(RetrieveEntityResult <TransformationText> .FromSuccess(text)); } }
/// <summary> /// Loads and retrieves the bundled transformation messages. /// </summary> /// <param name="this">The content service.</param> /// <returns>A retrieval result which may or may not have succeeded.</returns> public static Result <TransformationText> GetTransformationMessages ( this ContentService @this ) { if ([email protected](TransformationMessagesPath)) { return(new InvalidOperationError("Transformation messages not found.")); } using var reader = new StreamReader ( @this.FileSystem.OpenFile ( TransformationMessagesPath, FileMode.Open, FileAccess.Read, FileShare.Read ) ); var content = reader.ReadToEnd(); return(TransformationText.TryDeserialize(content, out var text) ? Result <TransformationText> .FromSuccess(text) : new ParsingError <TransformationText>("Failed to parse the messages.")); }
/// <summary> /// Initializes a new instance of the <see cref="TransformationDescriptionBuilder"/> class. /// </summary> /// <param name="services">The available services.</param> /// <param name="transformationText">The content service.</param> public TransformationDescriptionBuilder ( [NotNull] IServiceProvider services, [NotNull] TransformationText transformationText ) { _tokenizer = new TransformationTextTokenizer(services); _tokenizer.DiscoverAvailableTokens(); _transformationText = transformationText; }