Candles. Build from OL fixes.

Candles. Build from OL fixes.

--- Algo/Candles/Compression/CandleBuilderMessageAdapter.cs
+++ Algo/Candles/Compression/CandleBuilderMessageAdapter.cs
@@ -198,7 +198,7 @@

 					var execMsg = (ExecutionMessage)message;

-					if (execMsg.ExecutionType != ExecutionTypes.Tick)
+					if (execMsg.ExecutionType != ExecutionTypes.Tick && execMsg.ExecutionType != ExecutionTypes.OrderLog)
 						break;

 					ProcessValue(execMsg.SecurityId, execMsg.OriginalTransactionId, execMsg);
@@ -344,6 +344,7 @@
 				case MarketDataTypes.Level1:
 				case MarketDataTypes.MarketDepth:
 				case MarketDataTypes.Trades:
+				case MarketDataTypes.OrderLog:
 				{
 					SendNotSupported(info);
 					break;
@@ -398,6 +399,7 @@
 				case MarketDataTypes.Level1:
 				case MarketDataTypes.MarketDepth:
 				case MarketDataTypes.Trades:
+				case MarketDataTypes.OrderLog:
 				{
 					SendMarketDataFinished(info);
 					break;


Fixed color enum order

Fixed color enum order

--- GhostFinders/Assets/ProjectAssets/Scripts/Scripts.cs
+++ GhostFinders/Assets/ProjectAssets/Scripts/Scripts.cs
@@ -7,12 +7,12 @@
     public enum colors
     {
         unknown = 0,
-        blue,
-        red,
+        red = 1,
+        yellow,
         green,
         cyan,
-        magenta,
-        yellow
+        blue,
+        magenta
     }
     public enum DIRECTION
     {


Use file move instead of file copy for mo better performance

--- src/Camera.cs
+++ src/Camera.cs
@@ -49,8 +49,11 @@

 			if (file.HasExtension(CONVERT_FOOTAGE_FORMAT))
 			{
-				//save some time & just copy the file rather than going through ffmpeg
-				File.Copy(file.FilePath, outputFile, true);
+				//clear if it already exists for some reason (previous process run failed?)
+				File.Delete(outputFile);
+
+				//save some time & just move the file directly rather than going through ffmpeg
+				File.Move(file.FilePath, outputFile);
 			}
 			else if (!VideoConverter.CodecCopy(file.FilePath, outputFile))
 			{


all unit tests now pass ... yay

all unit tests now pass ... yay

--- App/StackExchange.DataExplorer.Tests/Models/TestUser.cs
+++ App/StackExchange.DataExplorer.Tests/Models/TestUser.cs
@@ -27,7 +27,7 @@
             var u2 = Current.DB.Query<User>("select * from Users where Login = @Login", new {Login = "Fred"}).First();
             Assert.AreEqual("Fred", u2.Login);

-            var o = Current.DB.Query<UserOpenId>("select * from UserOpenId where OpenIdClaim = @claim", new {claim = "xyz"}).FirstOrDefault();
+            var o = Current.DB.Query<UserOpenId>("select * from UserOpenIds where OpenIdClaim = @claim", new {claim = "xyz"}).FirstOrDefault();
             Assert.AreEqual("xyz", o.OpenIdClaim);
         }


Remove final dash before baking the string

I haven't profiled (or even tested) this, but this should be better.

--- App/StackExchange.DataExplorer/Helpers/HtmlUtilities.cs
+++ App/StackExchange.DataExplorer/Helpers/HtmlUtilities.cs
@@ -819,9 +819,9 @@
             }

             if (prevdash)
-                return sb.ToString().Substring(0, sb.Length - 1);
-            else
-                return sb.ToString();
+                sb.Length -= 1;
+
+            return sb.ToString();
         }

         /// <summary>
@@ -879,4 +879,4 @@
             return buffer.ToString();
         }
     }
-}+}


Omdøbt metode til mere sigende navn

Omdøbt metode til mere sigende navn

--- Presentation.Web/Controllers/OData/ReportsController.cs
+++ Presentation.Web/Controllers/OData/ReportsController.cs
@@ -14,7 +14,7 @@

         // GET /Organizations(1)/Reports
         [ODataRoute("Organizations({key})/Reports")]
-        public IHttpActionResult GetItContracts(int key)
+        public IHttpActionResult GetReportsByOrganization(int key)
         {
             return GetByOrganizationKey(key);
         }


testing.

testing.

--- Assets/MiyamasuTestRunner/Editor/MiyamasuTestIgniter.cs
+++ Assets/MiyamasuTestRunner/Editor/MiyamasuTestIgniter.cs
@@ -1,3 +1,4 @@
+using NUnit.Framework;
 using UnityEditor;
 using UnityEngine;

@@ -37,11 +38,13 @@
 			Debug.LogError("start testing from method.");
 			RunTests();
 		}
-	}
-}
+	}

-public static class Something {
-	public static void Run () {
-		Debug.LogError("run!");
+
+
+	public class Something {
+		[Test] public static void Run () {
+			Debug.LogError("run!");
+		}
 	}
 }


fix permission replacement link

fix permission replacement link

--- Producer/Producer.Functions/DocumentClientExtensions.cs
+++ Producer/Producer.Functions/DocumentClientExtensions.cs
@@ -267,7 +267,7 @@

 						log?.Info ($"Replacing {permissionMode.ToString ().ToUpper ()} Permission for User {userId} with PermissionId {permissionId}...");

-						var permissionResponse = await client.ReplacePermissionAsync (newPermission, permissionRequestOptions);
+						var permissionResponse = await client.ReplacePermissionAsync (UriFactory.CreatePermissionUri (dbId, userId, permissionId), newPermission, permissionRequestOptions);

 						return permissionResponse?.Resource;


Added new AsteriskVersions to determineVersion()

Added up to Asterisk v17.
Added an attempt at getting newer versions too.

--- Asterisk.2013/Asterisk.NET/Manager/ManagerConnection.cs
+++ Asterisk.2013/Asterisk.NET/Manager/ManagerConnection.cs
@@ -167,7 +167,7 @@
 		/// <summary> Default Slow Reconnect interval in milliseconds.</summary>
 		private int reconnectIntervalMax = 10000;

-        public char[] VAR_DELIMITER = { '|' };
+		public char[] VAR_DELIMITER = { '|' };

 		#endregion

@@ -1646,43 +1646,68 @@
 						if (m.Groups.Count >= 2)
 						{
 							version = m.Groups[1].Value;
-                            if (version.StartsWith("1.4."))
-                            {
-                                VAR_DELIMITER = new char[] { '|' };
-                                return AsteriskVersion.ASTERISK_1_4;
-                            }
-                            else if (version.StartsWith("1.6."))
-                            {
-                                VAR_DELIMITER = new char[] { '|' };
-                                return Manager.AsteriskVersion.ASTERISK_1_6;
-                            }
-                            else if (version.StartsWith("1.8."))
-                            {
-                                VAR_DELIMITER = new char[] { '|' };
-                                return Manager.AsteriskVersion.ASTERISK_1_8;
-                            }
-                            else if (version.StartsWith("10."))
-                            {
-                                VAR_DELIMITER = new char[] { '|' };
-                                return Manager.AsteriskVersion.ASTERISK_10;
-                            }
-                            else if (version.StartsWith("11."))
-                            {
-                                VAR_DELIMITER = new char[] { ',' };
-                                return Manager.AsteriskVersion.ASTERISK_11;
-                            }
-                            else if (version.StartsWith("12."))
-                            {
-                                VAR_DELIMITER = new char[] { ',' };
-                                return Manager.AsteriskVersion.ASTERISK_12;
-                            }
-                            else if (version.StartsWith("13."))
-                            {
-                                VAR_DELIMITER = new char[] { ',' };
-                                return Manager.AsteriskVersion.ASTERISK_13;
-                            }
-                            else
-                                throw new ManagerException("Unknown Asterisk version " + version);
+							if (version.StartsWith("1.4."))
+							{
+								VAR_DELIMITER = new char[] { '|' };
+								return AsteriskVersion.ASTERISK_1_4;
+							}
+							else if (version.StartsWith("1.6."))
+							{
+								VAR_DELIMITER = new char[] { '|' };
+								return Manager.AsteriskVersion.ASTERISK_1_6;
+							}
+							else if (version.StartsWith("1.8."))
+							{
+								VAR_DELIMITER = new char[] { '|' };
+								return Manager.AsteriskVersion.ASTERISK_1_8;
+							}
+							else if (version.StartsWith("10."))
+							{
+								VAR_DELIMITER = new char[] { '|' };
+								return Manager.AsteriskVersion.ASTERISK_10;
+							}
+							else if (version.StartsWith("11."))
+							{
+								VAR_DELIMITER = new char[] { ',' };
+								return Manager.AsteriskVersion.ASTERISK_11;
+							}
+							else if (version.StartsWith("12."))
+							{
+								VAR_DELIMITER = new char[] { ',' };
+								return Manager.AsteriskVersion.ASTERISK_12;
+							}
+							else if (version.StartsWith("13."))
+							{
+								VAR_DELIMITER = new char[] { ',' };
+								return Manager.AsteriskVersion.ASTERISK_13;
+							}
+							else if (version.StartsWith("14."))
+							{
+								VAR_DELIMITER = new char[] { ',' };
+								return Manager.AsteriskVersion.ASTERISK_14;
+							}
+							else if (version.StartsWith("15."))
+							{
+								VAR_DELIMITER = new char[] { ',' };
+								return Manager.AsteriskVersion.ASTERISK_15;
+							}
+							else if (version.StartsWith("16."))
+							{
+								VAR_DELIMITER = new char[] { ',' };
+								return Manager.AsteriskVersion.ASTERISK_16;
+							}
+							else if (version.StartsWith("17."))
+							{
+								VAR_DELIMITER = new char[] { ',' };
+								return Manager.AsteriskVersion.ASTERISK_17;
+							}
+							else if (version.IndexOf('.') >= 2)
+							{
+								VAR_DELIMITER = new char[] { ',' };
+								return Manager.AsteriskVersion.ASTERISK_Newer;
+							}
+							else
+								throw new ManagerException("Unknown Asterisk version " + version);
 						}
 					}
 				}
@@ -1697,7 +1722,10 @@
 					string line1;
 					line1 = (string)showVersionFilesResult[0];
 					if (line1 != null && line1.StartsWith("File"))
+					{
+						VAR_DELIMITER = new char[] { '|' };
 						return AsteriskVersion.ASTERISK_1_2;
+					}
 				}
 			}
 			return AsteriskVersion.ASTERISK_1_0;


add contributed users.

add contributed users.

--- Inscribe/ViewModels/Dialogs/Common/AboutViewModel.cs
+++ Inscribe/ViewModels/Dialogs/Common/AboutViewModel.cs
@@ -29,6 +29,9 @@
             new ContributorViewModel("キスショさん", "__kiss"),
             new ContributorViewModel("れき", "reki_frequent"),
             new ContributorViewModel("月夜見命", "ls_akari"),
+            new ContributorViewModel("colorfulpastel", "colorfulpastel"),
+            new ContributorViewModel("502bg", "502bg"),
+            new ContributorViewModel("ponica", "ponica"),
             new ContributorViewModel("トランキ", "trankie00"),
             new ContributorViewModel("めびう寿司", "catina013"),
             new ContributorViewModel("くりゅー", "chry545"),
@@ -51,7 +54,7 @@

         public AboutViewModel()
         {
-            Task.Factory.StartNew(() => CheckUpdate());
+            Task.Factory.StartNew(CheckUpdate);
         }

         public IEnumerable<ContributorViewModel> Contributors


#45 Refactored dynamic binding tests.

#45 Refactored dynamic binding tests.

--- IronVelocity.Tests/TemplateExecution/DynamicTests.cs
+++ IronVelocity.Tests/TemplateExecution/DynamicTests.cs
@@ -18,31 +18,31 @@
         }

         [Test]
