Example #1
0
    /// <summary>
    /// Creates a new child context based on the current context instance.
    /// Includes an optional configuration method that can be immediately
    /// applied to the new context.  This method is used internally to create
    /// contexts for cloned clients and network method calls having custom
    /// configuration callbacks.
    /// </summary>
    private MirrorContextStack CreateChildContext(Action <IMirrorContext>?configure)
    {
        var context = new MirrorContextStack(_context);

        configure?.Invoke(context);
        return(context);
    }
Example #2
0
 /// <summary>
 /// Internal implementation of mirror client creation.  Accounts for  newly created
 /// clients and cloning of clients alike.
 /// </summary>
 /// <param name="configure">
 /// The optional <see cref="IContext"/> callback method, passed in from public
 /// instantiation or a <see cref="MirrorClient.Clone(Action{IMirrorContext})"/> method call.
 /// </param>
 /// <param name="parent">
 /// The parent <see cref="MirrorContextStack"/> if this creation is a result of a
 /// <see cref="Client.Clone(Action{IContext})"/> method call.
 /// </param>
 private MirrorClient(Action <IMirrorContext>?configure, MirrorContextStack?parent)
 {
     if (parent is null)
     {
         // Create a Context with System Defaults
         // that are unreachable and can't be "Reset".
         // At the moment, there are no defaults to set
         // but we still want a "root".
         parent = new MirrorContextStack(null);
     }
     _context = new MirrorContextStack(parent);
     configure?.Invoke(_context);
 }