text:
using System;
using System.Linq;

using LinqToDB;

using NUnit.Framework;

namespace Tests.Linq
{
	using Model;

	[TestFixture]
	public class GroupByTest : TestBase
	{
		[Test, DataContextSource]
		public void Simple1(string context)
		{
			LinqToDB.Common.Configuration.Linq.PreloadGroups = true;

			using (var db = GetDataContext(context))
			{
				db.BeginTransaction();

				var q =
					from ch in db.Child
					group ch by ch.ParentID;

				var list = q.ToList().Where(n => n.Key < 6).OrderBy(n => n.Key).ToList();

				Assert.AreEqual(4, list.Count);

				for (var i = 0; i < list.Count; i++)
				{
					var values = list[i].OrderBy(c => c.ChildID).ToList();

					Assert.AreEqual(i + 1, list[i].Key);
					Assert.AreEqual(i + 1, values.Count);

					for (var j = 0; j < values.Count; j++)
						Assert.AreEqual((i + 1) * 10 + j + 1, values[j].ChildID);
				}
			}
		}

		[Test, DataContextSource]
		public void Simple2(string context)
		{
			LinqToDB.Common.Configuration.Linq.PreloadGroups = false;

			using (var db = GetDataContext(context))
			{
				var q =
					from ch in db.GrandChild
					group ch by new { ch.ParentID, ch.ChildID };

				var list = q.ToList();

				Assert.AreEqual   (8, list.Count);
				Assert.AreNotEqual(0, list.OrderBy(c => c.Key.ParentID).First().ToList().Count);
			}
		}

		[Test, DataContextSource]
		public void Simple3(string context)
		{
			using (var db = GetDataContext(context))
			{
				var q =
					from ch in db.Child
					group ch by ch.ParentID into g
					select g.Key;

				var list = q.ToList().Where(n => n < 6).OrderBy(n => n).ToList();

				Assert.AreEqual(4, list.Count);
				for (var i = 0; i < list.Count; i++) Assert.AreEqual(i + 1, list[i]);
			}
		}

		[Test, DataContextSource]
		public void Simple4(string context)
		{
			using (var db = GetDataContext(context))
			{
				var q =
					from ch in db.Child
					group ch by ch.ParentID into g
					orderby g.Key
					select g.Key;

				var list = q.ToList().Where(n => n < 6).ToList();

				Assert.AreEqual(4, list.Count);
				for (var i = 0; i < list.Count; i++) Assert.AreEqual(i + 1, list[i]);
			}
		}

		[Test, DataContextSource]
		public void Simple5(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					from ch in GrandChild
					group ch by new { ch.ParentID, ch.ChildID } into g
					group g  by new { g.Key.ParentID }          into g
					select g.Key
					,
					from ch in db.GrandChild
					group ch by new { ch.ParentID, ch.ChildID } into g
					group g  by new { g.Key.ParentID }          into g
					select g.Key);
		}

		[Test, DataContextSource]
		public void Simple6(string context)
		{
			using (var db = GetDataContext(context))
			{
				var q    = db.GrandChild.GroupBy(ch => new { ch.ParentID, ch.ChildID }, ch => ch.GrandChildID);
				var list = q.ToList();

				Assert.AreNotEqual(0, list[0].Count());
				Assert.AreEqual   (8, list.Count);
			}
		}

		[Test, DataContextSource]
		public void Simple7(string context)
		{
			using (var db = GetDataContext(context))
			{
				var q = db.GrandChild
					.GroupBy(ch => new { ch.ParentID, ch.ChildID }, ch => ch.GrandChildID)
					.Select (gr => new { gr.Key.ParentID, gr.Key.ChildID });

				var list = q.ToList();
				Assert.AreEqual(8, list.Count);
			}
		}

		[Test, DataContextSource]
		public void Simple8(string context)
		{
			using (var db = GetDataContext(context))
			{
				var q = db.GrandChild.GroupBy(ch => new { ch.ParentID, ch.ChildID }, (g,ch) => g.ChildID);

				var list = q.ToList();
				Assert.AreEqual(8, list.Count);
			}
		}

		[Test, DataContextSource]
		public void Simple9(string context)
		{
			using (var db = GetDataContext(context))
			{
				var q    = db.GrandChild.GroupBy(ch => new { ch.ParentID, ch.ChildID }, ch => ch.GrandChildID,  (g,ch) => g.ChildID);
				var list = q.ToList();

				Assert.AreEqual(8, list.Count);
			}
		}

		[Test, DataContextSource]
		public void Simple10(string context)
		{
			using (var db = GetDataContext(context))
			{
				var expected = (from ch in    Child group ch by ch.ParentID into g select g).ToList().OrderBy(p => p.Key).ToList();
				var result   = (from ch in db.Child group ch by ch.ParentID into g select g).ToList().OrderBy(p => p.Key).ToList();

				AreEqual(expected[0], result[0]);
				AreEqual(expected.Select(p => p.Key), result.Select(p => p.Key));
				AreEqual(expected[0].ToList(), result[0].ToList());
			}
		}

		[Test, DataContextSource]
		public void Simple11(string context)
		{
			using (var db = GetDataContext(context))
			{
				var q1 = GrandChild
					.GroupBy(ch => new { ParentID = ch.ParentID + 1, ch.ChildID }, ch => ch.ChildID);

				var q2 = db.GrandChild
					.GroupBy(ch => new { ParentID = ch.ParentID + 1, ch.ChildID }, ch => ch.ChildID);

				var list1 = q1.AsEnumerable().OrderBy(_ => _.Key.ChildID).ToList();
				var list2 = q2.AsEnumerable().OrderBy(_ => _.Key.ChildID).ToList();

				Assert.AreEqual(list1.Count,       list2.Count);
				Assert.AreEqual(list1[0].ToList(), list2[0].ToList());
			}
		}

		[Test, DataContextSource]
		public void Simple12(string context)
		{
			using (var db = GetDataContext(context))
			{
				var q = db.GrandChild
					.GroupBy(ch => new { ParentID = ch.ParentID + 1, ch.ChildID }, (g,ch) => g.ChildID);

				var list = q.ToList();
				Assert.AreEqual(8, list.Count);
			}
		}

		[Test, DataContextSource]
		public void Simple13(string context)
		{
			using (var db = GetDataContext(context))
			{
				var q = db.GrandChild
					.GroupBy(ch => new { ParentID = ch.ParentID + 1, ch.ChildID }, ch => ch.ChildID, (g,ch) => g.ChildID);

				var list = q.ToList();
				Assert.AreEqual(8, list.Count);
			}
		}

