PageRenderTime 48ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/MySpaceSilverlight/MySpaceSilverlightKit/opensocial/Environment.cs

#
C# | 102 lines | 45 code | 12 blank | 45 comment | 0 complexity | 6ab1d4fb9eb9824b92f48fccb408dd96 MD5 | raw file
  1. // <copyright file="Environment.cs" company="Microsoft Corporation">
  2. // Copyright (c) 2009 Microsoft Corporation All Rights Reserved
  3. // </copyright>
  4. // <author>Michael S. Scherotter</author>
  5. // <email>mischero@microsoft.com</email>
  6. // <date>2008-09-23</date>
  7. // <summary>The Silverlight Application</summary>
  8. // Ignore SA1300
  9. namespace opensocial
  10. {
  11. using System.Windows.Browser;
  12. /// <summary>
  13. /// OpenSocial Environment
  14. /// </summary>
  15. public class Environment
  16. {
  17. /// <summary>
  18. /// JavaScript environment object
  19. /// </summary>
  20. private ScriptObject environment;
  21. /// <summary>
  22. /// Initializes a new instance of the Environment class.
  23. /// </summary>
  24. /// <param name="environment">environment object</param>
  25. internal Environment(ScriptObject environment)
  26. {
  27. this.environment = environment;
  28. }
  29. /// <summary>
  30. /// Get the domain
  31. /// </summary>
  32. /// <returns>the domain</returns>
  33. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "Mirroring OpenSocial API."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "get", Justification = "Mirroring OpenSocial API.")]
  34. public string getDomain()
  35. {
  36. return this.environment.Invoke("getDomain") as string;
  37. }
  38. /// <summary>
  39. /// Get the surfaces
  40. /// </summary>
  41. /// <returns>the OpenSocial Surface</returns>
  42. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "Mirroring OpenSocial API."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "get", Justification = "Mirroring OpenSocial API.")]
  43. public Surface getSurface()
  44. {
  45. Surface surface = new Surface(this.environment.Invoke("getSurface") as ScriptObject);
  46. return surface;
  47. }
  48. /// <summary>
  49. /// Returns an array of all the supported surfaces.
  50. /// </summary>
  51. /// <returns>an array of all the supported surfaces</returns>
  52. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "Mirroring OpenSocial API."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "get", Justification = "Mirroring OpenSocial API.")]
  53. public ScriptObject getSupportedSurfaces()
  54. {
  55. return this.environment.Invoke("getSupportedSurfaces") as ScriptObject;
  56. }
  57. /// <summary>
  58. /// get the parameters
  59. /// </summary>
  60. /// <returns>the parameters</returns>
  61. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "Mirroring OpenSocial API."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Params", Justification = "Mirroring OpenSocial API."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "get", Justification = "Mirroring OpenSocial API.")]
  62. public Map<string, string> getParams()
  63. {
  64. ScriptObject parameters = this.environment.Invoke("getParams") as ScriptObject;
  65. var result = new Map<string, string>(parameters);
  66. return result;
  67. }
  68. /// <summary>
  69. /// returns if the environment has a capability
  70. /// </summary>
  71. /// <param name="functionName">the function name</param>
  72. /// <returns>true if the environment has a capability</returns>
  73. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "has", Justification = "Mirroring OpenSocial API.")]
  74. public bool hasCapability(string functionName)
  75. {
  76. return (bool) this.environment.Invoke("hasCapability", functionName);
  77. }
  78. /// <summary>
  79. /// returns whether the environment supports a field
  80. /// </summary>
  81. /// <param name="objectType">the objectType</param>
  82. /// <param name="fieldName">the field name</param>
  83. /// <returns>the environment supports a field</returns>
  84. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "supports", Justification = "Mirroring OpenSocial API.")]
  85. public bool supportsField(string objectType, string fieldName)
  86. {
  87. return (bool) this.environment.Invoke("supportsField", objectType.ToString(), fieldName);
  88. }
  89. }
  90. }