Class TsModule
- Namespace
- TypedRest.CodeGeneration.TypeScript.Model
- Assembly
- TypedRest.CodeGeneration.TypeScript.dll
A TypeScript module that a type can be imported from.
public sealed class TsModule : IEquatable<TsModule>
- Inheritance
-
objectTsModule
- Implements
Properties
FilePath
The path of the file holding this module, relative to the output directory.
public string FilePath { get; }
Property Value
Exceptions
- InvalidOperationException
The module is not generated by this tool.
IsGenerated
Indicates whether this module is generated by this tool rather than provided by a package.
public bool IsGenerated { get; }
Property Value
Name
The last segment of the Specifier, which for a generated module is the name of the type it declares.
public string Name { get; }
Property Value
Specifier
The module specifier. For generated modules this is the file path without the extension.
public string Specifier { get; }
Property Value
Methods
Equals(object?)
Determines whether the specified object is equal to the current object.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current object.
Returns
Equals(TsModule?)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(TsModule? other)
Parameters
otherTsModuleAn object to compare with this object.
Returns
External(string)
A module provided by a package, e.g. typedrest/endpoints/generic.
public static TsModule External(string specifier)
Parameters
specifierstring
Returns
Generated(string)
A module generated by this tool, identified by its file path relative to the output directory without the
.ts extension, e.g. dtos/Contact.
public static TsModule Generated(string path)
Parameters
pathstring
Returns
GetHashCode()
Serves as the default hash function.
public override int GetHashCode()
Returns
- int
A hash code for the current object.
RelativeTo(string)
Returns the specifier to use when importing this module from the file at fromFilePath.
public string RelativeTo(string fromFilePath)
Parameters
fromFilePathstringThe path of the importing file relative to the output directory, e.g.
dtos/Contact.ts.
Returns
Remarks
Generated modules get a relative specifier without a file extension. External modules are returned as-is. This deliberately does not use Path, which would emit backslashes on Windows.
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.
WithName(string)
Returns a copy of this module in the same directory but with a different Name.
public TsModule WithName(string name)
Parameters
namestring