Open GoogleCodeExporter opened 9 years ago
Original comment by pele...@google.com
on 11 Feb 2013 at 5:59
Two issues to consider:
1. It may be a good idea to also provide a string input option in case a
developer wants to specify a string for convenience, or because they are using
an older-built version of the library that doesn't list a new enum value even
though the server already supports it.
2. There is an issue that the generated enum value constants might look bad.
For example FREEBUSYREADER is hard to read. For that case, you may want to
insert "_" along the capitalization border, i.e. FREE_BUSY_READER.
Occasionally though the enum value may not be a legal name (e.g. numeric value
of "1") or may produce a really ugly name (e.g. URI value of
"http://somedomain.com/some/long/path"). So there are edge cases to worry
about here.
Original comment by yan...@google.com
on 11 Feb 2013 at 6:30
[deleted comment]
1. that's what I meant. So to be more clear, here is a sample code (based on
the discovery above:
- Keep the old way (to suppport older built versions).
As you can see the field reminds string.
private string _minAccessRole;
public string MinAccessRole
{
get { return _minAccessRole; }
set { this._minAccessRole = value; }
}
IN ADDITION:
// generate enum:
///<summary>The minimum access role for the user in the returned entires.
Optional. The default is no restriction.</summary>
public enum MinAccessRole
{
///<summary>The user can read free/busy information</summary>
FreeBusyReader,
///<summary>The user can read and modify events and access control lists</summary>
Owner,
///<summary>The user can read events that are not private</summary>
Reader,
///<summary>The user can read and modify events</summary>
Writer,
}
And add another property similar to this:
public MinAccessRole MinAccessRoleEnum
{
get { return (MinAccessRole) Enum.Parse(typeof(MinAccessRole), _minAccessRole); }
set { this._minAccessRole = value.ToString(); }
}
NOTICE: we should also consider to add None value to the enum, so in case of
the Enum getter above we will return MinAccessRole.None in case _minAccessRole
is null
2. C# standards of enums is Pascal case as you can see above.
And of course we should check that the generated enum and its values are valid
(as we do to all properties, classes, etc.)
Original comment by pele...@google.com
on 11 Feb 2013 at 7:36
Issue 384 has been merged into this issue.
Original comment by pele...@google.com
on 6 Sep 2013 at 7:24
Original comment by pele...@google.com
on 28 Nov 2013 at 6:01
Issue 384 has been merged into this issue.
Original comment by pele...@google.com
on 4 Dec 2013 at 9:53
Original issue reported on code.google.com by
pele...@google.com
on 11 Feb 2013 at 5:59