ConfigurationSource.cs 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using SuperSocket.Common;
  6. namespace SuperSocket.SocketBase.Config
  7. {
  8. /// <summary>
  9. /// Poco configuration source
  10. /// </summary>
  11. [Serializable]
  12. public class ConfigurationSource : RootConfig, IConfigurationSource
  13. {
  14. /// <summary>
  15. /// Initializes a new instance of the <see cref="ConfigurationSource"/> class.
  16. /// </summary>
  17. public ConfigurationSource()
  18. {
  19. }
  20. /// <summary>
  21. /// Initializes a new instance of the <see cref="ConfigurationSource"/> class.
  22. /// </summary>
  23. /// <param name="source">The source.</param>
  24. public ConfigurationSource(IConfigurationSource source)
  25. : base(source)
  26. {
  27. if (source.Servers != null && source.Servers.Any())
  28. {
  29. this.Servers = source.Servers.Select(s => new ServerConfig(s)).ToArray();
  30. }
  31. if (source.ServerTypes != null && source.ServerTypes.Any())
  32. {
  33. this.ServerTypes = source.ServerTypes.Select(s => s.CopyPropertiesTo(new TypeProviderConfig())).ToArray();
  34. }
  35. if (source.ConnectionFilters != null && source.ConnectionFilters.Any())
  36. {
  37. this.ConnectionFilters = source.ConnectionFilters.Select(s => s.CopyPropertiesTo(new TypeProviderConfig())).ToArray();
  38. }
  39. if (source.LogFactories != null && source.LogFactories.Any())
  40. {
  41. this.LogFactories = source.LogFactories.Select(s => s.CopyPropertiesTo(new TypeProviderConfig())).ToArray();
  42. }
  43. if (source.ReceiveFilterFactories != null && source.ReceiveFilterFactories.Any())
  44. {
  45. this.ReceiveFilterFactories = source.ReceiveFilterFactories.Select(s => s.CopyPropertiesTo(new TypeProviderConfig())).ToArray();
  46. }
  47. if (source.CommandLoaders != null && source.CommandLoaders.Any())
  48. {
  49. this.CommandLoaders = source.CommandLoaders.Select(s => s.CopyPropertiesTo(new TypeProviderConfig())).ToArray();
  50. }
  51. }
  52. /// <summary>
  53. /// Gets the servers definitions.
  54. /// </summary>
  55. public IEnumerable<IServerConfig> Servers { get; set; }
  56. /// <summary>
  57. /// Gets/sets the server types definition.
  58. /// </summary>
  59. public IEnumerable<ITypeProvider> ServerTypes { get; set; }
  60. /// <summary>
  61. /// Gets/sets the connection filters definition.
  62. /// </summary>
  63. public IEnumerable<ITypeProvider> ConnectionFilters { get; set; }
  64. /// <summary>
  65. /// Gets/sets the log factories definition.
  66. /// </summary>
  67. public IEnumerable<ITypeProvider> LogFactories { get; set; }
  68. /// <summary>
  69. /// Gets/sets the Receive filter factories definition.
  70. /// </summary>
  71. public IEnumerable<ITypeProvider> ReceiveFilterFactories { get; set; }
  72. /// <summary>
  73. /// Gets/sets the command loaders definition.
  74. /// </summary>
  75. public IEnumerable<ITypeProvider> CommandLoaders { get; set; }
  76. }
  77. }