/// <summary>
        /// Extension method that generates the default value syntax for a parameter in the C# language.
        /// </summary>
        /// <param name="source">The target default value to format.</param>
        /// <param name="type">The target type of the value to be formatted.</param>
        /// <returns>The fully formatted syntax for the default value or null if data was missing.</returns>
        public static string FormatCSharpParameterDefaultValueSyntax(this CsParameterDefaultValue source, CsType type)
        {
            var dotNetParameterDefaultValue = source as IDotNetParameterDefaultValue;
            var dotNetType = type as IDotNetType;

            return(dotNetParameterDefaultValue.FormatCSharpParameterDefaultValueSyntax(dotNetType));
        }
Beispiel #2
0
 /// <summary>
 /// Constructor for the <see cref="CsParameter"/>
 /// </summary>
 /// <param name="isLoaded">Flag that determines if the model was loaded.</param>
 /// <param name="hasErrors">Flag that determine if errors were found creating the model.</param>
 /// <param name="loadedFromSource">Flag that determines if the model was loaded from source code or from an existing library.</param>
 /// <param name="language">The target language the model was generated from.</param>
 /// <param name="defaultValue">The default value assigned to this parameter.</param>
 /// <param name="sourceDocument">The source document that was used to build this model. This is optional parameter and can be null.</param>
 /// <param name="modelStore">Optional the lookup storage for models created during the compile or lookup of the model.</param>
 /// <param name="modelErrors">Optional the error that occured while creating the model.</param>
 /// <param name="attributes">Attributes assigned to this model.</param>
 /// <param name="lookupPath">The fully qualified path of the model that is stored in the model store.</param>
 /// <param name="name">The name of the parameter.</param>
 /// <param name="isOut">Parameter is assigned the out keyword.</param>
 /// <param name="isRef">Parameter is assigned the ref keyword.</param>
 /// <param name="isParams">Parameter supports a parameter array.</param>
 /// <param name="isOptional">Parameter is optional.</param>
 /// <param name="isGenericParameter">Is a generic parameter.</param>
 /// <param name="hasDefaultValue">Parameter has an assigned default value.</param>
 /// <param name="parentPath">The fully qualified path name for the parent model to this model.</param>
 /// <param name="parameterType">The type that this parameter supports.</param>
 protected CsParameter(bool isLoaded, bool hasErrors, bool loadedFromSource, SourceCodeType language,
                       IReadOnlyList <CsAttribute> attributes, string lookupPath, string name, bool isOut, bool isRef, bool isParams,
                       bool isOptional, bool isGenericParameter, bool hasDefaultValue, string parentPath, CsType parameterType,
                       CsParameterDefaultValue defaultValue, string sourceDocument = null, ModelStore <ICsModel> modelStore = null,
                       IReadOnlyList <ModelLoadException> modelErrors = null)
     : base(isLoaded, hasErrors, loadedFromSource, language, CsModelType.Parameter, sourceDocument, modelStore, modelErrors)
 {
     _attributes         = attributes ?? ImmutableList <CsAttribute> .Empty;
     _lookupPath         = lookupPath;
     _name               = name;
     _isOut              = isOut;
     _isRef              = isRef;
     _isParams           = isParams;
     _isOptional         = isOptional;
     _isGenericParameter = isGenericParameter;
     _hasDefaultValue    = hasDefaultValue;
     _parentPath         = parentPath;
     _parameterType      = parameterType;
     _defaultValue       = defaultValue;
 }