relativitydev / Gravity

ORM Framework for Relativity Custom Development
Other
16 stars 10 forks source link

Create RelativityChoice attribute #68

Closed Arithmomaniac closed 6 years ago

Arithmomaniac commented 6 years ago

Instead of code like

[RelativityObjectField("C3B2943D-C9C2-4C92-A88D-115B3F9ED64D", (int)RdoFieldType.MultipleChoice, typeof(MultipleChoiceFieldChoices))]
public IList<MultipleChoiceFieldChoices> MultipleChoiceFieldChoices { get; set; }
[RelativityObjectField("CEDB347B-679D-44ED-93D3-0B3027C7E6F5", (int)RdoFieldType.SingleChoice, typeof(SingleChoiceFieldChoices))]
public SingleChoiceFieldChoices SingleChoice { get; set; }

We should have a RelativityChoiceField attribute that looks like this:

[RelativityChoiceField("C3B2943D-C9C2-4C92-A88D-115B3F9ED64D")]
public IList<MultipleChoiceFieldChoices> MultipleChoiceFieldChoices { get; set; }
[RelativityChoiceField("CEDB347B-679D-44ED-93D3-0B3027C7E6F5")]
public SingleChoiceFieldChoices SingleChoice { get; set; }

Whether it it single or multiple choice can be determined by checking whether the property type is an IEnumerable<>, and the choice type can be read from the property like we are doing in #41.

At a minimum, we could make it possible to do without the type parameter in RelativityObjectField.

mrobustelli commented 6 years ago

Decided to try and keep attribute decoration as simple as possible so users do not have to remember different syntax for different field types.