		//[Test, DataContextSource]
		public void Simple14(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					from p in    Parent
					select
						from c in p.Children
						group c by c.ParentID into g
						select g.Key,
					from p in db.Parent
					select
						from c in p.Children
						group c by c.ParentID into g
						select g.Key);
		}

		[Test, DataContextSource]
		public void MemberInit1(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					from ch in Child
					group ch by new Child { ParentID = ch.ParentID } into g
					select g.Key
					,
					from ch in db.Child
					group ch by new Child { ParentID = ch.ParentID } into g
					select g.Key);
		}

		class GroupByInfo
		{
			public GroupByInfo Prev;
			public object      Field;

			public override bool Equals(object obj)
			{
				return Equals(obj as GroupByInfo);
			}

			public bool Equals(GroupByInfo other)
			{
				if (ReferenceEquals(null, other)) return false;
				if (ReferenceEquals(this, other)) return true;
				return Equals(other.Prev, Prev) && Equals(other.Field, Field);
			}

			public override int GetHashCode()
			{
				unchecked
				{
					return ((Prev != null ? Prev.GetHashCode() : 0) * 397) ^ (Field != null ? Field.GetHashCode() : 0);
				}
			}
		}

		[Test, DataContextSource]
		public void MemberInit2(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					from ch in Child
					group ch by new GroupByInfo { Prev = new GroupByInfo { Field = ch.ParentID }, Field = ch.ChildID } into g
					select g.Key
					,
					from ch in db.Child
					group ch by new GroupByInfo { Prev = new GroupByInfo { Field = ch.ParentID }, Field = ch.ChildID } into g
					select g.Key);
		}

		[Test, DataContextSource]
		public void MemberInit3(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					from ch in Child
					group ch by new { Prev = new { Field = ch.ParentID }, Field = ch.ChildID } into g
					select g.Key
					,
					from ch in db.Child
					group ch by new { Prev = new { Field = ch.ParentID }, Field = ch.ChildID } into g
					select g.Key);
		}

		[Test, DataContextSource]
		public void SubQuery1(string context)
		{
			var n = 1;

			using (var db = GetDataContext(context))
				AreEqual(
					from ch in
						from ch in Child select ch.ParentID + 1
					where ch + 1 > n
					group ch by ch into g
					select g.Key
					,
					from ch in
						from ch in db.Child select ch.ParentID + 1
					where ch > n
					group ch by ch into g
					select g.Key);
		}

		[Test, DataContextSource]
		public void SubQuery2(string context)
		{
			var n = 1;

			using (var db = GetDataContext(context))
				AreEqual(
					from ch in Child select new { ParentID = ch.ParentID + 1 } into ch
					where ch.ParentID > n
					group ch by ch into g
					select g.Key
					,
					from ch in db.Child select new { ParentID = ch.ParentID + 1 } into ch
					where ch.ParentID > n
					group ch by ch into g
					select g.Key);
		}

		[Test, DataContextSource]
		public void SubQuery3(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					from ch in
						from ch in Child
						select new { ch, n = ch.ChildID + 1 }
					group ch by ch.n into g
					select new
					{
						g.Key,
						Sum = g.Sum(_ => _.ch.ParentID)
					}
					,
					from ch in
						from ch in db.Child
						select new { ch, n = ch.ChildID + 1 }
					group ch by ch.n into g
					select new
					{
						g.Key,
						Sum = g.Sum(_ => _.ch.ParentID)
					});
		}

		[Test, DataContextSource]
		public void SubQuery31(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					from ch in
						from ch in Child
						select new { ch, n = ch.ChildID + 1 }
					group ch.ch by ch.n into g
					select new
					{
						g.Key,
						Sum = g.Sum(_ => _.ParentID)
					}
					,
					from ch in
						from ch in db.Child
						select new { ch, n = ch.ChildID + 1 }
					group ch.ch by ch.n into g
					select new
					{
						g.Key,
						Sum = g.Sum(_ => _.ParentID)
					});
		}

		[Test, DataContextSource]
		public void SubQuery32(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					from ch in
						from ch in Child
						select new { ch, n = ch.ChildID + 1 }
					group ch.ch.ParentID by ch.n into g
					select new
					{
						g.Key,
						Sum = g.Sum(_ => _)
					}
					,
					from ch in
						from ch in db.Child
						select new { ch, n = ch.ChildID + 1 }
					group ch.ch.ParentID by ch.n into g
					select new
					{
						g.Key,
						Sum = g.Sum(_ => _)
					});
		}

		[Test, DataContextSource]
		public void SubQuery4(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					from ch in Child
					group ch by new { n = ch.ChildID + 1 } into g
					select new
					{
						g.Key,
						Sum = g.Sum(_ => _.ParentID)
					}
					,
					from ch in db.Child
					group ch by new { n = ch.ChildID + 1 } into g
					select new
					{
						g.Key,
						Sum = g.Sum(_ => _.ParentID)
					});
		}

		[Test, DataContextSource]
		public void SubQuery5(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					from ch in Child
					join p in Parent on ch.ParentID equals p.ParentID into pg
					from p in pg.DefaultIfEmpty()
					group ch by ch.ChildID into g
					select g.Sum(_ => _.ParentID)
					,
					from ch in db.Child
					join p in db.Parent on ch.ParentID equals p.ParentID into pg
					from p in pg.DefaultIfEmpty()
					group ch by ch.ChildID into g
					select g.Sum(_ => _.ParentID));
		}

		[Test, DataContextSource]
		public void SubQuery6(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					from ch in Child select new { ParentID = ch.ParentID + 1 } into ch
					group ch.ParentID by ch into g
					select g.Key
					,
					from ch in db.Child select new { ParentID = ch.ParentID + 1 } into ch
					group ch.ParentID by ch into g
					select g.Key);
		}

		[Test, DataContextSource]
		public void SubQuery7(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					from p in Parent
					join c in
						from c in Child
						where c.ParentID == 1
						select c
					on p.ParentID equals c.ParentID into g
					from c in g.DefaultIfEmpty()
					group p by c == null ? 0 : c.ChildID into gg
					select new { gg.Key }
					,
					from p in db.Parent
					join c in
						from c in db.Child
						where c.ParentID == 1
						select c
					on p.ParentID equals c.ParentID into g
					from c in g.DefaultIfEmpty()
					group p by c.ChildID into gg
					select new { gg.Key });
		}

		[Test, DataContextSource]
		public void Calculated1(string context)
		{
			using (var db = GetDataContext(context))
			{
				db.BeginTransaction();

				var expected =
					(
						from ch in Child
						group ch by ch.ParentID > 2 ? ch.ParentID > 3 ? "1" : "2" : "3"
						into g select g
					).ToList().OrderBy(p => p.Key).ToList();

				var result =
					(
						from ch in db.Child
						group ch by ch.ParentID > 2 ? ch.ParentID > 3 ? "1" : "2" : "3"
						into g select g
					).ToList().OrderBy(p => p.Key).ToList();

				AreEqual(expected[0], result[0]);
				AreEqual(expected.Select(p => p.Key), result.Select(p => p.Key));
			}
		}

		[Test, DataContextSource]
		public void Calculated2(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					from p in
						from ch in
							from ch in Child
							group ch by ch.ParentID > 2 ? ch.ParentID > 3 ? "1" : "2" : "3"
							into g select g
						select ch.Key + "2"
					where p == "22"
					select p
					,
					from p in
						from ch in
							from ch in db.Child
							group ch by ch.ParentID > 2 ? ch.ParentID > 3 ? "1" : "2" : "3"
							into g select g
						select ch.Key + "2"
					where p == "22"
					select p);
		}

		[Test, DataContextSource]
		public void GroupBy1(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					   Child.GroupBy(ch => ch.ParentID).GroupBy(ch => ch).GroupBy(ch => ch).Select(p => p.Key.Key.Key),
					db.Child.GroupBy(ch => ch.ParentID).GroupBy(ch => ch).GroupBy(ch => ch).Select(p => p.Key.Key.Key));
		}

		[Test, DataContextSource]
		public void GroupBy2(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					from p in Parent
					join c in Child on p.ParentID equals c.ParentID
					group p by new
					{
						ID = p.Value1 ?? c.ChildID
					} into gr
					select new
					{
						gr.Key.ID,
						ID1 = gr.Key.ID + 1,
					}
					,
					from p in db.Parent
					join c in db.Child on p.ParentID equals c.ParentID
					group p by new
					{
						ID = p.Value1 ?? c.ChildID
					} into gr
					select new
					{
						gr.Key.ID,
						ID1 = gr.Key.ID + 1,
					});
		}

		[Test, DataContextSource]
		public void GroupBy3(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					from p in Parent
					join c in Child on p.ParentID equals c.ParentID
					group p by p.Value1 ?? c.ChildID into gr
					select new
					{
						gr.Key
					}
					,
					from p in db.Parent
					join c in db.Child on p.ParentID equals c.ParentID
					group p by p.Value1 ?? c.ChildID into gr
					select new
					{
						gr.Key
					});
		}

		[Test, DataContextSource]
		public void Sum1(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					from ch in Child
					group ch by ch.ParentID into g
					select g.Sum(p => p.ChildID)
					,
					from ch in db.Child
					group ch by ch.ParentID into g
					select g.Sum(p => p.ChildID));
		}

		[Test, DataContextSource]
		public void Sum2(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					from ch in Child
					group ch by ch.ParentID into g
					select new { Sum = g.Sum(p => p.ChildID) }
					,
					from ch in db.Child
					group ch by ch.ParentID into g
					select new { Sum = g.Sum(p => p.ChildID) });
		}

		[Test, DataContextSource(ProviderName.SqlCe)]
		public void Sum3(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					from ch in Child
					group ch by ch.Parent into g
					select g.Key.Children.Sum(p => p.ChildID),
					from ch in db.Child
					group ch by ch.Parent into g
					select g.Key.Children.Sum(p => p.ChildID));
		}

		[Test, DataContextSource]
		public void SumSubQuery1(string context)
		{
			var n = 1;

			using (var db = GetDataContext(context))
				AreEqual(
					from ch in
						from ch in Child select new { ParentID = ch.ParentID + 1, ch.ChildID }
					where ch.ParentID + 1 > n group ch by ch into g
					select g.Sum(p => p.ParentID - 3)
					,
					from ch in
						from ch in db.Child select new { ParentID = ch.ParentID + 1, ch.ChildID }
					where ch.ParentID + 1 > n group ch by ch into g
					select g.Sum(p => p.ParentID - 3));
		}

		[Test, DataContextSource]
		public void GroupByMax(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					from ch in    Child group ch.ParentID by ch.ChildID into g select new { Max = g.Max() },
					from ch in db.Child group ch.ParentID by ch.ChildID into g select new { Max = g.Max() });
		}

		[Test, DataContextSource]
		public void Aggregates1(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					from  ch in Child
					group ch by ch.ParentID into g
					select new
					{
						Cnt = g.Count(),
						Sum = g.Sum(c => c.ChildID),
						Min = g.Min(c => c.ChildID),
						Max = g.Max(c => c.ChildID),
						Avg = (int)g.Average(c => c.ChildID),
					},
					from  ch in db.Child
					group ch by ch.ParentID into g
					select new
					{
						Cnt = g.Count(),
						Sum = g.Sum(c => c.ChildID),
						Min = g.Min(c => c.ChildID),
						Max = g.Max(c => c.ChildID),
						Avg = (int)g.Average(c => c.ChildID),
					});
		}

		[Test, DataContextSource]
		public void Aggregates2(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					from  ch in Child
					group ch by ch.ParentID into g
					select new
					{
						Sum = g.Select(c => c.ChildID).Sum(),
						Min = g.Select(c => c.ChildID).Min(),
						Max = g.Select(c => c.ChildID).Max(),
						Avg = (int)g.Select(c => c.ChildID).Average(),
						Cnt = g.Count()
					},
					from  ch in db.Child
					group ch by ch.ParentID into g
					select new
					{
						Sum = g.Select(c => c.ChildID).Sum(),
						Min = g.Select(c => c.ChildID).Min(),
						Max = g.Select(c => c.ChildID).Max(),
						Avg = (int)g.Select(c => c.ChildID).Average(),
						Cnt = g.Count()
					});
		}

		[Test, DataContextSource(ProviderName.SqlCe)]
		public void Aggregates3(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					from  ch in Child
					where ch.ChildID > 30
					group ch by ch.ParentID into g
					select new
					{
						Sum =      g.Select(c => c.ChildID).Where(_ => _ > 30).Sum(),
						Min =      g.Select(c => c.ChildID).Where(_ => _ > 30).Min(),
						Max =      g.Select(c => c.ChildID).Where(_ => _ > 30).Max(),
						Avg = (int)g.Select(c => c.ChildID).Where(_ => _ > 30).Average(),
					},
					from  ch in db.Child
					where ch.ChildID > 30
					group ch by ch.ParentID into g
					select new
					{
						Sum =      g.Select(c => c.ChildID).Where(_ => _ > 30).Sum(),
						Min =      g.Select(c => c.ChildID).Where(_ => _ > 30).Min(),
						Max =      g.Select(c => c.ChildID).Where(_ => _ > 30).Max(),
						Avg = (int)g.Select(c => c.ChildID).Where(_ => _ > 30).Average(),
					});
		}

		[Test, DataContextSource(ProviderName.SqlCe)]
		public void Aggregates4(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					from  ch in Child
					group ch by ch.ParentID into g
					select new
					{
						Count = g.Count(_ => _.ChildID > 30),
						Sum   = g.Where(_ => _.ChildID > 30).Sum(c => c.ChildID),
					},
					from  ch in db.Child
					group ch by ch.ParentID into g
					select new
					{
						Count = g.Count(_ => _.ChildID > 30),
						Sum   = g.Where(_ => _.ChildID > 30).Sum(c => c.ChildID),
					});
		}

		[Test, DataContextSource]
		public void SelectMax(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					from ch in Child
					group ch by ch.ParentID into g
					select g.Max(c => c.ChildID)
					,
					from ch in db.Child
					group ch by ch.ParentID into g
					select g.Max(c => c.ChildID));
		}

		[Test, DataContextSource]
		public void JoinMax(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					from ch in Child
						join max in
							from ch in Child
							group ch by ch.ParentID into g
							select g.Max(c => c.ChildID)
						on ch.ChildID equals max
					select ch
					,
					from ch in db.Child
						join max in
							from ch in db.Child
							group ch by ch.ParentID into g
							select g.Max(c => c.ChildID)
						on ch.ChildID equals max
					select ch);
		}

		[Test, DataContextSource]
		public void Min1(string context)
		{
			using (var db = GetDataContext(context))
				Assert.AreEqual(
					   Child.Min(c => c.ChildID),
					db.Child.Min(c => c.ChildID));
		}

		[Test, DataContextSource]
		public void Min2(string context)
		{
			using (var db = GetDataContext(context))
				Assert.AreEqual(
					   Child.Select(c => c.ChildID).Min(),
					db.Child.Select(c => c.ChildID).Min());
		}

		[Test, DataContextSource]
		public void Max1(string context)
		{
			var expected = Child.Max(c => c.ChildID);
			Assert.AreNotEqual(0, expected);

			using (var db = GetDataContext(context))
				Assert.AreEqual(expected, db.Child.Max(c => c.ChildID));
		}

		[Test, DataContextSource]
		public void Max11(string context)
		{
			using (var db = GetDataContext(context))
				Assert.AreEqual(
					   Child.Max(c => c.ChildID > 20),
					db.Child.Max(c => c.ChildID > 20));
		}

		[Test, DataContextSource]
		public void Max12(string context)
		{
			using (var db = GetDataContext(context))
				Assert.AreEqual(
					   Child.Max(c => (bool?)(c.ChildID > 20)),
					db.Child.Max(c => (bool?)(c.ChildID > 20)));
		}

		[Test, DataContextSource]
		public void Max2(string context)
		{
			using (var db = GetDataContext(context))
			{
				var expected =
					from p in Parent
						join c in Child on p.ParentID equals c.ParentID
					where c.ChildID > 20
					select p;

				var result =
					from p in db.Parent
						join c in db.Child on p.ParentID equals c.ParentID
					where c.ChildID > 20
					select p;

				Assert.AreEqual(expected.Max(p => p.ParentID), result.Max(p => p.ParentID));
			}
		}

		[Test, DataContextSource]
		public void Max3(string context)
		{
			using (var db = GetDataContext(context))
				Assert.AreEqual(
					   Child.Select(c => c.ChildID).Max(),
					db.Child.Select(c => c.ChildID).Max());
		}

		[Test, DataContextSource]
		public void Max4(string context)
		{
			using (var db = GetDataContext(context))
				Assert.AreEqual(
					from t1 in Types
					join t2 in
						from sub in Types
						where
							sub.ID == 1 &&
							sub.DateTimeValue <= DateTime.Today
						group sub by new
						{
							sub.ID
						} into g
						select new
						{
							g.Key.ID,
							DateTimeValue = g.Max( p => p.DateTimeValue )
						}
					on new { t1.ID, t1.DateTimeValue } equals new { t2.ID, t2.DateTimeValue }
					select t1.MoneyValue,
					from t1 in db.Types
					join t2 in
						from sub in db.Types
						where
							sub.ID == 1 &&
							sub.DateTimeValue <= DateTime.Today
						group sub by new
						{
							sub.ID
						} into g
						select new
						{
							g.Key.ID,
							DateTimeValue = g.Max( p => p.DateTimeValue )
						}
					on new { t1.ID, t1.DateTimeValue } equals new { t2.ID, t2.DateTimeValue }
					select t1.MoneyValue
					);
		}

		[Test, DataContextSource]
		public void Average1(string context)
		{
			using (var db = GetDataContext(context))
				Assert.AreEqual(
					(int)db.Child.Average(c => c.ChildID),
					(int)   Child.Average(c => c.ChildID));
		}

		[Test, DataContextSource]
		public void Average2(string context)
		{
			using (var db = GetDataContext(context))
				Assert.AreEqual(
					(int)   Child.Select(c => c.ChildID).Average(),
					(int)db.Child.Select(c => c.ChildID).Average());
		}

		[Test, DataContextSource]
		public void GrooupByAssociation1(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					from ch in GrandChild1
					group ch by ch.Parent into g
					where g.Count() > 2
					select g.Key.Value1
					,
					from ch in db.GrandChild1
					group ch by ch.Parent into g
					where g.Count() > 2
					select g.Key.Value1);
		}

		[Test, DataContextSource]
		public void GrooupByAssociation101(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					from ch in GrandChild1
					group ch by ch.Parent into g
					where g.Max(_ => _.ParentID) > 2
					select g.Key.Value1
					,
					from ch in db.GrandChild1
					group ch by ch.Parent into g
					where g.Max(_ => _.ParentID) > 2
					select g.Key.Value1);
		}

		[Test, DataContextSource(ProviderName.Informix)]
		public void GrooupByAssociation102(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					from ch in GrandChild1
					group ch by ch.Parent into g
					where g.Count(_ => _.ChildID >= 20) > 2
					select g.Key.Value1
					,
					from ch in db.GrandChild1
					group ch by ch.Parent into g
					where g.Count(_ => _.ChildID >= 20) > 2
					select g.Key.Value1);
		}

		[Test, DataContextSource(ProviderName.SqlCe, ProviderName.Access, ProviderName.Informix /* Can be fixed*/)]
		public void GrooupByAssociation1022(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					from ch in GrandChild1
					group ch by ch.Parent into g
					where g.Count(_ => _.ChildID >= 20) > 2 && g.Where(_ => _.ChildID >= 19).Sum(p => p.ParentID) > 0
					select g.Key.Value1
					,
					from ch in db.GrandChild1
					group ch by ch.Parent into g
					where g.Count(_ => _.ChildID >= 20) > 2 && g.Where(_ => _.ChildID >= 19).Sum(p => p.ParentID) > 0
					select g.Key.Value1);
		}

		[Test, DataContextSource(ProviderName.SqlCe, ProviderName.Access, ProviderName.Informix /* Can be fixed.*/)]
		public void GrooupByAssociation1023(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					from ch in GrandChild1
					group ch by ch.Parent into g
					where
						g.Count(_ => _.ChildID >= 20) > 2 &&
						g.Where(_ => _.ChildID >= 19).Sum(p => p.ParentID) > 0 &&
						g.Where(_ => _.ChildID >= 19).Max(p => p.ParentID) > 0
					select g.Key.Value1
					,
					from ch in db.GrandChild1
					group ch by ch.Parent into g
					where
						g.Count(_ => _.ChildID >= 20) > 2 &&
						g.Where(_ => _.ChildID >= 19).Sum(p => p.ParentID) > 0 &&
						g.Where(_ => _.ChildID >= 19).Max(p => p.ParentID) > 0
					select g.Key.Value1);
		}

		[Test, DataContextSource(ProviderName.SqlCe, ProviderName.Access, ProviderName.Informix) /* Can be fixed. */]
		public void GrooupByAssociation1024(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					from ch in GrandChild1
					group ch by ch.Parent into g
					where
						g.Count(_ => _.ChildID >= 20) > 2 &&
						g.Where(_ => _.ChildID >= 19).Sum(p => p.ParentID) > 0 &&
						g.Where(_ => _.ChildID >= 19).Max(p => p.ParentID) > 0 &&
						g.Where(_ => _.ChildID >= 18).Max(p => p.ParentID) > 0
					select g.Key.Value1
					,
					from ch in db.GrandChild1
					group ch by ch.Parent into g
					where
						g.Count(_ => _.ChildID >= 20) > 2 &&
						g.Where(_ => _.ChildID >= 19).Sum(p => p.ParentID) > 0 &&
						g.Where(_ => _.ChildID >= 19).Max(p => p.ParentID) > 0 &&
						g.Where(_ => _.ChildID >= 18).Max(p => p.ParentID) > 0
					select g.Key.Value1);
		}

		[Test, DataContextSource]
		public void GrooupByAssociation2(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					from ch in GrandChild1
					group ch by ch.Parent into g
					where g.Count() > 2 && g.Key.ParentID != 1
					select g.Key.Value1
					,
					from ch in db.GrandChild1
					group ch by ch.Parent into g
					where g.Count() > 2 && g.Key.ParentID != 1
					select g.Key.Value1);
		}

		[Test, NorthwindDataContext]
		public void GrooupByAssociation3(string context)
		{
			using (var db = new NorthwindDB())
			{
				var result =
					from p in db.Product
					group p by p.Category into g
					where g.Count() == 12
					select g.Key.CategoryName;

				var list = result.ToList();
				Assert.AreEqual(3, list.Count);
			}
		}

		[Test, NorthwindDataContext]
		public void GrooupByAssociation4(string context)
		{
			using (var db = new NorthwindDB())
			{
				var result =
					from p in db.Product
					group p by p.Category into g
					where g.Count() == 12
					select g.Key.CategoryID;

				var list = result.ToList();
				Assert.AreEqual(3, list.Count);
			}
		}

		[Test, DataContextSource(ProviderName.SqlCe)]
		public void GroupByAggregate1(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					from p in Parent
					group p by p.Children.Count > 0 && p.Children.Average(c => c.ParentID) > 3 into g
					select g.Key
					,
					from p in db.Parent
					group p by p.Children.Average(c => c.ParentID) > 3 into g
					select g.Key);
		}

		[Test, DataContextSource(ProviderName.SqlCe)]
		public void GroupByAggregate11(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					from p in Parent
					where p.Children.Count > 0
					group p by p.Children.Average(c => c.ParentID) > 3 into g
					select g.Key
					,
					from p in db.Parent
					where p.Children.Count > 0
					group p by p.Children.Average(c => c.ParentID) > 3 into g
					select g.Key);
		}

		[Test, DataContextSource(ProviderName.SqlCe)]
		public void GroupByAggregate12(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					from p in Parent
					group p by p.Children.Count > 0 && p.Children.Average(c => c.ParentID) > 3 into g
					select g.Key
					,
					from p in db.Parent
					group p by p.Children.Count > 0 && p.Children.Average(c => c.ParentID) > 3 into g
					select g.Key);
		}

		[Test, NorthwindDataContext]
		public void GroupByAggregate2(string context)
		{
			using (var db = new NorthwindDB())
				AreEqual(
					(
						from c in Customer
						group c by c.Orders.Count > 0 && c.Orders.Average(o => o.Freight) >= 80
					).ToList().Select(k => k.Key),
					(
						from c in db.Customer
						group c by c.Orders.Average(o => o.Freight) >= 80
					).ToList().Select(k => k.Key));
		}

		[Test, DataContextSource(ProviderName.SqlCe)]
		public void GroupByAggregate3(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					(
						from p in Parent
						group p by p.Children.Count > 0 && p.Children.Average(c => c.ParentID) > 3
					).ToList().First(g => !g.Key)
					,
					(
						from p in db.Parent
						group p by p.Children.Average(c => c.ParentID) > 3
					).ToList().First(g => !g.Key));
		}

		[Test, DataContextSource]
		public void ByJoin(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					from c1 in Child
					join c2 in Child on c1.ChildID equals c2.ChildID + 1
					group c2 by c1.ParentID into g
					select g.Sum(_ => _.ChildID)
					,
					from c1 in db.Child
					join c2 in db.Child on c1.ChildID equals c2.ChildID + 1
					group c2 by c1.ParentID into g
					select g.Sum(_ => _.ChildID));
		}

		[Test, DataContextSource]
		public void SelectMany(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					   Child.GroupBy(ch => ch.ParentID).SelectMany(g => g),
					db.Child.GroupBy(ch => ch.ParentID).SelectMany(g => g));
		}

		[Test, DataContextSource(ProviderName.SqlCe)]
		public void Scalar1(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					(from ch in Child
					 group ch by ch.ParentID into g
					 select g.Select(ch => ch.ChildID).Max()),
					(from ch in db.Child
					 group ch by ch.ParentID into g
					 select g.Select(ch => ch.ChildID).Max()));
		}

		[Test, DataContextSource]
		public void Scalar101(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					from ch in Child
					select ch.ChildID into id
					group id by id into g
					select g.Max()
					,
					from ch in db.Child
					select ch.ChildID into id
					group id by id into g
					select g.Max());
		}

		[Test, DataContextSource(ProviderName.SqlCe)]
		public void Scalar2(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					(from ch in Child
					 group ch by ch.ParentID into g
					 select new
						 {
							 Max1 = g.Select(ch => ch.ChildID              ).Max(),
							 Max2 = g.Select(ch => ch.ChildID + ch.ParentID).Max()
						 }),
					(from ch in db.Child
					 group ch by ch.ParentID into g
					 select new
						 {
							 Max1 = g.Select(ch => ch.ChildID              ).Max(),
							 Max2 = g.Select(ch => ch.ChildID + ch.ParentID).Max()
						 }));
		}

		[Test, DataContextSource(ProviderName.SqlCe)]
		public void Scalar3(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					(from ch in Child
					 group ch by ch.ParentID into g
					 select g.Select(ch => ch.ChildID).Where(id => id > 0).Max()),
					(from ch in db.Child
					 group ch by ch.ParentID into g
					 select g.Select(ch => ch.ChildID).Where(id => id > 0).Max()));
		}

		[Test, DataContextSource(ProviderName.SqlCe, ProviderName.Access, ProviderName.Informix)]
		public void Scalar4(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					from ch in Child
					group ch by ch.ParentID into g
					where g.Where(ch => ch.ParentID > 2).Select(ch => (int?)ch.ChildID).Min() != null
					select g.Where(ch => ch.ParentID > 2).Select(ch => ch.ChildID).Min()
					,
					from ch in db.Child
					group ch by ch.ParentID into g
					where g.Where(ch => ch.ParentID > 2).Select(ch => (int?)ch.ChildID).Min() != null
					select g.Where(ch => ch.ParentID > 2).Select(ch => ch.ChildID).Min());
		}

		[Test, DataContextSource(ProviderName.SqlCe, ProviderName.Access, ProviderName.Informix)]
		public void Scalar41(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					from ch in Child
					group ch by ch.ParentID into g
					select new { g } into g
					where g.g.Where(ch => ch.ParentID > 2).Select(ch => (int?)ch.ChildID).Min() != null
					select g.g.Where(ch => ch.ParentID > 2).Select(ch => ch.ChildID).Min()
					,
					from ch in db.Child
					group ch by ch.ParentID into g
					select new { g } into g
					where g.g.Where(ch => ch.ParentID > 2).Select(ch => (int?)ch.ChildID).Min() != null
					select g.g.Where(ch => ch.ParentID > 2).Select(ch => ch.ChildID).Min());
		}

		[Test, DataContextSource]
		public void Scalar5(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					from ch in Child
					select ch.ParentID into id
					group id by id into g
					select g.Max()
					,
					from ch in db.Child
					select ch.ParentID into id
					group id by id into g
					select g.Max());
		}

		//[Test, DataContextSource]
		public void Scalar51(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					from ch in Child
					group ch by ch.ParentID into g
					select g.Max()
					,
					from ch in db.Child
					group ch by ch.ParentID into g
					select g.Max());
		}

		[Test, DataContextSource(ProviderName.SqlCe)]
		public void Scalar6(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					(from ch in Child
					 where ch.ParentID < 3
					 group ch by ch.ParentID into g
					 select g.Where(ch => ch.ParentID < 3).Max(ch => ch.ChildID))
					 ,
					(from ch in db.Child
					 where ch.ParentID < 3
					 group ch by ch.ParentID into g
					 select g.Where(ch => ch.ParentID < 3).Max(ch => ch.ChildID)));
		}

		[Test, DataContextSource(ProviderName.SqlCe)]
		public void Scalar7(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					(from ch in Child
					 group ch by ch.ParentID into g
					 select new { max = g.Select(ch => ch.ChildID).Max()}).Select(id => id.max)
					 ,
					(from ch in db.Child
					 group ch by ch.ParentID into g
					 select new { max = g.Select(ch => ch.ChildID).Max()}).Select(id => id.max));
		}

		[Test, DataContextSource]
		public void Scalar8(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					(from ch in Child
					group ch by ch.ParentID into g
					select new { max = g.Max(ch => ch.ChildID)}).Select(id => id.max)
					,
					(from ch in db.Child
					group ch by ch.ParentID into g
					select new { max = g.Max(ch => ch.ChildID)}).Select(id => id.max));
		}

		[Test, DataContextSource(ProviderName.SqlCe)]
		public void Scalar9(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					(from ch in Child
					 group ch by ch.ParentID into g
					 select g.Select(ch => ch.ChildID).Where(id => id < 30).Count()),
					(from ch in db.Child
					 group ch by ch.ParentID into g
					 select g.Select(ch => ch.ChildID).Where(id => id < 30).Count()));
		}

		[Test, DataContextSource(ProviderName.SqlCe)]
		public void Scalar10(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					(from ch in Child
					 group ch by ch.ParentID into g
					 select g.Select(ch => ch.ChildID).Where(id => id < 30).Count(id => id >= 20))
					 ,
					(from ch in db.Child
					 group ch by ch.ParentID into g
					 select g.Select(ch => ch.ChildID).Where(id => id < 30).Count(id => id >= 20)));
		}

		[Test, IncludeDataContextSource(ProviderName.MySql)]
		public void GroupByExtraFieldBugTest(string context)
		{
			// https://github.com/igor-tkachev/LinqToDB/issues/42
			// extra field is generated in the GROUP BY clause, for example:
			// GROUP BY p.LastName, p.LastName <--- the second one is redundant

			using (var db = new TestDataConnection(context))
			{
				var q =
					from d in db.Doctor
					join p in db.Person on d.PersonID equals p.ID
					group d by p.LastName into g
					select g.Key;

				q.ToList();

				const string fieldName = "LastName";

				var lastQuery  = db.LastQuery;
				var groupByPos = lastQuery.IndexOf("GROUP BY");
				var fieldPos   = lastQuery.IndexOf(fieldName, groupByPos);

				// check that our field does not present in the GROUP BY clause second time.
				//
				Assert.AreEqual(-1, lastQuery.IndexOf(fieldName, fieldPos + 1));
			}
		}

		[Test, DataContextSource]
		public void DoubleGroupBy1(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					from t in
						from p in Parent
						where p.Value1 != null
						group p by p.ParentID into g
						select new
						{
							ID  = g.Key,
							Max = g.Max(t => t.Value1)
						}
					group t by t.ID into g
					select new
					{
						g.Key,
						Sum = g.Sum(t => t.Max)
					},
					from t in
						from p in db.Parent
						where p.Value1 != null
						group p by p.ParentID into g
						select new
						{
							ID  = g.Key,
							Max = g.Max(t => t.Value1)
						}
					group t by t.ID into g
					select new
					{
						g.Key,
						Sum = g.Sum(t => t.Max)
					});
		}

		[Test, DataContextSource]
		public void DoubleGroupBy2(string context)
		{
			using (var db = GetDataContext(context))
				AreEqual(
					from p in Parent
					where p.Value1 != null
					group p by p.ParentID into g
					select new
					{
						ID  = g.Key,
						Max = g.Max(t => t.Value1)
					} into t
					group t by t.ID into g
					select new
					{
						g.Key,
						Sum = g.Sum(t => t.Max)
					},
					from p in db.Parent
					where p.Value1 != null
					group p by p.ParentID into g
					select new
					{
						ID  = g.Key,
						Max = g.Max(t => t.Value1)
					} into t
					group t by t.ID into g
					select new
					{
						g.Key,
						Sum = g.Sum(t => t.Max)
					});
		}

		[Test, DataContextSource(ProviderName.SqlCe, ProviderName.SapHana)]
		public void InnerQuery(string context)
		{
			using (var db = GetDataContext(context))
			{
				AreEqual(
					   Doctor.GroupBy(s => s.PersonID).Select(s => s.Select(d => d.Taxonomy).First()),
					db.Doctor.GroupBy(s => s.PersonID).Select(s => s.Select(d => d.Taxonomy).First()));
			}
		}

		[Test, DataContextSource]
		public void CalcMember(string context)
		{
			using (var db = GetDataContext(context))
			{
				AreEqual(
					from parent in Parent
					from child  in Person
					where child.ID == parent.ParentID
					let data = new
					{
						parent.Value1,
						Value = child.FirstName == "John" ? child.FirstName : "a"
					}
					group data by data.Value into groupedData
					select new
					{
						groupedData.Key,
						Count = groupedData.Count()
					},
					from parent in db.Parent
					from child  in db.Person
					where child.ID == parent.ParentID
					let data = new
					{
						parent.Value1,
						Value = child.FirstName == "John" ? child.FirstName : "a"
					}
					group data by data.Value into groupedData
					select new
					{
						groupedData.Key,
						Count = groupedData.Count()
					});
			}
		}

		[Test, DataContextSource]
		public void GroupByNone(string context)
		{
			using (var db = GetDataContext(context))
			{
				AreEqual(
					from parent in Parent
					group parent by Sql.GroupBy.None into gr
					select new
					{
						Min = gr.Min(p => p.ParentID),
						Max = gr.Max(p => p.ParentID),
					},
					from parent in db.Parent
					group parent by Sql.GroupBy.None into gr
					select new
					{
						Min = gr.Min(p => p.ParentID),
						Max = gr.Max(p => p.ParentID),
					});
			}
		}

		[Test, DataContextSource]
		public void GroupByExpression(string context)
		{
			using (var db = GetDataContext(context))
			{
				var defValue = 10;

				AreEqual(
					from parent in Parent
					group parent by Sql.GroupBy.None into gr
					select new
					{
						Min = Sql.AsSql(gr.Min(p => (int?)p.ParentID) ?? defValue),
					},
					from parent in db.Parent
					group parent by Sql.GroupBy.None into gr
					select new
					{
						Min = Sql.AsSql(gr.Min(p => (int?)p.ParentID) ?? defValue),
					});
			}
		}

		// TODO: [Test, DataContextSource]
		public void GroupByDate1(string context)
		{
			using (var db = GetDataContext(context))
			{
				AreEqual(
					from t in Types
					group t by new { t.DateTimeValue.Month, t.DateTimeValue.Year } into grp
					select new
					{
						Total = grp.Sum(_ => _.MoneyValue),
						year  = grp.Key.Year,
						month = grp.Key.Month
					},
					from t in db.Types
					group t by new { t.DateTimeValue.Month, t.DateTimeValue.Year } into grp
					select new
					{
						Total = grp.Sum(_ => _.MoneyValue),
						year  = grp.Key.Year,
						month = grp.Key.Month
					});
			}
		}

		// TODO: [Test, DataContextSource]
		public void GroupByDate2(string context)
		{
			using (var db = GetDataContext(context))
			{
				AreEqual(
					from t in Types2
					group t by new { t.DateTimeValue.Value.Month, t.DateTimeValue.Value.Year } into grp
					select new
					{
						Total = grp.Sum(_ => _.MoneyValue),
						year  = grp.Key.Year,
						month = grp.Key.Month
					},
					from t in db.Types2
					group t by new { t.DateTimeValue.Value.Month, t.DateTimeValue.Value.Year } into grp
					select new
					{
						Total = grp.Sum(_ => _.MoneyValue),
						year  = grp.Key.Year,
						month = grp.Key.Month
					});
			}
		}

		[Test, DataContextSource]
		public void GroupByCount(string context)
		{
			using (var db = GetDataContext(context))
			{
				Assert.AreEqual(
					(from t in    Child group t by t.ParentID into gr select new { gr.Key, List = gr.ToList() }).Count(),
					(from t in db.Child group t by t.ParentID into gr select new { gr.Key, List = gr.ToList() }).Count());
			}
		}

		[Test, DataContextSource]
		public void AggregateAssociation(string context)
		{
			using (var db = GetDataContext(context))
			{
				AreEqual(
					from t in Child
					group t by t.ParentID into grp
					select new
					{
						Value = grp.Sum(c => c.Parent.Value1 ?? 0)
					},
					from t in db.Child
					group t by t.ParentID into grp
					select new
					{
						Value = grp.Sum(c => c.Parent.Value1 ?? 0)
					});
			}
		}
	}
}


