Esempio n. 1
0
        private bool AddWordCapitalized(string word, FlagSet flags, MorphSet morphs, CapitalizationType capType)
        {
            // add inner capitalized forms to handle the following allcap forms:
            // Mixed caps: OpenOffice.org -> OPENOFFICE.ORG
            // Allcaps with suffixes: CIA's -> CIA'S

            if (
                (
                    capType == CapitalizationType.Huh ||
                    capType == CapitalizationType.HuhInit ||
                    (capType == CapitalizationType.All && flags.HasItems)
                )
                &&
                !flags.Contains(Affix.ForbiddenWord)
                )
            {
                flags = Builder.Dedup(FlagSet.Union(flags, SpecialFlags.OnlyUpcaseFlag));

                var textInfo       = Affix.Culture.TextInfo;
                var initCapBuilder = StringBuilderPool.Get(word);
                if (initCapBuilder.Length > 0)
                {
                    initCapBuilder[0] = textInfo.ToUpper(initCapBuilder[0]);

                    for (var i = 1; i < initCapBuilder.Length; i++)
                    {
                        initCapBuilder[i] = textInfo.ToLower(initCapBuilder[i]);
                    }
                }

                return(AddWord(StringBuilderPool.GetStringAndReturn(initCapBuilder), flags, morphs, true));
            }

            return(false);
        }
Esempio n. 2
0
        public Deposit(int id, double initial, double current, double rate, CapitalizationType capitalization, DateTimeOffset initialdate, DateTimeOffset expiration)
        {
            Logger.Log.Info("Deposit constructor was called");

            Id             = id;
            InitialMoney   = initial;
            CurrentMoney   = current;
            InterestRate   = rate;
            Capitalization = capitalization;
            InitialDate    = initialdate;
            ExpirationDate = expiration;
        }
Esempio n. 3
0
        public DepositsRepository()
        {
            try
            {
                var data = File.ReadAllLines(_path);

                foreach (var credit in data.Skip(1))
                {
                    var strg = credit.Split(';');
                    int.TryParse(strg[0], out int id);
                    double.TryParse(strg[1], out double initial);
                    double.TryParse(strg[2], out double current);
                    double.TryParse(strg[3], out double rate);

                    CapitalizationType capitalization = (CapitalizationType)Enum.Parse(typeof(SpendingCategory), strg[4]);
                    DateTimeOffset.TryParse(strg[5], out DateTimeOffset initialdate);
                    DateTimeOffset.TryParse(strg[6], out DateTimeOffset expiration);

                    var diff = DateTimeOffset.UtcNow - initialdate;

                    if (capitalization == CapitalizationType.No)
                    {
                        current = initial + (initial * rate * diff.Days / (365 * 100));
                    }
                    else
                    if (capitalization == CapitalizationType.Monthly)
                    {
                        double percent = 1 + (rate * 30 / (100 * 365));
                        current = initial * Math.Pow(percent, diff.Days / 30);
                    }
                    else
                    {
                        double percent = 1 + (rate * 365 / (100 * 365));
                        current = initial * Math.Pow(percent, diff.Days / 365);
                    }

                    _deposits.Add(new Deposit(id, initial, current, rate, capitalization, initialdate, expiration));
                    Count++;
                }
                Logger.Log.Info("Deposits repository was created");
            }
            catch (FileNotFoundException)
            {
                Logger.Log.Error("Deposits file was not found");
                var file = File.Create(_path);
                Logger.Log.Info("Deposits file was created");
                file.Dispose();
            }
        }
            private WordEntry CheckDetailsInitCap(int abbv, CapitalizationType capType, ref string scw, ref SpellCheckResultType resultType, out string root)
            {
                var u8buffer = HunspellTextFunctions.MakeAllSmall(scw, TextInfo);

                scw = HunspellTextFunctions.MakeInitCap(u8buffer, TextInfo);

                resultType |= SpellCheckResultType.OrigCap;
                if (capType == CapitalizationType.Init)
                {
                    resultType |= SpellCheckResultType.InitCap;
                }

                var rv = CheckWord(scw, ref resultType, out root);

                if (capType == CapitalizationType.Init)
                {
                    resultType &= ~SpellCheckResultType.InitCap;
                }

                // forbid bad capitalization
                // (for example, ijs -> Ijs instead of IJs in Dutch)
                // use explicit forms in dic: Ijs/F (F = FORBIDDENWORD flag)

                if (EnumEx.HasFlag(resultType, SpellCheckResultType.Forbidden))
                {
                    rv = null;
                    return(rv);
                }

                if (capType == CapitalizationType.All && rv != null && IsKeepCase(rv))
                {
                    rv = null;
                }

                if (rv != null || (!Affix.CultureUsesDottedI && scw.StartsWith('İ')))
                {
                    return(rv);
                }

                rv = CheckWord(u8buffer, ref resultType, out root);

                if (abbv != 0 && rv == null)
                {
                    u8buffer += ".";
                    rv        = CheckWord(u8buffer, ref resultType, out root);
                    if (rv == null)
                    {
                        u8buffer = scw + ".";
                        if (capType == CapitalizationType.Init)
                        {
                            resultType |= SpellCheckResultType.InitCap;
                        }

                        rv = CheckWord(u8buffer, ref resultType, out root);

                        if (capType == CapitalizationType.Init)
                        {
                            resultType &= ~SpellCheckResultType.InitCap;
                        }

                        if (capType == CapitalizationType.All && rv != null && IsKeepCase(rv))
                        {
                            rv = null;
                        }

                        return(rv);
                    }
                }

                if (
                    rv != null
                    &&
                    IsKeepCase(rv)
                    &&
                    (
                        capType == CapitalizationType.All
                        ||
                        // if CHECKSHARPS: KEEPCASE words with \xDF  are allowed in INITCAP form, too.
                        !(Affix.CheckSharps && u8buffer.Contains('ß'))
                    )
                    )
                {
                    rv = null;
                }

                return(rv);
            }