コード例 #1
0
 public Task EnlistAsync(IWeakActivationExtension subject, IWeakActivationFactor factor)
 {
     Registrations[subject] = factor switch
     {
         FakeWeakActivationFactor activity => activity,
                                  _ => throw new NotSupportedException(),
     };
     return(Task.CompletedTask);
 }
コード例 #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()
            });
コード例 #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);
        }
コード例 #4
0
 public Entry(IWeakActivationFactor factor)
 {
     Factor = factor ?? throw new ArgumentNullException(nameof(factor));
 }
コード例 #5
0
 public int CompareTo(IWeakActivationFactor other)
 {
     return(other is FakeWeakActivationFactor factor
         ? FakeProperty.CompareTo(factor.FakeProperty)
         : throw new InvalidOperationException());
 }