text:
process.env.NODE_ENV = 'test';
var superagent  = require('superagent');
var should      = require('should');
var mongoose    = require('mongoose');
var http        = require('http');
var fs          = require('fs');
//var config      = require('../config.js');
var config    = JSON.parse(fs.readFileSync('config.json', 'ascii'));
var port        = 1234;
var opts        = {};
var app;
var server;
//mongoose.connect(config.db);
opts.port       = port;
opts.http       = http;
opts.should     = should;
opts.superagent = superagent

// SETUP AND TEARDOWN
before(function(done) {
  app       = require(__dirname + './../server/index.js');
  app.set('port', port);
  server    = app.listen(port);
  opts.app  = app;
  done();
});

after(function(done) {
  server.close();
  done();
});

// CONSTANT
describe('[CONSTANT]', function() {
  var constant = 13;
  it('13 should equal 13', function() {
    constant.should.equal(13);
  });
});

// Server
require('./server.js')(opts);

// Models
require('./server.models.dj.js')(opts);
//require('./server.models.artist.js')(opts);
//require('./server.models.song.js')(opts);
// Routes
//require('./server.routes.djs.js')(opts);
//require('./server.routes.artists.js')(opts);
//require('./server.routes.songs.js')(opts);

redpajama_set_name: RedPajamaGithub


text:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen android:title="@string/zen_mode_priority_settings_title" android:key="zen_mode_priority_settings"
  xmlns:android="http://schemas.android.com/apk/res/android">
    <SwitchPreference android:enabled="false" android:title="@string/zen_mode_alarms" android:key="alarms" android:defaultValue="true" />
    <SwitchPreference android:title="@string/zen_mode_reminders" android:key="reminders" />
    <SwitchPreference android:title="@string/zen_mode_events" android:key="events" />
    <DropDownPreference android:title="@string/zen_mode_messages" android:key="messages" android:summary="%s" />
    <DropDownPreference android:title="@string/zen_mode_calls" android:key="calls" android:summary="%s" />
    <SwitchPreference android:title="@string/zen_mode_repeat_callers" android:key="repeat_callers" />
</PreferenceScreen>


text:
WRITE8_HANDLER( konami_sh_irqtrigger_w );
READ8_HANDLER( trackfld_sh_timer_r );
READ8_DEVICE_HANDLER( trackfld_speech_r );
WRITE8_DEVICE_HANDLER( trackfld_sound_w );
READ8_HANDLER( hyperspt_sh_timer_r );
WRITE8_DEVICE_HANDLER( hyperspt_sound_w );
WRITE8_HANDLER( konami_SN76496_latch_w );
WRITE8_DEVICE_HANDLER( konami_SN76496_w );

