How to define read-only (c#) class property?

0 votes
asked Dec 27, 2014 in To be sorted by anonymous

Now I am using syntax:

class SomeClass {
   int SomeProperty {get;}
}
 
Is there better solution? With icon support?
 
Thanks,
Josef

1 Answer

0 votes
answered Dec 28, 2014 by plantuml (294,960 points)
 
Best answer

Today, there is no better solution.

However, if you have some suggestion for some icon to be used for readonly, and also some suggestion for the syntax, we could implement that easily.

For example, what about this :

class SomeClass {
   $ readOnly
   + public
   - private
}
 
commented Dec 28, 2014 by anonymous
I spend more time to think about, it is not easy. Any character is completely fine for me, but..

a) I am using only properties (in diagrams), but not fields.
b) I always use method instead of writeOnly property.

There is lot of possible combinations, it can be confusing. I will happy with current implementation :D

Thanks for answer.
Josef
commented Dec 29, 2014 by plantuml (294,960 points)
There is another option.
You can also use sprites http://plantuml.com/sprite.html

Like in the following example:

@startuml
sprite $readonly[16x16/16z] {
DOzH4iKW20CV4Y1jt-ZzRrl0kZ-w4pFWMibDydhMnmneOfpRG-696LiV82gX-R_yKf-xPdUTLDyzjgjx8CawcGb-1n5f7z8CrNOPK34JsF5yOD5vdDnZm51k
dLSTd-Sbry-1dukSSUtr5uyDrmi0
}
class SomeClass {
   <$readonly> int SomeProperty
}
@enduml

http://www.plantuml.com/plantuml/png/FSzDJuCm083XUtz53ruRwOIAoUA5PZF2XD1zE1PZO2spV1HIEaTPzjzDTl3s9i_f7NejZO0FMkIyKuqzO39YyeZ9z0MlWCRJcol3tSm9jkuULmPbKweRfyxGnUqNkvKigEK_AzKg4PTzkaJaXKHowyzEdoZzjc69neHlrX6rKtMgHZ_8ByTbWR3ookV93_H7d8HFxlkmy6nClLzELTPwk0OyOckEMA4jmlnSCxOnsZjRgblfW1iuDlamGDQr8hZN5K08v_yJhr0gS-T4TxtGneBR7m00

Of course, you can choose a better image for your sprite.

Regards,
commented Dec 29, 2014 by anonymous
This is perfect solution! Thanks!
...