using System;
namespace CapnpC.CSharp.Generator
{
///
/// Represents the generation result of a single .capnp file
///
public class FileGenerationResult
{
///
/// Constructs an instance in case of successful generation
///
/// path to .capnp file
/// generated C# code
public FileGenerationResult(string capnpFilePath, string generatedContent)
{
CapnpFilePath = capnpFilePath;
GeneratedContent = generatedContent;
}
///
/// Constructs an instance in case of unsuccessful generation
///
/// path to .capnp file
/// Exception giving details on the error which prevented generation
public FileGenerationResult(string capnpFilePath, Exception exception)
{
CapnpFilePath = capnpFilePath;
Exception = exception;
}
///
/// Path to .capnp file
///
public string CapnpFilePath { get; }
///
/// Generated C# or null if generation failed
///
public string GeneratedContent { get; }
///
/// Exception giving details on the error which prevented generation
///
public Exception Exception { get; }
///
/// true iff generation was successful
///
public bool IsSuccess => !string.IsNullOrEmpty(GeneratedContent);
}
}