DECLARE_LEGACY_SOUND_DEVICE(TRACKFLD_AUDIO, trackfld_audio);


text:
puppet-windows_common
=====================

This module contains a set of types and classes that we have found useful while
doing different administration tasks on Microsoft Windows systems.

If you have a manifest that could make others administrator's lives easier and
it is not that important to be designed as an independent module, you are
welcome to open a pull request!

client::mapped_drive
--------------------

The define type **mapped_drive** allows you to map a share folder to a drive
letter.

    windows_common::client::mapped_drive { 'my-drive':
      ensure       => present,
      drive_letter => 'Z:',
      server       => 'public.host.com',
      share        => 'folder',
    }

Contributors
------------
 * Peter Pouliot <peter@pouliot.net>
 * Luis Fernandez Alvarez <luis.fernandez.alvarez@cern.ch>
 * Octavian Ciuhandu <ociuhandu@cloudbasesolutions.com>
 * Vijay Tripathi  <vijayt@microsoft.com>
 * Tim Rogers


text:
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.42000
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace TGC.Group {

    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
    internal sealed partial class Game : global::System.Configuration.ApplicationSettingsBase {

        private static Game defaultInstance = ((Game)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Game())));

        public static Game Default {
            get {
                return defaultInstance;
            }
        }

        [global::System.Configuration.UserScopedSettingAttribute()]
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
        [global::System.Configuration.DefaultSettingValueAttribute("Alumnos")]
        public string Category {
            get {
                return ((string)(this["Category"]));
            }
            set {
                this["Category"] = value;
            }
        }

        [global::System.Configuration.UserScopedSettingAttribute()]
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
        [global::System.Configuration.DefaultSettingValueAttribute("SurvivalCraft - Descripción de la idea")]
        public string Description {
            get {
                return ((string)(this["Description"]));
            }
            set {
                this["Description"] = value;
            }
        }

        [global::System.Configuration.UserScopedSettingAttribute()]
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
        [global::System.Configuration.DefaultSettingValueAttribute("..\\..\\Shaders\\")]
        public string ShadersDirectory {
            get {
                return ((string)(this["ShadersDirectory"]));
            }
            set {
                this["ShadersDirectory"] = value;
            }
        }

        [global::System.Configuration.UserScopedSettingAttribute()]
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
        [global::System.Configuration.DefaultSettingValueAttribute("..\\..\\Media\\")]
        public string MediaDirectory {
            get {
                return ((string)(this["MediaDirectory"]));
            }
            set {
                this["MediaDirectory"] = value;
            }
        }

        [global::System.Configuration.UserScopedSettingAttribute()]
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
        [global::System.Configuration.DefaultSettingValueAttribute("cajaMadera4.jpg")]
        public string TexturaCaja {
            get {
                return ((string)(this["TexturaCaja"]));
            }
            set {
                this["TexturaCaja"] = value;
            }
        }

        [global::System.Configuration.UserScopedSettingAttribute()]
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
        [global::System.Configuration.DefaultSettingValueAttribute("Google Group")]
        public string Name {
            get {
                return ((string)(this["Name"]));
            }
            set {
                this["Name"] = value;
            }
        }
    }
}


text:
/* Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.camunda.bpm.engine.impl.cmd;

import java.io.Serializable;
import org.camunda.bpm.engine.history.HistoricProcessInstance;
import org.camunda.bpm.engine.impl.interceptor.Command;
import org.camunda.bpm.engine.impl.interceptor.CommandContext;

import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull;

/**
 * @author Frederik Heremans
 */
public class DeleteHistoricProcessInstanceCmd implements Command<Object>, Serializable {

  private static final long serialVersionUID = 1L;
  protected String processInstanceId;

  public DeleteHistoricProcessInstanceCmd(String processInstanceId) {
    this.processInstanceId = processInstanceId;
  }

  public Object execute(CommandContext commandContext) {
    ensureNotNull("processInstanceId", processInstanceId);
    // Check if process instance is still running
    HistoricProcessInstance instance = commandContext
      .getHistoricProcessInstanceManager()
      .findHistoricProcessInstance(processInstanceId);

    ensureNotNull("No historic process instance found with id: " + processInstanceId, "instance", instance);
    ensureNotNull("Process instance is still running, cannot delete historic process instance: " + processInstanceId, "instance.getEndTime()", instance.getEndTime());

    commandContext
      .getHistoricProcessInstanceManager()
      .deleteHistoricProcessInstanceById(processInstanceId);

    return null;
  }

}


text:
package Tools;

import java.util.*;
import star.base.neo.*;

import star.base.report.*;
import star.common.*;
import star.flow.*;

/**
 *
 * The purpose of class ReportTool is to make generating and obtaining
 * common STAR-CCM+ Reports much more straight forward.
 *
 * Consider it primarily a common usage API shortcut tool.
 *
 */
public class ReportTool {

public static void reportToolPrint(Simulation tmpSim, String toOutputWindow){
  tmpSim.println(toOutputWindow);
}

// General
public static Report getReport(Simulation tmpSim, String repName){
  Report tmpReport = null;
  try{
    tmpReport=tmpSim.getReportManager().getReport(repName);
  }catch(NeoException e){
    reportToolPrint(tmpSim,"RepTool MSG: No Report "+repName
            +" exists! Likely failure!");
  }
  return tmpReport;
}

// Force
public static ForceReport forceReport(Simulation tmpSim,String repName,
  CoordinateSystem repCsys, double[] repDirection,
  Collection<? extends NamedObject> repParts,
  Representation repRepresentation){
  ForceReport fRep;
  try{
    fRep = (ForceReport) tmpSim.getReportManager().getObject(repName);
  }catch(NeoException e){
    fRep = tmpSim.getReportManager().createReport(ForceReport.class);
    fRep.setPresentationName(repName);
  }
  fRep.setCoordinateSystem(repCsys);
  fRep.getDirection().setComponents(
          repDirection[0], repDirection[1],repDirection[2]);
  fRep.setRepresentation(repRepresentation);
  fRep.getParts().setObjects(repParts);
  return fRep;
}

public static ForceReport aSyncforceReport(Simulation tmpSim,String repName,
  CoordinateSystem repCsys, double[] repDirection,
  Collection<? extends NamedObject> repParts,
  Representation repRepresentation){
  ForceReport fRep;
  try{
    fRep = (ForceReport) tmpSim.getReportManager().getObject(repName);
  }catch(NeoException e){
    tmpSim.getReportManager().createReportNoResult(ForceReport.class);
    fRep = tmpSim.getReportManager().createReport(ForceReport.class);
    fRep.setPresentationName(repName);
  }
  fRep.setCoordinateSystem(repCsys);
  fRep.getDirection().setComponents(
          repDirection[0], repDirection[1],repDirection[2]);
  fRep.setRepresentation(repRepresentation);
  fRep.getParts().setObjects(repParts);
  return fRep;
}

public static ForceReport forceReport(Simulation tmpSim, String repName,
    CoordinateSystem repCsys, double[] repDirection,
    Collection<? extends NamedObject> repParts,
    Representation repRepresentation, String pressOrSkinFric){
  ForceReport fRepC = forceReport(tmpSim, repName, repCsys, repDirection,
      repParts, repRepresentation);
  if(pressOrSkinFric.equals("pressure")){
    fRepC.getForceOption().setSelected(ForceReportForceOption.Type.PRESSURE);
  }else if(pressOrSkinFric.equals("shear")){
    fRepC.getForceOption().setSelected(ForceReportForceOption.Type.SHEAR);
  }else{
    throw new NeoException("Report Tool, forceReport: "
        + "Option is not recognized. Choose either "
        + "\"pressure\" or \"shear\". ");
  }

  return fRepC;
}
  //
  // Moment
  public static MomentReport momentReport(Simulation tmpSim,String repName,
          CoordinateSystem repCsys, double[] repOrigin, double[] repAxis,
          Collection<? extends NamedObject> repParts,
          Representation repRepresentation){
      MomentReport mRepC;
      try{
          mRepC = (MomentReport) tmpSim.getReportManager().getObject(repName);
      }catch(NeoException e){
          mRepC = tmpSim.getReportManager().createReport(MomentReport.class);
          try{
            Thread.sleep(100);
          }catch(InterruptedException f){

          }
          mRepC.setPresentationName(repName);
      }
      mRepC.getDirection().setComponents(repAxis[0], repAxis[1], repAxis[2]);
      mRepC.getOrigin().setComponents(repOrigin[0], repOrigin[1], repOrigin[2]);
      mRepC.setCoordinateSystem(repCsys);
      mRepC.setRepresentation(repRepresentation);
      mRepC.getParts().setObjects(repParts);
      return mRepC;
  }
  //
  // Force Coefficients
  public static ForceCoefficientReport forceCoefReport(
          Simulation tmpSim,String repName,
          CoordinateSystem repCsys, double[] repDirection,
          double refRho, double refVel, double refArea,
          Collection<? extends NamedObject> repParts,
          Representation repRepresentation){
    ForceCoefficientReport fRepC;
    try{
        fRepC = (ForceCoefficientReport) tmpSim.getReportManager().
                getObject(repName);
    }catch(NeoException e){
        fRepC = tmpSim.getReportManager().createReport(
                ForceCoefficientReport.class);
        try{
          Thread.sleep(100);
        }catch(InterruptedException f){

        }
        fRepC.setPresentationName(repName);
    }
    fRepC.setCoordinateSystem(repCsys);
    fRepC.getDirection().setComponents(
        repDirection[0], repDirection[1], repDirection[2]);
    fRepC.getReferenceDensity().setDefinition("" + refRho);
    fRepC.getReferenceVelocity().setDefinition("" + refVel);
    fRepC.getReferenceArea().setDefinition("" + refArea);
    fRepC.setRepresentation(repRepresentation);
    fRepC.getParts().setObjects(repParts);
    return fRepC;
  }
  public static ForceCoefficientReport forceCoefReport(Simulation tmpSim,
      String repName, CoordinateSystem repCsys, double[] repDirection,
      double refRho, double refVel, double refArea,
      Collection<? extends NamedObject> repParts,
      Representation repRepresentation, String pressOrSkinFric){
      ForceCoefficientReport fRepC = forceCoefReport(tmpSim, repName,
          repCsys, repDirection, refRho, refVel, refArea, repParts,
          repRepresentation);
    if(pressOrSkinFric.equals("pressure")){
      fRepC.getForceOption().setSelected(ForceReportForceOption.Type.PRESSURE);
    }else if(pressOrSkinFric.equals("shear")){
      fRepC.getForceOption().setSelected(ForceReportForceOption.Type.SHEAR);
    }else{
      throw new NeoException("Report Tool, forceReport: "
          + "Option is not recognized. Choose either "
          + "\"pressure\" or \"shear\". ");
    }
    return fRepC;
  }

