ResolveSettings
Namespace:
Itinero
We found 10 examples in language CSharp for this search.
You will see 41 fragments of code.
Other methods
Other methods
Project:ProyectoTSP
File:ResolveSettings.cs
Examples:2
/// <summary>
/// Creates a deep-copy.
/// </summary>
/// <returns></returns>
public ResolveSettings Clone()
{
return new ResolveSettings()
{
MinIslandSize = this.MinIslandSize
};
}
/// <summary>
/// Returns true if the other object has the same settings in it.
/// </summary>
/// <param name="obj">The other object.</param>
/// <returns>True if the other object has the same settings in it.</returns>
public override bool Equals(object obj)
{
return obj is ResolveSettings other && other.MinIslandSize == this.MinIslandSize;
}
Project:Renderings
File:ISiteSettingsResolver.cs
Examples:2
/// <summary>
/// Resolves site settings content for given type and homepage node id
/// </summary>
/// <param name="settingsViewModelType"></param>
/// <param name="homepageNodeId"></param>
/// <param name="umbracoHelper"></param>
/// <returns></returns>
IPublishedContent ResolveSettings(Type settingsViewModelType, int? homepageNodeId, UmbracoHelper umbracoHelper = null);
/// <summary>
/// Resolves site settings content for generic T and homepage node Id
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="homepageNodId"></param>
/// <param name="umbracoHelper"></param>
/// <returns></returns>
IPublishedContent ResolveSettings<T>(int? homepageNodId, UmbracoHelper umbracoHelper = null);
Project:Ifood-GeekStore
File:DependencyInjectionConfig.cs
Examples:6
public static IServiceCollection ResolveDependencies(this IServiceCollection services)
{
services.ResolveContexts();
services.ResolveRepositories();
services.ResolveServices();
services.ResolveHttpServices();
services.ResolveSettings();
services.ResolveBuildingBlocks();
return services;
}
private static IServiceCollection ResolveContexts(this IServiceCollection services)
{
services.AddScoped<IGeekStoreDbContextService, GeekStoreDbContextService>();
services.AddScoped<GeekStoreDbContext>();
return services;
}
private static IServiceCollection ResolveRepositories(this IServiceCollection services)
{
services.AddScoped<IProdutoRepository, ProdutoRepository>();
return services;
}
private static IServiceCollection ResolveServices(this IServiceCollection services)
{
services.AddScoped<IProdutoService, ProdutoService>();
return services;
}
private static IServiceCollection ResolveHttpServices(this IServiceCollection services)
{
services.AddHttpClient<IAuthenticationFacade, AuthenticationFacade>()
.AddPolicyHandler(PollyExtensions.EsperarTentar())
.AddTransientHttpErrorPolicy(x =>
x.CircuitBreakerAsync(5, TimeSpan.FromSeconds(30)));
return services;
}
public static IServiceCollection ResolveSettings(this IServiceCollection services)
{
services.AddScoped<SwaggerSettings>();
services.AddScoped<ApiAuthenticationSettings>();
services.AddScoped<AppSettings>();
services.AddScoped<FileServerSettings>();
return services;
}
Project:Licence-Thesis-UTCN
File:ResolveSettings.cs
Examples:3
/// <summary>
/// Creates a deep-copy.
/// </summary>
/// <returns></returns>
public ResolveSettings Clone()
{
return new ResolveSettings()
{
MinIslandSize = this.MinIslandSize
};
}
/// <summary>
/// Serves as the default hash function.
/// </summary>
/// <returns></returns>
public override int GetHashCode()
{
unchecked // Overflow is fine, just wrap
{
var hash = 17;
hash = hash * 23 + this.MinIslandSize.GetHashCode();
return hash;
}
}
/// <summary>
/// Returns true if the other object has the same settings in it.
/// </summary>
/// <param name="obj">The other object.</param>
/// <returns>True if the other object has the same settings in it.</returns>
public override bool Equals(object obj)
{
return obj is ResolveSettings other && other.MinIslandSize == this.MinIslandSize;
}
Project:Licence-Thesis-UTCN
File:ResolveSettings.cs
Examples:3
/// <summary>
/// Creates a deep-copy.
/// </summary>
/// <returns></returns>
public ResolveSettings Clone()
{
return new ResolveSettings()
{
MinIslandSize = this.MinIslandSize
};
}
/// <summary>
/// Serves as the default hash function.
/// </summary>
/// <returns></returns>
public override int GetHashCode()
{
unchecked // Overflow is fine, just wrap
{
var hash = 17;
hash = hash * 23 + this.MinIslandSize.GetHashCode();
return hash;
}
}
/// <summary>
/// Returns true if the other object has the same settings in it.
/// </summary>
/// <param name="obj">The other object.</param>
/// <returns>True if the other object has the same settings in it.</returns>
public override bool Equals(object obj)
{
return obj is ResolveSettings other && other.MinIslandSize == this.MinIslandSize;
}
Project:routing
File:ResolverCache.cs
Examples:4
//private int _hits = 0;
/// <summary>
/// Tries to get from this cache, the closest point on the routing network that's routable for the given profiles.
/// </summary>
/// <param name="profileInstances">The profile instances.</param>
/// <param name="latitude">The latitude.</param>
/// <param name="longitude">The longitude.</param>
/// <param name="isBetter">The is better function.</param>
/// <param name="maxSearchDistance">The maximum search distance.</param>
/// <param name="settings">The settings, if any.</param>
/// <returns>The resulting router point in cache.</returns>
public Result<RouterPoint> TryGet(IProfileInstance[] profileInstances, float latitude, float longitude, Func<RoutingEdge, bool> isBetter,
float maxSearchDistance, ResolveSettings settings)
{
var key = new Key(profileInstances, isBetter, maxSearchDistance, settings);
if (!_data.TryGetValue(key, out var lruCache))
{
return null;
}
if (!lruCache.TryGet(new Coordinate(latitude, longitude), out var cachedResult))
{
return null;
}
//_hits++;
//Console.WriteLine($"Cache hit: {_hits}");
return cachedResult;
}
//private int _added = 0;
/// <summary>
/// Adds to this cache, the closest point on the routing network that's routable for the given profiles.
/// </summary>
/// <param name="profileInstances">The profile instances.</param>
/// <param name="latitude">The latitude.</param>
/// <param name="longitude">The longitude.</param>
/// <param name="isBetter">The is better function.</param>
/// <param name="maxSearchDistance">The maximum search distance.</param>
/// <param name="settings">The settings, if any.</param>
/// <param name="routerPointResult">The result to keep.</param>
/// <returns>The resulting router point in cache.</returns>
public void Add(IProfileInstance[] profileInstances, float latitude, float longitude, Func<RoutingEdge, bool> isBetter, float maxSearchDistance,
ResolveSettings settings, Result<RouterPoint> routerPointResult)
{
var key = new Key(profileInstances, isBetter, maxSearchDistance, settings);
if (!_data.TryGetValue(key, out var lruCache))
{
_data.TryAdd(key, new LRUCache<Coordinate, Result<RouterPoint>>(_size));
_data.TryGetValue(key, out lruCache);
if (lruCache == null)
{ // can this happen, it shouldn't, how does concurrent dictionary work exactly?
return;
}
}
var location = new Coordinate(latitude, longitude);
if (lruCache.TryGet(location, out var cachedResult))
{ // already in cache.
return;
}
//_added++;
//Console.WriteLine($"Added: {_added}");
lruCache.Add(location, cachedResult);
}
public override bool Equals(object obj)
{
if (!(obj is Key other)) return false;
if (this.MaxSearchDistance != other.MaxSearchDistance) return false;
if (this.IsBetterFunc != other.IsBetterFunc) return false;
if (!this.ResolveSettings.Equals(other.ResolveSettings)) return false;
if (this.ProfileInstanceNames.Length != other.ProfileInstanceNames.Length) return false;
for (var i = 0; i < this.ProfileInstanceNames.Length; i++)
{
if (this.ProfileInstanceNames[i] != other.ProfileInstanceNames[i]) return false;
}
return true;
}
public override int GetHashCode()
{
unchecked
{
var hash = 17;
hash = hash * 23 + this.ProfileInstanceNames.Length.GetHashCode();
for (var i = 0; i < this.ProfileInstanceNames.Length; i++)
{
hash = hash * 23 + this.ProfileInstanceNames[i].GetHashCode();
}
if (this.IsBetterFunc != null)
{
hash = hash * 23 + this.IsBetterFunc.GetHashCode();
}
hash = hash * 23 + this.MaxSearchDistance.GetHashCode();
hash = hash * 23 + this.ResolveSettings.GetHashCode();
return hash;
}
}
Project:brandon-utils
File:Prettification.cs
Examples:6
[NotNull]
public static PrettificationSettings ResolveSettings(PrettificationSettings? settings) {
return settings ?? PrettificationSettings.DefaultSettings;
}
public static void RegisterPrettifier([NotNull] IPrettifier prettifier) {
Prettifiers.Register(prettifier);
}
public static IPrettifier? UnregisterPrettifier([NotNull] Type prettifierType) {
return Prettifiers.Deregister(prettifierType);
}
#region Finding Prettifiers
#region Generics
#endregion
#endregion
[Pure]
[NotNull]
public static string Prettify(this object? cinderella) {
return cinderella.Prettify(default);
}
[Pure]
[NotNull]
public static string Prettify(this object? cinderella, PrettificationSettings? settings) {
settings = ResolveSettings(settings);
settings.TraceWriter.Info(() => $"👸 Prettifying [{cinderella?.GetType().Name}]");
if (cinderella == null) {
return settings.NullPlaceholder.Value ?? "";
}
var prettifier = PrettifierFinders.FindPrettifier(
Prettifiers,
cinderella.GetType(),
settings,
Finders
);
return prettifier
.IfPresentOrElse(
it => it.PrettifySafely(cinderella, settings),
() => LastResortPrettifier(cinderella, settings)
);
}
[NotNull]
internal static string LastResortPrettifier(object? cinderella, PrettificationSettings? settings) {
settings ??= new PrettificationSettings();
settings.TraceWriter.Verbose(() => $"⛑ Using the LAST RESORT prettifier for [{cinderella?.GetType()}]: {nameof(Convert.ToString)}!");
return Convert.ToString(cinderella);
}
Project:configgen
File:XmlSettingsLoader.cs
Examples:3
public IResult<IEnumerable<IDictionary<string, object>>, IEnumerable<Error>> LoadSettings([NotNull] string settingsFile)
{
if (settingsFile == null) throw new ArgumentNullException(nameof(settingsFile));
if (!File.Exists(settingsFile))
{
throw new ArgumentException(string.Format($"File '{settingsFile}' does not exist"), nameof(settingsFile)); //TODO: migrate this exception to an error
}
ConfigGenSettings settings;
var deserializer = new XmlSerializer(typeof(ConfigGenSettings));
using (var file = File.OpenRead(settingsFile))
{
var reader = new XmlTextReader(file);
if (!deserializer.CanDeserialize(reader))
{
throw new ArgumentException($"Cannot read settings from file '{settingsFile}'", nameof(settingsFile)); //TODO: migrate this exception to an error
}
settings = (ConfigGenSettings)deserializer.Deserialize(reader);
}
var settingGroups = new Dictionary<string, IDictionary<string, string>>();
if (settings.SettingGroups != null)
{
foreach (var settingGroup in settings.SettingGroups)
{
var settingsInGroup = new Dictionary<string, string>();
foreach (var setting in settingGroup.Settings)
{
settingsInGroup[setting.Token] = setting.Value;
}
settingGroups.Add(settingGroup.Key, settingsInGroup);
}
}
var machineConfigurations = new List<Dictionary<string,object>>();
ProcessConfigurationContainerRecursive(new Dictionary<string, object>(), settingGroups, machineConfigurations, settings.ConfigFileName, settings);
return Result<IEnumerable<IDictionary<string, object>>, IEnumerable<Error>>.CreateSuccessResult(machineConfigurations);
}
private void ProcessConfigurationContainerRecursive(
IDictionary<string, object> settings,
IDictionary<string, IDictionary<string, string>> settingGroups,
IList<Dictionary<string, object>> configurations,
string configFileName,
IConfigurationContainer container)
{
var containerSettings = ResolveSettings(settings, settingGroups, container);
if (container.Groups != null)
{
foreach (var @group in container.Groups)
{
string localConfigFileName = string.IsNullOrEmpty(@group.ConfigFileName) ? configFileName : @group.ConfigFileName;
ProcessConfigurationContainerRecursive(containerSettings, settingGroups, configurations, localConfigFileName, @group);
}
}
if (container.Configurations != null)
{
foreach (var configuration in container.Configurations)
{
var localSettings = ResolveSettings(containerSettings, settingGroups, configuration);
string localConfigFileName = string.IsNullOrEmpty(container.ConfigFileName) ? configFileName : container.ConfigFileName;
if (!configuration.Name.IsNullOrEmpty())
{
//HACK: the "special case" value of MachineName from old configgen has been deprecated. MachineName is just another setting now.
//However, if present, add it into the collection of settings for backwards compatibility.
localSettings.Add("MachineName", configuration.Name);
}
if (!localConfigFileName.IsNullOrEmpty())
{
//HACK: the "special case" value of ConfigFilePath from old configgen has been deprecated. ConfigFilePath is just another setting now.
//However, if present, add it into the collection of settings for backwards compatibility.
localSettings.Add("ConfigFilePath", localConfigFileName);
}
configurations.Add(localSettings);
}
}
}
private static Dictionary<string, object> ResolveSettings(
IDictionary<string, object> settings,
IDictionary<string, IDictionary<string, string>> settingGroups,
ISettingContainer container)
{
var resolvedSettings = settings.ToDictionary(kv => kv.Key, kv => kv.Value);
if (container.Includes != null)
{
foreach (var include in container.Includes)
{
if (!settingGroups.ContainsKey(include.SettingGroup))
{
throw new InvalidOperationException(string.Format($"SettingGroup with key '{include.SettingGroup} not found")); //TODO: migrate this exception to an error
}
IDictionary<string, string> settingGroupEntries = settingGroups[include.SettingGroup];
foreach (var key in settingGroupEntries.Keys)
{
resolvedSettings[key] = settingGroupEntries[key];
}
}
}
if (container.Settings != null)
{
foreach (var setting in container.Settings)
{
resolvedSettings[setting.Token] = setting.Value;
}
}
return resolvedSettings;
}
Project:BSharp
File:Prettification.cs
Examples:6
public static PrettificationSettings ResolveSettings(PrettificationSettings? settings) {
return settings ?? PrettificationSettings.Default;
}
public static void RegisterPrettifier(IPrettifier prettifier) {
Prettifiers.Register(prettifier);
}
public static IPrettifier? UnregisterPrettifier(Type prettifierType) {
return Prettifiers.Deregister(prettifierType);
}
#region Finding Prettifiers
#region Generics
#endregion
#endregion
[Pure]
public static string Prettify(this object? cinderella) {
return cinderella.Prettify(default);
}
[Pure]
public static string Prettify(this object? cinderella, PrettificationSettings? settings) {
settings = ResolveSettings(settings);
settings.TraceWriter.Info(() => $"👸 Prettifying [{cinderella?.GetType().Name}]");
if (cinderella == null) {
return settings.NullPlaceholder;
}
var prettifier = PrettifierFinders.FindPrettifier(
Prettifiers,
cinderella.GetType(),
settings,
Finders
);
return prettifier
.IfPresentOrElse(
it => it.PrettifySafely(cinderella, settings),
() => LastResortPrettifier(cinderella, settings)
);
}
internal static string LastResortPrettifier(object? cinderella, PrettificationSettings? settings) {
settings ??= new PrettificationSettings();
settings.TraceWriter.Verbose(() => $"⛑ Using the LAST RESORT prettifier for [{cinderella?.GetType()}]: {nameof(Convert.ToString)}!");
return Convert.ToString(cinderella);
}
Project:prsd-weee
File:ConfigurationService.cs
Examples:6
private AppConfiguration ResolveSettings()
{
return ResolveConfigObject(new AppConfiguration(), SettingPrefix);
}
private T ResolveConfigObject<T>(T configurationInstance, string prefix)
{
// Iterate over the properties
foreach (var property in GetConfigProperties(configurationInstance))
{
string baseName = String.IsNullOrEmpty(property.DisplayName) ? property.Name : property.DisplayName;
string settingName = prefix + baseName;
string value = ReadSetting(settingName);
if (String.IsNullOrEmpty(value))
{
var defaultValue = property.Attributes.OfType<DefaultValueAttribute>().FirstOrDefault();
if (defaultValue != null && defaultValue.Value != null)
{
if (defaultValue.Value.GetType() == property.PropertyType)
{
property.SetValue(configurationInstance, defaultValue.Value);
continue;
}
}
}
if (!String.IsNullOrEmpty(value))
{
if (property.PropertyType.IsAssignableFrom(typeof(string)))
{
property.SetValue(configurationInstance, value);
}
else if (property.Converter != null && property.Converter.CanConvertFrom(typeof(string)))
{
// Convert the value
property.SetValue(configurationInstance, property.Converter.ConvertFromString(value));
}
}
else if (property.Attributes.OfType<RequiredAttribute>().Any())
{
throw new ConfigurationErrorsException(String.Format(CultureInfo.InvariantCulture, "Missing required configuration setting: '{0}'", settingName));
}
}
return configurationInstance;
}
protected static IEnumerable<PropertyDescriptor> GetConfigProperties<T>(T instance)
{
return TypeDescriptor.GetProperties(instance).Cast<PropertyDescriptor>().Where(p => !p.IsReadOnly);
}
public virtual string ReadSetting(string settingName)
{
string value;
var connectionString = GetConnectionString(settingName);
if (connectionString != null)
{
value = connectionString.ConnectionString;
}
else
{
value = GetAppSetting(settingName);
}
return value;
}
protected virtual string GetAppSetting(string settingName)
{
return CloudConfigurationManager.GetSetting(settingName);
}
protected virtual ConnectionStringSettings GetConnectionString(string settingName)
{
return WebConfigurationManager.ConnectionStrings[settingName];
}
Itinero.Algorithms.Search.ResolveSettings : Object
Fields :
public static Int32 DefaultMinIslandSizeConstructors :
public ResolveSettings()Methods :
public Int32 get_MinIslandSize()public Void set_MinIslandSize(Int32 value = )
public ResolveSettings Clone()
public Int32 GetHashCode()
public Boolean Equals(Object obj = )
public Type GetType()
public String ToString()