コード例 #1
0
ファイル: OscAddress.cs プロジェクト: HakanL/Haukcode.Osc
        /// <summary>
        /// Does a address match a address pattern
        /// </summary>
        /// <param name="addressPattern">address pattern (may include wildcards and lists)</param>
        /// <param name="address">literal address</param>
        /// <returns>true if the addess matches the pattern</returns>
        public static bool IsMatch(string addressPattern, string address)
        {
            if (IsValidAddressLiteral(address) == false)
            {
                return(false);
            }

            // are they both literals
            if (IsValidAddressLiteral(addressPattern) == true)
            {
                // preform a string match
                return(addressPattern.Equals(address));
            }

            if (IsValidAddressPattern(addressPattern) == false)
            {
                return(false);
            }

            // create a new pattern for the match
            OscAddress pattern = new OscAddress(addressPattern);

            // return the result
            return(pattern.Match(address));
        }
コード例 #2
0
ファイル: OscAddress.cs プロジェクト: HakanL/Haukcode.Osc
 /// <summary>
 /// Match this address against another
 /// </summary>
 /// <param name="address">the address to match against</param>
 /// <returns>true if the addresses match, otherwise false</returns>
 public bool Match(OscAddress address)
 {
     // if both addresses are literals then we can match on original string
     if (type == OscAddressType.Literal &&
         address.type == OscAddressType.Literal)
     {
         return(OrigialString.Equals(address.OrigialString));
     }
     // if this address is a literal then use the others regex
     else if (type == OscAddressType.Literal)
     {
         return(address.regex.IsMatch(OrigialString));
     }
     // if the other is a literal use this ones regex
     else if (address.type == OscAddressType.Literal)
     {
         return(regex.IsMatch(address.OrigialString));
     }
     // if both are patterns then we just match on pattern original strings
     else
     {
         return(OrigialString.Equals(address.OrigialString));
     }
 }