-        public void ShouldInvokeOnCustomDynamic()
-        {
-            var dynamic = new CustomDynamic();
+        public void ShouldDoInvokeMemberOperationOnCustomDynamic()
+        {
+            var dynamic = new TestDynamicMetaObjectProvider();
             var context = new { Dynamic = dynamic };

             var execution = ExecuteTemplate("$dynamic.Foo('hello')", context);

-            Assert.That(execution.Output, Is.EqualTo("Invoke Foo: (hello)"));
-        }
-
-        [Test]
-        public void ShouldGetMemberOnCustomDynamic()
-        {
-            dynamic dynamic = new CustomDynamic();
+            Assert.That(execution.Output, Is.EqualTo("DMO InvokeMember Foo: (hello)"));
+        }
+
+        [Test]
+        public void ShouldDoGetMemberOperationOnCustomDynamic()
+        {
+            dynamic dynamic = new TestDynamicMetaObjectProvider();
             var context = new { Dynamic = dynamic };

             var execution = ExecuteTemplate("$dynamic.Fizz", context);

-            Assert.That(execution.Output, Is.EqualTo("GetMember: Fizz"));
-        }
-
-        [Test]
-        public void ShouldSetMemberOnCustomDynamic()
-        {
-            var dynamic = new CustomDynamic();
+            Assert.That(execution.Output, Is.EqualTo("DMO GetMember: Fizz"));
+        }
+
+        [Test]
+        public void ShouldDoSetMemberOperationOnCustomDynamic()
+        {
+            var dynamic = new TestDynamicMetaObjectProvider();
             var context = new { Dynamic = dynamic };

             var execution = ExecuteTemplate("#set($dynamic.Bar = 7.45)", context);
@@ -53,28 +53,28 @@

         [Test]
-        public void ShouldBinaryOnCustomDynamicForMathematicalExpression()
-        {
-            var dynamic = new CustomDynamic();
+        public void ShouldDoBinaryOperationOnCustomDynamicForMathematicalExpression()
+        {
+            var dynamic = new TestDynamicMetaObjectProvider();
             var context = new { Dynamic = dynamic };

             var execution = ExecuteTemplate("#set($result = $dynamic + 1)", context);

-            var result = execution.Context["result"];
-            Assert.That(result, Is.EqualTo("Binary Add: 1"));
-        }
-
-
-        [Test]
-        public void ShouldBinaryOnCustomDynamicForRelationalExpression()
-        {
-            var dynamic = new CustomDynamic();
+            Assert.That(execution.Context.Keys, Contains.Item("result"));
+            Assert.That(execution.Context["result"], Is.EqualTo("DMO Binary Add: 1"));
+        }
+
+
+        [Test]
+        public void ShouldDoBinaryOperationOnCustomDynamicForRelationalExpression()
+        {
+            var dynamic = new TestDynamicMetaObjectProvider();
             var context = new { Dynamic = dynamic };

             var execution = ExecuteTemplate("#set($result = ($dynamic > 472))", context);

-            var result = execution.Context["result"];
-            Assert.That(result, Is.EqualTo("Binary GreaterThan: 472"));
+            Assert.That(execution.Context.Keys, Contains.Item("result"));
+            Assert.That(execution.Context["result"], Is.EqualTo("DMO Binary GreaterThan: 472"));
         }

@@ -171,7 +171,7 @@
         }

-        public class CustomDynamic : IDynamicMetaObjectProvider
+        public class TestDynamicMetaObjectProvider : IDynamicMetaObjectProvider
         {
             public IDictionary<string, object> SetValues { get; } = new Dictionary<string, object>();

@@ -182,22 +182,22 @@

             private class CustomDynamicMetaObject : DynamicMetaObject
             {
-                private readonly CustomDynamic _customDynamic;
-
-                public CustomDynamicMetaObject(Expression expression, CustomDynamic value)
+                private readonly TestDynamicMetaObjectProvider _customDynamic;
+
+                public CustomDynamicMetaObject(Expression expression, TestDynamicMetaObjectProvider value)
                     : base(expression, BindingRestrictions.Empty, value)
                 {
                     _customDynamic = value;
                 }

                 public override DynamicMetaObject BindGetMember(GetMemberBinder binder)
-                    => ConstantDynamicMetaObject($"GetMember: {binder.Name}");
+                    => ConstantDynamicMetaObject($"DMO GetMember: {binder.Name}");

                 public override DynamicMetaObject BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args)
-                    => ConstantDynamicMetaObject($"Invoke {binder.Name}: ({string.Join(", ", args.Select(x => x.Value))})");
+                    => ConstantDynamicMetaObject($"DMO InvokeMember {binder.Name}: ({string.Join(", ", args.Select(x => x.Value))})");

                 public override DynamicMetaObject BindBinaryOperation(BinaryOperationBinder binder, DynamicMetaObject arg)
-                    => ConstantDynamicMetaObject($"Binary {binder.Operation}: {arg.Value}");
+                    => ConstantDynamicMetaObject($"DMO Binary {binder.Operation}: {arg.Value}");

                 public override DynamicMetaObject BindSetMember(SetMemberBinder binder, DynamicMetaObject value)
@@ -219,7 +219,7 @@

         }

-        public class MyDynamicObject : DynamicObject
+        public class TestDynamicObject : DynamicObject
         {
             public override DynamicMetaObject GetMetaObject(Expression parameter)
             {


Finish removing the big angular velocity slowdown hack.

--- Aurora/Physics/AuroraOpenDynamicsEngine/AODEDynamics.cs
+++ Aurora/Physics/AuroraOpenDynamicsEngine/AODEDynamics.cs
@@ -825,7 +825,7 @@
                 m_angularMotorApply--;        // This is done so that if script request rate is less than phys frame rate the expected
                 // velocity may still be acheived.
             }
-            else
+            else if(m_angularMotorVelocity != Vector3.Zero)
             {
                 // no motor recently applied, keep the body velocity
                 /*        m_angularMotorVelocity.X = angularVelocity.X;
@@ -833,7 +833,9 @@
                         m_angularMotorVelocity.Z = angularVelocity.Z; */

                 // and decay the velocity
-                m_angularMotorVelocity -= m_angularMotorVelocity / (m_angularMotorDecayTimescale / (pTimestep * pTimestep));
+                m_angularMotorVelocity -= m_angularMotorVelocity / (m_angularMotorDecayTimescale / pTimestep);
+                if(m_angularMotorVelocity.ApproxEquals(Vector3.Zero, 0.1f))
+                    m_angularMotorVelocity = Vector3.Zero;
             } // end motor section

             // Vertical attractor section
@@ -975,7 +977,6 @@
             if(parent.IsColliding)
             {
                 decayamount *= 100;
-                decayamount += new Vector3(0.1f, 0.1f, 0.25f);
                 if(decayamount.X > 1)
                     decayamount.X = 1;
                 if(decayamount.Y > 1)


Make boats function better, can use the encog boat script now, except that when turning, it becomes shaky in the client (unsure why yet).

--- Aurora/Physics/AuroraOpenDynamicsEngine/AODEDynamics.cs
+++ Aurora/Physics/AuroraOpenDynamicsEngine/AODEDynamics.cs
@@ -573,10 +573,10 @@
             grav.Z = _pParentScene.gravityz * Mass * (float)parent.ParentEntity.GravityMultiplier * (1f - m_VehicleBuoyancy);
             // Preserve the current Z velocity
             d.Vector3 vel_now = d.BodyGetLinearVel (Body);
-            if(m_lastLinearVelocityVector.Z == 0 && m_verticalAttractionTimescale == 0)
+            if (m_lastLinearVelocityVector.Z == 0 && Type != Vehicle.TYPE_AIRPLANE && Type != Vehicle.TYPE_BALLOON)
                 m_dir.Z = vel_now.Z;        // Preserve the accumulated falling velocity
-            else if(Type != Vehicle.TYPE_AIRPLANE && Type != Vehicle.TYPE_BALLOON)
-                m_dir.Z += vel_now.Z;
+            //else if(Type != Vehicle.TYPE_AIRPLANE && Type != Vehicle.TYPE_BALLOON)
+            //    m_dir.Z += vel_now.Z;

             d.Vector3 pos = d.BodyGetPosition (Body);
             //            Vector3 accel = new Vector3(-(m_dir.X - m_lastLinearVelocityVector.X / 0.1f), -(m_dir.Y - m_lastLinearVelocityVector.Y / 0.1f), m_dir.Z - m_lastLinearVelocityVector.Z / 0.1f);
@@ -646,6 +646,11 @@
                 {
                     if ((pos.Z - m_VhoverTargetHeight) > .2 || (pos.Z - m_VhoverTargetHeight) < -.2)
                     {
+                        float h = m_VhoverTargetHeight;
+                        float groundHeight = _pParentScene.GetTerrainHeightAtXY (pos.X, pos.Y);
+                        if (groundHeight >= m_VhoverTargetHeight)
+                            h = groundHeight;
+
                         d.BodySetPosition (Body, pos.X, pos.Y, m_VhoverTargetHeight);
                     }
                 }
@@ -682,6 +687,8 @@
             {
                 if (Zchange > -0.1f)
                 {
+                    if (Zchange > 0.5f)
+                        Zchange = 0.5f;
                     //Requires idea of 'up', so use reference frame to rotate it
                     //Add to the X, because that will normally tilt the vehicle downward (if its rotated, it'll be rotated by the ref. frame
                     grav += (new Vector3 (0, 0, ((float)Math.Abs (Zchange) * (pTimestep * -_pParentScene.PID_D * _pParentScene.PID_D))));


Allow filtering by APFT/ABCP status

Allow filtering by APFT/ABCP status

--- Battery-Commander.Web/Controllers/SoldiersController.cs
+++ Battery-Commander.Web/Controllers/SoldiersController.cs
@@ -22,7 +22,7 @@
             this.db = db;
         }

-        public async Task<IActionResult> Index(int? unit = null)
+        public async Task<IActionResult> Index(int? unit = null, Soldier.EventStatus? abcp = null, Soldier.EventStatus? apft = null)
         {
             // TODO Filtering by Rank, MOS, Position, Name, Status

@@ -33,6 +33,8 @@
                 .Include(_ => _.ABCPs)
                 .Include(_ => _.APFTs)
                 .Where(_ => !unit.HasValue || _.UnitId == unit)
+                .Where(_ => !abcp.HasValue || _.AbcpStatus == abcp)
+                .Where(_ => !apft.HasValue || _.ApftStatus == apft)
                 .ToListAsync();

             return View("List", soldiers);
@@ -147,5 +149,7 @@
                 Value = $"{soldier.Id}"
             });
         }
+
+
     }
 }


Some changes

Some changes

--- ProducerConsumer/Program.cs
+++ ProducerConsumer/Program.cs
@@ -15,7 +15,7 @@
             TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;

             int consumerThreadCount = 1;
-            bool isInterruptImmidiately = false;
+            bool isInterruptImmidiately = true; // Not execute remaining actions when stopping
             int producerThreadCount = 3;

             Console.WriteLine("For interruption produce-consume process press Enter");


Prevent trying to call invalid URLs.

Prevent trying to call invalid URLs.

--- LIC.Malone.Client.Desktop/ViewModels/AppViewModel.cs
+++ LIC.Malone.Client.Desktop/ViewModels/AppViewModel.cs
@@ -26,6 +26,8 @@
 		private IAuthorizationState _authorizationState;
 		private DialogManager _dialogManager = new DialogManager();

+		private static readonly List<string> AllowedSchemes = new List<string> { "http", "https" };
+
 		#region Databound properties

 		private IObservableCollection<Request> _history = new BindableCollection<Request>();
@@ -152,7 +154,11 @@

 		public bool CanSend
 		{
-			get { return !string.IsNullOrWhiteSpace(Url); }
+			get
+			{
+				Uri url;
+				return Uri.TryCreate(Url, UriKind.Absolute, out url) && AllowedSchemes.Contains(url.Scheme);
+			}
 		}

 		#endregion


Reuse date formatter

Reuse date formatter

--- R7.University.Core/Templates/WorkbookToCsvSerializer.cs
+++ R7.University.Core/Templates/WorkbookToCsvSerializer.cs
@@ -15,6 +15,8 @@

         public string EmptyCellValue { get; set; } = "";

+        DataFormatter _formatter = new DataFormatter ();
+
         public StringBuilder Serialize (IWorkbook book, StringBuilder builder)
         {
             for (var s = 0; s < book.NumberOfSheets; s++) {
@@ -28,23 +30,22 @@

         protected void SerializeSheet (ISheet sheet, StringBuilder builder)
         {
-            var formatter = new DataFormatter ();
             for (var r = sheet.FirstRowNum; r <= sheet.LastRowNum; r++) {
                 var row = sheet.GetRow (r);
                 if (row == null) {
                     continue;
                 }
                 foreach (var cell in row.Cells) {
-                    builder.Append (FormatCellValue (cell, formatter));
+                    builder.Append (FormatCellValue (cell));
                     builder.Append (CellSeparator);
                 }
                 builder.AppendLine ();
             }
         }

-        protected virtual string FormatCellValue (ICell cell, DataFormatter formatter)
+        protected virtual string FormatCellValue (ICell cell)
         {
-            var text = formatter.FormatCellValue (cell);
+            var text = _formatter.FormatCellValue (cell);

             if (!string.IsNullOrWhiteSpace (text)) {
                 text = text.Replace ("\r\n", " ");


Added more code-behind for regression testing

--- RelhaxModpack/RelhaxModpack/Windows/PatchTester.xaml.cs
+++ RelhaxModpack/RelhaxModpack/Windows/PatchTester.xaml.cs
@@ -704,6 +704,10 @@
             {
                 RightSideTabControl.SelectedItem = LogOutputTab;
             }
+            Logging.Info("Regex regressions start");
+            Regression regression = new Regression(RegressionTypes.regex, BuildRegexUnittests());
+            regression.RunRegressions();
+            Logging.Info("Regex regressions end");
         }

         private void XmlRegressionTesting_Click(object sender, RoutedEventArgs e)
@@ -712,6 +716,10 @@
             {
                 RightSideTabControl.SelectedItem = LogOutputTab;
             }
+            Logging.Info("Xml regressions start");
+            Regression regression = new Regression(RegressionTypes.xml, BuildRegexUnittests());
+            regression.RunRegressions();
+            Logging.Info("Xml regressions end");
         }

         private void JsonRegressionTesting_Click(object sender, RoutedEventArgs e)
@@ -720,6 +728,40 @@
             {
                 RightSideTabControl.SelectedItem = LogOutputTab;
             }
+            Logging.Info("Json regressions start");
+            Regression regression = new Regression(RegressionTypes.json, BuildRegexUnittests());
+            regression.RunRegressions();
+            Logging.Info("Json regressions end");
+        }
+        #endregion
+
+        #region json regressions
+        private List<UnitTest> BuildJsonUnittests()
+        {
+            return new List<UnitTest>()
+            {
+
+            };
+        }
+        #endregion
+
+        #region xml regressions
+        private List<UnitTest> BuildXmlUnittests()
+        {
+            return new List<UnitTest>()
+            {
+
+            };
+        }
+        #endregion
+
+        #region regex regressions
+        private List<UnitTest> BuildRegexUnittests()
+        {
+            return new List<UnitTest>()
+            {
+
+            };
         }
         #endregion
     }


Nori in C#: Ensure that closing the form window occurs on the UI Thread.

--- Libraries/Nori/native/csharp-app/source/NoriFrame.cs
+++ Libraries/Nori/native/csharp-app/source/NoriFrame.cs
@@ -1,3 +1,4 @@
+using System;
 using System.Collections.Generic;
 using System.Linq;

@@ -160,9 +161,21 @@
             }
         }

