static void Main(string[] args)
        {
            string text =
                " Hola, esta cadena tiene las primeras dos palabras separadas por dos separadores:  Una coma y un espacio";

            char[] separators = { ' ', '.', ',', ':' };
            foreach (TokenInfo ti in Tokenize.GetTokens(text, separators))
            {
                Console.WriteLine("Token: {0}, {1}", text.Substring(ti.StartPosition, ti.Length), ti);
            }
            //Get the substring that contains the first 2 words (tokens):
            int tokens = 0;
            int start  = 0;
            int end    = 0;

            foreach (TokenInfo ti in Tokenize.GetTokens(text, separators))
            {
                if (++tokens == 1)
                {
                    start = ti.StartPosition;
                }
                else if (tokens == 2)
                {
                    end = ti.StartPosition + ti.Length;
                }
                else
                {
                    break;
                }
            }
            Console.WriteLine();
            Console.WriteLine("Subcadena que contiene las 2 primeras palabras (tokens):  \"{0}\"", text.Substring(start, end - start));
        }
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (AuthorizationMode != null)
         {
             hashCode = hashCode * 59 + AuthorizationMode.GetHashCode();
         }
         if (CustomerReference != null)
         {
             hashCode = hashCode * 59 + CustomerReference.GetHashCode();
         }
         if (RecurringPaymentSequenceIndicator != null)
         {
             hashCode = hashCode * 59 + RecurringPaymentSequenceIndicator.GetHashCode();
         }
         if (RequiresApproval != null)
         {
             hashCode = hashCode * 59 + RequiresApproval.GetHashCode();
         }
         if (SkipAuthentication != null)
         {
             hashCode = hashCode * 59 + SkipAuthentication.GetHashCode();
         }
         if (SkipFraudService != null)
         {
             hashCode = hashCode * 59 + SkipFraudService.GetHashCode();
         }
         if (Token != null)
         {
             hashCode = hashCode * 59 + Token.GetHashCode();
         }
         if (Tokenize != null)
         {
             hashCode = hashCode * 59 + Tokenize.GetHashCode();
         }
         if (TransactionChannel != null)
         {
             hashCode = hashCode * 59 + TransactionChannel.GetHashCode();
         }
         if (UnscheduledCardOnFileIndicator != null)
         {
             hashCode = hashCode * 59 + UnscheduledCardOnFileIndicator.GetHashCode();
         }
         if (UnscheduledCardOnFileRequestor != null)
         {
             hashCode = hashCode * 59 + UnscheduledCardOnFileRequestor.GetHashCode();
         }
         return(hashCode);
     }
 }
