Ejemplo n.º 1
0
 public Task EnlistAsync(IWeakActivationExtension subject, IWeakActivationFactor factor)
 {
     Registrations[subject] = factor switch
     {
         FakeWeakActivationFactor activity => activity,
                                  _ => throw new NotSupportedException(),
     };
     return(Task.CompletedTask);
 }
Ejemplo n.º 2
0
        public int CompareTo(IWeakActivationFactor other)
        {
            return(other switch
            {
                // a defined value is always greater than null
                null => 1,

                // apply comparison rules
                ActivityState activity => Priority.CompareTo(activity.Priority),

                // this factor only supports comparing against the same factor type
                _ => throw new InvalidOperationException()
            });
Ejemplo n.º 3
0
        public Task EnlistAsync(IWeakActivationExtension subject, IWeakActivationFactor factor)
        {
            if (subject is null)
            {
                throw new ArgumentNullException(nameof(subject));
            }
            if (factor is null)
            {
                throw new ArgumentNullException(nameof(factor));
            }

            _registry[subject] = new Entry(factor);

            return(Task.CompletedTask);
        }
Ejemplo n.º 4
0
 public Entry(IWeakActivationFactor factor)
 {
     Factor = factor ?? throw new ArgumentNullException(nameof(factor));
 }
Ejemplo n.º 5
0
 public int CompareTo(IWeakActivationFactor other)
 {
     return(other is FakeWeakActivationFactor factor
         ? FakeProperty.CompareTo(factor.FakeProperty)
         : throw new InvalidOperationException());
 }