+        private delegate int UiThreadInvoker();
+
+        private void InvokeMethodOnUiThread(Func<int> fn)
+        {
+            UiThreadInvoker invoker = () => { return fn(); };
+            this.form.Invoke(invoker);
+        }
+
         internal void Close()
         {
-            this.form.Close();
+            this.InvokeMethodOnUiThread(() =>
+            {
+                this.form.Close();
+                return 1;
+            });
         }

         private string GetHtmlDocument(string initialUiData)


Added RestParticleDistance to make particle of fluid sample fall

--- Branch/PhysX.Net-3.2/Samples/FluidSample/FluidSample.cs
+++ Branch/PhysX.Net-3.2/Samples/FluidSample/FluidSample.cs
@@ -30,6 +30,8 @@

 			// Create the particle fluid
 			var particleFluid = scene.Physics.CreateParticleFluid(d * d * d);
+
+			particleFluid.RestParticleDistance *= 10.5f;

 			//


Use SequenceEqual instead of equal operator for whirlpool digest

--- RuneScapeCacheTools/Cache/RuneTek5/RuneTek5CacheFile.cs
+++ RuneScapeCacheTools/Cache/RuneTek5/RuneTek5CacheFile.cs
@@ -157,7 +157,7 @@
                 var calculatedWhirlpool = new byte[whirlpool.GetDigestSize()];
                 whirlpool.DoFinal(calculatedWhirlpool, 0);

-                if (calculatedWhirlpool != file.Info.WhirlpoolDigest)
+                if (!calculatedWhirlpool.SequenceEqual(file.Info.WhirlpoolDigest))
                 {
                     throw new CacheException("Calculated whirlpool digest did not match expected.");
                 }


Plant checkout description improvement

Plant checkout description improvement

--- RussellGroup.Pims.Website/Controllers/HireController.cs
+++ RussellGroup.Pims.Website/Controllers/HireController.cs
@@ -53,9 +53,8 @@
                     (f.StatusId == Status.Unknown || f.StatusId == Status.Available))
                 .Take(5)
                 .OrderBy(f => f.XPlantId)
-                // can't use f.XPlantIds here because LINQ to Entities won't accept it
-                .Select(f => new { id = f.Id, description = f.Description, xid = f.XPlantId + "/" + f.XPlantNewId })
-                .ToArray();
+                .ToArray()
+                .Select(f => new { id = f.Id, description = f.Description, xid = f.XPlantIdAndXPlantNewId });

             var json = Json(result, JsonRequestBehavior.AllowGet);


Added PkIsIdentity property for Insert and Update methods. Allows insert and update for POCO objects which have an auto-incrementing id field defined in the Db and exposed on the POCO class

--- Massive.cs
+++ Massive.cs
@@ -146,10 +146,12 @@
             return dm;
         }
         public DynamicModel(string connectionStringName, string tableName = "",
-            string primaryKeyField = "", string descriptorField = "") {
+            string primaryKeyField = "", string descriptorField = "", bool pkIsIdentityColumn = true)
+        {
             TableName = tableName == "" ? this.GetType().Name : tableName;
             PrimaryKeyField = string.IsNullOrEmpty(primaryKeyField) ? "ID" : primaryKeyField;
             DescriptorField = descriptorField;
+            PkIsIdentityColumn = pkIsIdentityColumn;
             var _providerName = "System.Data.SqlClient";

             if (!string.IsNullOrWhiteSpace(ConfigurationManager.ConnectionStrings[connectionStringName].ProviderName))
@@ -313,6 +315,7 @@
             o.ToDictionary().TryGetValue(PrimaryKeyField, out result);
             return result;
         }
+        public virtual bool PkIsIdentityColumn { get; set; }
         public virtual string TableName { get; set; }
         /// <summary>
         /// Returns all records complying with the passed-in WHERE clause and arguments,
@@ -413,6 +416,10 @@
             var stub = "INSERT INTO {0} ({1}) \r\n VALUES ({2})";
             result = CreateCommand(stub, null);
             int counter = 0;
