public override void InitFromString(string declaration)
{
Match match = propertyRegex.Match(declaration);
RaiseChangedEvent = false;
try {
if (match.Success) {
ClearModifiers();
ReadAccess = AccessModifier.Default;
WriteAccess = AccessModifier.Default;
Group nameGroup = match.Groups["name"];
Group typeGroup = match.Groups["type"];
Group accessGroup = match.Groups["access"];
Group modifierGroup = match.Groups["modifier"];
Group nameDotGroup = match.Groups["namedot"];
Group argsGroup = match.Groups["args"];
Group getGroup = match.Groups["get"];
Group setGroup = match.Groups["set"];
Group getAccessGroup = match.Groups["getaccess"];
Group setAccessGroup = match.Groups["setaccess"];
ArgumentList.InitFromString(argsGroup.Value);
// Validating identifier's name
if ((nameGroup.Value != "this" || !HasParameter) &&
CSharpLanguage.Instance.IsForbiddenName(nameGroup.Value)) {
throw new BadSyntaxException(Strings.ErrorInvalidName);
}
else {
ValidName = nameGroup.Value;
}
// Validating type's name
if (CSharpLanguage.Instance.IsForbiddenTypeName(typeGroup.Value))
throw new BadSyntaxException(Strings.ErrorInvalidTypeName);
else
ValidType = typeGroup.Value;
IsExplicitImplementation = nameDotGroup.Success;
AccessModifier = Language.TryParseAccessModifier(accessGroup.Value);
IsReadonly = getGroup.Success && !setGroup.Success;
IsWriteonly = !getGroup.Success && setGroup.Success;
ReadAccess = Language.TryParseAccessModifier(getAccessGroup.Value);
WriteAccess = Language.TryParseAccessModifier(setAccessGroup.Value);
foreach (Capture modifierCapture in modifierGroup.Captures) {
if (modifierCapture.Value == "static")
IsStatic = true;
if (modifierCapture.Value == "virtual")
IsVirtual = true;
if (modifierCapture.Value == "abstract")
IsAbstract = true;
if (modifierCapture.Value == "override")
IsOverride = true;
if (modifierCapture.Value == "sealed")
IsSealed = true;
if (modifierCapture.Value == "new")
IsHider = true;
}
}
else {
throw new BadSyntaxException(Strings.ErrorInvalidDeclaration);
}
}
finally {
RaiseChangedEvent = true;
}
}