NClass.CSharp.CSharpField.InitFromString C# (CSharp) Method

InitFromString() public method

/// The does not fit to the syntax. ///
public InitFromString ( string declaration ) : void
declaration string
return void
		public override void InitFromString(string declaration)
		{
			Match match = fieldRegex.Match(declaration);
			RaiseChangedEvent = false;

			try {
				if (match.Success) {
					ClearModifiers();
					Group nameGroup = match.Groups["name"];
					Group typeGroup = match.Groups["type"];
					Group accessGroup = match.Groups["access"];
					Group modifierGroup = match.Groups["modifier"];
					Group initGroup = match.Groups["initvalue"];

					if (CSharpLanguage.Instance.IsForbiddenName(nameGroup.Value))
						throw new BadSyntaxException(Strings.ErrorInvalidName);
					if (CSharpLanguage.Instance.IsForbiddenTypeName(typeGroup.Value))
						throw new BadSyntaxException(Strings.ErrorInvalidTypeName);
					if (typeGroup.Value == "void")
						throw new BadSyntaxException(string.Format(Strings.ErrorType, "void"));

					ValidName = nameGroup.Value;
					ValidType = typeGroup.Value;
					AccessModifier = Language.TryParseAccessModifier(accessGroup.Value);
					InitialValue = (initGroup.Success) ? initGroup.Value : null;

					foreach (Capture modifierCapture in modifierGroup.Captures) {
						if (modifierCapture.Value == "static")
							IsStatic = true;
						if (modifierCapture.Value == "readonly")
							IsReadonly = true;
						if (modifierCapture.Value == "const")
							IsConstant = true;
						if (modifierCapture.Value == "new")
							IsHider = true;
						if (modifierCapture.Value == "volatile")
							IsVolatile = true;
					}
				}
				else {
					throw new BadSyntaxException(Strings.ErrorInvalidDeclaration);
				}
			}
			finally {
				RaiseChangedEvent = true;
			}
		}