Пример #1
0
        private static string GetNormalizedText(MarkupRule markupRule, InputLine inputLine)
        {
            var length = markupRule.Signifier.Length;
            var text   = inputLine.Text;

            text = text.TrimStart();
            return(text.Substring(length, text.Length - length));
        }
Пример #2
0
 public void AddRule(MarkupRule markupRule)
 {
     Invariant.ArgumentNotNull(markupRule, "markupRule");
     if (MarkupRules.Find(x => x.Signifier == markupRule.Signifier) != null)
     {
         throw new ArgumentException(string.Format("A MarkupRule with the signifier '{0}' has already been added.", markupRule.Signifier));
     }
     MarkupRules.Add(markupRule);
     MarkupRules.Sort((x, y) => x.Signifier.Length.CompareTo(y.Signifier.Length));
 }
        public MarkupRule GetMarkupByID(int MarkupID)
        {
            MarkupRule markup = new MarkupRule();

            using (BusinessRulesDBEntities db = new BusinessRulesDBEntities())
            {
                SalesMarkup salesMarkup = db.SalesMarkups.Where(a => a.ID == MarkupID).FirstOrDefault();
                if (salesMarkup != null)
                {
                    markup.ID              = salesMarkup.ID;
                    markup.Name            = salesMarkup.MarkupName;
                    markup.Base            = salesMarkup.MarkupBase;
                    markup.commAmount      = salesMarkup.CommAmt.Value;
                    markup.commRelatedUnit = salesMarkup.CommRelatedUnit;
                    markup.commRound       = salesMarkup.CommRound;
                    markup.commType        = salesMarkup.CommType;
                    markup.EndDate         = salesMarkup.MarkupEndDate.Value;
                    markup.Priority        = salesMarkup.MarkupPriority.Value;
                    markup.StartDate       = salesMarkup.MarkupStartDate.Value;
                    List <SalesMarkupCriteria> markupCriteria = db.SalesMarkupCriterias.Where(a => a.MarkupID == markup.Name).ToList();
                    if (markupCriteria.Count > 0)
                    {
                        markup.CriteriaList = (from mc in markupCriteria
                                               join c in db.Criterias_Difinition on mc.MarkupCriteria equals c.ID.ToString()
                                               select new SalesRulesCriteria
                        {
                            criteriaName = c.criteriaName,
                            operation = mc.operation,
                            textValue = mc.CriteriaValueText,
                            value = mc.CriteriaValue
                        }).ToList();
                    }
                }
            }
            return(markup);
        }
Пример #4
0
        /// <summary>
        /// StringTest tests strings. To be converted into a UnitTest later.
        /// </summary>
        public static void StringTest()
        {
            Console.Read();

            const MarkupRule hiLite = MarkupRule.HiLight;
            var hiLiteAsList        = new HashSet <MarkupRule> {
                hiLite
            };
            var testString1 = new MarkupString(new Markup(hiLiteAsList));
            var testString2 = new MarkupString();

            /* ----------------------------------
             *  Testing Ansi Insert and Remove
             * ---------------------------------- */
            Console.WriteLine("Inserting DOOD into HiLite markup string 1 at position 0.");
            testString1.Insert("DOOD", 0);
            Console.WriteLine("Inserting Omnomnom into markup string 2 at position 0.");
            testString2.Insert("Omnomnom", 0);
            Console.WriteLine("Inserting markup string 1 into markup string 2 at position 4.");
            testString2.Insert(testString1, 4);
            Console.WriteLine("Printing markup string 2: ");
            Console.WriteLine(testString2.ToString());
            Console.WriteLine("Removing 4 characters starting at position 3 from markup string 2.");
            testString2.Remove(3, 4);
            Console.WriteLine("Printing markup string 2: ");
            Console.WriteLine(testString2.ToString());

            /* ----------------------------------
             *  Testing Ansi Flattening
             * ---------------------------------- */
            Console.WriteLine("Ansi Flattening Tests");
            var testString3 = new List <MarkupString>();

            testString2.FlattenInto(ref testString3);

            Console.WriteLine("Flattening string 2 into string 3, and printing.");
            Console.WriteLine(testString2.ToString());

            var sb2 = new StringBuilder();

            foreach (MarkupString each in testString3)
            {
                sb2.Append(each.ToTestString());
            }

            Console.WriteLine(sb2.ToString());
            Console.WriteLine("\n\n\n");
            Console.ReadLine();


            Console.WriteLine("Creating string 4 from string 2 (" + testString2 + "), starting at position 2, length 4.");
            var testString4 = new MarkupString(testString2, 2, 4);

            Console.WriteLine(testString4.ToString());

            Console.WriteLine("\nInserting 'Graaaa' into string 4 at position 2.");
            testString4.Insert("Graaaa", 2);

            Console.WriteLine("Printing test string 4");
            Console.WriteLine(testString4);

            Console.WriteLine("Replacing string 4 at position 3 for length 4 with 'IttyBittyKittyCommitty'");
            testString4.Replace(new MarkupString("IttyBittyKittyCommitty"), 3, 4);
            Console.WriteLine("Printing test string 4");
            Console.WriteLine(testString4);

            Console.WriteLine("Replacing string 4 at position 4 for length 2 with string 2 (" + testString2 + ")");
            testString4.Replace(testString2, 4, 2);
            Console.WriteLine("Printing test string 4");
            Console.WriteLine(testString4);
            Console.ReadLine();
        }