  // Moment Coefficient
  public static MomentCoefficientReport momentCoefReport(
          Simulation tmpSim,String repName,
          CoordinateSystem repCsys, double[] repOrigin, double[] repAxis,
          double refRho, double refVel, double refArea, double refRad,
          Collection<? extends NamedObject> repParts,
          Representation repRepresentation){
    /*Method creates/modifies a moment coefficient report */
    MomentCoefficientReport mRepC;
    try{
        mRepC = (MomentCoefficientReport) tmpSim.getReportManager().
                getObject(repName);
    }catch(NeoException e){
        mRepC = tmpSim.getReportManager().
                createReport(MomentCoefficientReport.class);
        try{
          Thread.sleep(100);
        }catch(InterruptedException f){

        }
        mRepC.setPresentationName(repName);
    }
    mRepC.getReferenceArea().setValue(refArea);
    mRepC.getReferenceVelocity().setValue(refVel);
    mRepC.getReferenceDensity().setValue(refRho);

    mRepC.getDirection().setComponents(repAxis[0], repAxis[1], repAxis[2]);
    mRepC.getOrigin().setComponents(repOrigin[0], repOrigin[1], repOrigin[2]);
    mRepC.getReferenceRadius().setValue(refRad);
    mRepC.setCoordinateSystem(repCsys);
    mRepC.setRepresentation(repRepresentation);
    mRepC.getParts().setObjects(repParts);
    return mRepC;
  }
  //
  //Surface Integral
  public static SurfaceIntegralReport surfIntegralReport(
          Simulation tmpSim,String repName, FieldFunction tmpFF,
          Collection<? extends Boundary> tmpBnd,
          Representation repRepresentation){
      SurfaceIntegralReport retRep;
      try{
          retRep = (SurfaceIntegralReport) tmpSim.getReportManager().
                  getObject(repName);
      }catch(NeoException e){
          retRep = tmpSim.getReportManager().createReport(
                  SurfaceIntegralReport.class);
          retRep.setPresentationName(repName);
      }
      retRep.setRepresentation(repRepresentation);
      retRep.setFieldFunction(tmpFF);
      retRep.getParts().setObjects(tmpBnd);
      return retRep;
  }
  //
  //Surface Average
  public static AreaAverageReport surfAveReport(Simulation tmpSim,
          String repName, FieldFunction tmpFF,
          Collection<? extends NamedObject> repParts,
          Representation repRepresentation){
      AreaAverageReport surfAveRep;
      try{
          surfAveRep = (AreaAverageReport) tmpSim.getReportManager().
                  getObject(repName);
      }catch(NeoException e){
          surfAveRep = tmpSim.getReportManager().
                  createReport(AreaAverageReport.class);
          surfAveRep.setPresentationName(repName);
      }
      surfAveRep.setRepresentation(repRepresentation);
      surfAveRep.setFieldFunction(tmpFF);
      surfAveRep.getParts().setObjects(repParts);
      return surfAveRep;
  }

  //Sum
  public static SumReport sumReport(Simulation tmpSim,String repName,
          FieldFunction tmpFF,
  Collection<? extends NamedObject> repParts,
  Representation repRepresentation){
      SumReport tmpRep;
      try{
          tmpRep = (SumReport) tmpSim.getReportManager().getObject(repName);
      }catch(NeoException e){
          tmpRep = tmpSim.getReportManager().createReport(SumReport.class);
          tmpRep.setPresentationName(repName);
      }
      tmpRep.setRepresentation(repRepresentation);
      tmpRep.setFieldFunction(tmpFF);
      tmpRep.getParts().setObjects(repParts);
      return tmpRep;
  }
  public static ExpressionReport getExpressionReport(Simulation tmpSim,
          String repName){
  ExpressionReport tmpRep;
   try{
       tmpRep = (ExpressionReport) tmpSim.getReportManager().getObject(repName);
   }catch(NeoException e){
       tmpRep = tmpSim.getReportManager().createReport(ExpressionReport.class);
       tmpRep.setPresentationName(repName);
   }

   return tmpRep;
}

  //Max
  public static MaxReport maxReport(Simulation tmpSim,String repName,
          FieldFunction tmpFF,
          Collection<? extends NamedObject> repParts,
          Representation repRepresentation){
      MaxReport retRep;
      try{
          retRep = (MaxReport) tmpSim.getReportManager().getObject(repName);
      }catch(NeoException e){
          retRep = tmpSim.getReportManager().createReport(MaxReport.class);
          retRep.setPresentationName(repName);
      }
      retRep.setRepresentation(repRepresentation);
      //retRep.setScalar(tmpFF);
      retRep.setFieldFunction(tmpFF);
      retRep.getParts().setObjects(repParts);
      return retRep;
  }

  //Min
  public static MinReport minReport(Simulation tmpSim,String repName,
          FieldFunction tmpFF,
          Collection<? extends NamedObject> repParts,
          Representation repRepresentation){
      MinReport retRep;
      try{
          retRep = (MinReport) tmpSim.getReportManager().getObject(repName);
      }catch(NeoException e){
          retRep = tmpSim.getReportManager().createReport(MinReport.class);
          retRep.setPresentationName(repName);
      }
      retRep.setRepresentation(repRepresentation);
      retRep.setFieldFunction(tmpFF);
      retRep.getParts().setObjects(repParts);
      return retRep;
  }
  //
  //HPC Reports
  public static void makeHPCReports(Simulation tmpSim, int iterationPerCheck){
      //
      CumulativeElapsedTimeReport wallTime;
      IteratorElapsedTimeReport itPerSec;
      //
      IterationMaximumMemoryReport resMem;
      IterationMaximumMemoryReport virtMem;
      IterationMaximumMemoryReport resWatermark;
      IterationMaximumMemoryReport virtWatermark;
      int itPerMemCheck=iterationPerCheck;
      Units memUnits =
        ((Units) tmpSim.getReportManager().getSimulation().getUnitsManager().
                getObject("GiB"));
      //Wall time
      try{
          wallTime=(CumulativeElapsedTimeReport) tmpSim.getReportManager().
                  getReport("Wall Time");
      }catch(NeoException e){
          wallTime =
            tmpSim.getReportManager().createReport(
                    CumulativeElapsedTimeReport.class);
          wallTime.setPresentationName("Wall Time");
      }
      wallTime.setUnits((Units) tmpSim.getReportManager().getSimulation().
              getUnitsManager().getObject("hr"));

      // Seconds per Iteration
      try{
          itPerSec = (IteratorElapsedTimeReport) tmpSim.getReportManager().
                  getReport("Seconds Per Iteration");
      }catch(NeoException e){
          itPerSec =
            tmpSim.getReportManager().createReport(
                    IteratorElapsedTimeReport.class);
          itPerSec.setPresentationName("Seconds Per Iteration");
      }

      // Memory Management
      try{
          resMem =(IterationMaximumMemoryReport) tmpSim.getReportManager().
                  getReport("RES Memory");
      }catch(NeoException e){
          resMem =
            tmpSim.getReportManager().createReport(
                    IterationMaximumMemoryReport.class);
          resMem.setPresentationName("RES Memory");
      }
      resMem.getMemoryReportMetricOption().setSelected(
              MemoryReportMetricOption.Type.RESIDENT);
      resMem.setUnits(memUnits);
      resMem.setSamplingFrequency(itPerMemCheck);
      //
      try{
          virtMem =(IterationMaximumMemoryReport) tmpSim.getReportManager().
                  getReport("VIRT Memory");
      }catch(NeoException e){
          virtMem =
            tmpSim.getReportManager().createReport(
                    IterationMaximumMemoryReport.class);
          virtMem.setPresentationName("VIRT Memory");
      }
      virtMem.getMemoryReportMetricOption().setSelected(
              MemoryReportMetricOption.Type.VIRTUAL);
      virtMem.setUnits(memUnits);
      virtMem.setSamplingFrequency(itPerMemCheck);
      //
      try{
          resWatermark =(IterationMaximumMemoryReport)
                  tmpSim.getReportManager().getReport("RES Watermark Memory");
      }catch(NeoException e){
          resWatermark =
            tmpSim.getReportManager().
                    createReport(IterationMaximumMemoryReport.class);
          resWatermark.setPresentationName("RES Watermark Memory");
      }
      resWatermark.getMemoryReportMetricOption().
              setSelected(MemoryReportMetricOption.Type.RESIDENTHWM);
      resWatermark.setUnits(memUnits);
      resWatermark.setSamplingFrequency(itPerMemCheck);
      //
      try{
          virtWatermark =(IterationMaximumMemoryReport) tmpSim.
                  getReportManager().getReport("VIRT Watermark Memory");
      }catch(NeoException e){
          virtWatermark =
            tmpSim.getReportManager().createReport(
                    IterationMaximumMemoryReport.class);
          virtWatermark.setPresentationName("VIRT Watermark Memory");
      }
      virtWatermark.getMemoryReportMetricOption().
              setSelected(MemoryReportMetricOption.Type.VIRTUALHWM);
      virtWatermark.setUnits(memUnits);
      virtWatermark.setSamplingFrequency(itPerMemCheck);

  }
  //
  // Grouping methods
  public static ClientServerObjectGroup getReportGroup(Simulation tmpSim,
          String groupName){
      ClientServerObjectGroup tmp;
      try{
          tmp=((ClientServerObjectGroup) tmpSim.getReportManager().
                  getGroupsManager().getObject(groupName));
      }catch(NeoException e){
          tmpSim.getReportManager().getGroupsManager().createGroup(groupName);
          try{
            Thread.sleep(100);
          }catch(InterruptedException f){
          }
          tmp=((ClientServerObjectGroup) tmpSim.getReportManager().
                  getGroupsManager().getObject(groupName));
      }

      return tmp;
  }
  public static void groupReports(Simulation tmpSim, String groupName,
          Collection<Report> toBeGrouped){
      //Groups
      getReportGroup(tmpSim,groupName).getGroupsManager().
              groupObjects(groupName, toBeGrouped, true);

  }

}


