예제 #1
0
		private LocalMessageReceiver (string receiverName,
					     ReceiverNameScope nameScope,
					     IEnumerable<string> allowedSenderDomains,
					     bool checkDomains)
			: this (NativeMethods.local_message_receiver_new (receiverName,
									  (int)nameScope), true)
		{
			if (receiverName == null)
				throw new ArgumentNullException ("receiverName");
			if (receiverName.Length > 256)
				throw new ArgumentException ("receiverName");

			string[] sender_domains;

			if (checkDomains) {
				if (allowedSenderDomains == null)
					throw new ArgumentNullException ("allowedSenderDomains");

				List<string> domains = new List<string> ();
				foreach (string s in allowedSenderDomains) {
					if (s == null)
						throw new ArgumentNullException ("allowedSenderDomains");
					if ((s.Length > 256) || (s.IndexOfAny (InvalidChars) != -1))
						throw new ArgumentException ("allowedSenderDomains");
					domains.Add (s);
				}
				sender_domains = domains.ToArray ();
				this.allowedSenderDomains = new ReadOnlyCollection<string> (domains);
			} else {
				sender_domains = new string [] { "*" };
				// AllowedSenderDomains needs to be 'null'
			}

			NativeMethods.local_message_receiver_set_allowed_sender_domains (NativeHandle, sender_domains, sender_domains.Length);
		}
예제 #2
0
        private LocalMessageReceiver(string receiverName,
                                     ReceiverNameScope nameScope,
                                     IEnumerable <string> allowedSenderDomains,
                                     bool checkDomains)
            : this(NativeMethods.local_message_receiver_new(receiverName,
                                                            (int)nameScope), true)
        {
            if (receiverName == null)
            {
                throw new ArgumentNullException("receiverName");
            }
            if (receiverName.Length > 256)
            {
                throw new ArgumentException("receiverName");
            }

            string[] sender_domains;

            if (checkDomains)
            {
                if (allowedSenderDomains == null)
                {
                    throw new ArgumentNullException("allowedSenderDomains");
                }

                List <string> domains = new List <string> ();
                foreach (string s in allowedSenderDomains)
                {
                    if (s == null)
                    {
                        throw new ArgumentNullException("allowedSenderDomains");
                    }
                    if ((s.Length > 256) || (s.IndexOfAny(InvalidChars) != -1))
                    {
                        throw new ArgumentException("allowedSenderDomains");
                    }
                    domains.Add(s);
                }
                sender_domains            = domains.ToArray();
                this.allowedSenderDomains = new ReadOnlyCollection <string> (domains);
            }
            else
            {
                sender_domains = new string [] { "*" };
                // AllowedSenderDomains needs to be 'null'
            }

            NativeMethods.local_message_receiver_set_allowed_sender_domains(NativeHandle, sender_domains, sender_domains.Length);
        }
예제 #3
0
		public LocalMessageReceiver (string receiverName,
					     ReceiverNameScope nameScope,
					     IEnumerable<string> allowedSenderDomains)
			: this (NativeMethods.local_message_receiver_new (receiverName,
									  (int)nameScope), true)
		{
			int i = 0;
			foreach (string s in allowedSenderDomains)
				i ++;

			string[] sender_domains = new string[i];
			i = 0;

			foreach (string s in allowedSenderDomains)
				sender_domains[i++] = s;

			NativeMethods.local_message_receiver_set_allowed_sender_domains (NativeHandle, sender_domains, sender_domains.Length);
		}
예제 #4
0
 public LocalMessageReceiver(string receiverName, ReceiverNameScope nameScope, IEnumerable <string> allowedSenderDomains)
 {
 }
예제 #5
0
		public LocalMessageReceiver (string receiverName,
					     ReceiverNameScope nameScope,
					     IEnumerable<string> allowedSenderDomains)
			: this (receiverName, nameScope, allowedSenderDomains, true)
		{
		}