/// <summary> /// Creates the channel by calling the ChannelManager. /// </summary> /// <returns>The channel with the given name.</returns> /// <param name="attribute">The attribute describing the channel to create.</param> /// <typeparam name="T">The type of data in the channel.</typeparam> protected virtual IChannel <T> DoCreateChannel <T>(ChannelNameAttribute attribute) { // Recusively visit the scope create helpers var cur = this; while (cur != null) { if (!string.IsNullOrWhiteSpace(attribute.Name) && cur.m_namedCreateHelpers.TryGetValue(attribute.Name, out var creator)) { var res = creator(this, attribute); if (res != null) { return((IChannel <T>)res); } } foreach (var p in cur.m_createOverrides) { var res = p(this, attribute); if (res != null) { return((IChannel <T>)res); } } cur = cur.ParentScope; } return(ChannelManager.CreateChannelForScope <T>(attribute)); }
/// <summary> /// Helper method to invoke the default channel instance creator /// </summary> /// <returns>The created channel.</returns> /// <param name="attribute">The attribute describing the channel to create.</param> protected IChannel <T> BaseCreateChannel <T>(ChannelNameAttribute attribute) { if (ParentScope != Root) { return(ParentScope.GetOrCreate <T>(attribute)); } return(ChannelManager.CreateChannelForScope <T>(attribute)); }
/// <summary> /// Creates the channel by calling the ChannelManager. /// </summary> /// <returns>The channel with the given name.</returns> /// <param name="attribute">The attribute describing the channel to create.</param> /// <typeparam name="T">The type of data in the channel.</typeparam> protected virtual IChannel <T> DoCreateChannel <T>(ChannelNameAttribute attribute) { var cur = this; while (cur != null && cur != Root) { var res = cur.TryCreateChannel <T>(attribute); if (res != null) { return(res); } cur = cur.ParentScope; } return(ChannelManager.CreateChannelForScope <T>(attribute)); }
/// <summary> /// Returns the default channel type /// </summary> /// <returns>The created channel.</returns> /// <param name="attribute">The channel attribute.</param> /// <typeparam name="T">The channel type parameter.</typeparam> protected override IChannel <T> TryCreateChannel <T>(ChannelNameAttribute attribute) { return(ChannelManager.CreateChannelForScope <T>(attribute)); }
/// <summary> /// Creates the channel by calling the ChannelManager. /// </summary> /// <returns>The channel with the given name.</returns> /// <param name="attribute">The attribute describing the channel to create.</param> /// <typeparam name="T">The type of data in the channel.</typeparam> protected virtual IChannel <T> DoCreateChannel <T>(ChannelNameAttribute attribute) { return(ChannelManager.CreateChannelForScope <T>(attribute)); }