text:
FROM busybox

RUN mkdir -p /rpcx-service
COPY ./client /rpcx-service/client

WORKDIR /rpcx-service

ENTRYPOINT [ "/rpcx-service/client" ]


text:
package io.crate.plugin;

import io.crate.test.integration.CrateUnitTest;
import org.elasticsearch.cluster.ClusterService;
import org.elasticsearch.common.inject.AbstractModule;
import org.elasticsearch.common.inject.Module;
import org.elasticsearch.common.inject.ModulesBuilder;
import org.elasticsearch.common.settings.ImmutableSettings;
import org.junit.Test;
import org.mockito.Mock;

import static org.hamcrest.Matchers.instanceOf;

public class CrateCorePluginTest extends CrateUnitTest {

    @Mock
    public ClusterService clusterService;

    private final class TestModule extends AbstractModule {

        @Override
        protected void configure() {
            bind(ClusterService.class).toInstance(clusterService);
        }
    }

    @Test
    public void testPluginLoadsCrateComponentModulesWithSettings() throws Exception {

        CrateCorePlugin plugin = new CrateCorePlugin(ImmutableSettings.EMPTY);
        ModulesBuilder modulesBuilder = new ModulesBuilder();

        // mock ClusterService for ClusterIdService, which is bound in CrateCoreModule
        modulesBuilder.add(new TestModule());

        for (Module module : plugin.modules(ImmutableSettings.EMPTY)) {
            modulesBuilder.add(module);
        }
        ExampleCrateComponent.IBound iBoundImpl = modulesBuilder.createInjector()
                .getInstance(ExampleCrateComponent.IBound.class);
        assertThat(iBoundImpl, instanceOf(ExampleCrateComponent.Bound.class));
    }
}


text:
<!DOCTYPE html>

  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  {% if site.bing_meta %} <meta name="msvalidate.01" content="{{site.bing_meta}}" /> {% endif %}
  {% seo %}

  <link href="{{ '/css/main.css' | prepend: site.baseurl }}" rel="stylesheet">

  {% if site.baidu_tongji_id %}

  {% endif %}
  {% if site.google_analytics_id %}

  {% endif %}

      <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
      你貌似开启了广告屏蔽插件... 写博客不容易,希望能将广告过滤去掉,谢谢!

      {% include header.html %}

      {{ content }}

      {% include footer.html %}


text:
<?php
/**
 * Created by PhpStorm.
 * User: jonas
 * Date: 12.04.2017
 * Time: 12:46
 */

namespace Source\Models\Helpers\FormValidators;

use Source\Models\DAOs\UserDAO;

abstract class JsonFormValidator {

    protected $userDAO;
    protected $errors;

    public function __construct(UserDAO $userDAO){
        $this->userDAO = $userDAO;
        $this->errors = array();
    }

    public abstract function validate($data);

    protected function checkFieldExistence($data, $fieldNames){
        $exist = true;
        foreach($fieldNames as $name){
            if(!isset($data[$name])){
                $this->errors[$name] = "The field " . $name . " is missing.";
                $exist = false;
            }
        }
        return $exist;
    }

    public function getErrors(){
        return $this->errors;
    }
}


text:
package com.jalotsav.sarvamsugar.common;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;

import com.jalotsav.sarvamsugar.Login;

/**
 * Created by JALOTSAV Dev. on 11/8/16.
 */
public class UserSessionManager {

    // Shared Preferences reference
    SharedPreferences pref;

    // Editor reference for Shared preferences
    SharedPreferences.Editor editor;

    // Context
    Context _context;

    // Shared pref mode
    int PRIVATE_MODE = 0;

    // Sharedpref file name
    private static String PREFER_NAME;

    // All Shared Preferences Keys
    // Is User Login or not (make variable public to access from outside)
    private static final String IS_USER_LOGIN = "IsUserLoggedIn";

    // Username
    public static final String KEY_USERNAME = "username";

    // UserId
    public static final String KEY_USERID = "userId";

    // UserType
    public static final String KEY_USERTYPE = "userType";

    // Constructor
    public UserSessionManager(Context context) {

        this._context = context;
        PREFER_NAME = _context.getPackageName() + "_shrdprfrnc";
        pref = _context.getSharedPreferences(PREFER_NAME, PRIVATE_MODE);
        editor = pref.edit();
        editor.apply();
    }

    // Create login session
    // Get-Set UserName to SharedPreferences
    public String getUserName() {

        String userName = pref.getString(KEY_USERNAME, "");
        return userName;
    }

    public void setUserName(String userName) {

        // Storing login value as TRUE
        editor.putBoolean(IS_USER_LOGIN, true);
        editor.putString(KEY_USERNAME, userName);
        editor.commit();
    }

    // Get-Set UserId to SharedPreferences
    public String getUserId() {

        String userId = pref.getString(KEY_USERID, "");
        return userId;
    }

    public void setUserId(String userId) {

        editor.putString(KEY_USERID, userId);
        editor.commit();
    }
    // Get-Set UserType to SharedPreferences
    public String getUserType() {

        String userType = pref.getString(KEY_USERTYPE, "");
        return userType;
    }

    public void setUserType(String userType) {

        editor.putString(KEY_USERTYPE, userType);
        editor.commit();
    }

    /**
     * Check login method will check user login status
     * If false it will redirect user to login page
     * Else do anything
     */
    public boolean checkLogin() {
        // Check login status
        if (!this.isUserLoggedIn()) {

            // user is not logged in redirect him to MainActivity
            Intent i = new Intent(_context, Login.class);
            i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
            _context.startActivity(i);

            return false;
        }
        return true;
    }

    /**
     * Clear session details
     */
    public void logoutUser() {

        // Clearing all user data from Shared Preferences
        editor.clear();
        editor.commit();

        // After logout redirect user to Login Activity
        Intent i = new Intent(_context, Login.class);
        i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
        _context.startActivity(i);
    }

    // Check for login
    public boolean isUserLoggedIn() {
        return pref.getBoolean(IS_USER_LOGIN, false);
    }
}


text:
import Archiver = require('archiver');
import * as fs from 'fs';

const options: Archiver.ArchiverOptions = {
    statConcurrency: 1,
    allowHalfOpen: true,
    readableObjectMode: true,
    writeableObjectMode: true,
    decodeStrings: true,
    encoding: 'test',
    highWaterMark: 1,
    objectmode: true,
    comment: 'test',
    forceLocalTime: true,
    forceZip64: true,
    store: true,
    zlib: {},
    gzip: true,
    gzipOptions: {},
};

Archiver('zip', options);

const archiver = Archiver.create('zip');

const writeStream = fs.createWriteStream('./archiver.d.ts');
const readStream = fs.createReadStream('./archiver.d.ts');

archiver.abort();

archiver.pipe(writeStream);
archiver.append(readStream, { name: 'archiver.d.ts' });
archiver.append(readStream, { name: 'buffer.txt', date: '05/05/1991' });
archiver.append(readStream, { name: 'buffer.txt', date: new Date() });
archiver.append(readStream, { name: 'buffer.txt', mode: 1 });
archiver.append(readStream, { name: 'buffer.txt', mode: 1, stats: new fs.Stats() });
archiver.append('Some content', { name: 'filename', store: true });
archiver.append(readStream, { name: 'archiver.d.ts' }).append(readStream, { name: 'archiver.d.ts' });

archiver.directory('./path', './someOtherPath');
archiver.directory('./', '', {});
archiver.directory('./', false, { name: 'test' });
archiver.directory('./', false, (entry: Archiver.EntryData) => {
    entry.name = 'foobar';
    return entry;
});
archiver.directory('./', false, (entry: Archiver.EntryData) => false);

archiver.append(readStream, {
    name: 'sub/folder.xml',
});

archiver.glob('**', {
    cwd: 'path/to/files',
});
archiver.glob('./path', {}, {});

archiver.file('./path', { name: 'test' });

archiver.setFormat('zip');
archiver.setModule(() => {});

archiver.pointer();
archiver.use(() => {});

archiver.finalize();

archiver.symlink('./path', './target');

function fakeHandler(err: Archiver.ArchiverError) {
    console.log(err.code);
    console.log(err.message);
    console.log(err.stack);
    console.log(err.data);
}

const fakeError = new Archiver.ArchiverError('code', 'foo');

archiver.on('error', fakeHandler);
archiver.on('warning', fakeHandler);


text:
package au.edu.unimelb.csse.mugle.client.api;

import au.edu.unimelb.csse.mugle.shared.api.GameTokenError;

import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;

/**
 * Developer API for accessing the current user's high-score. This allows the
 * game to save the user's highest score.
 */
@RemoteServiceRelativePath("api-highscore")
public interface HighscoreService extends RemoteService {
	/**
	 * Saves the score for the current player. If this is better than the
	 * player's current high score, sets the new high score. Otherwise, does
	 * nothing.
	 *
	 * @param gameToken
	 *            The secret token for the current game.
	 * @param score
	 *            The player's score.
	 */
	public void saveScore(String gameToken, int score) throws GameTokenError;

	/**
	 * Gets the highest score of the current player.
	 *
	 * @param gameToken
	 *            The secret token for the current game.
	 * @return The player's highest score.
	 */
	public int getHighScore(String gameToken) throws GameTokenError;
}