+            if (PkIsIdentityColumn)
+            {
+                settings.Remove(PrimaryKeyField);
+            }
             foreach (var item in settings) {
                 sbKeys.AppendFormat("{0},", item.Key);
                 sbVals.AppendFormat("@{0},", counter.ToString());
@@ -437,6 +444,10 @@
             var args = new List<object>();
             var result = CreateCommand(stub, null);
             int counter = 0;
+            if (PkIsIdentityColumn)
+            {
+                settings.Remove(PrimaryKeyField);
+            }
             foreach (var item in settings) {
                 var val = item.Value;
                 if (!item.Key.Equals(PrimaryKeyField, StringComparison.OrdinalIgnoreCase) && item.Value != null) {
@@ -488,8 +499,14 @@
                     var cmd = CreateInsertCommand(ex);
                     cmd.Connection = conn;
                     cmd.ExecuteNonQuery();
-                    cmd.CommandText = "SELECT @@IDENTITY as newID";
-                    ex.ID = cmd.ExecuteScalar();
+                    if (PkIsIdentityColumn)
+                    {
+                        cmd.CommandText = "SELECT @@IDENTITY as newID";
+                        // Work with expando as dictionary:
+                        var d = ex as IDictionary<string, object>;
+                        // Set the new identity/PK:
+                        d[PrimaryKeyField] = (int)cmd.ExecuteScalar();
+                    }
                     Inserted(ex);
                 }
                 return ex;


Added async methods (thanks to Damien Edwards) and Rails ActiveRecord style querying

--- Massive.cs
+++ Massive.cs
@@ -1,364 +1,416 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Configuration;
-using System.Data;
-using System.Data.Common;
-using System.Dynamic;
-using System.Linq;
-using System.Text;
-
-namespace Massive {
-    public static class ObjectExtensions {
-        /// <summary>
-        /// Extension method for adding in a bunch of parameters
-        /// </summary>
-        public static void AddParams(this DbCommand cmd, params object[] args) {
-            foreach (var item in args) {
-                AddParam(cmd, item);
-            }
-        }
-        /// <summary>
-        /// Extension for adding single parameter
-        /// </summary>
-        public static void AddParam(this DbCommand cmd, object item) {
-            var p = cmd.CreateParameter();
-            p.ParameterName = string.Format("@{0}", cmd.Parameters.Count);
-            if (item == null) {
-                p.Value = DBNull.Value;
-            } else {
-                if (item.GetType() == typeof(Guid)) {
-                    p.Value = item.ToString();
-                    p.DbType = DbType.String;
-                    p.Size = 4000;
-                } else if (item.GetType() == typeof(ExpandoObject)) {
-                    var d = (IDictionary<string, object>)item;
-                    p.Value = d.Values.FirstOrDefault();
-                } else {
-                    p.Value = item;
-                }
-                if (item.GetType() == typeof(string))
-                    p.Size = ((string)item).Length > 4000 ? -1 : 4000;
-            }
-            cmd.Parameters.Add(p);
-        }
-        /// <summary>
-        /// Turns an IDataReader to a Dynamic list of things
-        /// </summary>
-        public static List<dynamic> ToExpandoList(this IDataReader rdr) {
-            var result = new List<dynamic>();
-            while (rdr.Read()) {
-                result.Add(rdr.RecordToExpando());
-            }
-            return result;
-        }
-        public static dynamic RecordToExpando(this IDataReader rdr) {
-            dynamic e = new ExpandoObject();
-            var d = e as IDictionary<string, object>;
+using System;
+using System.Collections.Generic;
+using System.Collections.Specialized;
+using System.Configuration;
+using System.Data;
+using System.Data.Common;
+using System.Dynamic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Data.SqlClient;
+
+namespace Massive {
+    public static class ObjectExtensions {
+        /// <summary>
+        /// Extension method for adding in a bunch of parameters
+        /// </summary>
+        public static void AddParams(this DbCommand cmd, params object[] args) {
+            foreach (var item in args) {
+                AddParam(cmd, item);
+            }
+        }
+        /// <summary>
+        /// Extension for adding single parameter
+        /// </summary>
+        public static void AddParam(this DbCommand cmd, object item) {
+            var p = cmd.CreateParameter();
+            p.ParameterName = string.Format("@{0}", cmd.Parameters.Count);
+            if (item == null) {
+                p.Value = DBNull.Value;
+            } else {
+                if (item.GetType() == typeof(Guid)) {
+                    p.Value = item.ToString();
+                    p.DbType = DbType.String;
+                    p.Size = 4000;
+                } else if (item.GetType() == typeof(ExpandoObject)) {
+                    var d = (IDictionary<string, object>)item;
+                    p.Value = d.Values.FirstOrDefault();
+                } else {
+                    p.Value = item;
+                }
+                if (item.GetType() == typeof(string))
+                    p.Size = ((string)item).Length > 4000 ? -1 : 4000;
+            }
+            cmd.Parameters.Add(p);
+        }
+        /// <summary>
+        /// Turns an IDataReader to a Dynamic list of things
+        /// </summary>
+        public static List<dynamic> ToExpandoList(this IDataReader rdr) {
+            var result = new List<dynamic>();
+            while (rdr.Read()) {
+                result.Add(rdr.RecordToExpando());
+            }
+            return result;
+        }
+        public static dynamic RecordToExpando(this IDataReader rdr) {
+            dynamic e = new ExpandoObject();
+            var d = e as IDictionary<string, object>;
             for (int i = 0; i < rdr.FieldCount; i++)
-                d.Add(rdr.GetName(i), DBNull.Value.Equals(rdr[i]) ? null : rdr[i]);
-            return e;
-        }
-        /// <summary>
-        /// Turns the object into an ExpandoObject
-        /// </summary>
-        public static dynamic ToExpando(this object o) {
-            var result = new ExpandoObject();
-            var d = result as IDictionary<string, object>; //work with the Expando as a Dictionary
-            if (o.GetType() == typeof(ExpandoObject)) return o; //shouldn't have to... but just in case
-            if (o.GetType() == typeof(NameValueCollection) || o.GetType().IsSubclassOf(typeof(NameValueCollection))) {
-                var nv = (NameValueCollection)o;
-                nv.Cast<string>().Select(key => new KeyValuePair<string, object>(key, nv[key])).ToList().ForEach(i => d.Add(i));
-            } else {
-                var props = o.GetType().GetProperties();
-                foreach (var item in props) {
-                    d.Add(item.Name, item.GetValue(o, null));
-                }
-            }
-            return result;
-        }
-        /// <summary>
-        /// Turns the object into a Dictionary
-        /// </summary>
-        public static IDictionary<string, object> ToDictionary(this object thingy) {
-            return (IDictionary<string, object>)thingy.ToExpando();
-        }
-    }
-    /// <summary>
-    /// A class that wraps your database table in Dynamic Funtime
-    /// </summary>
-    public class DynamicModel {
-        DbProviderFactory _factory;
-        string _connectionString;
-
-        public DynamicModel(string connectionStringName = "", string tableName = "", string primaryKeyField = "") {
-            TableName = tableName == "" ? this.GetType().Name : tableName;
-            PrimaryKeyField = string.IsNullOrEmpty(primaryKeyField) ? "ID" : primaryKeyField;
-            if (connectionStringName == "")
-                connectionStringName = ConfigurationManager.ConnectionStrings[0].Name;
-            var _providerName = "System.Data.SqlClient";
-            if (ConfigurationManager.ConnectionStrings[connectionStringName] != null) {
-                if (!string.IsNullOrEmpty(ConfigurationManager.ConnectionStrings[connectionStringName].ProviderName))
-                    _providerName = ConfigurationManager.ConnectionStrings[connectionStringName].ProviderName;
-            } else {
-                throw new InvalidOperationException("Can't find a connection string with the name '" + connectionStringName + "'");
-            }
-            _factory = DbProviderFactories.GetFactory(_providerName);
-            _connectionString = ConfigurationManager.ConnectionStrings[connectionStringName].ConnectionString;
-        }
-        /// <summary>
-        /// Enumerates the reader yielding the result - thanks to Jeroen Haegebaert
-        /// </summary>
-        public virtual IEnumerable<dynamic> Query(string sql, params object[] args) {
-            using (var conn = OpenConnection()) {
-                var rdr = CreateCommand(sql, conn, args).ExecuteReader();
-                while (rdr.Read()) {
-                    yield return rdr.RecordToExpando(); ;
-                }
-            }
-        }
-        public virtual IEnumerable<dynamic> Query(string sql, DbConnection connection, params object[] args) {
-            using (var rdr = CreateCommand(sql, connection, args).ExecuteReader()) {
-                while (rdr.Read()) {
-                    yield return rdr.RecordToExpando(); ;
-                }
-            }
-
-        }
-        /// <summary>
-        /// Returns a single result
-        /// </summary>
-        public virtual object Scalar(string sql, params object[] args) {
-            object result = null;
-            using (var conn = OpenConnection()) {
-                result = CreateCommand(sql, conn, args).ExecuteScalar();
-            }
-            return result;
-        }
-        /// <summary>
-        /// Creates a DBCommand that you can use for loving your database.
-        /// </summary>
-        DbCommand CreateCommand(string sql, DbConnection conn, params object[] args) {
-            var result = _factory.CreateCommand();
-            result.Connection = conn;
-            result.CommandText = sql;
-            if (args.Length > 0)
-                result.AddParams(args);
-            return result;
-        }
-        /// <summary>
-        /// Returns and OpenConnection
-        /// </summary>
-        public virtual DbConnection OpenConnection() {
-            var result = _factory.CreateConnection();
-            result.ConnectionString = _connectionString;
-            result.Open();
-            return result;
-        }
-        /// <summary>
-        /// Builds a set of Insert and Update commands based on the passed-on objects.
-        /// These objects can be POCOs, Anonymous, NameValueCollections, or Expandos. Objects
-        /// With a PK property (whatever PrimaryKeyField is set to) will be created at UPDATEs
-        /// </summary>
-        public virtual List<DbCommand> BuildCommands(params object[] things) {
-            var commands = new List<DbCommand>();
-            foreach (var item in things) {
-                if (HasPrimaryKey(item)) {
-                    commands.Add(CreateUpdateCommand(item, GetPrimaryKey(item)));
-                } else {
-                    commands.Add(CreateInsertCommand(item));
-                }
-            }
-
-            return commands;
-        }
-        /// <summary>
-        /// Executes a set of objects as Insert or Update commands based on their property settings, within a transaction.
-        /// These objects can be POCOs, Anonymous, NameValueCollections, or Expandos. Objects
-        /// With a PK property (whatever PrimaryKeyField is set to) will be created at UPDATEs
-        /// </summary>
-        public virtual int Save(params object[] things) {
-            var commands = BuildCommands(things);
-            return Execute(commands);
-        }
-        public virtual int Execute(DbCommand command) {
-            return Execute(new DbCommand[] { command });
-        }
-        /// <summary>
-        /// Executes a series of DBCommands in a transaction
-        /// </summary>
-        public virtual int Execute(IEnumerable<DbCommand> commands) {
-            var result = 0;
-            using (var conn = OpenConnection()) {
-                using (var tx = conn.BeginTransaction()) {
-                    foreach (var cmd in commands) {
-                        cmd.Connection = conn;
-                        cmd.Transaction = tx;
-                        result += cmd.ExecuteNonQuery();
-                    }
-                    tx.Commit();
-                }
-            }
-            return result;
-        }
-        public virtual string PrimaryKeyField { get; set; }
-        /// <summary>
-        /// Conventionally introspects the object passed in for a field that
-        /// looks like a PK. If you've named your PrimaryKeyField, this becomes easy
-        /// </summary>
-        public virtual bool HasPrimaryKey(object o) {
-            return o.ToDictionary().ContainsKey(PrimaryKeyField);
-        }
-        /// <summary>
-        /// If the object passed in has a property with the same name as your PrimaryKeyField
-        /// it is returned here.
-        /// </summary>
-        public virtual object GetPrimaryKey(object o) {
-            object result = null;
-            o.ToDictionary().TryGetValue(PrimaryKeyField, out result);
-            return result;
-        }
-        public virtual string TableName { get; set; }
-        /// <summary>
-        /// Creates a command for use with transactions - internal stuff mostly, but here for you to play with
-        /// </summary>
-        public virtual DbCommand CreateInsertCommand(object o) {
-            DbCommand result = null;
-            var expando = o.ToExpando();
-            var settings = (IDictionary<string, object>)expando;
-            var sbKeys = new StringBuilder();
-            var sbVals = new StringBuilder();
-            var stub = "INSERT INTO {0} ({1}) \r\n VALUES ({2})";
-            result = CreateCommand(stub, null);
-            int counter = 0;
-            foreach (var item in settings) {
-                sbKeys.AppendFormat("{0},", item.Key);
-                sbVals.AppendFormat("@{0},", counter.ToString());
-                result.AddParam(item.Value);
-                counter++;
-            }
-            if (counter > 0) {
-                var keys = sbKeys.ToString().Substring(0, sbKeys.Length - 1);
-                var vals = sbVals.ToString().Substring(0, sbVals.Length - 1);
-                var sql = string.Format(stub, TableName, keys, vals);
-                result.CommandText = sql;
-            } else throw new InvalidOperationException("Can't parse this object to the database - there are no properties set");
-            return result;
-        }
-        /// <summary>
-        /// Creates a command for use with transactions - internal stuff mostly, but here for you to play with
-        /// </summary>
-        public virtual DbCommand CreateUpdateCommand(object o, object key) {
-            var expando = o.ToExpando();
-            var settings = (IDictionary<string, object>)expando;
-            var sbKeys = new StringBuilder();
-            var stub = "UPDATE {0} SET {1} WHERE {2} = @{3}";
-            var args = new List<object>();
-            var result = CreateCommand(stub, null);
-            int counter = 0;
-            foreach (var item in settings) {
-                var val = item.Value;
-                if (!item.Key.Equals(PrimaryKeyField, StringComparison.CurrentCultureIgnoreCase) && item.Value != null) {
-                    result.AddParam(val);
-                    sbKeys.AppendFormat("{0} = @{1}, \r\n", item.Key, counter.ToString());
-                    counter++;
-                }
-            }
-            if (counter > 0) {
-                //add the key
-                result.AddParam(key);
-                //strip the last commas
-                var keys = sbKeys.ToString().Substring(0, sbKeys.Length - 4);
-                result.CommandText = string.Format(stub, TableName, keys, PrimaryKeyField, counter);
-            } else throw new InvalidOperationException("No parsable object was sent in - could not divine any name/value pairs");
-            return result;
-        }
-        /// <summary>
-        /// Removes one or more records from the DB according to the passed-in WHERE
-        /// </summary>
-        public virtual DbCommand CreateDeleteCommand(string where = "", object key = null, params object[] args) {
-            var sql = string.Format("DELETE FROM {0} ", TableName);
-            if (key != null) {
-                sql += string.Format("WHERE {0}=@0", PrimaryKeyField);
-                args = new object[] { key };
-            } else if (!string.IsNullOrEmpty(where)) {
-                sql += where.Trim().StartsWith("where", StringComparison.CurrentCultureIgnoreCase) ? where : "WHERE " + where;
-            }
-            return CreateCommand(sql, null, args);
-        }
-        /// <summary>
-        /// Adds a record to the database. You can pass in an Anonymous object, an ExpandoObject,
-        /// A regular old POCO, or a NameValueColletion from a Request.Form or Request.QueryString
-        /// </summary>
-        public virtual object Insert(object o) {
-            dynamic result = 0;
-            using (var conn = OpenConnection()) {
-                var cmd = CreateInsertCommand(o);
-                cmd.Connection = conn;
-                cmd.ExecuteNonQuery();
-                cmd.CommandText = "SELECT @@IDENTITY as newID";
-                result = cmd.ExecuteScalar();
-            }
-            return result;
-        }
-        /// <summary>
-        /// Updates a record in the database. You can pass in an Anonymous object, an ExpandoObject,
-        /// A regular old POCO, or a NameValueCollection from a Request.Form or Request.QueryString
-        /// </summary>
-        public virtual int Update(object o, object key) {
-            return Execute(CreateUpdateCommand(o, key));
-        }
-        /// <summary>
-        /// Removes one or more records from the DB according to the passed-in WHERE
-        /// </summary>
-        public int Delete(object key = null, string where = "", params object[] args) {
-            return Execute(CreateDeleteCommand(where: where, key: key, args: args));
-        }
-        /// <summary>
-        /// Returns all records complying with the passed-in WHERE clause and arguments,
-        /// ordered as specified, limited (TOP) by limit.
-        /// </summary>
-        public virtual IEnumerable<dynamic> All(string where = "", string orderBy = "", int limit = 0, string columns = "*", params object[] args) {
-            string sql = limit > 0 ? "SELECT TOP " + limit + " {0} FROM {1} " : "SELECT {0} FROM {1} ";
-            if (!string.IsNullOrEmpty(where))
-                sql += where.Trim().StartsWith("where", StringComparison.CurrentCultureIgnoreCase) ? where : "WHERE " + where;
-            if (!String.IsNullOrEmpty(orderBy))
-                sql += orderBy.Trim().StartsWith("order by", StringComparison.CurrentCultureIgnoreCase) ? orderBy : " ORDER BY " + orderBy;
-            return Query(string.Format(sql, columns, TableName), args);
-        }
-
-        /// <summary>
-        /// Returns a dynamic PagedResult. Result properties are Items, TotalPages, and TotalRecords.
-        /// </summary>
-        public virtual dynamic Paged(string where = "", string orderBy = "", string columns = "*", int pageSize = 20, int currentPage = 1, params object[] args) {
-            dynamic result = new ExpandoObject();
-            var countSQL = string.Format("SELECT COUNT({0}) FROM {1}", PrimaryKeyField, TableName);
-            if (String.IsNullOrEmpty(orderBy))
-                orderBy = PrimaryKeyField;
-
-            if (!string.IsNullOrEmpty(where)) {
-                if (!where.Trim().StartsWith("where", StringComparison.CurrentCultureIgnoreCase)) {
-                    where = "WHERE " + where;
-                }
-            }
-            var sql = string.Format("SELECT {0} FROM (SELECT ROW_NUMBER() OVER (ORDER BY {2}) AS Row, {0} FROM {3} {4}) AS Paged ", columns, pageSize, orderBy, TableName, where);
-            var pageStart = (currentPage - 1) * pageSize;
-            sql += string.Format(" WHERE Row > {0} AND Row <={1}", pageStart, (pageStart + pageSize));
-            countSQL += where;
-            result.TotalRecords = Scalar(countSQL, args);
-            result.TotalPages = result.TotalRecords / pageSize;
-            if (result.TotalRecords % pageSize > 0)
-                result.TotalPages += 1;
-            result.Items = Query(string.Format(sql, columns, TableName), args);
-            return result;
-        }
-        /// <summary>
-        /// Returns a single row from the database
-        /// </summary>
-        public virtual dynamic Single(object key, string columns = "*") {
-            var sql = string.Format("SELECT {0} FROM {1} WHERE {2} = @0", columns, TableName, PrimaryKeyField);
-            var items = Query(sql, key).ToList();
-            return items.FirstOrDefault();
-        }
-    }
+                d.Add(rdr.GetName(i), DBNull.Value.Equals(rdr[i]) ? null : rdr[i]);
+            return e;
+        }
+        /// <summary>
+        /// Turns the object into an ExpandoObject
+        /// </summary>
+        public static dynamic ToExpando(this object o) {
+            var result = new ExpandoObject();
+            var d = result as IDictionary<string, object>; //work with the Expando as a Dictionary
+            if (o.GetType() == typeof(ExpandoObject)) return o; //shouldn't have to... but just in case
+            if (o.GetType() == typeof(NameValueCollection) || o.GetType().IsSubclassOf(typeof(NameValueCollection))) {
+                var nv = (NameValueCollection)o;
+                nv.Cast<string>().Select(key => new KeyValuePair<string, object>(key, nv[key])).ToList().ForEach(i => d.Add(i));
+            } else {
+                var props = o.GetType().GetProperties();
+                foreach (var item in props) {
+                    d.Add(item.Name, item.GetValue(o, null));
+                }
+            }
+            return result;
+        }
+        /// <summary>
+        /// Turns the object into a Dictionary
+        /// </summary>
+        public static IDictionary<string, object> ToDictionary(this object thingy) {
+            return (IDictionary<string, object>)thingy.ToExpando();
+        }
+    }
+    /// <summary>
+    /// A class that wraps your database table in Dynamic Funtime
+    /// </summary>
+    public class DynamicModel:DynamicObject {
+        DbProviderFactory _factory;
+        string _connectionString;
+
+        public DynamicModel(string connectionStringName = "", string tableName = "", string primaryKeyField = "") {
+            TableName = tableName == "" ? this.GetType().Name : tableName;
+            PrimaryKeyField = string.IsNullOrEmpty(primaryKeyField) ? "ID" : primaryKeyField;
+            if (connectionStringName == "")
+                connectionStringName = ConfigurationManager.ConnectionStrings[0].Name;
+            var _providerName = "System.Data.SqlClient";
+            if (ConfigurationManager.ConnectionStrings[connectionStringName] != null) {
+                if (!string.IsNullOrEmpty(ConfigurationManager.ConnectionStrings[connectionStringName].ProviderName))
+                    _providerName = ConfigurationManager.ConnectionStrings[connectionStringName].ProviderName;
+            } else {
+                throw new InvalidOperationException("Can't find a connection string with the name '" + connectionStringName + "'");
+            }
+            _factory = DbProviderFactories.GetFactory(_providerName);
+            _connectionString = ConfigurationManager.ConnectionStrings[connectionStringName].ConnectionString;
+        }
+        /// <summary>
+        /// Enumerates the reader yielding the result - thanks to Jeroen Haegebaert
+        /// </summary>
+        public virtual IEnumerable<dynamic> Query(string sql, params object[] args) {
+            using (var conn = OpenConnection()) {
+                var rdr = CreateCommand(sql, conn, args).ExecuteReader();
+                while (rdr.Read()) {
+                    yield return rdr.RecordToExpando(); ;
+                }
+            }
+        }
+        /// <summary>
+        /// Enumerates the reader yielding the result - thanks to Jeroen Haegebaert
+        /// </summary>
+        public void QueryAsync(string sql, Action<List<dynamic>> callback, params object[] args) {
+            using (var conn = OpenConnection()) {
+                var cmd = new SqlCommand(sql,new SqlConnection(_connectionString));
+                cmd.AddParams(args);
+                cmd.Connection.Open();
+                var task = Task.Factory.FromAsync<IDataReader>(cmd.BeginExecuteReader, cmd.EndExecuteReader, null);
+                task.ContinueWith(x => callback.Invoke(x.Result.ToExpandoList()));
+            }
+        }
+
+
+        public virtual IEnumerable<dynamic> Query(string sql, DbConnection connection, params object[] args) {
+            using (var rdr = CreateCommand(sql, connection, args).ExecuteReader()) {
+                while (rdr.Read()) {
+                    yield return rdr.RecordToExpando(); ;
+                }
+            }
+
+        }
+        /// <summary>
+        /// Returns a single result
+        /// </summary>
+        public virtual object Scalar(string sql, params object[] args) {
+            object result = null;
+            using (var conn = OpenConnection()) {
+                result = CreateCommand(sql, conn, args).ExecuteScalar();
+            }
+            return result;
+        }
+        /// <summary>
+        /// Creates a DBCommand that you can use for loving your database.
+        /// </summary>
+        DbCommand CreateCommand(string sql, DbConnection conn, params object[] args) {
+            var result = _factory.CreateCommand();
+            result.Connection = conn;
+            result.CommandText = sql;
+            if (args.Length > 0)
+                result.AddParams(args);
+            return result;
+        }
+        /// <summary>
+        /// Returns and OpenConnection
+        /// </summary>
+        public virtual DbConnection OpenConnection() {
+            var result = _factory.CreateConnection();
+            result.ConnectionString = _connectionString;
+            result.Open();
+            return result;
+        }
+        /// <summary>
+        /// Builds a set of Insert and Update commands based on the passed-on objects.
+        /// These objects can be POCOs, Anonymous, NameValueCollections, or Expandos. Objects
+        /// With a PK property (whatever PrimaryKeyField is set to) will be created at UPDATEs
+        /// </summary>
+        public virtual List<DbCommand> BuildCommands(params object[] things) {
+            var commands = new List<DbCommand>();
+            foreach (var item in things) {
+                if (HasPrimaryKey(item)) {
+                    commands.Add(CreateUpdateCommand(item, GetPrimaryKey(item)));
+                } else {
+                    commands.Add(CreateInsertCommand(item));
+                }
+            }
+
+            return commands;
+        }
+        /// <summary>
+        /// Executes a set of objects as Insert or Update commands based on their property settings, within a transaction.
+        /// These objects can be POCOs, Anonymous, NameValueCollections, or Expandos. Objects
+        /// With a PK property (whatever PrimaryKeyField is set to) will be created at UPDATEs
+        /// </summary>
+        public virtual int Save(params object[] things) {
+            var commands = BuildCommands(things);
+            return Execute(commands);
+        }
+        public virtual int Execute(DbCommand command) {
+            return Execute(new DbCommand[] { command });
+        }
+        /// <summary>
+        /// Executes a series of DBCommands in a transaction
+        /// </summary>
+        public virtual int Execute(IEnumerable<DbCommand> commands) {
+            var result = 0;
+            using (var conn = OpenConnection()) {
+                using (var tx = conn.BeginTransaction()) {
+                    foreach (var cmd in commands) {
+                        cmd.Connection = conn;
+                        cmd.Transaction = tx;
+                        result += cmd.ExecuteNonQuery();
+                    }
+                    tx.Commit();
+                }
+            }
+            return result;
+        }
+        public virtual string PrimaryKeyField { get; set; }
+        /// <summary>
+        /// Conventionally introspects the object passed in for a field that
+        /// looks like a PK. If you've named your PrimaryKeyField, this becomes easy
+        /// </summary>
+        public virtual bool HasPrimaryKey(object o) {
+            return o.ToDictionary().ContainsKey(PrimaryKeyField);
+        }
+        /// <summary>
+        /// If the object passed in has a property with the same name as your PrimaryKeyField
+        /// it is returned here.
+        /// </summary>
+        public virtual object GetPrimaryKey(object o) {
+            object result = null;
+            o.ToDictionary().TryGetValue(PrimaryKeyField, out result);
+            return result;
+        }
+        public virtual string TableName { get; set; }
+        /// <summary>
+        /// Creates a command for use with transactions - internal stuff mostly, but here for you to play with
+        /// </summary>
+        public virtual DbCommand CreateInsertCommand(object o) {
+            DbCommand result = null;
+            var expando = o.ToExpando();
+            var settings = (IDictionary<string, object>)expando;
+            var sbKeys = new StringBuilder();
+            var sbVals = new StringBuilder();
+            var stub = "INSERT INTO {0} ({1}) \r\n VALUES ({2})";
+            result = CreateCommand(stub, null);
+            int counter = 0;
+            foreach (var item in settings) {
+                sbKeys.AppendFormat("{0},", item.Key);
+                sbVals.AppendFormat("@{0},", counter.ToString());
+                result.AddParam(item.Value);
+                counter++;
+            }
+            if (counter > 0) {
+                var keys = sbKeys.ToString().Substring(0, sbKeys.Length - 1);
+                var vals = sbVals.ToString().Substring(0, sbVals.Length - 1);
+                var sql = string.Format(stub, TableName, keys, vals);
+                result.CommandText = sql;
+            } else throw new InvalidOperationException("Can't parse this object to the database - there are no properties set");
+            return result;
+        }
+        /// <summary>
+        /// Creates a command for use with transactions - internal stuff mostly, but here for you to play with
+        /// </summary>
+        public virtual DbCommand CreateUpdateCommand(object o, object key) {
+            var expando = o.ToExpando();
+            var settings = (IDictionary<string, object>)expando;
+            var sbKeys = new StringBuilder();
+            var stub = "UPDATE {0} SET {1} WHERE {2} = @{3}";
+            var args = new List<object>();
+            var result = CreateCommand(stub, null);
+            int counter = 0;
+            foreach (var item in settings) {
+                var val = item.Value;
+                if (!item.Key.Equals(PrimaryKeyField, StringComparison.CurrentCultureIgnoreCase) && item.Value != null) {
+                    result.AddParam(val);
+                    sbKeys.AppendFormat("{0} = @{1}, \r\n", item.Key, counter.ToString());
+                    counter++;
+                }
+            }
+            if (counter > 0) {
+                //add the key
+                result.AddParam(key);
+                //strip the last commas
+                var keys = sbKeys.ToString().Substring(0, sbKeys.Length - 4);
+                result.CommandText = string.Format(stub, TableName, keys, PrimaryKeyField, counter);
+            } else throw new InvalidOperationException("No parsable object was sent in - could not divine any name/value pairs");
+            return result;
+        }
+        /// <summary>
+        /// Removes one or more records from the DB according to the passed-in WHERE
+        /// </summary>
+        public virtual DbCommand CreateDeleteCommand(string where = "", object key = null, params object[] args) {
+            var sql = string.Format("DELETE FROM {0} ", TableName);
+            if (key != null) {
+                sql += string.Format("WHERE {0}=@0", PrimaryKeyField);
+                args = new object[] { key };
+            } else if (!string.IsNullOrEmpty(where)) {
+                sql += where.Trim().StartsWith("where", StringComparison.CurrentCultureIgnoreCase) ? where : "WHERE " + where;
+            }
+            return CreateCommand(sql, null, args);
+        }
+        /// <summary>
+        /// Adds a record to the database. You can pass in an Anonymous object, an ExpandoObject,
+        /// A regular old POCO, or a NameValueColletion from a Request.Form or Request.QueryString
+        /// </summary>
+        public virtual object Insert(object o) {
+            dynamic result = 0;
+            using (var conn = OpenConnection()) {
+                var cmd = CreateInsertCommand(o);
+                cmd.Connection = conn;
+                cmd.ExecuteNonQuery();
+                cmd.CommandText = "SELECT @@IDENTITY as newID";
+                result = cmd.ExecuteScalar();
+            }
+            return result;
+        }
+        /// <summary>
+        /// Updates a record in the database. You can pass in an Anonymous object, an ExpandoObject,
+        /// A regular old POCO, or a NameValueCollection from a Request.Form or Request.QueryString
+        /// </summary>
+        public virtual int Update(object o, object key) {
+            return Execute(CreateUpdateCommand(o, key));
+        }
+        /// <summary>
+        /// Removes one or more records from the DB according to the passed-in WHERE
+        /// </summary>
+        public int Delete(object key = null, string where = "", params object[] args) {
+            return Execute(CreateDeleteCommand(where: where, key: key, args: args));
+        }
+
+
+        /// <summary>
+        /// Returns all records complying with the passed-in WHERE clause and arguments,
+        /// ordered as specified, limited (TOP) by limit.
+        /// </summary>
+        public virtual IEnumerable<dynamic> All(string where = "", string orderBy = "", int limit = 0, string columns = "*", params object[] args) {
+            string sql = BuildSelect(where, orderBy, limit);
+            return Query(string.Format(sql, columns, TableName), args);
+        }
+
+        private static string BuildSelect(string where, string orderBy, int limit) {
+            string sql = limit > 0 ? "SELECT TOP " + limit + " {0} FROM {1} " : "SELECT {0} FROM {1} ";
+            if (!string.IsNullOrEmpty(where))
+                sql += where.Trim().StartsWith("where", StringComparison.CurrentCultureIgnoreCase) ? where : "WHERE " + where;
+            if (!String.IsNullOrEmpty(orderBy))
+                sql += orderBy.Trim().StartsWith("order by", StringComparison.CurrentCultureIgnoreCase) ? orderBy : " ORDER BY " + orderBy;
+            return sql;
+        }
+        /// <summary>
+        /// Returns all records complying with the passed-in WHERE clause and arguments,
+        /// ordered as specified, limited (TOP) by limit.
+        /// </summary>
+        public virtual void AllAsync(Action<List<dynamic>> callback,string where = "", string orderBy = "", int limit = 0, string columns = "*", params object[] args) {
+            string sql = BuildSelect(where, orderBy, limit);
+            QueryAsync(string.Format(sql, columns, TableName),callback, args);
+        }
+        /// <summary>
+        /// Returns a dynamic PagedResult. Result properties are Items, TotalPages, and TotalRecords.
+        /// </summary>
+        public virtual dynamic Paged(string where = "", string orderBy = "", string columns = "*", int pageSize = 20, int currentPage = 1, params object[] args) {
+            dynamic result = new ExpandoObject();
+            var countSQL = string.Format("SELECT COUNT({0}) FROM {1}", PrimaryKeyField, TableName);
+            if (String.IsNullOrEmpty(orderBy))
+                orderBy = PrimaryKeyField;
+
+            if (!string.IsNullOrEmpty(where)) {
+                if (!where.Trim().StartsWith("where", StringComparison.CurrentCultureIgnoreCase)) {
+                    where = "WHERE " + where;
+                }
+            }
+            var sql = string.Format("SELECT {0} FROM (SELECT ROW_NUMBER() OVER (ORDER BY {2}) AS Row, {0} FROM {3} {4}) AS Paged ", columns, pageSize, orderBy, TableName, where);
+            var pageStart = (currentPage - 1) * pageSize;
+            sql += string.Format(" WHERE Row > {0} AND Row <={1}", pageStart, (pageStart + pageSize));
+            countSQL += where;
+            result.TotalRecords = Scalar(countSQL, args);
+            result.TotalPages = result.TotalRecords / pageSize;
+            if (result.TotalRecords % pageSize > 0)
+                result.TotalPages += 1;
+            result.Items = Query(string.Format(sql, columns, TableName), args);
+            return result;
+        }
+        /// <summary>
+        /// Returns a single row from the database
+        /// </summary>
+        public virtual dynamic Single(object key, string columns = "*") {
+            var sql = string.Format("SELECT {0} FROM {1} WHERE {2} = @0", columns, TableName, PrimaryKeyField);
+            var items = Query(sql, key).ToList();
+            return items.FirstOrDefault();
+        }
+
+        /// <summary>
+        /// A little Rails-y love for ya
+        /// </summary>
+        public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result) {
+            //parse the method
+            var stems = binder.Name.Split('_');
+            var sb = new List<string>();
+
+            //first should be "FindBy or whatever"
+            var op = stems[0];
+            var counter = 0;
+            for (int i = 1; i < stems.Length; i++) {
+                if (stems[i].Trim().ToLower() != "and") {
+                    sb.Add(stems[i] + "=@" + counter);
+                    counter++;
+                }
+            }
+            var sql = "SELECT * FROM " + TableName + " WHERE " + string.Join(" AND ", sb.ToArray());
+            result = Query(sql, args);
+            return true;
+        }
+    }
 }


Visit lite ToStr in EntityCompleter to avoid exceptions when non- expressionToString is used (like AdditionalBinding in an Embedded entity)

--- Signum.Engine/Linq/ExpressionVisitor/EntityCompleter.cs
+++ Signum.Engine/Linq/ExpressionVisitor/EntityCompleter.cs
@@ -42,8 +42,9 @@

             var typeId = binder.GetEntityType(lite.Reference);
             var toStr = LiteToString(lite, typeId);
-
-            return new LiteValueExpression(lite.Type, typeId, id, toStr);
+            var toStr2 = Visit(toStr); //AdditionalBinding in embedded
+
+            return new LiteValueExpression(lite.Type, typeId, id, toStr2);
         }

         private Expression? LiteToString(LiteReferenceExpression lite, Expression typeId)


workaround exception for CLI called with redirected output (#3613)

--- Source/LinqToDB.CLI/CommandLine/Commands/HelpCommand.cs
+++ Source/LinqToDB.CLI/CommandLine/Commands/HelpCommand.cs
@@ -186,6 +186,14 @@

 		private void WriteOptionHelp(CliCommand command, int maxOptionNameWidth, string indent, OptionCategory? category, CliOption option)
 		{
+			// workaround for https://github.com/linq2db/linq2db/issues/3612
+			var consoleWidth = 80;
+			try
+			{
+				consoleWidth = Console.BufferWidth;
+			}
+			catch { };
+
 			Console.Out.WriteLine();
 			Console.Out.Write("   ");

@@ -315,7 +323,7 @@
 				{
 					var line = lines[i];

-					var lineWidth            = Console.BufferWidth - indent.Length - 1;
+					var lineWidth            = consoleWidth - indent.Length - 1;
 					var incompleteLineLength = line.Length % lineWidth;
 					var partsCount           = line.Length / lineWidth + (incompleteLineLength > 0 ? 1 : 0);


Remove UpdateIndexHelper

Remove UpdateIndexHelper

Not necessary, we'll cast the fetched index to IUpdateIndex when needed.

--- Source/Solution/FormEditor/Storage/UpdateIndexHelper.cs
+++ Source/Solution/FormEditor/Storage/UpdateIndexHelper.cs
@@ -1,31 +0,0 @@
-using System;
-using System.Configuration;
-
-namespace FormEditor.Storage
-{
-	public class UpdateIndexHelper
-	{
-		public static IUpdateIndex GetIndex(int contentId)
-		{
-			if (Configuration.Instance.IndexType != null)
-			{
-				// Ninject, go home :-)
-				try
-				{
-					var index = Activator.CreateInstance(Configuration.Instance.IndexType, contentId) as IUpdateIndex;
-					if (index == null)
-					{
-						throw new ConfigurationErrorsException(string.Format("Activator was unable to instantiate the custom Index type \"{0}\"", Configuration.Instance.IndexType.AssemblyQualifiedName));
-					}
-					return index;
-				}
-				catch (Exception ex)
-				{
-					Log.Error(ex, "Could not create an instance of the custom Index type");
-				}
-			}
-			// revert to default index
-			return new Index(contentId);
-		}
-	}
-}


fixed up CommandReferencesConverter for runtime.

--- Src/Library/Source/Design/CommandReferencesConverter.cs
+++ Src/Library/Source/Design/CommandReferencesConverter.cs
@@ -21,10 +21,16 @@
             var references = baseResult as Collection<CommandReference>;
             if (references != null)
             {
-                var settings = (ICommandSettings)context.Instance;
+                // Assign commandSettings (design-time only)
+                if (context != null && context.Instance != null)
+                {
+                    var settings = (ICommandSettings)context.Instance;

-                var values = (Collection<CommandReference>)baseResult;
-                return values.Select(val => new CommandReference(settings) { CommandId = val.CommandId });
+                    var values = (Collection<CommandReference>)baseResult;
+                    return values.Select(val => new CommandReference(settings) { CommandId = val.CommandId });
+                }
+
+                return references;
             }

             return baseResult;


Fix the fully qualified type name of GitVersionInformation

The solution has been described in GitTools/GitVersion#1546 and resolves #17.

--- ThScoreFileConverter/ViewModels/AboutWindowViewModel.cs
+++ ThScoreFileConverter/ViewModels/AboutWindowViewModel.cs
@@ -41,7 +41,7 @@

             var thisAsm = Assembly.GetExecutingAssembly();
             var asmName = thisAsm.GetName();
-            var gitVerInfoType = thisAsm.GetType(asmName.Name + ".GitVersionInformation");
+            var gitVerInfoType = thisAsm.GetType("GitVersionInformation");
             var verField = gitVerInfoType.GetField("MajorMinorPatch");
             var attrs = thisAsm.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), true);


Add unit test

Add unit test

--- UnitTestUsefullFunctions/UnitTestFunctionsMathPrimes.cs
+++ UnitTestUsefullFunctions/UnitTestFunctionsMathPrimes.cs
@@ -688,6 +688,15 @@
         public void TestMethod_IsPrime_257()
         {
             const int source = 257;
+            const bool expected = true;
+            bool result = FunctionsMath.IsPrime(source);
+            Assert.AreEqual(result, expected);
+        }
+
+        [TestMethod]
+        public void TestMethod_IsPrime_263()
+        {
+            const int source = 263;
             const bool expected = true;
             bool result = FunctionsMath.IsPrime(source);
             Assert.AreEqual(result, expected);


Better collision detection

Better collision detection

--- Client/Harmony/DestructibleBuilding_OnCollisionEnter.cs
+++ Client/Harmony/DestructibleBuilding_OnCollisionEnter.cs
@@ -24,6 +24,9 @@
             var crashingVessel = c.gameObject.GetComponentUpwards<Part>()?.vessel;
             if (crashingVessel != null)
             {
+                if (crashingVessel.rootPart != null)
+                    return float.IsPositiveInfinity(crashingVessel.rootPart.crashTolerance);
+
                 if (!LockSystem.LockQuery.UpdateLockExists(crashingVessel.id)) return true;
                 return LockSystem.LockQuery.UpdateLockBelongsToPlayer(crashingVessel.id, SettingsSystem.CurrentSettings.PlayerName);
             }


Add unit tests

Add unit tests

--- UnitTestUsefullFunctions/UnitTestNumberOfOccurrences.cs
+++ UnitTestUsefullFunctions/UnitTestNumberOfOccurrences.cs
@@ -106,5 +106,24 @@
       Assert.AreEqual(result, expected);
     }

+    [TestMethod]
+    public void TestMethod_NumberOfOccurrences_ar_2()
+    {
+      const string source1 = "ar";
+      const string source2 = "a long long time ago in a galaxy far far away";
+      const int expected = 2;
+      int result = StringFunc.NumberOfOccurrences(source1, source2);
+      Assert.AreEqual(result, expected);
+    }
+
+    [TestMethod]
+    public void TestMethod_NumberOfOccurrences_a_9()
+    {
+      const string source1 = "a";
+      const string source2 = "a long long time ago in a galaxy far far away";
+      const int expected = 9;
+      int result = StringFunc.NumberOfOccurrences(source1, source2);
+      Assert.AreEqual(result, expected);
+    }
   }
 }


