Class NamespaceManager
Utility class that allows you to load in a collection of namespaces that will be used for code formatting operations for the C# programming language.
Inherited Members
Namespace: CodeFactory.Formatting.CSharp
Assembly: CodeFactory.Formatting.CSharp.dll
Syntax
public class NamespaceManager
Constructors
| Improve this Doc View SourceNamespaceManager(IEnumerable<ICsUsingStatement>, string)
Creates an instance of the NamespaceManager
Declaration
public NamespaceManager(IEnumerable<ICsUsingStatement> usingStatements, string targetNamespace = null)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<ICsUsingStatement> | usingStatements | Using statements to be used for formatting in code output. |
string | targetNamespace | Additional namespace to check for that will be the target namespace the content will be managed under. |
Methods
| Improve this Doc View SourceAddNamespace(ICsUsingStatement)
Adds additional namespace to the namespace manager.
Declaration
public NamespaceManager AddNamespace(ICsUsingStatement nameSpace)
Parameters
Type | Name | Description |
---|---|---|
ICsUsingStatement | nameSpace | Using statement to add to the namespace manager. |
Returns
Type | Description |
---|---|
NamespaceManager | New instance of the namespace manager with the added using statements. |
AddNamespace(string, string)
Adds an additional namespace to the namespace manager.
Declaration
public NamespaceManager AddNamespace(string nameSpace, string alias = null)
Parameters
Type | Name | Description |
---|---|---|
string | nameSpace | Target namespace to be added to the manager. |
string | alias | Optional, the alias to assign to the target namespace. |
Returns
Type | Description |
---|---|
NamespaceManager |
AddNamespaces(IEnumerable<ICsUsingStatement>)
Adds additional namespaces to the namespace manager.
Declaration
public NamespaceManager AddNamespaces(IEnumerable<ICsUsingStatement> nameSpaces)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<ICsUsingStatement> | nameSpaces | Using statements to add to the namespace manager. |
Returns
Type | Description |
---|---|
NamespaceManager | New instance of the namespace manager with the added using statements. |
AppendingNamespace(string)
Defines the appending namespace that will be appended to types or other declares based on if the namespace is currently supported by using or namespace definitions.
Declaration
public string AppendingNamespace(string nameSpace)
Parameters
Type | Name | Description |
---|---|---|
string | nameSpace | Namespace to format |
Returns
Type | Description |
---|---|
string | Null if the namespace is not needed or the formatted substring of the namespace used in declarations and other actions. |
ValidNameSpace(string)
Determines if the provides namespace was found.
Declaration
public (bool namespaceFound, bool hasAlias, string alias) ValidNameSpace(string nameSpace)
Parameters
Type | Name | Description |
---|---|---|
string | nameSpace | The namespace to search for in the namespace manager. |
Returns
Type | Description |
---|---|
(bool namespaceFound, bool hasAlias, string alias) | Returns a tuple that determine the namespace was found and if the found namespace had an alias. |