Skip to content

Commit

Permalink
Add comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
Codespilot committed Jul 8, 2023
1 parent 894f9f7 commit f92b731
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 25 deletions.
3 changes: 3 additions & 0 deletions Source/Euonia.Bus.InMemory/InMemoryMessageBusModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace Nerosoft.Euonia.Bus.InMemory;

/// <summary>
/// Import this module to use the in-memory message bus.
/// </summary>
[DependsOn(typeof(MessageBusModule))]
public class InMemoryMessageBusModule : ModuleContextBase
{
Expand Down
13 changes: 13 additions & 0 deletions Source/Euonia.Bus.InMemory/MessageBus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ protected MessageBus(IMessageHandlerContext handlerContext, IServiceAccessor acc
ServiceAccessor = accessor;
}

/// <summary>
/// Gets the service accessor.
/// </summary>
protected IServiceAccessor ServiceAccessor { get; }

/// <summary>
Expand Down Expand Up @@ -96,11 +99,21 @@ protected virtual void OnMessageAcknowledged(MessageAcknowledgedEventArgs args)
MessageAcknowledged?.Invoke(this, args);
}

/// <summary>
/// Subscribes the specified message type.
/// </summary>
/// <param name="messageType"></param>
/// <param name="handlerType"></param>
public virtual void Subscribe(Type messageType, Type handlerType)
{
HandlerContext.Register(messageType, handlerType);
}

