You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

98 lines
2.7 KiB

  1. // Copyright (C) 2015 Google, 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. namespace GoogleMobileAds.Api
  15. {
  16. public class AdSize
  17. {
  18. private bool isSmartBanner;
  19. private int width;
  20. private int height;
  21. public static readonly AdSize Banner = new AdSize(320, 50);
  22. public static readonly AdSize MediumRectangle = new AdSize(300, 250);
  23. public static readonly AdSize IABBanner = new AdSize(468, 60);
  24. public static readonly AdSize Leaderboard = new AdSize(728, 90);
  25. public static readonly AdSize SmartBanner = new AdSize(true);
  26. public static readonly int FullWidth = -1;
  27. public AdSize(int width, int height)
  28. {
  29. isSmartBanner = false;
  30. this.width = width;
  31. this.height = height;
  32. }
  33. private AdSize(bool isSmartBanner) : this(0, 0)
  34. {
  35. this.isSmartBanner = isSmartBanner;
  36. }
  37. public int Width
  38. {
  39. get
  40. {
  41. return width;
  42. }
  43. }
  44. public int Height
  45. {
  46. get
  47. {
  48. return height;
  49. }
  50. }
  51. public bool IsSmartBanner
  52. {
  53. get
  54. {
  55. return isSmartBanner;
  56. }
  57. }
  58. public override bool Equals(object obj)
  59. {
  60. if (obj == null || GetType() != obj.GetType())
  61. return false;
  62. AdSize other = (AdSize)obj;
  63. return (width == other.width) && (height == other.height) && (isSmartBanner == other.isSmartBanner);
  64. }
  65. public static bool operator ==(AdSize a, AdSize b)
  66. {
  67. return a.Equals(b);
  68. }
  69. public static bool operator !=(AdSize a, AdSize b)
  70. {
  71. return !a.Equals(b);
  72. }
  73. public override int GetHashCode()
  74. {
  75. int hashBase = 71;
  76. int hashMultiplier = 11;
  77. int hash = hashBase;
  78. hash = (hash * hashMultiplier) ^ width.GetHashCode();
  79. hash = (hash * hashMultiplier) ^ height.GetHashCode();
  80. hash = (hash * hashMultiplier) ^ isSmartBanner.GetHashCode();
  81. return hash;
  82. }
  83. }
  84. }