Ejemplo n.º 1
0
 public Parameter(
     string name,
     ParameterTypeKind typeKind,
     ArgumentKind argumentKind       = ArgumentKind.Expression,
     IReadOnlyList <object> values   = null,
     IReadOnlyList <string> examples = null,
     bool isCaseSensitive            = false,
     string defaultValueIndicator    = null,
     int minOccurring        = 1,
     int maxOccurring        = 1,
     Expression defaultValue = null,
     string description      = null)
     : this(
         name,
         typeKind,
         null,
         argumentKind,
         values,
         examples,
         isCaseSensitive,
         defaultValueIndicator,
         minOccurring,
         maxOccurring,
         defaultValue,
         description)
 {
 }
Ejemplo n.º 2
0
        private Parameter(
            string name,
            ParameterTypeKind typeKind,
            TypeSymbol[] types,
            ArgumentKind argumentKind,
            IEnumerable <object> values,
            IEnumerable <string> examples,
            bool isCaseSensitive,
            string defaultValueIndicator,
            int minOccurring,
            int maxOccurring,
            Expression defaultValue,
            string description)
        {
            if (typeKind == ParameterTypeKind.Declared)
            {
                if (types == null)
                {
                    throw new ArgumentNullException(nameof(types));
                }
                else if (types.Length == 0)
                {
                    throw new ArgumentException("Must have at least one declared type.", nameof(types));
                }
            }

            this.Name          = name;
            this.TypeKind      = typeKind;
            this.DeclaredTypes = types.ToReadOnly();
            this.ArgumentKind  = argumentKind;
            this.Values        = values != null?values.ToReadOnly() : NoValues;

            this.Examples = examples != null?examples.ToReadOnly() : NoExamples;

            this.IsCaseSensitive       = isCaseSensitive;
            this.MinOccurring          = defaultValue != null ? 0 : minOccurring;
            this.MaxOccurring          = defaultValue != null ? 1 : maxOccurring;
            this.DefaultValueIndicator = defaultValueIndicator;
            this.DefaultValue          = defaultValue;
            this.Description           = description ?? "";
        }