NoOpElementNameValidator.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* Copyright 2010-present MongoDB Inc.
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. namespace MongoDB.Bson.IO
  16. {
  17. /// <summary>
  18. /// Represents an element name validator that does no validation.
  19. /// </summary>
  20. public class NoOpElementNameValidator : IElementNameValidator
  21. {
  22. // private static fields
  23. private static readonly NoOpElementNameValidator __instance = new NoOpElementNameValidator();
  24. // public static properties
  25. /// <summary>
  26. /// Gets the instance.
  27. /// </summary>
  28. /// <value>
  29. /// The instance.
  30. /// </value>
  31. public static NoOpElementNameValidator Instance
  32. {
  33. get { return __instance; }
  34. }
  35. // public methods
  36. /// <summary>
  37. /// Gets the validator to use for child content (a nested document or array).
  38. /// </summary>
  39. /// <param name="elementName">The name of the element.</param>
  40. /// <returns>The validator to use for child content.</returns>
  41. public IElementNameValidator GetValidatorForChildContent(string elementName)
  42. {
  43. return this;
  44. }
  45. /// <summary>
  46. /// Determines whether the element name is valid.
  47. /// </summary>
  48. /// <param name="elementName">The name of the element.</param>
  49. /// <returns>True if the element name is valid.</returns>
  50. public bool IsValidElementName(string elementName)
  51. {
  52. return true;
  53. }
  54. }
  55. }