BindServiceMethodAttribute.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #region Copyright notice and license
  2. // Copyright 2019 The gRPC Authors
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. #endregion
  16. using System;
  17. namespace Grpc.Core
  18. {
  19. /// <summary>
  20. /// Specifies the location of the service bind method for a gRPC service.
  21. /// The bind method is typically generated code and is used to register a service's
  22. /// methods with the server on startup.
  23. ///
  24. /// The bind method signature takes a <see cref="ServiceBinderBase"/> and an optional
  25. /// instance of the service base class, e.g. <c>static void BindService(ServiceBinderBase, GreeterService)</c>.
  26. /// </summary>
  27. [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
  28. public class BindServiceMethodAttribute : Attribute
  29. {
  30. /// <summary>
  31. /// Initializes a new instance of the <see cref="BindServiceMethodAttribute"/> class.
  32. /// </summary>
  33. /// <param name="bindType">The type the service bind method is defined on.</param>
  34. /// <param name="bindMethodName">The name of the service bind method.</param>
  35. public BindServiceMethodAttribute(Type bindType, string bindMethodName)
  36. {
  37. BindType = bindType;
  38. BindMethodName = bindMethodName;
  39. }
  40. /// <summary>
  41. /// Gets the type the service bind method is defined on.
  42. /// </summary>
  43. public Type BindType { get; }
  44. /// <summary>
  45. /// Gets the name of the service bind method.
  46. /// </summary>
  47. public string BindMethodName { get; }
  48. }
  49. }