/// <summary>
/// Subscribes the specified message name.
/// </summary>
/// <param name="messageName"></param>
/// <param name="handlerType"></param>
public virtual void Subscribe(string messageName, Type handlerType)
{
HandlerContext.Register(messageName, handlerType);
Expand Down
13 changes: 13 additions & 0 deletions Source/Euonia.Bus.InMemory/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,16 @@

namespace Microsoft.Extensions.DependencyInjection;

/// <summary>
/// Message bus extensions for <see cref="IServiceCollection"/>.
/// </summary>
public static class ServiceCollectionExtensions
{
/// <summary>
/// Adds the in-memory command bus to the service collection.
/// </summary>
/// <param name="services"></param>
/// <returns></returns>
public static IServiceCollection AddInMemoryCommandBus(this IServiceCollection services)
{
return services.AddSingleton<ICommandBus>(provider =>
Expand All @@ -26,6 +34,11 @@ public static IServiceCollection AddInMemoryCommandBus(this IServiceCollection s
});
}

/// <summary>
/// Adds the in-memory event bus to the service collection.
/// </summary>
/// <param name="services"></param>
/// <returns></returns>
public static IServiceCollection AddInMemoryEventBus(this IServiceCollection services)
{
return services.AddSingleton<IEventBus>(provider =>
Expand Down
4 changes: 2 additions & 2 deletions Source/Euonia.Caching.Memory/MemoryCacheHandle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ namespace Nerosoft.Euonia.Caching.Memory;
/// <typeparam name="TCacheValue">The type of the cache value.</typeparam>
public class MemoryCacheHandle<TCacheValue> : BaseCacheHandle<TCacheValue>
{
private const string DefaultName = "default";
private const string DEFAULT_NAME = "default";

private readonly string _cacheName = string.Empty;

private volatile MemoryCache _cache = null;
private volatile MemoryCache _cache;

/// <summary>
/// Initializes a new instance of the <see cref="MemoryCacheHandle{TCacheValue}"/> class.
Expand Down
4 changes: 2 additions & 2 deletions Source/Euonia.Caching.Memory/MemoryCacheOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ public class MemoryCacheOptions : Microsoft.Extensions.Caching.Memory.MemoryCach
/// </summary>
public int RetryTimeout { get; set; } = 3000;

// <summary>
/// <summary>
/// Gets or sets the redis cache update mode.
/// </summary>
/// <see cref="CacheUpdateMode"/>
/// <value>None,Up</value>
/// <remarks>Default: Up.</remarks>
/// </summary>
public CacheUpdateMode UpdateMode { get; set; } = CacheUpdateMode.Up;

/// <summary>
Expand Down
23 changes: 10 additions & 13 deletions Source/Euonia.Caching.Redis/RedisConfigurationBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
using System;
using System.Collections.Generic;

namespace Nerosoft.Euonia.Caching.Redis;
namespace Nerosoft.Euonia.Caching.Redis;

/// <summary>
/// <see cref="RedisConfigurationBuilder"/> helps creating the <see cref="RedisConfiguration"/>
/// object via code.
/// </summary>
public class RedisConfigurationBuilder
{
private bool _allowAdmin = false;
private bool _allowAdmin;
private int _connectionTimeout = 5000;
private int _database = 0;
private IList<ServerEndPoint> _endpoints = new List<ServerEndPoint>();
private bool _isSsl = false;
private string _key = string.Empty;
private string _password = null;
private string _sslHost = null;
private bool _enabledKeyspaceNotifications = false;
private int _database;
private readonly IList<ServerEndPoint> _endpoints = new List<ServerEndPoint>();
private bool _isSsl;
private readonly string _key;
private string _password;
private string _sslHost;
private bool _enabledKeyspaceNotifications;
private string _useVersion;
private bool _useTwemproxy;

Expand All @@ -39,7 +36,7 @@ public RedisConfigurationBuilder(string configurationKey)
/// </summary>
/// <returns>The <c>RedisConfiguration</c></returns>
public RedisConfiguration Build() =>
new RedisConfiguration(
new(
key: _key,
endpoints: _endpoints,
database: _database,
Expand Down
12 changes: 6 additions & 6 deletions Source/Euonia.Caching/BaseCacheManager.GetOrAdd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ public partial class BaseCacheManager<TValue>
{
/// <inheritdoc />
public TValue GetOrAdd(string key, TValue value)
=> GetOrAdd(key, (k) => value);
=> GetOrAdd(key, _ => value);

/// <inheritdoc />
public TValue GetOrAdd(string key, string region, TValue value)
=> GetOrAdd(key, region, (k, r) => value);
=> GetOrAdd(key, region, (_, _) => value);

/// <inheritdoc />
public TValue GetOrAdd(string key, Func<string, TValue> valueFactory)
{
Check.EnsureNotNullOrWhiteSpace(key, nameof(key));
Check.EnsureNotNull(valueFactory, nameof(valueFactory));

return GetOrAddInternal(key, null, (k, r) => new CacheItem<TValue>(k, valueFactory(k))).Value;
return GetOrAddInternal(key, null, (k, _) => new CacheItem<TValue>(k, valueFactory(k))).Value;
}

/// <inheritdoc />
Expand All @@ -35,7 +35,7 @@ public CacheItem<TValue> GetOrAdd(string key, Func<string, CacheItem<TValue>> va
Check.EnsureNotNullOrWhiteSpace(key, nameof(key));
Check.EnsureNotNull(valueFactory, nameof(valueFactory));

return GetOrAddInternal(key, null, (k, r) => valueFactory(k));
return GetOrAddInternal(key, null, (k, _) => valueFactory(k));
}

/// <inheritdoc />
Expand All @@ -57,7 +57,7 @@ public bool TryGetOrAdd(string key, Func<string, TValue> valueFactory, out TValu
if (TryGetOrAddInternal(
key,
null,
(k, r) =>
(k, _) =>
{
var newValue = valueFactory(k);
return newValue == null ? null : new CacheItem<TValue>(k, newValue);
Expand Down Expand Up @@ -103,7 +103,7 @@ public bool TryGetOrAdd(string key, Func<string, CacheItem<TValue>> valueFactory
Check.EnsureNotNullOrWhiteSpace(key, nameof(key));
Check.EnsureNotNull(valueFactory, nameof(valueFactory));

return TryGetOrAddInternal(key, null, (k, r) => valueFactory(k), out item);
return TryGetOrAddInternal(key, null, (k, _) => valueFactory(k), out item);
}

/// <inheritdoc />
Expand Down
24 changes: 22 additions & 2 deletions Source/Euonia.Repository.Mongo/Core/ModelProfile.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Linq.Expressions;
using System.Linq.Expressions;
using MongoDB.Bson.Serialization;
using Nerosoft.Euonia.Reflection;

Expand All @@ -25,24 +24,45 @@ public class ModelProfile

internal bool? BypassDocumentValidation { get; set; }

/// <summary>
/// Sets the model key.
/// </summary>
/// <param name="key"></param>
/// <param name="type"></param>
/// <returns></returns>
public ModelKeyBuilder HasKey(string key, Type type = null)
{
_keyBuilder = new ModelKeyBuilder(key, type);
return _keyBuilder;
}

/// <summary>
/// Sets the collection name for current model.
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
public ModelProfile ToCollection(string name)
{
CollectionName = name;
return this;
}

/// <summary>
/// Sets a value indicating whether to automatically map properties.
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public ModelProfile AutoMap(bool value)
{
AutoMapProperty = value;
return this;
}

/// <summary>
/// Sets a value indicating whether to bypass document validation.
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public ModelProfile BypassValidation(bool value)
{
BypassDocumentValidation = value;
Expand Down

0 comments on commit f92b731

Please sign in to comment.