Skip to content

Commit

Permalink
Merge pull request #140 from MichaelCleverdon/Documentation
Browse files Browse the repository at this point in the history
Adding documentation to RazorEngineCompilationOptionsBuilder
  • Loading branch information
adoconnection committed Feb 23, 2024
2 parents 64dbcd9 + e32f1cc commit 6045d53
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
41 changes: 41 additions & 0 deletions RazorEngineCore/IRazorEngineCompilationOptionsBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,53 @@ public interface IRazorEngineCompilationOptionsBuilder
{
RazorEngineCompilationOptions Options { get; set; }

/// <summary>
/// Loads the Assembly by name and adds it to the Engine's Assembly Reference list
/// </summary>
/// <param name="assemblyName">Full Name of the Assembly to add to the assembly list</param>
void AddAssemblyReferenceByName(string assemblyName);

/// <summary>
/// Adds a loaded assembly to the Engine's Assembly Reference list
/// </summary>
/// <param name="assembly">Assembly to add to the assembly list</param>
void AddAssemblyReference(Assembly assembly);

/// <summary>
/// <para>Adds a type's assembly to the Engine's Assembly Reference list</para>
/// <para>Also adds the type's GenericTypeArguments to the Reference list as well</para>
/// </summary>
/// <param name="type">The type who's assembly should be added to the assembly list</param>
void AddAssemblyReference(Type type);

/// <summary>
/// Adds a MetadataReference for use in the Engine's Assembly Reference generation
/// </summary>
/// <param name="reference">Metadata Reference to add to the Engine's Referenced Assemblies</param>
void AddMetadataReference(MetadataReference reference);

/// <summary>
/// <para>Adds a default <c>using</c> to the compiled view. This is equivalent to adding <c>@using [NAMESPACE]</c> to every template rendered by the engine'</para>
/// Current Defaults:
/// <list type="bullet">
/// <listheader></listheader>
/// <item>System.Linq</item>
/// <item>System.Collections</item>
/// <item>System.Collections.Generic</item>
/// </list>
/// </summary>
/// <param name="namespaceName">Namespace to add to default usings</param>
void AddUsing(string namespaceName);

/// <summary>
/// Adds <c>@inherits</c> directive to the compiled template
/// </summary>
/// <param name="type">Type to <c>@inherits</c> from</param>
void Inherits(Type type);

/// <summary>
/// Enables debug info
/// </summary>
void IncludeDebuggingInfo();
}
}
35 changes: 35 additions & 0 deletions RazorEngineCore/RazorEngineCompilationOptionsBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,30 @@ public RazorEngineCompilationOptionsBuilder(RazorEngineCompilationOptions option
this.Options = options ?? new RazorEngineCompilationOptions();
}

/// <summary>
/// Loads the Assembly by name and adds it to the Engine's Assembly Reference list
/// </summary>
/// <param name="assemblyName">Full Name of the Assembly to add to the assembly list</param>
public void AddAssemblyReferenceByName(string assemblyName)
{
Assembly assembly = Assembly.Load(new AssemblyName(assemblyName));
this.AddAssemblyReference(assembly);
}

/// <summary>
/// Adds a loaded assembly to the Engine's Assembly Reference list
/// </summary>
/// <param name="assembly">Assembly to add to the assembly list</param>
public void AddAssemblyReference(Assembly assembly)
{
this.Options.ReferencedAssemblies.Add(assembly);
}

/// <summary>
/// <para>Adds a type's assembly to the Engine's Assembly Reference list</para>
/// <para>Also adds the type's GenericTypeArguments to the Reference list as well</para>
/// </summary>
/// <param name="type">The type who's assembly should be added to the assembly list</param>
public void AddAssemblyReference(Type type)
{
this.AddAssemblyReference(type.Assembly);
Expand All @@ -36,16 +49,35 @@ public void AddAssemblyReference(Type type)
}
}

/// <summary>
/// Adds a MetadataReference for use in the Engine's Assembly Reference generation
/// </summary>
/// <param name="reference">Metadata Reference to add to the Engine's Referenced Assemblies</param>
public void AddMetadataReference(MetadataReference reference)
{
this.Options.MetadataReferences.Add(reference);
}

/// <summary>
/// <para>Adds a default <c>using</c> to the compiled view. This is equivalent to adding <c>@using [NAMESPACE]</c> to the template rendered by the engine'</para>
/// Current Defaults:
/// <list type="bullet">
/// <listheader></listheader>
/// <item>System.Linq</item>
/// <item>System.Collections</item>
/// <item>System.Collections.Generic</item>
/// </list>
/// </summary>
/// <param name="namespaceName">Namespace to add to default usings</param>
public void AddUsing(string namespaceName)
{
this.Options.DefaultUsings.Add(namespaceName);
}

/// <summary>
/// Adds <c>@inherits</c> directive to the compiled template
/// </summary>
/// <param name="type">Type to <c>@inherits</c> from</param>
public void Inherits(Type type)
{
this.Options.Inherits = this.RenderTypeName(type);
Expand Down Expand Up @@ -94,6 +126,9 @@ private string RenderDeclaringType(Type type)
return parent + "." + type.Name;
}

/// <summary>
/// Enables debug info
/// </summary>
public void IncludeDebuggingInfo()
{
this.Options.IncludeDebuggingInfo = true;
Expand Down

0 comments on commit 6045d53

Please sign in to comment.