Skip to content

Commit

Permalink
Add sun and shadow settings support
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeyNefyodov committed Sep 2, 2024
1 parent 78e6a9a commit 77aec0b
Showing 1 changed file with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,52 @@ public override Func<IVariants> Resolve(Document context, string target, Paramet
return target switch
{
nameof(SunAndShadowSettings.GetActiveSunAndShadowSettings) => ResolveGet,
nameof(SunAndShadowSettings.GetSunrise) => ResolveGetSunrise,
nameof(SunAndShadowSettings.GetSunset) => ResolveGetSunset,
nameof(SunAndShadowSettings.IsTimeIntervalValid) => ResolveTimeInterval,
nameof(SunAndShadowSettings.IsAfterStartDateAndTime) => ResolveAfterStart,
nameof(SunAndShadowSettings.IsBeforeEndDateAndTime) => ResolveBeforeStart,
_ => null
};

IVariants ResolveGet()
{
return Variants.Single(SunAndShadowSettings.GetActiveSunAndShadowSettings(settings.Document));
}

IVariants ResolveGetSunrise()
{
return Variants.Single(settings.GetSunrise(DateTime.Today));
}

IVariants ResolveGetSunset()
{
return Variants.Single(settings.GetSunset(DateTime.Today));
}

IVariants ResolveAfterStart()
{
return Variants.Single(settings.IsAfterStartDateAndTime(DateTime.Today));
}

IVariants ResolveBeforeStart()
{
return Variants.Single(settings.IsBeforeEndDateAndTime(DateTime.Today));
}

IVariants ResolveTimeInterval()
{
var conditions = Enum.GetValues(typeof(SunStudyTimeInterval));
var variants = new Variants<bool>(conditions.Length);

foreach (SunStudyTimeInterval condition in conditions)
{
var result = settings.IsTimeIntervalValid(condition);
variants.Add(result, $"{condition}: {result}");
}

return variants;
}
}

public override void RegisterExtensions(IExtensionManager manager)
Expand Down

0 comments on commit 77aec0b

Please sign in to comment.