- Microoptimization in EntityManager.GetComponent()

--- Unity/Assets/GameFramework/Modules/ECS/EntityManager.cs
+++ Unity/Assets/GameFramework/Modules/ECS/EntityManager.cs
@@ -482,9 +482,10 @@
             if (EntityExists(entity)) {
                 List<IComponent> components = _entities[entity];
                 int _componentsCount = components.Count;
+                Type t = typeof(T);
                 for(int i=0; i< _componentsCount; ++i){
                     IComponent comp = components[i];
-                    if (comp.GetType() == typeof(T)) {
+                    if (comp.GetType() == t) {
                         return (T)comp;
                     }
                 }
@@ -498,11 +499,12 @@
                 List<IComponent> components = _entities[entity];

                 int _componentsCount = components.Count;
+                Type t = typeof(T);
                 for (int i = 0; i < _componentsCount; ++i) {

                     IComponent comp = components[i];
                     // ~3 ms
-                    if (comp.GetType() == typeof(T)) {
+                    if (comp.GetType() == t) {
                         return (T)comp;
                     }

@@ -597,9 +599,10 @@
                 IComponent c = null;//
                 List<IComponent> components = _entities[entity];
                 int _componentsCount = components.Count;
+                Type t = typeof(T);
                 for (int i=0; i<_componentsCount; ++i){
                     IComponent comp = components[i];
-                    if (comp.GetType() == typeof(T)) {
+                    if (comp.GetType() == t) {
                         c = (T)comp;
                         break;
                     }


interoperability bug - 1874

interoperability bug - 1874

Former-commit-id: 62cbea5f7d20183a7a03c153e7bbb6abb973f077

--- MeTLMeeting/MeTLLib/DataTypes/ConversationDetails.cs
+++ MeTLMeeting/MeTLLib/DataTypes/ConversationDetails.cs
@@ -232,10 +232,10 @@

         public bool UserHasPermission(Credentials credentials)
         {
-            if (!(credentials.authorizedGroups.Select(g => g.groupKey).Contains(Subject))
-                && Subject != "Unrestricted"
+            if (!(credentials.authorizedGroups.Select(g => g.groupKey.ToLower()).Contains(Subject.ToLower()))
+                && Subject.ToLower() != "Unrestricted".ToLower()
                 && !(String.IsNullOrEmpty(Subject))
-                && !(credentials.authorizedGroups.Select(su => su.groupKey).Contains("Superuser"))) return false;
+                && !(credentials.authorizedGroups.Select(su => su.groupKey.ToLower()).Contains("Superuser".ToLower()))) return false;
             return true;
         }
         public override bool Equals(object obj)


SubtitlesRepo and SubtitlesModel added, HomeController Modified

--- 3viknaSolutions/3vikna/Views/Home/Index.cshtml
+++ 3viknaSolutions/3vikna/Views/Home/Index.cshtml
@@ -1,4 +1,5 @@
-@{
+@model IEnumerable<_3vikna.Models.Subtitles>
+@{
     ViewBag.Title = "Home Page";
 }

@@ -69,9 +70,13 @@

Getting started

-                ASP.NET MVC gives you a powerful, patterns-based way to build dynamic websites that
-                enables a clean separation of concerns and gives you full control over markup
-                for enjoyable, agile development.
+

+                    @foreach (var item in Model)
+                    {
+
@item.MediaName

+                    }
+

+

Learn more »


infoGraphic: added maxBoxLength background

--- ARKBreedingStats/library/CreatureExtensions.cs
+++ ARKBreedingStats/library/CreatureExtensions.cs
@@ -53,6 +53,7 @@
                 int xLevelValue = xStatName + 30 + (creature.levelsWild[2].ToString().Length) * 7;
                 int xRightBrValue = xLevelValue + 14 + MaxBreedingValueLength(creature.valuesBreeding) * 7;
                 int maxBoxLength = xRightBrValue - xStatName;
+                const int statBoxHeight = 2;
                 g.DrawString("Levels", font, fontBrush, xLevelValue, currentYPosition, stringFormatRight);
                 g.DrawString("Values", font, fontBrush, xRightBrValue, currentYPosition, stringFormatRight);
                 int statDisplayIndex = 0;
@@ -63,12 +64,15 @@
                         continue;

                     int y = currentYPosition + 20 + (statDisplayIndex++) * 15;
+
                     // box
+                    // empty box to show the max possible length
+                    using (var b = new SolidBrush(Color.DarkGray))
+                        g.FillRectangle(b, xStatName, y + 14, maxBoxLength, statBoxHeight);
                     double levelFractionOfMax = Math.Min(1, (double)creature.levelsWild[statIndex] / maxGraphLevel);
                     if (levelFractionOfMax < 0) levelFractionOfMax = 0;
                     int levelPercentageOfMax = (int)(100 * levelFractionOfMax);
                     int statBoxLength = Math.Max((int)(maxBoxLength * levelFractionOfMax), 1);
-                    const int statBoxHeight = 2;
                     var statColor = Utils.GetColorFromPercent(levelPercentageOfMax);
                     using (var b = new SolidBrush(statColor))
                         g.FillRectangle(b, xStatName, y + 14, statBoxLength, statBoxHeight);


Added tests for cookie persistence

Added tests for cookie persistence

--- AlexaCore.Tests/Content/ContentServiceTests.cs
+++ AlexaCore.Tests/Content/ContentServiceTests.cs
@@ -1,5 +1,6 @@
 using System;
 using System.Collections.Generic;
+using System.Linq;
 using System.Net.Http;
 using Alexa.NET.Request;
 using AlexaCore.Content;
@@ -14,25 +15,81 @@
         [Test]
         public void WhenContentIsRequested_ValidTextIsReturned()
         {
-            var queue = new PersistentQueue<ApplicationParameter>(null,
-                new Session {Attributes = new Dictionary<string, object>()}, "key");
+            var queue = BuildQueue();
+
+            var responseText = "Welcome to the house of fun";

             var contentService = new TestContentService(queue, "userId",
-                new MockHttpClient(new HttpResponseMessage
-                {
-                    Content = new StringContent(
-                        JsonConvert.SerializeObject(new IntentContent
-                        {
-                            Content = "Welcome to the house of fun"
-                        }))
-                }));
+                new MockHttpClient(BuildResponseMessage(responseText)));

             var result = contentService.LoadAndFormatContent("HelpIntent", "default text");

-            Console.WriteLine(result);
+            Assert.That(result, Is.EqualTo(responseText));
+        }

-            //todo - need some tests around cookies and persistance
-            //todo - need to actually test it working
+        [Test]
+        public void WhenContentIsRequested_CookiesGetPersistedInQueue()
+        {
+            var queue = BuildQueue();
+
+            var aspNetSessionid = "ASP.NET_SessionId";
+
+            var cookieValue = "123";
+
+            var contentService = new TestContentService(queue, "userId",
+                new MockHttpClient(BuildResponseMessage("text",
+                    new[] {new CookieValue {Key = aspNetSessionid, Value = cookieValue}})));
+
+            contentService.LoadAndFormatContent("HelpIntent", "default text");
+
+            VerifyQueueContainsCookie(queue, aspNetSessionid, cookieValue);
+
+            contentService = new TestContentService(queue, "userId",
+                new MockHttpClient(BuildResponseMessage("text")));
+
+            contentService.LoadAndFormatContent("HelpIntent", "default text");
+
+            VerifyQueueContainsCookie(queue, aspNetSessionid, cookieValue);
+        }
+
+        private void VerifyQueueContainsCookie(PersistentQueue<ApplicationParameter> queue, string cookieName, string cookieValue)
+        {
+            var cookieEntry = queue.GetValue("__cookies");
+
+            Assert.That(cookieEntry, Is.Not.Null);
+
+            var cookieValues = JsonConvert.DeserializeObject<CookieValue[]>(cookieEntry);
+
+            var matchingCookie = cookieValues.FirstOrDefault(a => a.Key == cookieName);
+
+            Assert.That(matchingCookie, Is.Not.Null);
+
+            Assert.That(matchingCookie.Value, Is.EqualTo(cookieValue));
+        }
+
+        private static HttpResponseMessage BuildResponseMessage(string responseText, CookieValue[] cookies = null)
+        {
+            var responseMessage = new HttpResponseMessage
+            {
+                Content = new StringContent(
+                    JsonConvert.SerializeObject(new IntentContent
+                    {
+                        Content = responseText
+                    })),
+            };
+
+            if (cookies != null)
+            {
+                responseMessage.Headers.Add("set-cookie", String.Join(";", cookies.Select(a => a.ToString())));
+            }
+
+            return responseMessage;
+        }
+
+        private static PersistentQueue<ApplicationParameter> BuildQueue()
+        {
+            return new PersistentQueue<ApplicationParameter>(null,
+                new Session {Attributes = new Dictionary<string, object>()}, "key");
         }
     }
 }


Increase timeout to prevent random test fails.

--- repomonitor-core/src/test/ProcessExecutorTest.cs
+++ repomonitor-core/src/test/ProcessExecutorTest.cs
@@ -11,6 +11,11 @@
   /// </summary>
   [TestFixture]
   public class ProcessExecutorTest {
+    /// <summary>
+    /// Default timeout for tests is 3 seconds.
+    /// </summary>
+    const int DEFAULT_TIMEOUT = 3;
+
     /// <summary>
     /// Configures the <see cref="ProcessExecutor"/> mock.
     /// </summary>
@@ -58,7 +63,7 @@
       ProcessExecutor pe = new ProcessExecutor();
       ProcessExecutor.Result result = pe.Execute(TestUtil.EchoerPath,
           String.Format("-exit {0}", expected),
-          null, null, TimeSpan.FromSeconds(1));
+          null, null, TimeSpan.FromSeconds(DEFAULT_TIMEOUT));

       int actual = result.ExitCode;

@@ -75,7 +80,7 @@
       ProcessExecutor pe = new ProcessExecutor();
       ProcessExecutor.Result result = pe.Execute(TestUtil.EchoerPath,
           String.Format("-out \"{0}\"", expected),
-          null, null, TimeSpan.FromSeconds(1));
+          null, null, TimeSpan.FromSeconds(DEFAULT_TIMEOUT));

       String actual = result.StdOut;

@@ -92,7 +97,7 @@
       ProcessExecutor pe = new ProcessExecutor();
       ProcessExecutor.Result result = pe.Execute(TestUtil.EchoerPath,
           String.Format("-err \"{0}\"", expected),
-          null, null, TimeSpan.FromSeconds(1));
+          null, null, TimeSpan.FromSeconds(DEFAULT_TIMEOUT));

       String actual = result.StdErr;

@@ -113,7 +118,7 @@
       ProcessExecutor pe = new ProcessExecutor();
       ProcessExecutor.Result result = pe.Execute(TestUtil.EchoerPath,
           String.Format("-env {0}", expectedName),
-          null, expectedVars, TimeSpan.FromSeconds(1));
+          null, expectedVars, TimeSpan.FromSeconds(DEFAULT_TIMEOUT));

       String actual = result.StdOut;

@@ -138,7 +143,7 @@
       String invalidPath = TestUtil.EchoerPath + "-not";

       new ProcessExecutor().Execute(invalidPath, "-out Ouch!",
-          null, null, TimeSpan.FromSeconds(1));
+          null, null, TimeSpan.FromSeconds(DEFAULT_TIMEOUT));
     }

     /// <summary>
