Ejemplo n.º 1
0
        public string Encode(string markerStr, string resultName)
        {
            if (!InfectiousMarker.IsValidate(markerStr))
            {
                throw new Exception("Invalid InfectiousMarker.");
            }

            TR tr = TR.TRList.Where(r => r.Name == resultName).FirstOrDefault();

            if (tr == null)
            {
                throw new Exception("Invalid TestResultName.");
            }

            if (Coop == null)
            {
                throw new Exception("Invalid Coop TestResult.");
            }

            string coopTRName = Coop.Decode(markerStr);

            int value = value2TR.Where(r => r.Result.Name == tr.Name)
                        .Join(Coop.value2TR.Where(r => r.Result.Name == coopTRName),
                              r1 => r1.Value,
                              r2 => r2.Value,
                              (r1, r2) => r1.Value).FirstOrDefault();

            return(markerStr.Substring(0, Index) + value.ToString() + markerStr.Substring(Index + 1));
        }
Ejemplo n.º 2
0
        public string Decode(string markerStr)
        {
            if (!InfectiousMarker.IsValidate(markerStr))
            {
                return("Invalid InfectiousMarker.");
                //throw new Exception("Invalid InfectiousMarker.");
            }


            int value = markerStr.Substring(this.Index, 1).ToInt();

            return(this.value2TR.Where(r => r.Value == value).Select(r => r.Result.Name).FirstOrDefault());
        }