Binoculars icon indicating copy to clipboard operation
Binoculars copied to clipboard

Configuration/Settings Method

Open StudioLE opened this issue 5 years ago • 5 comments

We need to add Settings or Configuration methods in to the application. I'm leaning towards a Settings class that reads a settings.json file within the extension folder.

StudioLE avatar Apr 15 '19 13:04 StudioLE

I theorised this as json file but that could just be due to my background in javascript. Dynamo is also moving towards json so it is fitting but what would the standard C# way be? @radumg @brencass

Would something simpler to understand such as yaml be more fitting?

  • https://en.wikipedia.org/wiki/YAML
  • https://yaml.org/

StudioLE avatar Apr 19 '19 15:04 StudioLE

Working prototype is on the settings branch. It's still a work in progress so refinement is needed before it's merged.

StudioLE avatar Apr 20 '19 08:04 StudioLE

I theorised this as json file but that could just be due to my background in javascript.

you'll find this very useful : https://app.quicktype.io/#l=cs&r=json2csharp

Dynamo is also moving towards json so it is fitting but what would the standard C# way be? @radumg @brencass

Json 👍 Yaml 👎

radumg avatar Apr 22 '19 11:04 radumg

Had a look on the settings branch, here's a few notes

Settings should be a non-static class with children objects if required. This will allow easy deserialisation & use throughout code (instead of using error-prone dictionary lookups).

{
  "consent": {
    "requested": true,
    "given":  true
  }

For example, the Consent "section" above could be quickly modelled as :

public class Consent
{
    public bool Requested { get; set; }
    public bool Given { get; set; }
}

Similarly for the collect section :

  "collect": {
    "user": true,
    "computerName": true,
    "dynamoVersion": true,
    "revitVersion": true,
    "ip": true,
    "geolocation": true,
    "latlng": true,
    "city": true,
    "country": true,
    "filename": true,
    "date": true
  }

would be

public class DataCollectionSettings
{
    public bool User { get; set; }
    public bool ComputerName { get; set; }
    public bool DynamoVersion { get; set; }
    public bool RevitVersion { get; set; }
    public bool Ip { get; set; }
    public bool Geolocation { get; set; }
    public bool LatLng { get; set; }
    public bool City { get; set; }
    public bool Country { get; set; }
    public bool Filename { get; set; }
    public bool Date { get; set; }
}

etc.

radumg avatar Apr 22 '19 18:04 radumg

Settings have now been merged into master https://github.com/teamtreedyn/Binoculars/pull/32 but I'll leave this issue open until @radumg comments are resolved.

StudioLE avatar Jun 22 '19 09:06 StudioLE