text:
namespace precartillas.UserCatalogos
{
    partial class UserControlEstudios
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Component Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(UserControlEstudios));
            this.splitContainer1 = new System.Windows.Forms.SplitContainer();
            this.advTreeEstudios = new DevComponents.AdvTree.AdvTree();
            this.MenuArbol = new System.Windows.Forms.ContextMenuStrip(this.components);
            this.agregarElementoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.eliminarElementoSeleccionadoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.nodeRoot = new DevComponents.AdvTree.Node();
            this.nodeConnector1 = new DevComponents.AdvTree.NodeConnector();
            this.elementStyle1 = new DevComponents.DotNetBar.ElementStyle();
            this.splitContainer2 = new System.Windows.Forms.SplitContainer();
            this.propertyGridEstudios = new System.Windows.Forms.PropertyGrid();
            this.btnActualizar = new System.Windows.Forms.Button();
            ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
            this.splitContainer1.Panel1.SuspendLayout();
            this.splitContainer1.Panel2.SuspendLayout();
            this.splitContainer1.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.advTreeEstudios)).BeginInit();
            this.MenuArbol.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit();
            this.splitContainer2.Panel1.SuspendLayout();
            this.splitContainer2.Panel2.SuspendLayout();
            this.splitContainer2.SuspendLayout();
            this.SuspendLayout();
            //
            // splitContainer1
            //
            this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.splitContainer1.Location = new System.Drawing.Point(0, 0);
            this.splitContainer1.Name = "splitContainer1";
            //
            // splitContainer1.Panel1
            //
            this.splitContainer1.Panel1.Controls.Add(this.advTreeEstudios);
            //
            // splitContainer1.Panel2
            //
            this.splitContainer1.Panel2.Controls.Add(this.splitContainer2);
            this.splitContainer1.Size = new System.Drawing.Size(485, 485);
            this.splitContainer1.SplitterDistance = 217;
            this.splitContainer1.TabIndex = 0;
            //
            // advTreeEstudios
            //
            this.advTreeEstudios.AccessibleRole = System.Windows.Forms.AccessibleRole.Outline;
            this.advTreeEstudios.AllowDrop = true;
            this.advTreeEstudios.BackColor = System.Drawing.SystemColors.Window;
            //
            //
            //
            this.advTreeEstudios.BackgroundStyle.Class = "TreeBorderKey";
            this.advTreeEstudios.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
            this.advTreeEstudios.ContextMenuStrip = this.MenuArbol;
            this.advTreeEstudios.Dock = System.Windows.Forms.DockStyle.Fill;
            this.advTreeEstudios.Location = new System.Drawing.Point(0, 0);
            this.advTreeEstudios.Name = "advTreeEstudios";
            this.advTreeEstudios.Nodes.AddRange(new DevComponents.AdvTree.Node[] {
            this.nodeRoot});
            this.advTreeEstudios.NodesConnector = this.nodeConnector1;
            this.advTreeEstudios.NodeStyle = this.elementStyle1;
            this.advTreeEstudios.PathSeparator = ";";
            this.advTreeEstudios.Size = new System.Drawing.Size(217, 485);
            this.advTreeEstudios.Styles.Add(this.elementStyle1);
            this.advTreeEstudios.TabIndex = 0;
            this.advTreeEstudios.Text = "advTreeEstudios";
            this.advTreeEstudios.AfterNodeSelect += new DevComponents.AdvTree.AdvTreeNodeEventHandler(this.advTreeEstudios_AfterNodeSelect);
            //
            // MenuArbol
            //
            this.MenuArbol.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.agregarElementoToolStripMenuItem,
            this.eliminarElementoSeleccionadoToolStripMenuItem});
            this.MenuArbol.Name = "MenuArbol";
            this.MenuArbol.Size = new System.Drawing.Size(243, 70);
            //
            // agregarElementoToolStripMenuItem
            //
            this.agregarElementoToolStripMenuItem.Name = "agregarElementoToolStripMenuItem";
            this.agregarElementoToolStripMenuItem.Size = new System.Drawing.Size(242, 22);
            this.agregarElementoToolStripMenuItem.Text = "Agregar elemento";
            this.agregarElementoToolStripMenuItem.Click += new System.EventHandler(this.agregarElementoToolStripMenuItem_Click);
            //
            // eliminarElementoSeleccionadoToolStripMenuItem
            //
            this.eliminarElementoSeleccionadoToolStripMenuItem.Name = "eliminarElementoSeleccionadoToolStripMenuItem";
            this.eliminarElementoSeleccionadoToolStripMenuItem.Size = new System.Drawing.Size(242, 22);
            this.eliminarElementoSeleccionadoToolStripMenuItem.Text = "Eliminar elemento seleccionado";
            this.eliminarElementoSeleccionadoToolStripMenuItem.Click += new System.EventHandler(this.eliminarElementoSeleccionadoToolStripMenuItem_Click);
            //
            // nodeRoot
            //
            this.nodeRoot.Expanded = true;
            this.nodeRoot.Image = ((System.Drawing.Image)(resources.GetObject("nodeRoot.Image")));
            this.nodeRoot.Name = "nodeRoot";
            this.nodeRoot.Text = "Grados de estudios";
            //
            // nodeConnector1
            //
            this.nodeConnector1.LineColor = System.Drawing.SystemColors.ControlText;
            //
            // elementStyle1
            //
            this.elementStyle1.Class = "";
            this.elementStyle1.CornerType = DevComponents.DotNetBar.eCornerType.Square;
            this.elementStyle1.Name = "elementStyle1";
            this.elementStyle1.TextColor = System.Drawing.SystemColors.ControlText;
            //
            // splitContainer2
            //
            this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill;
            this.splitContainer2.Location = new System.Drawing.Point(0, 0);
            this.splitContainer2.Name = "splitContainer2";
            this.splitContainer2.Orientation = System.Windows.Forms.Orientation.Horizontal;
            //
            // splitContainer2.Panel1
            //
            this.splitContainer2.Panel1.Controls.Add(this.propertyGridEstudios);
            //
            // splitContainer2.Panel2
            //
            this.splitContainer2.Panel2.Controls.Add(this.btnActualizar);
            this.splitContainer2.Size = new System.Drawing.Size(264, 485);
            this.splitContainer2.SplitterDistance = 348;
            this.splitContainer2.TabIndex = 0;
            //
            // propertyGridEstudios
            //
            this.propertyGridEstudios.Dock = System.Windows.Forms.DockStyle.Fill;
            this.propertyGridEstudios.Location = new System.Drawing.Point(0, 0);
            this.propertyGridEstudios.Name = "propertyGridEstudios";
            this.propertyGridEstudios.PropertySort = System.Windows.Forms.PropertySort.Categorized;
            this.propertyGridEstudios.Size = new System.Drawing.Size(264, 348);
            this.propertyGridEstudios.TabIndex = 0;
            this.propertyGridEstudios.ToolbarVisible = false;
            this.propertyGridEstudios.PropertyValueChanged += new System.Windows.Forms.PropertyValueChangedEventHandler(this.propertyGridEstudios_PropertyValueChanged);
            //
            // btnActualizar
            //
            this.btnActualizar.Location = new System.Drawing.Point(21, 19);
            this.btnActualizar.Name = "btnActualizar";
            this.btnActualizar.Size = new System.Drawing.Size(75, 23);
            this.btnActualizar.TabIndex = 0;
            this.btnActualizar.Text = "Actulizar";
            this.btnActualizar.UseVisualStyleBackColor = true;
            this.btnActualizar.Click += new System.EventHandler(this.btnActualizar_Click);
            //
            // UserControlEstudios
            //
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.Controls.Add(this.splitContainer1);
            this.Name = "UserControlEstudios";
            this.Size = new System.Drawing.Size(485, 485);
            this.Load += new System.EventHandler(this.UserControlEstudios_Load);
            this.splitContainer1.Panel1.ResumeLayout(false);
            this.splitContainer1.Panel2.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
            this.splitContainer1.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.advTreeEstudios)).EndInit();
            this.MenuArbol.ResumeLayout(false);
            this.splitContainer2.Panel1.ResumeLayout(false);
            this.splitContainer2.Panel2.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit();
            this.splitContainer2.ResumeLayout(false);
            this.ResumeLayout(false);

        }

        #endregion

        private System.Windows.Forms.SplitContainer splitContainer1;
        private System.Windows.Forms.SplitContainer splitContainer2;
        private System.Windows.Forms.PropertyGrid propertyGridEstudios;
        private System.Windows.Forms.ContextMenuStrip MenuArbol;
        private System.Windows.Forms.ToolStripMenuItem agregarElementoToolStripMenuItem;
        private System.Windows.Forms.ToolStripMenuItem eliminarElementoSeleccionadoToolStripMenuItem;
        private System.Windows.Forms.Button btnActualizar;
        private DevComponents.AdvTree.AdvTree advTreeEstudios;
        private DevComponents.AdvTree.Node nodeRoot;
        private DevComponents.AdvTree.NodeConnector nodeConnector1;
        private DevComponents.DotNetBar.ElementStyle elementStyle1;
    }
}


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<title>org.hibernate.loader.spi (Hibernate JavaDocs)</title>
<meta name="date" content="2014-03-03">
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">

org.hibernate.loader.spi

Interfaces

AfterLoadAction


text:
title:  További Tanulmányozásra
date:  05/08/2022
---

Ellen G. White: Pátriárkák és próféták. Budapest, 1993, Advent Kiadó, "A küzdelem éjszakája" c. fejezet, 156-162. o.; Jézushoz vezető út. Budapest, 2008, Advent Irodalmi Műhely, "Odaadás" c. fejezet, 33-37. o.

"Az akaraterő, ami igen fontos része a jellemnek, a bűnbeeséskor Sátán uralma alá került. Az ördög pedig azóta azon dolgozik, hogy az ember a saját kedvét keresse akaratban és tettekben, ami az emberiség teljes bukását és gyötrelmét okozza" (Ellen G. White: 5Testimonies. 515. o.).

"Azért, hogy megkapjuk Isten segítségét, el kell ismernünk gyengeségünket és elégtelenségünket; elménket azokra a nagy változásokra kell irányítanunk, amelyek bennünk végbe mennek. El kell kezdenünk komolyan és kitartóan imádkozni. El kell vetni magunktól a rossz szokásokat; a győzelmet csak akkor nyerhetjük el, ha határozott erőfeszítéssel igyekszünk tévedéseink kiigazítására és a helyes alapelvekhez való alkalmazkodásra. Sokan azért nem érnek el magas szintet – amelyet pedig elérhetnének –, mert Istenre várnak, hogy majd megcselekszi helyettük azt, aminek a megtételéhez elegendő erőt adott nekik. Mindazok, akik alkalmasak tisztségek betöltésére, a legszigorúbb értelmi és erkölcsi fegyelemmel kell nevelődjenek. Isten segítségükre lesz, mert erejét egyesíti az emberi törekvésekkel" (Ellen G. White: Pátriárkák és próféták. Budapest, 1993, Advent Kiadó, 208. o.).

**Beszélgessünk róla!**

`1) Vajon mennyire fogjuk fel, hogy az akaraterőnk "a bűnbeeséskor Sátán uralma alá került"? Hogyan segíthet jobban megérteni azt, hogy milyen mélyre süllyedtünk és milyen nagy Isten kegyelme irántunk, ha Jézus jellemére összpontosítunk?`

`2) Olvassuk el azt a történetet, amikor Jézus a Gecsemáné kertjében volt (Mt 26:36-42)! Mit érzett és mire vágyott, ellentétben Isten akaratával? Mit tanulhatunk meg ebből a példából?`

`3) Beszéljük meg az osztályban, hogy a kultúránk mely elemei bonthatják le a védőfalunkat és tesznek még sebezhetőbbé Sátán támadásaival szemben! Mit tehetünk azért, hogy segítsünk a gyülekezetünk tagjainak és a segítségre szorulóknak felismerni a veszélyeket?`

`4) Ismerünk valakit a gyülekezetből, aki már hosszabb ideje nem jár, vagy aki már-már feladni készül, vagy talán már fel is adta a küzdelmet? Mit tehetünk együtt a bátorításáért, nehogy elforduljon Jézustól? A gyakorlatban hogyan tudnánk segíteni neki?`

---

#### Ellen G. White idézetek

Pátriárkák és próféták, "A küzdelem éjszakája" c. fejezet.