2
0

ProfileParser.jvm.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. //
  2. // System.Web.UI.MasterPageParser
  3. //
  4. // Authors:
  5. // Vladimir Krasnov ([email protected])
  6. //
  7. //
  8. // Permission is hereby granted, free of charge, to any person obtaining
  9. // a copy of this software and associated documentation files (the
  10. // "Software"), to deal in the Software without restriction, including
  11. // without limitation the rights to use, copy, modify, merge, publish,
  12. // distribute, sublicense, and/or sell copies of the Software, and to
  13. // permit persons to whom the Software is furnished to do so, subject to
  14. // the following conditions:
  15. //
  16. // The above copyright notice and this permission notice shall be
  17. // included in all copies or substantial portions of the Software.
  18. //
  19. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  21. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  23. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  24. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  25. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  26. //
  27. #if NET_2_0
  28. using System;
  29. using System.Collections;
  30. using System.IO;
  31. using System.Web;
  32. using System.Web.Compilation;
  33. using System.Web.Util;
  34. using System.Web.J2EE;
  35. namespace System.Web.Profile
  36. {
  37. internal sealed class ProfileParser
  38. {
  39. internal ProfileParser (HttpContext context)
  40. {
  41. }
  42. public static Type GetProfileCommonType (HttpContext context)
  43. {
  44. if (!ProfileCommonTypeExists)
  45. return null;
  46. Type profileBaseType = Type.GetType ("ProfileCommon");
  47. if (profileBaseType == null) {
  48. //PageMapper call
  49. string virtualPath = "~/App_Code/ProfileCommon";
  50. string resolvedUrl = System.Web.Util.UrlUtils.ResolveVirtualPathFromAppAbsolute (virtualPath).TrimEnd ('/');
  51. profileBaseType = PageMapper.GetObjectType (resolvedUrl, false);
  52. ProfileCommonTypeExists = profileBaseType != null;
  53. }
  54. return profileBaseType;
  55. }
  56. public static Type GetProfileGroupType (HttpContext context, string groupName)
  57. {
  58. if (!ProfileGroupTypeExists)
  59. return null;
  60. Type profileGroupType = Type.GetType ("ProfileGroup" + groupName);
  61. if (profileGroupType == null) {
  62. //PageMapper call
  63. string virtualPath = "~/App_Code/ProfileGroup" + groupName;
  64. string resolvedUrl = System.Web.Util.UrlUtils.ResolveVirtualPathFromAppAbsolute (virtualPath).TrimEnd ('/');
  65. profileGroupType = PageMapper.GetObjectType (resolvedUrl, false);
  66. ProfileGroupTypeExists = profileGroupType != null;
  67. }
  68. return profileGroupType;
  69. }
  70. const string profileKey = "System.Web.Profile.ProfileCommonType";
  71. private static bool ProfileCommonTypeExists
  72. {
  73. get
  74. {
  75. object o = AppDomain.CurrentDomain.GetData (profileKey);
  76. if (o == null)
  77. return true;
  78. return (bool) o;
  79. }
  80. set { AppDomain.CurrentDomain.SetData (profileKey, value); }
  81. }
  82. const string groupKey = "System.Web.Profile.ProfileGroupType";
  83. private static bool ProfileGroupTypeExists
  84. {
  85. get
  86. {
  87. object o = AppDomain.CurrentDomain.GetData (groupKey);
  88. if (o == null)
  89. return true;
  90. return (bool) o;
  91. }
  92. set { AppDomain.CurrentDomain.SetData (groupKey, value); }
  93. }
  94. }
  95. }
  96. #endif