Esempio n. 3
0
        public void TokenTest()
        {
            var raveConfig = new RaveConfig(PbKey, ScKey, false);
            var tokenCard  = new Tokenize(raveConfig);

            var tokenparam = new TokensParams(raveConfig.SecretKey, "Olufumi", "Obafumiso", "*****@*****.**", tranxRef, 100, "NGN", "NG")
            {
                Token     = "flw-t1nf-139d69763063262928b77bc1f4fba199-m03k",
                Narration = "Test",
            };
            var tokenResponse = tokenCard.Charge(tokenparam).Result;


            try
            {
                Assert.IsNotNull(tokenResponse.Data);
                Assert.AreEqual(tokenResponse.Status, "success");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
        public void TokenizeCorrectlyConvertsToJson()
        {
            var tokenize = new Tokenize("/", 4);

            tokenize.ToString().ShouldEqual(TokenizeJson);
        }
Esempio n. 5
0
        private bool LoadRecordsFromFile()
        {
            bool          Succ = false;
            StreamReader  rs   = OpenStreamForReading();
            int           RdVal;
            Char          RdChar;
            StringBuilder KeySB, ValSB;

            KeySB = new StringBuilder();
            ValSB = new StringBuilder();
            Tokenize TokenSt = Tokenize.Idle;

            if (rs != null)
            {
                try
                {
                    // tokenize key, value and add to 'records'
                    while ((RdVal = rs.Read()) != -1) // EOF detection
                    {
                        RdChar = (Char)RdVal;
                        switch (RdChar)
                        {
                        case RecEndMarker:
                            bool NewRec = false;
                            switch (TokenSt)
                            {
                            case Tokenize.ValStarted:
                            case Tokenize.KeyEnded:         // Empty Value Field
                                TokenSt = Tokenize.ValEnded;
                                NewRec  = true;
                                break;
                            }
                            if (NewRec)
                            {
                                // Set Val to Key in Record
                                records[KeySB.ToString()] = ValSB.ToString();
                                // Reset String Builders
                                KeySB = KeySB.Remove(0, KeySB.Length);
                                ValSB = ValSB.Remove(0, ValSB.Length);
                            }
                            break;

                        case KeyValAssocMarker:
                            switch (TokenSt)
                            {
                            case Tokenize.KeyStarted:
                                TokenSt = Tokenize.KeyEnded;
                                break;
                            }
                            break;

                        default:
                            switch (TokenSt)
                            {
                            case Tokenize.Idle:
                            case Tokenize.ValEnded:
                                TokenSt = Tokenize.KeyStarted;
                                KeySB   = KeySB.Append(RdChar);
                                break;

                            case Tokenize.KeyStarted:
                                KeySB = KeySB.Append(RdChar);
                                break;

                            case Tokenize.KeyEnded:
                                TokenSt = Tokenize.ValStarted;
                                ValSB   = ValSB.Append(RdChar);
                                break;

                            case Tokenize.ValStarted:
                                ValSB = ValSB.Append(RdChar);
                                break;
                            }
                            break;
                        }
                    }
                    Succ = true;
                }
                catch (IOException)
                {
                    // Clear all Records
                    records.Clear();
                    Succ = false;
                }
                finally
                {
                    rs.Close();
                }
            }
            else
            {
                Succ = true; // No records from file
            }
            return(Succ);
        }
        /// <summary>
        /// Returns true if AbstractCardPaymentMethodSpecificInput instances are equal
        /// </summary>
        /// <param name="other">Instance of AbstractCardPaymentMethodSpecificInput to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(AbstractCardPaymentMethodSpecificInput other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     AuthorizationMode == other.AuthorizationMode ||
                     AuthorizationMode != null &&
                     AuthorizationMode.Equals(other.AuthorizationMode)
                     ) &&
                 (
                     CustomerReference == other.CustomerReference ||
                     CustomerReference != null &&
                     CustomerReference.Equals(other.CustomerReference)
                 ) &&
                 (
                     RecurringPaymentSequenceIndicator == other.RecurringPaymentSequenceIndicator ||
                     RecurringPaymentSequenceIndicator != null &&
                     RecurringPaymentSequenceIndicator.Equals(other.RecurringPaymentSequenceIndicator)
                 ) &&
                 (
                     RequiresApproval == other.RequiresApproval ||
                     RequiresApproval != null &&
                     RequiresApproval.Equals(other.RequiresApproval)
                 ) &&
                 (
                     SkipAuthentication == other.SkipAuthentication ||
                     SkipAuthentication != null &&
                     SkipAuthentication.Equals(other.SkipAuthentication)
                 ) &&
                 (
                     SkipFraudService == other.SkipFraudService ||
                     SkipFraudService != null &&
                     SkipFraudService.Equals(other.SkipFraudService)
                 ) &&
                 (
                     Token == other.Token ||
                     Token != null &&
                     Token.Equals(other.Token)
                 ) &&
                 (
                     Tokenize == other.Tokenize ||
                     Tokenize != null &&
                     Tokenize.Equals(other.Tokenize)
                 ) &&
                 (
                     TransactionChannel == other.TransactionChannel ||
                     TransactionChannel != null &&
                     TransactionChannel.Equals(other.TransactionChannel)
                 ) &&
                 (
                     UnscheduledCardOnFileIndicator == other.UnscheduledCardOnFileIndicator ||
                     UnscheduledCardOnFileIndicator != null &&
                     UnscheduledCardOnFileIndicator.Equals(other.UnscheduledCardOnFileIndicator)
                 ) &&
                 (
                     UnscheduledCardOnFileRequestor == other.UnscheduledCardOnFileRequestor ||
                     UnscheduledCardOnFileRequestor != null &&
                     UnscheduledCardOnFileRequestor.Equals(other.UnscheduledCardOnFileRequestor)
                 ));
        }
Esempio n. 7
0
 static void Main(string[] args)
 {
     Tokenize tokenizer = new Tokenize("Testing/countingLoop.cpp");
 }