상속: NClass.Core.Parameter
예제 #1
0
        /// <exception cref="BadSyntaxException">
        ///     The <paramref name="declaration" /> does not fit to the syntax.
        /// </exception>
        /// <exception cref="ReservedNameException">
        ///     The parameter name is already exists.
        /// </exception>
        public override Parameter Add(string declaration)
        {
            var match = singleParamterRegex.Match(declaration);

            if (match.Success)
            {
                var nameGroup     = match.Groups["name"];
                var typeGroup     = match.Groups["type"];
                var modifierGroup = match.Groups["modifier"];
                var defvalGroup   = match.Groups["defval"];

                if (IsReservedName(nameGroup.Value))
                {
                    throw new ReservedNameException(nameGroup.Value);
                }

                Parameter parameter = new CSharpParameter(nameGroup.Value,
                                                          typeGroup.Value,
                                                          ParseParameterModifier(modifierGroup.Value),
                                                          defvalGroup.Value);
                InnerList.Add(parameter);

                return(parameter);
            }
            throw new BadSyntaxException(
                      Strings.ErrorInvalidParameterDeclaration);
        }
        /// <exception cref="BadSyntaxException">
        /// The <paramref name="declaration"/> does not fit to the syntax.
        /// </exception>
        /// <exception cref="ReservedNameException">
        /// The parameter name is already exists.
        /// </exception>
        public override Parameter ModifyParameter(Parameter parameter, string declaration)
        {
            Match match = singleParamterRegex.Match(declaration);
            int   index = InnerList.IndexOf(parameter);

            if (index < 0)
            {
                return(parameter);
            }

            if (match.Success)
            {
                Group nameGroup     = match.Groups["name"];
                Group typeGroup     = match.Groups["type"];
                Group modifierGroup = match.Groups["modifier"];
                Group defvalGroup   = match.Groups["defval"];

                if (IsReservedName(nameGroup.Value, index))
                {
                    throw new ReservedNameException(nameGroup.Value);
                }

                Parameter newParameter = new CSharpParameter(nameGroup.Value, typeGroup.Value,
                                                             ParseParameterModifier(modifierGroup.Value), defvalGroup.Value);
                InnerList[index] = newParameter;
                return(newParameter);
            }
            else
            {
                throw new BadSyntaxException(
                          Strings.ErrorInvalidParameterDeclaration);
            }
        }
예제 #3
0
		/// <exception cref="BadSyntaxException">
		/// The <paramref name="declaration"/> does not fit to the syntax.
		/// </exception>
		/// <exception cref="ReservedNameException">
		/// The parameter name is already exists.
		/// </exception>
		public override Parameter Add(string declaration)
		{
			Match match = singleParamterRegex.Match(declaration);

			if (match.Success)
			{
				Group nameGroup = match.Groups["name"];
				Group typeGroup = match.Groups["type"];
				Group modifierGroup = match.Groups["modifier"];
				Group defvalGroup = match.Groups["defval"];

				if (IsReservedName(nameGroup.Value))
					throw new ReservedNameException(nameGroup.Value);

				Parameter parameter = new CSharpParameter(nameGroup.Value, typeGroup.Value,
					ParseParameterModifier(modifierGroup.Value), defvalGroup.Value);
				InnerList.Add(parameter);

				return parameter;
			}
			else
			{
				throw new BadSyntaxException(
					Strings.ErrorInvalidParameterDeclaration);
			}
		}
예제 #4
0
        /// <exception cref="BadSyntaxException">
        /// The <paramref name="declaration"/> does not fit to the syntax.
        /// </exception>
        /// <exception cref="ReservedNameException">
        /// The parameter name is already exists.
        /// </exception>
        public override Parameter Add(string declaration)
        {
            Match match = singleParamterRegex.Match(declaration);

            if (match.Success)
            {
                Group nameGroup     = match.Groups["name"];
                Group typeGroup     = match.Groups["type"];
                Group modifierGroup = match.Groups["modifier"];

                if (IsReservedName(nameGroup.Value))
                {
                    throw new ReservedNameException(nameGroup.Value);
                }

                Parameter parameter = new CSharpParameter(nameGroup.Value, typeGroup.Value,
                                                          ParseParameterModifier(modifierGroup.Value));
                InnerList.Add(parameter);

                return(parameter);
            }
            else
            {
                throw new BadSyntaxException(
                          Strings.GetString("error_invalid_parameter_declaration"));
            }
        }
예제 #5
0
        /// <exception cref="ReservedNameException">
        ///     The parameter name is already exists.
        /// </exception>
        public override Parameter Add(string name, string type, ParameterModifier modifier, string defaultValue)
        {
            if (IsReservedName(name))
            {
                throw new ReservedNameException(name);
            }

            Parameter parameter = new CSharpParameter(name, type, modifier, defaultValue);

            InnerList.Add(parameter);

            return(parameter);
        }
예제 #6
0
        /// <exception cref="BadSyntaxException">
        /// The <paramref name="declaration"/> does not fit to the syntax.
        /// </exception>
        /// <exception cref="ReservedNameException">
        /// The parameter name is already exists.
        /// </exception>
        public override Parameter Add(string declaration)
        {
            var param = CSharpParameterDeclaration.Create(declaration);

            if (IsReservedName(param.Name))
            {
                throw new ReservedNameException(param.Name);
            }

            var parameter = new CSharpParameter(param.Name, param.Type, param.Modifier, param.DefaultValue);

            InnerList.Add(parameter);

            return(parameter);
        }
예제 #7
0
        /// <exception cref="BadSyntaxException">
        /// The <paramref name="declaration"/> does not fit to the syntax.
        /// </exception>
        /// <exception cref="ReservedNameException">
        /// The parameter name is already exists.
        /// </exception>
        public override Parameter ModifyParameter(Parameter parameter, string declaration)
        {
            var param = CSharpParameterDeclaration.Create(declaration);
            var index = InnerList.IndexOf(parameter);

            if (index < 0)
            {
                return(parameter);
            }

            if (IsReservedName(param.Name, index))
            {
                throw new ReservedNameException(param.Name);
            }

            var newParameter = new CSharpParameter(param.Name, param.Type, param.Modifier, param.DefaultValue);

            InnerList[index] = newParameter;

            return(newParameter);
        }