X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2FSystem%2FSystem.Net%2FSocketPermissionAttribute.cs;h=1ccb8f107f93fb1486018a02ef86842b08825b45;hb=bd9e32f5d73882a39877c4435e6087d69d7ebb61;hp=9c7170c3232bea8cfa456bd3ebdeb324a9951677;hpb=c39d7ce9985a7067c1cbf44188007c9433901940;p=mono.git diff --git a/mcs/class/System/System.Net/SocketPermissionAttribute.cs b/mcs/class/System/System.Net/SocketPermissionAttribute.cs index 9c7170c3232..1ccb8f107f9 100644 --- a/mcs/class/System/System.Net/SocketPermissionAttribute.cs +++ b/mcs/class/System/System.Net/SocketPermissionAttribute.cs @@ -1,7 +1,7 @@ -// -// System.Net.SocketPermissionAttribute.cs -// -// Author: +// +// System.Net.SocketPermissionAttribute.cs +// +// Author: // Lawrence Pit (loz@cable.a2000.nl) // Sebastien Pouliot // @@ -26,133 +26,133 @@ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // - -using System.Security; -using System.Security.Permissions; - + +using System.Security; +using System.Security.Permissions; + namespace System.Net { - - [AttributeUsage (AttributeTargets.Assembly - | AttributeTargets.Class - | AttributeTargets.Struct - | AttributeTargets.Constructor - | AttributeTargets.Method, AllowMultiple = true, Inherited = false) - ] - [Serializable] + + [AttributeUsage (AttributeTargets.Assembly + | AttributeTargets.Class + | AttributeTargets.Struct + | AttributeTargets.Constructor + | AttributeTargets.Method, AllowMultiple = true, Inherited = false) + ] + [Serializable] public sealed class SocketPermissionAttribute : CodeAccessSecurityAttribute { - - // Fields - string m_access; - string m_host; - string m_port; - string m_transport; - - // Constructors + + // Fields + string m_access; + string m_host; + string m_port; + string m_transport; + + // Constructors public SocketPermissionAttribute (SecurityAction action) - : base (action) - { - } - - // Properties - - public string Access { - get { return m_access; } - set { - if (m_access != null) - AlreadySet ("Access"); - - m_access = value; - } - } - - public string Host { - get { return m_host; } - set { - if (m_host != null) - AlreadySet ("Host"); - - m_host = value; - } - } - - public string Port { - get { return m_port; } - set { - if (m_port != null) - AlreadySet ("Port"); - - m_port = value; - } - } - - public string Transport { - get { return m_transport; } - set { - if (m_transport != null) - AlreadySet ("Transport"); - - m_transport = value; - } - } - - // Methods - + : base (action) + { + } + + // Properties + + public string Access { + get { return m_access; } + set { + if (m_access != null) + AlreadySet ("Access"); + + m_access = value; + } + } + + public string Host { + get { return m_host; } + set { + if (m_host != null) + AlreadySet ("Host"); + + m_host = value; + } + } + + public string Port { + get { return m_port; } + set { + if (m_port != null) + AlreadySet ("Port"); + + m_port = value; + } + } + + public string Transport { + get { return m_transport; } + set { + if (m_transport != null) + AlreadySet ("Transport"); + + m_transport = value; + } + } + + // Methods + public override IPermission CreatePermission () - { - if (this.Unrestricted) - return new SocketPermission (PermissionState.Unrestricted); - - string missing = String.Empty; - if (m_access == null) - missing += "Access, "; - if (m_host == null) - missing += "Host, "; - if (m_port == null) - missing += "Port, "; + { + if (this.Unrestricted) + return new SocketPermission (PermissionState.Unrestricted); + + string missing = String.Empty; + if (m_access == null) + missing += "Access, "; + if (m_host == null) + missing += "Host, "; + if (m_port == null) + missing += "Port, "; if (m_transport == null) - missing += "Transport, "; + missing += "Transport, "; if (missing.Length > 0) { string msg = Locale.GetText ("The value(s) for {0} must be specified."); missing = missing.Substring (0, missing.Length - 2); // remove last separator throw new ArgumentException (String.Format (msg, missing)); - } - - NetworkAccess access; - TransportType transport; - int port = SocketPermission.AllPorts; - - if (String.Compare (m_access, "Connect", true) == 0) - access = NetworkAccess.Connect; - else if (String.Compare (m_access, "Accept", true) == 0) - access = NetworkAccess.Accept; - else { + } + + NetworkAccess access; + TransportType transport; + int port = SocketPermission.AllPorts; + + if (String.Compare (m_access, "Connect", true) == 0) + access = NetworkAccess.Connect; + else if (String.Compare (m_access, "Accept", true) == 0) + access = NetworkAccess.Accept; + else { string msg = Locale.GetText ("The parameter value for 'Access', '{1}, is invalid."); throw new ArgumentException (String.Format (msg, m_access)); - } - - if (String.Compare (m_port, "All", true) != 0) { - try { - port = Int32.Parse (m_port); + } + + if (String.Compare (m_port, "All", true) != 0) { + try { + port = Int32.Parse (m_port); } - catch { + catch { string msg = Locale.GetText ("The parameter value for 'Port', '{1}, is invalid."); throw new ArgumentException (String.Format (msg, m_port)); - } - // test whether port number is valid.. - new IPEndPoint (1, port); - } - - try { - transport = (TransportType) Enum.Parse (typeof (TransportType), m_transport, true); + } + // test whether port number is valid.. + new IPEndPoint (1, port); + } + + try { + transport = (TransportType) Enum.Parse (typeof (TransportType), m_transport, true); } - catch { + catch { string msg = Locale.GetText ("The parameter value for 'Transport', '{1}, is invalid."); throw new ArgumentException (String.Format (msg, m_transport)); - } - - SocketPermission perm = new SocketPermission (PermissionState.None); - perm.AddPermission (access, transport, m_host, port); - return perm; + } + + SocketPermission perm = new SocketPermission (PermissionState.None); + perm.AddPermission (access, transport, m_host, port); + return perm; } // helpers @@ -162,5 +162,5 @@ namespace System.Net { string msg = Locale.GetText ("The parameter '{0}' can be set only once."); throw new ArgumentException (String.Format (msg, property), property); } - } -} + } +}