Rosetta.Translation.VariableDeclarationTranslationUnit.Create C# (CSharp) Méthode

Create() public static méthode

public static Create ( ITranslationUnit type, ITranslationUnit names, ITranslationUnit expressions = null, bool shouldRenderDeclarationKeyword = true ) : VariableDeclarationTranslationUnit
type ITranslationUnit
names ITranslationUnit
expressions ITranslationUnit
shouldRenderDeclarationKeyword bool
Résultat VariableDeclarationTranslationUnit
        public static VariableDeclarationTranslationUnit Create(
            ITranslationUnit type, ITranslationUnit[] names, ITranslationUnit[] expressions = null, 
            bool shouldRenderDeclarationKeyword = true)
        {
            if (names == null)
            {
                throw new ArgumentNullException(nameof(names));
            }
            if (names.Length == 0)
            {
                throw new ArgumentException(nameof(names), "At least one name needed!");
            }
            if (expressions != null && expressions.Length != names.Length)
            {
                throw new ArgumentException(nameof(expressions), "Number of expressions should match number of names!");
            }

            return new VariableDeclarationTranslationUnit()
            {
                names = names,
                type = type,
                expressions = expressions,
                shouldRenderDeclarationKeyword = shouldRenderDeclarationKeyword
            };
        }

Usage Example

 /// <summary>
 /// Initializes a new instance of the <see cref="ArgumentDefinitionTranslationUnit"/> class.
 /// </summary>
 /// <param name="typeName"></param>
 /// <param name="name"></param>
 protected ArgumentDefinitionTranslationUnit(ITranslationUnit typeName, ITranslationUnit name)
 {
     this.variableDeclaration = VariableDeclarationTranslationUnit.Create(typeName, name, null, false);
 }