@@ -150,7 +155,7 @@
       String invalidPath = String.Format("{0}.exe", Path.GetRandomFileName());

       new ProcessExecutor().Execute(invalidPath, "-out Ouch!",
-          null, null, TimeSpan.FromSeconds(1));
+          null, null, TimeSpan.FromSeconds(DEFAULT_TIMEOUT));
     }

     /// <summary>
@@ -159,7 +164,7 @@
     [Test, ExpectedException(typeof(FileNotFoundException))]
     public void StaticExecAlsoWorks() {
       ProcessExecutor.Exec(TestUtil.EchoerPath + "-not", "-out Ouch!",
-          null, null, TimeSpan.FromSeconds(1));
+          null, null, TimeSpan.FromSeconds(DEFAULT_TIMEOUT));
     }
   }
 }


Removed public modifier and implemented canvas IDL

--- AngleSharp/DOM/Html/Media/HTMLCanvasElement.cs
+++ AngleSharp/DOM/Html/Media/HTMLCanvasElement.cs
@@ -5,8 +5,7 @@
     /// <summary>
     /// Represents the HTML canvas element.
     /// </summary>
-    [DomName("HTMLCanvasElement")]
-    public sealed class HTMLCanvasElement : HTMLElement
+    sealed class HTMLCanvasElement : HTMLElement, IHtmlCanvasElement
     {
         #region ctor

@@ -32,7 +31,6 @@
         /// </summary>
         /// <param name="contextId">A context id like 2d.</param>
         /// <returns>An object that defines the drawing context.</returns>
-        [DomName("getContext")]
         public RenderingContext GetContext(String contextId)
         {
             //TODO
@@ -44,7 +42,6 @@
         /// </summary>
         /// <param name="contextId">A context id like 2d.</param>
         /// <returns>True if the context is supported, otherwise false.</returns>
-        [DomName("supportsContext")]
         public Boolean SupportsContext(String contextId)
         {
             //TODO
@@ -55,7 +52,6 @@
         /// Changes the context the element is related to the given one.
         /// </summary>
         /// <param name="context">The new context.</param>
-        [DomName("setContext")]
         public void SetContext(RenderingContext context)
         {
             //TODO
@@ -66,7 +62,6 @@
         /// </summary>
         /// <param name="type">The type of image e.g image/png.</param>
         /// <returns>A data URI with the data if any.</returns>
-        [DomName("toDataURL")]
         public String ToDataURL(String type = null)
         {
             //TODO
@@ -79,7 +74,6 @@
         /// </summary>
         /// <param name="callback">The callback function.</param>
         /// <param name="type">The type of object to create.</param>
-        [DomName("toBlob")]
         public void ToBlob(Action<Object> callback, String type = null)
         {
             //TODO
@@ -92,21 +86,19 @@
         /// <summary>
         /// Gets or sets the displayed width of the canvas element.
         /// </summary>
-        [DomName("width")]
         public UInt32 Width
         {
-            get { return ToInteger(GetAttribute("width"), 300u); }
-            set { SetAttribute("width", value.ToString()); }
+            get { return ToInteger(GetAttribute(AttributeNames.Width), 300u); }
+            set { SetAttribute(AttributeNames.Width, value.ToString()); }
         }

         /// <summary>
         /// Gets or sets the displayed height of the canvas element.
         /// </summary>
-        [DomName("height")]
         public UInt32 Height
         {
-            get { return ToInteger(GetAttribute("height"), 150u); }
-            set { SetAttribute("height", value.ToString()); }
+            get { return ToInteger(GetAttribute(AttributeNames.Height), 150u); }
+            set { SetAttribute(AttributeNames.Height, value.ToString()); }
         }

         #endregion


Release of version 1.0

Release of version 1.0

--- ModMyFactory/ModMyFactory/Properties/AssemblyInfo.cs
+++ ModMyFactory/ModMyFactory/Properties/AssemblyInfo.cs
@@ -8,11 +8,11 @@
 // Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
 // die einer Assembly zugeordnet sind.
 [assembly: AssemblyTitle("ModMyFactory")]
-[assembly: AssemblyDescription("")]
+[assembly: AssemblyDescription("Factorio mod manager")]
 [assembly: AssemblyConfiguration("")]
 [assembly: AssemblyCompany("")]
 [assembly: AssemblyProduct("ModMyFactory")]
-[assembly: AssemblyCopyright("Copyright ©  2016")]
+[assembly: AssemblyCopyright("Copyright © 2016 Mathis Rech")]
 [assembly: AssemblyTrademark("")]
 [assembly: AssemblyCulture("")]

@@ -53,3 +53,5 @@
 // [assembly: AssemblyVersion("1.0.*")]
 [assembly: AssemblyVersion("1.0.0.0")]
 [assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: NeutralResourcesLanguage("en")]
+


Revert "Move private functions to end"

Revert "Move private functions to end"

This reverts commit 58a88ff5b0488265de3ade69b0996c7b5792ebf3.

--- ArithmeticTester/Controllers/ArithmeticTest.cs
+++ ArithmeticTester/Controllers/ArithmeticTest.cs
@@ -103,6 +103,17 @@
         }

         /// <summary>
+        /// Picks a new value for the factors for the next question.
+        /// </summary>
+        private void SetNextFactors()
+        {
+            factor2 = (byte)rd.Next(Arithmetic.minFactorValue, Arithmetic.maxFactorValue);
+
+            factor1 = (byte)rd.Next(Arithmetic.minFactorValue, Arithmetic.maxFactorValue);
+            if (arithmeticOperator == ArithmeticOperator.Divide) factor1 = (byte)Arithmetic.Multiply(factor2, factor1);
+        }
+
+        /// <summary>
         /// Public accessor method for the correct answer to the current question.
         /// </summary>
         /// <returns>Integer - the real answer.</returns>
@@ -112,6 +123,31 @@
         }

         /// <summary>
+        /// Returns the results of the arithmetic operation defined by the current factors and operator.
+        /// </summary>
+        /// <returns>Integer - the result of the arithmetic operation.</returns>
+        private void SetRealAnswer()
+        {
+            switch (arithmeticOperator)
+            {
+                case ArithmeticOperator.Add:
+                    realAnswer = Arithmetic.Add(factor1, factor2);
+                    break;
+                case ArithmeticOperator.Divide:
+                    realAnswer = Arithmetic.Divide(factor1, factor2);
+                    break;
+                case ArithmeticOperator.Multiply:
+                    realAnswer = Arithmetic.Multiply(factor1, factor2);
+                    break;
+                case ArithmeticOperator.Subtract:
+                    realAnswer = Arithmetic.Subtract(factor1, factor2);
+                    break;
+                default:
+                    throw new ArithmeticException(Properties.Resources.UnknownOperatorException);
+            }
+        }
+
+        /// <summary>
         /// Get count of correct answers.
         /// </summary>
         /// <returns>Byte - the number of correct answers.</returns>
@@ -155,6 +191,22 @@
         }

         /// <summary>
+        /// Increment count of guesses for current question.
+        /// </summary>
+        public void IncrementGuessCount()
+        {
+            guess++;
+        }
+
+        /// <summary>
+        /// Reset count of guesses for current question back to zero.
+        /// </summary>
+        private void ResetGuessCount()
+        {
+            guess = 0;
+        }
+
+        /// <summary>
         /// Get count of number of questions asked.
         /// </summary>
         /// <returns>Byte - the number of questions asked.</returns>
@@ -164,31 +216,6 @@
         }

         /// <summary>
-        /// Increment count of guesses for current question.
-        /// </summary>
-        public void IncrementGuessCount()
-        {
-            guess++;
-        }
-
-        /// <summary>
-        /// Reset count of guesses for current question back to zero.
-        /// </summary>
-        private void ResetGuessCount()
-        {
-            guess = 0;
-        }
-
-        /// <summary>
-        /// Get count of number of questions asked.
-        /// </summary>
-        /// <returns>Byte - the number of questions asked.</returns>
-        public byte GetQuestionCount()
-        {
-            return qcount;
-        }
-
-        /// <summary>
         /// Increment count of number of questions asked.
         /// </summary>
         private void IncrementQuestionCount()


Explicitly checking for admin access in page init

--- Modules/Geta.SEO.Sitemaps/AdminManageSitemap.aspx.cs
+++ Modules/Geta.SEO.Sitemaps/AdminManageSitemap.aspx.cs
@@ -42,6 +42,8 @@
         {
             base.OnInit(e);

+            if (!PrincipalInfo.HasAdminAccess) AccessDenied();
+
             if (!IsPostBack)
             {
                 BindList();


Fix blacklist

Fix blacklist

--- Assembly-CSharp.Mod.mm/src/YLMAPI/ModLoader.cs
+++ Assembly-CSharp.Mod.mm/src/YLMAPI/ModLoader.cs
@@ -30,8 +30,6 @@
         public static string ModsCacheDirectory;
         public static string ModsBlacklistFile;

-        private static List<string> _ModsBlacklist = new List<string>();
-
         public static void LoadMods() {
             Directory.CreateDirectory(ModsDirectory = Path.Combine(ModAPI.GameDirectory, "Mods"));
             Directory.CreateDirectory(ModsCacheDirectory = Path.Combine(ModsDirectory, "Cache"));
@@ -39,8 +37,9 @@

             ModLogger.Log("loader", "Loading game mods");

+            List<string> blacklist = new List<string>();
             if (File.Exists(ModsBlacklistFile)) {
-                _ModsBlacklist = File.ReadAllLines(ModsBlacklistFile).Select(l => (l.StartsWith("#") ? "" : l).Trim()).ToList();
+                blacklist = File.ReadAllLines(ModsBlacklistFile).Select(l => (l.StartsWith("#") ? "" : l).Trim()).ToList();
             } else
                 using (StreamWriter writer = File.CreateText(ModsBlacklistFile)) {
                     writer.WriteLine("# This is a blacklist file. Lines starting with # are ignored.");
@@ -51,14 +50,14 @@
             string[] files = Directory.GetFiles(ModsDirectory);
             for (int i = 0; i < files.Length; i++) {
                 string file = Path.GetFileName(files[i]);
-                if (!file.EndsWith(".zip"))
+                if (!file.EndsWith(".zip") || blacklist.Contains(file))
                     continue;
                 LoadModZIP(file);
             }
             files = Directory.GetDirectories(ModsDirectory);
             for (int i = 0; i < files.Length; i++) {
                 string file = Path.GetFileName(files[i]);
-                if (file == "Cache")
+                if (file == "Cache" || blacklist.Contains(file))
                     continue;
                 LoadModDir(file);
             }


Update ProviderABRASF201.cs

Update ProviderABRASF201.cs

--- src/ACBr.Net.NFSe/Providers/ProviderABRASF201.cs
+++ src/ACBr.Net.NFSe/Providers/ProviderABRASF201.cs
@@ -130,7 +130,10 @@
             var indPrestador = new XElement("IdentificacaoPrestador");
             prestador.AddChild(indPrestador);

-            indPrestador.AddChild(AdicionarTagCNPJCPF("", "Cpf", "Cnpj", nota.Prestador.CpfCnpj));
+            var cpfCNPJ = new XElement("CpfCnpj");
+            indPrestador.AddChild(cpfCNPJ);
+
+            cpfCNPJ.AddChild(AdicionarTagCNPJCPF("", "Cpf", "Cnpj", nota.Prestador.CpfCnpj));
             indPrestador.AddChild(AdicionarTag(TipoCampo.Str, "", "InscricaoMunicipal", 1, 15, Ocorrencia.NaoObrigatoria, nota.Prestador.InscricaoMunicipal));

             var endereco = new XElement("Endereco");
@@ -216,4 +219,4 @@

         #endregion Services
     }
-}+}