Esempio n. 1
0
        private void SetupSpecialUtilizations(ref SetMapping mapping, HiToTextEntryFieldNameSpecialUtilization[] specialUtilizations)
        {
            mapping.SpecialUtilizations = SetMapping.GetSpecialUtilizations(specialUtilizations);

            if (mapping.HasSpecialUtilization(SetMapping.SpecialUtilization.DetermineRank))
                mapping.DetermineRank = GetRankFunction(specialUtilizations);
            if (mapping.HasSpecialUtilization(SetMapping.SpecialUtilization.IncomingModified))
                mapping.IncomingModifiedFunction = GetIMF(specialUtilizations);
        }
Esempio n. 2
0
        private HTTF.WrapperString GetIMF(HiToTextEntryFieldNameSpecialUtilization[] specialUtilizations)
        {
            string fnName = string.Empty;

            foreach (HiToTextEntryFieldNameSpecialUtilization su in specialUtilizations)
            {
                if (su.Value.ToUpper().Equals("INCOMINGMODIFIED"))
                {
                    fnName = su.Function;
                    break;
                }
            }

            switch (fnName.ToUpper().Substring(0, 1))
            {
                case "/":
                    return delegate(string s) { return (Convert.ToInt32(s) / Convert.ToInt32(fnName.Substring(1))).ToString(); };
                case "+":
                    return delegate(string s) { return (Convert.ToInt32(s) + Convert.ToInt32(fnName.Substring(1))).ToString(); };
                case "*":
                    return delegate(string s) { return (Convert.ToInt32(s) * Convert.ToInt32(fnName.Substring(1))).ToString(); };
                case "-":
                    return delegate(string s) { return (Convert.ToInt32(s) - Convert.ToInt32(fnName.Substring(1))).ToString(); };
                case "%":
                    return delegate(string s) { return (Convert.ToInt32(s) % Convert.ToInt32(fnName.Substring(1))).ToString(); };
                default: //Mostly for string.empty.
                    return null;
            }
        }
Esempio n. 3
0
        private HTTF.ConvertByteArrayToInt GetRankFunction(HiToTextEntryFieldNameSpecialUtilization[] specialUtilizations)
        {
            string fnName = string.Empty;

            foreach (HiToTextEntryFieldNameSpecialUtilization su in specialUtilizations)
            {
                if (su.Value.ToUpper().Equals("DETERMINERANK"))
                {
                    fnName = su.Function;
                    break;
                }
            }

            switch (fnName.ToUpper())
            {
                case "STANDARD":
                    return HTTF.ByteArrayToInt.Standard;
                case "REVERSED":
                    return HTTF.ByteArrayToInt.Reversed;
                case "HEX":
                    return HTTF.ByteArrayToInt.Hex;
                case "HEXREVERSED":
                    return HTTF.ByteArrayToInt.HexReversed;
                case "BCD":
                    return HTTF.ByteArrayToInt.BCD;
                case "BCDREVERSED":
                    return HTTF.ByteArrayToInt.BCDReversed;
                case "INVERSEBCD":
                    return HTTF.ByteArrayToInt.InverseBCD;
                default: //For methods not described above.
                    MethodInfo[] methodInfos = typeof(HTTF.ByteArrayToInt).GetMethods(
                        BindingFlags.Public | BindingFlags.Static);
                    for (int i = 0; i < methodInfos.Length; i++)
                    {
                        if (methodInfos[i].Name.ToUpper().Equals(fnName.ToUpper()))
                        {
                            return (HTTF.ConvertByteArrayToInt)Delegate.CreateDelegate(
                                typeof(HTTF.ConvertByteArrayToInt), methodInfos[i]);
                        }
                    }

                    //If we still don't have a method, look to see if there's a CBAS function,
                    //and just convert that to an int.
                    MethodInfo[] methodInfos2 = typeof(HTTF.ConvertByteArraysToStrings).GetMethods(
                        BindingFlags.Public | BindingFlags.Static);
                    for (int i = 0; i < methodInfos2.Length; i++)
                    {
                        if (methodInfos2[i].Name.ToUpper().Equals(fnName.ToUpper()))
                        {
                            HTTF.ConvertByteArrayToString cbas =
                                (HTTF.ConvertByteArrayToString)Delegate.CreateDelegate(
                                    typeof(HTTF.ConvertByteArrayToString), methodInfos2[i]);

                            return delegate(byte[] score) { return Convert.ToInt32(cbas(score)); };
                        }
                    }

                    throw new Exception("Error: No known DetermineRank function for \"" + fnName + "\" was found.");
            }
        }
Esempio n. 4
0
        public static SetMapping.SpecialUtilization GetSpecialUtilizations(HiToTextEntryFieldNameSpecialUtilization[] specialUtilizations)
        {
            SetMapping.SpecialUtilization toReturn = SetMapping.SpecialUtilization.None;

            if (specialUtilizations == null)
                return SetMapping.SpecialUtilization.None;

            foreach (HiToTextEntryFieldNameSpecialUtilization su in specialUtilizations)
            {
                switch (su.Value.ToUpper())
                {
                    case "EMPTYSCORES":
                        if (toReturn.Equals(SetMapping.SpecialUtilization.None))
                            toReturn = SetMapping.SpecialUtilization.EmptyScores;
                        else
                            toReturn |= SetMapping.SpecialUtilization.EmptyScores;
                        break;
                    case "MODIFYNAME":
                        if (toReturn.Equals(SetMapping.SpecialUtilization.None))
                            toReturn = SetMapping.SpecialUtilization.ModifyName;
                        else
                            toReturn |= SetMapping.SpecialUtilization.ModifyName;
                        break;
                    case "ISHISCORE":
                        if (toReturn.Equals(SetMapping.SpecialUtilization.None))
                            toReturn = SetMapping.SpecialUtilization.IsHiScore;
                        else
                            toReturn |= SetMapping.SpecialUtilization.IsHiScore;
                        break;
                    case "DETERMINERANK":
                        if (toReturn.Equals(SetMapping.SpecialUtilization.None))
                            toReturn = SetMapping.SpecialUtilization.DetermineRank;
                        else
                            toReturn |= SetMapping.SpecialUtilization.DetermineRank;
                        break;
                    case "ISADJUSTED":
                        if (toReturn.Equals(SetMapping.SpecialUtilization.None))
                            toReturn = SetMapping.SpecialUtilization.IsAdjusted;
                        else
                            toReturn |= SetMapping.SpecialUtilization.IsAdjusted;
                        break;
                    case "INCOMINGMODIFIED":
                        if (toReturn.Equals(SetMapping.SpecialUtilization.None))
                            toReturn = SetMapping.SpecialUtilization.IncomingModified;
                        else
                            toReturn |= SetMapping.SpecialUtilization.IncomingModified;
                        break;
                }
            }

            return toReturn;
        }