Class CSharpGenerator
- Namespace
- SunamoDevCode
- Assembly
- SunamoDevCode.dll
Generates C# source code including classes, fields, constructors, regions, and attributes.
public class CSharpGenerator : GeneratorCodeAbstract
- Inheritance
-
CSharpGenerator
- Inherited Members
- Extension Methods
Methods
AddIntoClass(List<string>, List<string>, out int, string)
EN: Inserts lines into a class before the closing brace CZ: Vloží řádky do třídy před uzavírací složenou závorku
public static List<string> AddIntoClass(List<string> lines, List<string> insertedLines, out int classIndex, string namespaceName)
Parameters
linesList<string>File content as list of lines
insertedLinesList<string>Lines to insert into the class
classIndexintOutput: index of the class declaration line
namespaceNamestringNamespace name to process
Returns
AddValuesViaAddRange(int, string, string, string, List<string>, CSharpGeneratorArgs)
EN: Generates code to add multiple values to a collection via AddRange. Args.AddHyphens determines whether to wrap values in quotes. CZ: Generuje kód pro přidání více hodnot do kolekce pomocí AddRange. Args.AddHyphens určuje, zda obalit hodnoty do uvozovek.
public void AddValuesViaAddRange(int tabCount, string objectName, string collectionName, string type, List<string> values, CSharpGeneratorArgs args)
Parameters
tabCountintNumber of tabs for indentation
objectNamestringName of the object (can be null for static classes)
collectionNamestringName of the collection to add to
typestringType of the array elements
valuesList<string>Values to add to the collection
argsCSharpGeneratorArgsGenerator arguments (AddHyphens, etc.)
AddValuesViaAddRange(int, string, string, Type, List<string>, CSharpGeneratorArgs)
EN: Generates code to add multiple values to a collection via AddRange (Type overload). If you don't want to use object identifier (e.g., for static classes), pass null for objectName. CZ: Generuje kód pro přidání více hodnot do kolekce pomocí AddRange (Type přetížení). Pokud nechcete použít identifikátor objektu (např. u statické třídy), předejte null pro objectName.
public void AddValuesViaAddRange(int tabCount, string objectName, string collectionName, Type type, List<string> values, CSharpGeneratorArgs args)
Parameters
tabCountintNumber of tabs for indentation
objectNamestringName of the object (can be null for static classes)
collectionNamestringName of the collection to add to
typeTypeType of the array elements
valuesList<string>Values to add to the collection
argsCSharpGeneratorArgsGenerator arguments (AddHyphens, etc.)
AssignValue(int, string, string, string, CSharpGeneratorArgs)
EN: Generates an assignment statement (objectName.variable = value). Args.AddHyphens determines whether to wrap value in quotes. CZ: Generuje přiřazovací příkaz (objectName.variable = value). Args.AddHyphens určuje, zda obalit hodnotu do uvozovek.
public void AssignValue(int tabCount, string objectName, string variableName, string value, CSharpGeneratorArgs args)
Parameters
tabCountintNumber of tabs for indentation
objectNamestringName of the object
variableNamestringName of the variable/property to assign to
valuestringValue to assign
argsCSharpGeneratorArgsGenerator arguments (AddHyphens, etc.)
Attribute(int, string, string)
EN: Generates an attribute with parameters CZ: Generuje atribut s parametry
public void Attribute(int tabCount, string attributeName, string attributeParameters)
Parameters
tabCountintNumber of tabs for indentation
attributeNamestringName of the attribute
attributeParametersstringParameters for the attribute
CreateEnumItemsFromList(List<string>)
EN: Creates a list of EnumItem objects from a list of strings CZ: Vytvoří seznam EnumItem objektů ze seznamu stringů
public static List<EnumItem> CreateEnumItemsFromList(List<string> list)
Parameters
Returns
Ctor(int, ModifiersConstructor, string, bool, bool, params string[])
EN: Generates a constructor with automatic field assignment. Parameters are stored in pairs: type, name, type, name. Static constructors cannot be created here. CZ: Generuje konstruktor s automatickým přiřazením polí. Parametry jsou uloženy v párech: typ, název, typ, název. Statický konstruktor zde nelze vytvořit.
public void Ctor(int tabCount, ModifiersConstructor modifierType, string constructorName, bool autoAssign, bool isBase, params string[] parameters)
Parameters
tabCountintNumber of tabs for indentation
modifierTypeModifiersConstructorConstructor modifier (public, private, etc.)
constructorNamestringName of the constructor (should match class name)
autoAssignboolWhether to automatically assign parameters to fields
isBaseboolWhether this is a base class constructor
parametersstring[]Alternating type and name pairs for parameters
Ctor(int, ModifiersConstructor, string, string, params string[])
EN: Generates a constructor declaration with parameters CZ: Generuje deklaraci konstruktoru s parametry
public void Ctor(int tabCount, ModifiersConstructor modifierType, string constructorName, string bodyContent, params string[] parameters)
Parameters
tabCountintNumber of tabs for indentation
modifierTypeModifiersConstructorConstructor modifier (public, private, etc.)
constructorNamestringName of the constructor (should match class name)
bodyContentstringContent of the constructor body
parametersstring[]Alternating type and name pairs for parameters (type1, name1, type2, name2, ...)
DictionaryFromDictionaryInnerList<Key, Value>(int, string, Dictionary<Key, Value>, CSharpGeneratorArgs)
EN: Generates a Dictionary with List values from another dictionary. Default: addingValue = true. CZ: Generuje Dictionary s hodnotami List z jiného dictionary. Výchozí: addingValue = true.
public void DictionaryFromDictionaryInnerList<Key, Value>(int tabCount, string dictionaryName, Dictionary<Key, Value> dictionary, CSharpGeneratorArgs args) where Key : notnull
Parameters
tabCountintNumber of tabs for indentation
dictionaryNamestringName of the dictionary variable
dictionaryDictionary<Key, Value>Source dictionary
argsCSharpGeneratorArgsGenerator arguments
Type Parameters
KeyType of dictionary keys
ValueType of list values
DictionaryFromDictionary<Key, Value>(int, string, Dictionary<Key, Value>, CSharpGeneratorArgs?)
EN: Generates a Dictionary from another dictionary. Args.AddingValue = true. CZ: Generuje Dictionary z jiného dictionary. Args.AddingValue = true.
public void DictionaryFromDictionary<Key, Value>(int tabCount, string dictionaryName, Dictionary<Key, Value> dictionary, CSharpGeneratorArgs? args = null) where Key : notnull
Parameters
tabCountintNumber of tabs for indentation
dictionaryNamestringName of the dictionary variable
dictionaryDictionary<Key, Value>Source dictionary
argsCSharpGeneratorArgsGenerator arguments (AddingValue = true)
Type Parameters
KeyType of dictionary keys
ValueType of dictionary values
DictionaryFromRandomValue<Key, Value>(int, string, List<Key>, Func<Value>, CSharpGeneratorArgs?)
EN: Generates a Dictionary with keys and random values. Args.AddingValue = true as default. CZ: Generuje Dictionary s klíči a náhodnými hodnotami. Args.AddingValue = true jako výchozí.
public void DictionaryFromRandomValue<Key, Value>(int tabCount, string dictionaryName, List<Key> keys, Func<Value> randomValueGenerator, CSharpGeneratorArgs? args = null) where Key : notnull
Parameters
tabCountintNumber of tabs for indentation
dictionaryNamestringName of the dictionary variable
keysList<Key>List of keys
randomValueGeneratorFunc<Value>Function to generate random values
argsCSharpGeneratorArgsGenerator arguments (AddingValue = true as default)
Type Parameters
KeyType of dictionary keys
ValueType of dictionary values
DictionaryFromTwoList<Key, Value>(int, string, List<Key>, List<Value>, CSharpGeneratorArgs?)
EN: Generates a Dictionary from two lists (keys and values). Args.AddingValue = true was default. CZ: Generuje Dictionary ze dvou seznamů (klíče a hodnoty). Args.AddingValue = true byl výchozí.
public void DictionaryFromTwoList<Key, Value>(int tabCount, string dictionaryName, List<Key> keys, List<Value> values, CSharpGeneratorArgs? args = null) where Key : notnull
Parameters
tabCountintNumber of tabs for indentation
dictionaryNamestringName of the dictionary variable
keysList<Key>List of keys
valuesList<Value>List of values
argsCSharpGeneratorArgsGenerator arguments
Type Parameters
KeyType of dictionary keys
ValueType of dictionary values
DictionaryNumberNumber<T, U>(int, string, Dictionary<T, U>, CSharpGeneratorArgs?)
EN: Generates a Dictionary with numeric key-value pairs. Args.AddingValue = true as default. CZ: Generuje Dictionary s číselnými páry klíč-hodnota. Args.AddingValue = true jako výchozí.
public void DictionaryNumberNumber<T, U>(int tabCount, string dictionaryName, Dictionary<T, U> dictionary, CSharpGeneratorArgs? args = null) where T : notnull where U : notnull
Parameters
tabCountintNumber of tabs for indentation
dictionaryNamestringName of the dictionary variable
dictionaryDictionary<T, U>Dictionary with key-value pairs
argsCSharpGeneratorArgsGenerator arguments (AddingValue = true as default)
Type Parameters
TType of dictionary keys
UType of dictionary values
DictionaryStringListString(int, string, Dictionary<string, List<string>>, CSharpGeneratorArgs?)
EN: Generates a Dictionary<string, List<string>>. Args.CreateInstance = true as default. CZ: Generuje Dictionary<string, List<string>>. Args.CreateInstance = true jako výchozí.
public void DictionaryStringListString(int tabCount, string dictionaryName, Dictionary<string, List<string>> dictionary, CSharpGeneratorArgs? args = null)
Parameters
tabCountintNumber of tabs for indentation
dictionaryNamestringName of the dictionary variable
dictionaryDictionary<string, List<string>>Dictionary with string keys and string list values
argsCSharpGeneratorArgsGenerator arguments (CreateInstance = true as default)
DictionaryStringObject<Value>(int, string, Dictionary<string, Value>, CSharpGeneratorArgs)
EN: Generates a Dictionary<string, object> with values. Args.AddingValue = true as default. CZ: Generuje Dictionary<string, object> s hodnotami. Args.AddingValue = true jako výchozí.
public void DictionaryStringObject<Value>(int tabCount, string dictionaryName, Dictionary<string, Value> dictionary, CSharpGeneratorArgs args)
Parameters
tabCountintNumber of tabs for indentation
dictionaryNamestringName of the dictionary variable
dictionaryDictionary<string, Value>Source dictionary
argsCSharpGeneratorArgsGenerator arguments (AddingValue = true as default)
Type Parameters
ValueType of dictionary values
DictionaryStringString(int, string, Dictionary<string, string>, CSharpGeneratorArgs?)
EN: Generates a Dictionary<string, string>. Args.AddingValue = true as default. CZ: Generuje Dictionary<string, string>. Args.AddingValue = true jako výchozí.
public void DictionaryStringString(int tabCount, string dictionaryName, Dictionary<string, string> dictionary, CSharpGeneratorArgs? args = null)
Parameters
tabCountintNumber of tabs for indentation
dictionaryNamestringName of the dictionary variable
dictionaryDictionary<string, string>Dictionary with string key-value pairs
argsCSharpGeneratorArgsGenerator arguments (AddingValue = true as default)
Else(int)
EN: Generates an else statement with opening brace. Automatically adds the opening brace. CZ: Generuje else příkaz s otevírací závorkou. Automaticky přidává počáteční závorku.
public void Else(int tabCount)
Parameters
tabCountintNumber of tabs for indentation
EndRegion(int)
EN: Writes the end of a region directive CZ: Zapíše konec region direktivy
public void EndRegion(int tabCount)
Parameters
tabCountintNumber of tabs for indentation
Enum(int, AccessModifiers, string, List<EnumItem>)
EN: Generates an enum with XML comments and optional attributes for each member CZ: Generuje enum s XML komentáři a volitelnými atributy pro každý člen
public void Enum(int tabCount, AccessModifiers accessModifier, string enumName, List<EnumItem> enumItems)
Parameters
tabCountintNumber of tabs for indentation
accessModifierAccessModifiersAccess modifier for the enum
enumNamestringName of the enum
enumItemsList<EnumItem>List of enum items with their properties
EnumWithComments(int, AccessModifiers, string, Dictionary<string, string>)
EN: Generates an enum with XML summary comments for each member CZ: Generuje enum s XML summary komentáři pro každý člen
public void EnumWithComments(int tabCount, AccessModifiers accessModifier, string enumName, Dictionary<string, string> memberComments)
Parameters
tabCountintNumber of tabs for indentation
accessModifierAccessModifiersAccess modifier for the enum
enumNamestringName of the enum
memberCommentsDictionary<string, string>Dictionary mapping enum member names to their comments
Field(int, AccessModifiers, bool, VariableModifiers, string, string, ObjectInitializationOptions, string)
EN: Generates a field declaration with initialization CZ: Generuje deklaraci pole s inicializací
public void Field(int tabCount, AccessModifiers accessModifier, bool isStatic, VariableModifiers variableModifiers, string type, string name, ObjectInitializationOptions initializationOption, string value)
Parameters
tabCountintNumber of tabs for indentation
accessModifierAccessModifiersAccess modifier for the field. Private modifier is omitted (default).
isStaticboolWhether the field should be static. Ignored if initializationOption is NewAssign.
variableModifiersVariableModifiersVariable modifiers (const, readonly, etc.)
typestringType of the field
namestringName of the field
initializationOptionObjectInitializationOptionsHow to initialize the field: Original (use value as-is), Hyphens (add quotes), or NewAssign (use new constructor)
valuestringInitial value. If initializationOption is NewAssign, use string.Empty for empty constructor. If Original, put the part after =. Cannot be null.
Field(int, AccessModifiers, bool, VariableModifiers, string, string, bool)
EN: Generates a field declaration with optional default value CZ: Generuje deklaraci pole s volitelnou výchozí hodnotou
public void Field(int tabCount, AccessModifiers accessModifier, bool isStatic, VariableModifiers variableModifiers, string type, string name, bool isUsingDefaultValue)
Parameters
tabCountintNumber of tabs for indentation
accessModifierAccessModifiersAccess modifier for the field
isStaticboolWhether the field should be static
variableModifiersVariableModifiersVariable modifiers (const, readonly, etc.)
typestringType of the field
namestringName of the field
isUsingDefaultValueboolWhether to add a default value for the type
Field(int, AccessModifiers, bool, VariableModifiers, string, string, bool, string)
EN: Generates a field declaration with optional quotation of the value CZ: Generuje deklaraci pole s volitelným přidáním uvozovek k hodnotě
public void Field(int tabCount, AccessModifiers accessModifier, bool isStatic, VariableModifiers variableModifiers, string type, string name, bool isAddingHyphensToValue, string value)
Parameters
tabCountintNumber of tabs for indentation
accessModifierAccessModifiersAccess modifier for the field
isStaticboolWhether the field should be static
variableModifiersVariableModifiersVariable modifiers (const, readonly, etc.)
typestringType of the field
namestringName of the field
isAddingHyphensToValueboolWhether to add quotes around the value
valuestringInitial value of the field
GetDictionaryValuesFromDictionaryInnerList<Key, Value>(int, string, Dictionary<Key, List<Value>>, CSharpGeneratorArgs)
EN: Generates dictionary value assignments from a dictionary with List values CZ: Generuje přiřazení hodnot do dictionary ze slovníku s hodnotami List
public void GetDictionaryValuesFromDictionaryInnerList<Key, Value>(int tabCount, string dictionaryName, Dictionary<Key, List<Value>> dictionary, CSharpGeneratorArgs args) where Key : notnull
Parameters
tabCountintNumber of tabs for indentation
dictionaryNamestringName of the dictionary variable
dictionaryDictionary<Key, List<Value>>Source dictionary
argsCSharpGeneratorArgsGenerator arguments (AlsoField, UseCA, etc.)
Type Parameters
KeyType of dictionary keys
ValueType of list values
GetDictionaryValuesFromDictionary<Key, Value>(int, string, Dictionary<Key, Value>)
EN: Generates dictionary value assignments from a dictionary CZ: Generuje přiřazení hodnot do dictionary ze slovníku
public void GetDictionaryValuesFromDictionary<Key, Value>(int tabCount, string dictionaryName, Dictionary<Key, Value> dictionary) where Key : notnull
Parameters
tabCountintNumber of tabs for indentation
dictionaryNamestringName of the dictionary variable
dictionaryDictionary<Key, Value>Source dictionary
Type Parameters
KeyType of dictionary keys
ValueType of dictionary values
GetDictionaryValuesFromRandomValue<Key, Value>(int, string, List<Key>, Func<Value>)
EN: Generates dictionary value assignments from random values CZ: Generuje přiřazení hodnot do dictionary z náhodných hodnot
public void GetDictionaryValuesFromRandomValue<Key, Value>(int tabCount, string dictionaryName, List<Key> keys, Func<Value> randomValueGenerator) where Key : notnull
Parameters
tabCountintNumber of tabs for indentation
dictionaryNamestringName of the dictionary variable
keysList<Key>List of keys
randomValueGeneratorFunc<Value>Function to generate random values
Type Parameters
KeyType of dictionary keys
ValueType of dictionary values
GetDictionaryValuesFromTwoList<Key, Value>(int, string, List<Key>, List<Value>, CSharpGeneratorArgs)
EN: Generates dictionary value assignments from two lists. Args.SplitKeyWith allows splitting keys. CZ: Generuje přiřazení hodnot do dictionary ze dvou seznamů. Args.SplitKeyWith umožňuje rozdělení klíčů.
public void GetDictionaryValuesFromTwoList<Key, Value>(int tabCount, string dictionaryName, List<Key> keys, List<Value> values, CSharpGeneratorArgs args) where Key : notnull
Parameters
tabCountintNumber of tabs for indentation
dictionaryNamestringName of the dictionary variable
keysList<Key>List of keys
valuesList<Value>List of values
argsCSharpGeneratorArgsGenerator arguments (SplitKeyWith, etc.)
Type Parameters
KeyType of dictionary keys
ValueType of dictionary values
GetTKeyAndTValue<Key, Value>(Dictionary<Key, List<Value>>, out Type, out Type, out Key)
EN: Extracts key and value types from a dictionary with list values CZ: Získá typy klíče a hodnoty ze slovníku s hodnotami typu list
public static void GetTKeyAndTValue<Key, Value>(Dictionary<Key, List<Value>> dictionary, out Type keyType, out Type valueType, out Key firstKey) where Key : notnull
Parameters
dictionaryDictionary<Key, List<Value>>Source dictionary
keyTypeTypeOutput: key type
valueTypeTypeOutput: value type
firstKeyKeyOutput: first key from dictionary
Type Parameters
KeyType of dictionary keys
ValueType of list values
If(int, string)
EN: Generates an if statement with opening brace. Automatically adds the opening brace. CZ: Generuje if příkaz s otevírací závorkou. Automaticky přidává počáteční závorku.
public void If(int tabCount, string condition)
Parameters
List(int, string, string, List<string>, CSharpGeneratorArgs?)
EN: Generates a list initialization with specified generic type. Default: adds quotes to string values. CZ: Generuje inicializaci seznamu se zadaným generickým typem. Výchozí: přidává uvozovky k řetězcovým hodnotám.
public void List(int tabCount, string genericType, string listName, List<string> list, CSharpGeneratorArgs? args = null)
Parameters
tabCountintNumber of tabs for indentation
genericTypestringGeneric type parameter for the list (e.g., "string", "int")
listNamestringName of the list variable
listList<string>List of values to initialize with
argsCSharpGeneratorArgsOptional arguments for list generation (default: AddHyphens = true)
Method(int, AccessModifiers, bool, string, string, string, string)
EN: Generates a method declaration with body. The inner content must already be indented for this method. CZ: Generuje deklaraci metody s tělem. Vnitřní obsah již musí být odsazený pro tuto metodu.
public void Method(int tabCount, AccessModifiers accessModifier, bool isStatic, string returnType, string name, string bodyContent, string parametersDeclaration)
Parameters
tabCountintNumber of tabs for indentation
accessModifierAccessModifiersAccess modifier for the method
isStaticboolWhether the method is static
returnTypestringReturn type of the method
namestringName of the method
bodyContentstringBody content of the method (already indented)
parametersDeclarationstringMethod parameters declaration
Method(int, string, string)
EN: Generates a method with pre-formatted header and body content CZ: Generuje metodu s předformátovanou hlavičkou a obsahem těla
public void Method(int tabCount, string header, string bodyContent)
Parameters
tabCountintNumber of tabs for indentation
headerstringPre-formatted method header
bodyContentstringBody content of the method
Namespace(string)
EN: Generates a namespace declaration CZ: Generuje deklaraci namespace
public void Namespace(string namespaceName)
Parameters
namespaceNamestringName of the namespace
Property(int, AccessModifiers, bool, string, string, object, object, string, bool, bool)
EN: Generates a property with getter and setter. The get and set parameters can be string (custom implementation) or bool (auto-implementation). CZ: Generuje vlastnost s getterem a setterem. Parametry get a set mohou být string (vlastní implementace) nebo bool (auto-implementace).
public void Property(int tabCount, AccessModifiers accessModifier, bool isStatic, string returnType, string name, object getImplementation, object setImplementation, string field, bool shortGet, bool shortSet)
Parameters
tabCountintNumber of tabs for indentation
accessModifierAccessModifiersAccess modifier for the property
isStaticboolWhether the property is static
returnTypestringType of the property
namestringName of the property
getImplementationobjectGetter implementation: true for auto-implementation, string for custom code, null/false for none
setImplementationobjectSetter implementation: true for auto-implementation, string for custom code, null/false for none
fieldstringBacking field name
shortGetboolWhether to use short getter syntax (get;)
shortSetboolWhether to use short setter syntax (set;)
Region(int, string)
EN: Writes the start of a region directive with a name CZ: Zapíše začátek region direktivy se jménem
public void Region(int tabCount, string regionName)
Parameters
StartClass(int, AccessModifiers, bool, string, params string[])
EN: Generates the start of a class declaration with optional inheritance CZ: Generuje začátek deklarace třídy s volitelným děděním
public void StartClass(int tabCount, AccessModifiers accessModifier, bool isStatic, string className, params string[] derivedTypes)
Parameters
tabCountintNumber of tabs for indentation
accessModifierAccessModifiersAccess modifier for the class
isStaticboolWhether the class should be static
classNamestringName of the class
derivedTypesstring[]Base types or interfaces to derive from
This(int, string)
EN: Generates a this.memberName reference CZ: Generuje odkaz na this.memberName
public void This(int tabCount, string memberName)
Parameters
Using(string)
EN: Generates a using directive, automatically adding 'using' keyword and semicolon if needed CZ: Generuje using direktivu, automaticky přidává klíčové slovo 'using' a středník pokud chybí
public void Using(string usingStatement)
Parameters
usingStatementstringUsing statement (with or without 'using' keyword and semicolon)