Exemplo n.º 1
0
        private static Reference Create(Version.ScriptureInfo scriptureInfo, Range range)
        {
            Reference result = new Reference();

            result._scriptureInfo = scriptureInfo;

            result.HasSubReferences = false;
            result._ranges.Add(range);
            result.Length     = range.Length;
            result.FirstVerse = range.Start;
            result.LastVerse  = range.End;

            return(result);
        }
Exemplo n.º 2
0
        private static Reference Create(Version.ScriptureInfo scriptureInfo, IEnumerable <Range> ranges)
        {
            Reference result = new Reference();

            result._scriptureInfo = scriptureInfo;

            result.HasSubReferences = ranges.Count() > 1;
            result._ranges.AddRange(ranges);
            result.Length     = ranges.Sum(r => r.Length);
            result.FirstVerse = ranges.First().Start;
            result.LastVerse  = ranges.Last().End;

            return(result);
        }
Exemplo n.º 3
0
        public static bool TryParse(string s, Version.ScriptureInfo scriptureInfo, out Reference result)
        {
            if (s == null)
            {
                throw new ArgumentNullException("s", "s is null");
            }

            if (scriptureInfo == null)
            {
                throw new ArgumentNullException("scriptureInfo", "scriptureInfo is null");
            }

            //result = new Reference();

            Data.RawReference rawRef = Data.RawReference.Parse(s);

            if (rawRef.Count == 0)
            {
                result = null;
                return(false);
            }
            else if (rawRef.Count == 1)
            {
                result = Create(scriptureInfo, Range.Create(scriptureInfo, rawRef[0], 0, RepositoryMode.Safe));
            }
            else
            {
                int offset = 0;

                List <Range> ranges = new List <Range>();

                foreach (var r in rawRef)
                {
                    Range range = Range.Create(scriptureInfo, r, offset, RepositoryMode.Safe);
                    offset += range.Length;
                    ranges.Add(range);
                }

                result = Create(scriptureInfo, ranges);
            }
            return(true);
        }
 public static void MyClassInitialize(TestContext testContext)
 {
     ScriptureInfo.TryRegister("esv", @"e:\Users\Stephen\Desktop\SRP\trunk\Konves.Scripture\Data\esv.xml");
     si = ScriptureInfo.GetInstance("esv");
 }