public void Initialize(SkyContext context, ICollection <BaseCalc> calculators, ICollection <BaseAstroEventsProvider> eventProviders) { Context = context; Calculators.AddRange(calculators); EventProviders.AddRange(eventProviders); foreach (var calc in Calculators) { calc.Initialize(); Type calcType = calc.GetType(); IEnumerable <Type> genericCalcTypes = calcType.GetInterfaces().Where(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(ICelestialObjectCalc <>)); foreach (Type genericCalcType in genericCalcTypes) { Type bodyType = genericCalcType.GetGenericArguments().First(); Type concreteCalc = typeof(ICelestialObjectCalc <>).MakeGenericType(bodyType); // Ephemeris configs EphemerisConfig config = Activator.CreateInstance(typeof(EphemerisConfig <>).MakeGenericType(bodyType)) as EphemerisConfig; concreteCalc.GetMethod(nameof(ICelestialObjectCalc <CelestialObject> .ConfigureEphemeris)).Invoke(calc, new object[] { config }); if (!config.IsEmpty) { EphemConfigs[bodyType] = config; } // Celestial objects providers Type genericGetCelestialObjectsFuncType = typeof(GetCelestialObjectsDelegate <>).MakeGenericType(bodyType); CelestialObjectsProviders[bodyType] = concreteCalc.GetMethod(nameof(ICelestialObjectCalc <CelestialObject> .GetCelestialObjects)).CreateDelegate(genericGetCelestialObjectsFuncType, calc); // Info provider Type genericGetInfoFuncType = typeof(GetInfoDelegate <>).MakeGenericType(bodyType); InfoProviders[bodyType] = concreteCalc.GetMethod(nameof(ICelestialObjectCalc <CelestialObject> .GetInfo)).CreateDelegate(genericGetInfoFuncType, calc); // Search provider Type[] searchParameters = typeof(SearchDelegate).GetMethod("Invoke").GetParameters().Select(p => p.ParameterType).ToArray(); var searchFunc = concreteCalc.GetMethod(nameof(ICelestialObjectCalc <CelestialObject> .Search), searchParameters).CreateDelegate(typeof(SearchDelegate), calc) as SearchDelegate; if (!SearchProviders.Contains(searchFunc)) { SearchProviders.Add(searchFunc); } } } foreach (var eventProvider in EventProviders) { // Astro events provider AstroEventsConfig eventsConfig = new AstroEventsConfig(); eventProvider.ConfigureAstroEvents(eventsConfig); if (eventsConfig.Any()) { EventConfigs.Add(eventsConfig); } } LoadConstNames(); }
public override void ConfigureAstroEvents(AstroEventsConfig c) { c["MoonEvents.Phases"] = Phases; c["MoonEvents.Apsis"] = Apsis; c["MoonEvents.Librations"] = MaxLibrations; c["MoonEvents.MaxDeclinations"] = MaxDeclinations; c["MoonEvents.ConjWithStars"] = ConjunctionsWithStars; c["MoonEvents.ConjWithPlanets"] = ConjuntionsWithPlanets; }
public override void ConfigureAstroEvents(AstroEventsConfig c) { c["PlanetEvents.ConjunctionsInRightAscension"] = ConjunctionsInRightAscension; c["PlanetEvents.ConjunctionsInEclipticalLongitude"] = ConjunctionsInEclipticalLongitude; c["PlanetEvents.CloseApproaches"] = CloseApproaches; c["PlanetEvents.MaximalMagnitude"] = MaximalMagnitude; c["PlanetEvents.Stationaries"] = Stationaries; c["PlanetEvents.GreatestElongations"] = GreatestElongations; c["PlanetEvents.Oppositions"] = Oppositions; c["PlanetEvents.Conjunctions"] = Conjunctions; c["PlanetEvents.VisibilityPeriods"] = VisibilityPeriods; }
public override void ConfigureAstroEvents(AstroEventsConfig c) { c["CometsEvents.PerihelionPassages"] = PerihelionPassages; }
public override void ConfigureAstroEvents(AstroEventsConfig cfg) { cfg["Eclipses.Solar"] = FindSolarEclipses; cfg["Eclipses.Lunar"] = FindLunarEclipses; }
public abstract void ConfigureAstroEvents(AstroEventsConfig config);
public override void ConfigureAstroEvents(AstroEventsConfig c) { c["AsteroidsEvents.Oppositions"] = Oppositions; }
public override void ConfigureAstroEvents(AstroEventsConfig phenomena) { phenomena["SunEvents.Seasons"] = EventsSeasons; }
public override void ConfigureAstroEvents(AstroEventsConfig c) { c["MeteorsEvents.Begin"] = ctx => FindInstants(ctx, m => m.Begin, m => Text.Get("MeteorsEvents.Begin.Text", ("Name", m.Name))); c["MeteorsEvents.Max"] = ctx => FindInstants(ctx, m => m.Max, m => Text.Get("MeteorsEvents.Max.Text", ("Name", m.Name))); c["MeteorsEvents.End"] = ctx => FindInstants(ctx, m => m.End, m => Text.Get("MeteorsEvents.End.Text", ("Name", m.Name))); }