(RPM): moved archive index interpreter logic to separate class.

--- ArcFormats/RPM/ArcARC.cs
+++ ArcFormats/RPM/ArcARC.cs
@@ -92,7 +92,9 @@
             uint is_compressed = file.View.ReadUInt32 (4);
             if (is_compressed > 1) // should be either 0 or 1
                 return null;
-            var scheme = GuessScheme (file, count);
+
+            var index_reader = new ArcIndexReader (file, count, is_compressed != 0);
+            var scheme = index_reader.GuessScheme (8, new int[] { 0x20, 0x18 });
             // additional filename extension check avoids dialog popup on false positives
             if (null == scheme && KnownSchemes.Count > 0 && file.Name.HasExtension (".arc"))
                 scheme = QueryScheme();
@@ -104,35 +106,9 @@
                 && VFS.IsPathEqualsToFileName (file.Name, "instdata.arc"))
                 scheme = new EncryptionScheme ("inst", scheme.NameLength);

-            int index_size = count * (scheme.NameLength + 12);
-            var index = new byte[index_size];
-            if (index_size != file.View.Read (8, index, 0, (uint)index_size))
-                return null;
-            DecryptIndex (index, scheme.Keyword);
-
-            uint data_offset = LittleEndian.ToUInt32 (index, scheme.NameLength + 8);
-            if (data_offset != 8 + index_size)
-                return null;
-
-            int index_offset = 0;
-            var dir = new List<Entry> (count);
-            for (int i = 0; i < count; ++i)
-            {
-                var name = Binary.GetCString (index, index_offset, scheme.NameLength);
-                index_offset += scheme.NameLength;
-                var entry = FormatCatalog.Instance.Create<PackedEntry> (name);
-                entry.UnpackedSize  = LittleEndian.ToUInt32 (index, index_offset);
-                entry.Size          = LittleEndian.ToUInt32 (index, index_offset+4);
-                entry.Offset        = LittleEndian.ToUInt32 (index, index_offset+8);
-                entry.IsPacked      = is_compressed != 0;
-                if (0 != entry.Size)
-                {
-                    if (entry.Offset < data_offset || !entry.CheckPlacement (file.MaxOffset))
-                        return null;
-                }
-                dir.Add (entry);
-                index_offset += 12;
-            }
+            var dir = index_reader.ReadIndex (8, scheme);
+            if (null == dir)
+                return null;
             return new ArcFile (file, this, dir);
         }

@@ -147,18 +123,98 @@
             return new LzssStream (input);
         }

-        EncryptionScheme GuessScheme (ArcView file, int count)
-        {
-            int[] possible_sizes = { 0x20, 0x18 };
-            byte[] first_entry = new byte[possible_sizes[0] + 12];
-            if (first_entry.Length != file.View.Read (8, first_entry, 0, (uint)first_entry.Length))
+        public override ResourceOptions GetDefaultOptions ()
+        {
+            return new RpmOptions {
+                Scheme = GetScheme (Settings.Default.RPMScheme),
+            };
+        }
+
+        public override object GetAccessWidget ()
+        {
+            return new WidgetARC();
+        }
+
+        EncryptionScheme QueryScheme ()
+        {
+            var options = Query<RpmOptions> (arcStrings.RPMEncryptedNotice);
+            return options.Scheme;
+        }
+
+        static EncryptionScheme GetScheme (string title)
+        {
+            EncryptionScheme scheme = null;
+            KnownSchemes.TryGetValue (title, out scheme);
+            return scheme;
+        }
+    }
+
+    internal sealed class ArcIndexReader
+    {
+        ArcView             m_file;
+        int                 m_count;
+        bool                m_is_compressed;
+
+        public ArcIndexReader (ArcView file, int count, bool is_compressed)
+        {
+            m_file = file;
+            m_count = count;
+            m_is_compressed = is_compressed;
+        }
+
+        public List<Entry> ReadIndex (long offset, EncryptionScheme scheme)
+        {
+            int index_size = m_count * (scheme.NameLength + 12);
+            var index = m_file.View.ReadBytes (offset, (uint)index_size);
+            if (index.Length != index_size)
+                return null;
+            DecryptIndex (index, scheme.Keyword);
+
+            uint data_offset = LittleEndian.ToUInt32 (index, scheme.NameLength + 8);
+            if (data_offset != offset + index_size)
+                return null;
+
+            int index_offset = 0;
+            var dir = new List<Entry> (m_count);
+            for (int i = 0; i < m_count; ++i)
+            {
+                var name = Binary.GetCString (index, index_offset, scheme.NameLength);
+                index_offset += scheme.NameLength;
+                var entry = FormatCatalog.Instance.Create<PackedEntry> (name);
+                entry.UnpackedSize  = LittleEndian.ToUInt32 (index, index_offset);
+                entry.Size          = LittleEndian.ToUInt32 (index, index_offset+4);
+                entry.Offset        = LittleEndian.ToUInt32 (index, index_offset+8);
+                entry.IsPacked      = m_is_compressed;
+                if (0 != entry.Size)
+                {
+                    if (entry.Offset < data_offset || !entry.CheckPlacement (m_file.MaxOffset))
+                        return null;
+                }
+                dir.Add (entry);
+                index_offset += 12;
+            }
+            return dir;
+        }
+
+        internal static void DecryptIndex (byte[] data, string key)
+        {
+            for (int i = 0; i < data.Length; ++i)
+            {
+                data[i] += (byte)key[i % key.Length];
+            }
+        }
+
+        public EncryptionScheme GuessScheme (int index_offset, int[] possible_name_sizes)
+        {
+            byte[] first_entry = new byte[possible_name_sizes[0] + 12];
+            if (first_entry.Length != m_file.View.Read (index_offset, first_entry, 0, (uint)first_entry.Length))
                 return null;
             byte[] key_bits = new byte[4];
             byte[] actual_offset = new byte[4];
-            foreach (var name_length in possible_sizes)
-            {
-                int first_offset = 8 + count * (name_length + 12);
-                if (first_offset >= file.MaxOffset)
+            foreach (var name_length in possible_name_sizes)
+            {
+                int first_offset = index_offset + m_count * (name_length + 12);
+                if (first_offset >= m_file.MaxOffset)
                     continue;
                 LittleEndian.Pack (first_offset, actual_offset, 0);
                 int i;
@@ -208,38 +264,5 @@
             }
             return -1;
         }
-
-        private void DecryptIndex (byte[] data, string key)
-        {
-            for (int i = 0; i < data.Length; ++i)
-            {
-                data[i] += (byte)key[i % key.Length];
-            }
-        }
-
-        public override ResourceOptions GetDefaultOptions ()
-        {
-            return new RpmOptions {
-                Scheme = GetScheme (Settings.Default.RPMScheme),
-            };
-        }
-
-        public override object GetAccessWidget ()
-        {
-            return new WidgetARC();
-        }
-
-        EncryptionScheme QueryScheme ()
-        {
-            var options = Query<RpmOptions> (arcStrings.RPMEncryptedNotice);
-            return options.Scheme;
-        }
-
-        static EncryptionScheme GetScheme (string title)
-        {
-            EncryptionScheme scheme = null;
-            KnownSchemes.TryGetValue (title, out scheme);
-            return scheme;
-        }
     }
 }


Resolve #1079 -- RemoveAllListeners in ApiEventManager (#1080)

* RemoveAllListeners now properly removes all listeners in ApiEventManager.cs

--- GameServerLib/API/ApiEventManager.cs
+++ GameServerLib/API/ApiEventManager.cs
@@ -77,9 +77,11 @@
         {
             OnHitUnit.RemoveListener(owner);
             OnLaunchAttack.RemoveListener(owner);
+            OnLaunchMissile.RemoveListener(owner);
             OnPreAttack.RemoveListener(owner);
             OnSpellCast.RemoveListener(owner);
             OnSpellChannel.RemoveListener(owner);
+            OnSpellChannelCancel.RemoveListener(owner);
             OnSpellHit.RemoveListener(owner);
             OnSpellPostCast.RemoveListener(owner);
             OnSpellPostChannel.RemoveListener(owner);


Documented Url extensions

Documented Url extensions

--- Geta.EPi.Extensions/UrlExtensions.cs
+++ Geta.EPi.Extensions/UrlExtensions.cs
@@ -6,15 +6,19 @@
 using EPiServer.Web;
 using EPiServer.Web.Routing;

-namespace Geta.EPi.Cms.Extensions
+namespace Geta.EPi.Extensions
 {
+    /// <summary>
+    ///     Url extensions.
+    /// </summary>
     public static class UrlExtensions
     {
         /// <summary>
-        /// Creates external Uri from provided Url. Uses HttpContext if available, othervise uses EPiServer settings' SiteUrl
+        ///     Creates external Uri from provided Url.
+        ///     Uses HttpContext if available, othervise uses EPiServer SiteDefinition SiteUrl.
         /// </summary>
-        /// <param name="url">Url</param>
-        /// <returns>External Uri for Url</returns>
+        /// <param name="url">Url for which to create Uri.</param>
+        /// <returns>External Uri for Url.</returns>
         public static Uri ToExternalUri(this Url url)
         {
             if (url == null)
@@ -36,21 +40,36 @@
             return new Uri(baseUri, url.Uri);
         }

+        /// <summary>
+        ///     Creates Html string of provided Url.
+        /// </summary>
+        /// <param name="url">Url for which to create Html string.</param>
+        /// <returns>Html string with Url if Url is not null. Otherwise returns empty string.</returns>
         public static IHtmlString ToIHtmlString(this Url url)
         {
-            if (url == null)
-            {
-                return MvcHtmlString.Empty;
-            }
-
-            return MvcHtmlString.Create(url.ToString());
+            return url == null
+                ? MvcHtmlString.Empty
+                : MvcHtmlString.Create(url.ToString());
         }

+        /// <summary>
+        /// </summary>
+        /// <param name="url"></param>
+        /// <returns></returns>
         public static string Resolve(this Url url)
         {
             return url.Resolve(null);
         }

+        /// <summary>
+        ///     Returns string representation of URL for provided Url instance and language.
+        /// </summary>
+        /// <param name="url">Url for which to create string URL.</param>
+        /// <param name="language">Language code for which to create URL.</param>
+        /// <returns>
+        ///     String representation of URL. If Url represents EPiServer page it creates Url with provided language otherwise
+        ///     returns string representation of <paramref name="url" />
+        /// </returns>
         public static string Resolve(this Url url, string language)
         {
             if (url == null)
@@ -72,10 +91,10 @@
         {
             if (HttpContext.Current == null)
             {
-                return EPiServer.Configuration.Settings.Instance.SiteUrl;
+                return SiteDefinition.Current.SiteUrl;
             }

             return new Uri(HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority));
         }
     }
-}
+}


Changed refspec update to use wildcard to catch develop branch too

--- GitVersion/BuildServers/GitHelper.cs
+++ GitVersion/BuildServers/GitHelper.cs
@@ -11,7 +11,7 @@
             {
                 var remote = EnsureOnlyOneRemoteIsDefined(repo);

-                FetchMissingMasterRefSpec(repo, remote);
+                AddMissingRefSpecs(repo, remote);

                 Logger.WriteInfo(string.Format("Fetching from remote '{0}' using the following refspecs: {1}.",
                     remote.Name, string.Join(", ", remote.FetchRefSpecs.Select(r => r.Specification))));
@@ -41,18 +41,17 @@
             }
         }

-        static void FetchMissingMasterRefSpec(Repository repo, Remote remote)
+        static void AddMissingRefSpecs(Repository repo, Remote remote)
         {
-            if (remote.FetchRefSpecs.Any(r => r.Source == "refs/heads/master"))
+            if (remote.FetchRefSpecs.Any(r => r.Source == "refs/heads/*"))
                 return;

-            string masterRefSpec = string.Format("+refs/heads/master:refs/remotes/{0}/master", remote.Name);
+            string masterRefSpec = string.Format("+refs/heads/*:refs/remotes/{0}/*", remote.Name);

             Logger.WriteInfo(string.Format("Adding refspec: {0}", masterRefSpec));

             repo.Network.Remotes.Update(remote,
-                r => r.FetchRefSpecs.Add(masterRefSpec),
-                r => r.PushRefSpecs.Add(masterRefSpec));
+                r => r.FetchRefSpecs.Add(masterRefSpec));
         }

         static FetchOptions BuildFetchOptions(string username, string password)


Update TimeLogMapper.cs

Update TimeLogMapper.cs

TimeLogType TLG.C is a required attribute. Currently only the value "1" is defined.

--- ISOv4Plugin/Mappers/TimeLogMapper.cs
+++ ISOv4Plugin/Mappers/TimeLogMapper.cs
@@ -62,6 +62,7 @@
             //ID
             string id = operation.Id.FindIsoId() ?? GenerateId(5);
             isoTimeLog.Filename = id;
+            isoTimeLog.TimeLogType = 1; // TimeLogType TLG.C is a required attribute. Currently only the value "1" is defined.
             ExportIDs(operation.Id, id);

             List<DeviceElementUse> deviceElementUses = operation.GetAllSections();


fix path slash

fix path slash

--- Assets/game/GameUtils.cs
+++ Assets/game/GameUtils.cs
@@ -37,7 +37,7 @@
         CreateDocumentDir("procadia");

         string fileName = AppendTimeStamp("procadia");
-        string fullPath = GetDocumentsDir() + "\\procadia\\" + fileName + ".gif";
+        string fullPath = GetDocumentsDir() + "//procadia//" + fileName + ".gif";
         var file = System.IO.File.Create(fullPath);
         file.Close();


Move GLControl construction into Winform constructor

- Issue MatterHackers/MCCentral#3353
Frequent error on startup - AccessViolationException

--- PlatformWin32/win32/OpenGLSystemWindow.cs
+++ PlatformWin32/win32/OpenGLSystemWindow.cs
@@ -38,6 +38,15 @@

 		public OpenGLSystemWindow()
 		{
+			glControl = new AggGLControl()
+			{
+				Dock = DockStyle.Fill,
+				Location = new Point(0, 0),
+				TabIndex = 0,
+				VSync = false
+			};
+
+			this.Controls.Add(glControl);
 		}

 		private bool doneLoading = false;
@@ -57,19 +66,6 @@
 		protected override void OnLoad(EventArgs e)
 		{
 			id = count++;
-
-			switch (AggSystemWindow.BitDepth)
-			{
-				case 32:
-					glControl = new AggGLControl();
-					glControl.Dock = DockStyle.Fill;
-					break;
-
-				default:
-					throw new NotImplementedException();
-			}
-
-			Controls.Add(glControl);

 			base.OnLoad(e);


Resolved issue #389: The AutofacFilterProvider now caters for additional filters that are registered in the container without metadata.

--- AutofacFilterProvider.cs
+++ AutofacFilterProvider.cs
@@ -114,7 +114,7 @@
             where TFilter : class
         {
             var actionFilters = filterContext.LifetimeScope.Resolve<IEnumerable<Meta<Lazy<TFilter>, FilterMetadata>>>();
-            foreach (var actionFilter in actionFilters)
+            foreach (var actionFilter in actionFilters.Where(a => a.Metadata != null))
             {
                 var metadata = actionFilter.Metadata;
                 if (metadata.ControllerType.IsAssignableFrom(filterContext.ControllerType)
@@ -145,7 +145,7 @@
             where TFilter : class
         {
             var actionFilters = filterContext.LifetimeScope.Resolve<IEnumerable<Meta<Lazy<TFilter>, FilterMetadata>>>();
-            foreach (var actionFilter in actionFilters)
+            foreach (var actionFilter in actionFilters.Where(a => a.Metadata != null))
             {
                 var metadata = actionFilter.Metadata;
                 if (metadata.ControllerType.IsAssignableFrom(filterContext.ControllerType)


remove last bit of csv token-protected export

--- Joinrpg/Models/ApisIndexViewModel.cs
+++ Joinrpg/Models/ApisIndexViewModel.cs
@@ -8,13 +8,12 @@
   {
     public int ProjectId { get; }
     public int RootGroupId { get; }
-    public string CurrentUserToken { get; }

     public ApisIndexViewModel(Project project, int currentUserId)
     {
       ProjectId = project.ProjectId;
       RootGroupId = project.RootGroup.CharacterGroupId;
-      CurrentUserToken = project.ProjectAcls.Single(acl => acl.UserId == currentUserId).Token.ToHexString();
+      project.ProjectAcls.Single(acl => acl.UserId == currentUserId).Token.ToHexString();
     }
   }
 }


Bump dev version to v0.11

Bump dev version to v0.11

--- JustEnoughVi/Properties/AddinInfo.cs
+++ JustEnoughVi/Properties/AddinInfo.cs
@@ -4,7 +4,7 @@
 [assembly: Addin(
     "JustEnoughVi",
     Namespace = "JustEnoughVi",
-    Version = "0.10"
+    Version = "0.11"
 )]

 [assembly: AddinName("Just Enough Vi")]


Introduce method for setting a member's name and value.

This removes a little bit of duplication (textual only, I guess), but paves the way for factoring out an interface for this responsibility.

--- BobTheBuilder/Builder.cs
+++ BobTheBuilder/Builder.cs
@@ -24,17 +24,22 @@
             return true;
         }

+        internal void SetMemberNameAndValue(string name, object value)
+        {
+            _members[name] = value;
+        }
+
         private void ParseMembersFromMethodName(InvokeMemberBinder binder, object[] args)
         {
             var memberName = binder.Name.Replace("With", "");
-            _members[memberName] = args[0];
+            SetMemberNameAndValue(memberName, args[0]);
         }

         private void ParseMembersFromNamedArguments(CallInfo callInfo, object[] args)
         {
             var memberName = callInfo.ArgumentNames.First();
             memberName = memberName.First().ToString().ToUpper() + memberName.Substring(1);
-            _members[memberName] = args[0];
+            SetMemberNameAndValue(memberName, args[0]);
         }

         public T Build()


Fix code against ipapi

Fix code against ipapi

--- LMP.MasterServer/Structure/Server.cs
+++ LMP.MasterServer/Structure/Server.cs
@@ -1,6 +1,7 @@
 using LunaCommon;
 using LunaCommon.Message.Data.MasterServer;
 using LunaCommon.Time;
+using System;
 using System.Linq;
 using System.Net;
 using System.Net.Http;
@@ -104,10 +105,17 @@

         private static async void SetCountryFromEndpoint(ServerInfo server, IPEndPoint externalEndpoint)
         {
-            using (var client = new HttpClient())
+            try
             {
-                var countryCode = await client.GetStringAsync($"https://ipapi.co/{externalEndpoint.Address}/country/");
-                server.Country = countryCode;
+                using (var client = new HttpClient())
+                {
+                    var countryCode = await client.GetStringAsync($"https://ipapi.co/{externalEndpoint.Address}/country/");
+                    server.Country = countryCode;
+                }
+            }
+            catch (Exception)
+            {
+                // ignored
             }
         }


error recording results for grain(IIncomingGrainCallContext.ImplementationMethod )

--- OrleansDashboard/Metrics/GrainProfilerFilter.cs
+++ OrleansDashboard/Metrics/GrainProfilerFilter.cs
@@ -66,11 +66,19 @@
             }
         }

-        private static bool ShouldSkipProfiling(IIncomingGrainCallContext context)
+        private  bool ShouldSkipProfiling(IIncomingGrainCallContext context)
         {
-            return
+            try
+            {
+                return
                 context.Grain.GetType().GetCustomAttribute<NoProfilingAttribute>() != null ||
                 context.ImplementationMethod?.GetCustomAttribute<NoProfilingAttribute>() != null;
+            }
+            catch (Exception ex)
+            {
+                logger.LogError(100003, ex, "error recording results for grain");
+                return false;
+            }
         }
     }
 }


Removed unused usings.

Removed unused usings.

--- PlantUmlEditor/ViewModel/CodeEditorViewModel.cs
+++ PlantUmlEditor/ViewModel/CodeEditorViewModel.cs
@@ -1,7 +1,5 @@
-using System;
-using System.Collections.Generic;
+using System.Collections.Generic;
 using System.ComponentModel;
-using System.Diagnostics;
 using System.Windows;
 using ICSharpCode.AvalonEdit.Document;
 using ICSharpCode.AvalonEdit.Folding;


Fixed missing name for IDictionary objects

--- LiveSplit/LiveSplit.Core/Web/JSON.cs
+++ LiveSplit/LiveSplit.Core/Web/JSON.cs
@@ -166,6 +166,7 @@
                 }
                 else if (value is IDictionary<string, object>)
                 {
+                    sb.Append("\"" + HttpUtility.JavaScriptStringEncode(name) + "\": {\r\n");
                     new DynamicJsonObject((IDictionary<string, object>)value).ToString(sb, depth + 1);
                 }
                 else if (value is IEnumerable<object>)


Added ExtraString param "NoInteract" to UseItemWithHotSpots

--- Profiles/Quester/Scripts/UseItemWithHotSpots.cs
+++ Profiles/Quester/Scripts/UseItemWithHotSpots.cs
@@ -135,7 +135,8 @@
 		}
 		else if (unit.IsValid)
 		{
-			Interact.InteractWith(unit.GetBaseAddress); //Interact With Unit to Attack it
+			if(questObjective.ExtraString != "NoInteract")
+				Interact.InteractWith(unit.GetBaseAddress); //Interact With Unit to Attack it
 			nManagerSetting.AddBlackList(unit.Guid, 60*1000);
 		}


Remove Accord

Remove Accord

--- QuantSA/QuantSA.Valuation/SimulatedCashflows.cs
+++ QuantSA/QuantSA.Valuation/SimulatedCashflows.cs
@@ -1,5 +1,4 @@
 using System.Collections.Generic;
-using Accord.Math;
 using QuantSA.Shared.Dates;
 using QuantSA.Shared.Primitives;

@@ -44,7 +43,7 @@
         internal double[] GetPathwisePV(Date date, List<int> subPortfolio)
         {
             //TODO: This could be done faster for a set of dates if the cashflows are ordered by time.  Then the value in column i is the value in column i+1 plus the cashflows that take place between the dates associated with the columns.
-            var result = Vector.Zeros(_nSims);
+            var result = new double[_nSims];
             foreach (var productCounter in subPortfolio)
                 for (var pathCounter = 0; pathCounter < _nSims; pathCounter++)
                     foreach (var cf in _allCFs[productCounter][pathCounter])


Add support for hidden classes to table format

--- Rant/Vocabulary/RantDictionaryTable.Importer.cs
+++ Rant/Vocabulary/RantDictionaryTable.Importer.cs
@@ -42,6 +42,7 @@
             string name = null; // Stores the table name before final table construction
             int termsPerEntry = 0; // Stores the term count
             var subtypes = new Dictionary<string, int>(); // Stores subtypes before final table construction
+			var hidden = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase);
             RantDictionaryTable table = null; // The table object, constructed when first entry is found
             string l; // Current line string
             int line = 0; // Current line number
@@ -158,6 +159,15 @@
                                             }
                                             break;
                                         }
+									case "hide":
+										if (args.Count == 0) break;
+										foreach(var a in args)
+										{
+											if (!Util.ValidateName(a.Value))
+												throw new RantTableLoadException(origin, line, i, "err-table-invalid-class", a.Value);
+											hidden.Add(String.Intern(a.Value));
+										}
+										break;
                                     case "dummy":
                                         if (args.Count != 0)
                                             throw new RantTableLoadException(origin, line, i, "err-table-argc-mismatch", directiveName, 0, args.Count);
@@ -288,6 +298,12 @@
                     }
                 }
             }
+
+			// Add hidden classes
+			foreach(var hc in hidden)
+			{
+				table.HideClass(hc);
+			}

             table.Commit();


simplify imports

simplify imports

--- RemoteSignTool/RemoteSignTool.Client/Program.cs
+++ RemoteSignTool/RemoteSignTool.Client/Program.cs
@@ -286,12 +286,12 @@
             Logger.Error("Status code: {0}", response.StatusCode);
             Logger.Error(await response.Content.ReadAsStringAsync());
         }
-        private static void SendProgressHandler(object sender, System.Net.Http.Handlers.HttpProgressEventArgs e)
+        private static void SendProgressHandler(object sender, HttpProgressEventArgs e)
         {
             LogProgress("Sending:", e);
         }

-        private static void ReceiveProgressHandler(object sender, System.Net.Http.Handlers.HttpProgressEventArgs e)
+        private static void ReceiveProgressHandler(object sender, HttpProgressEventArgs e)
         {
             LogProgress("Receive:", e);
         }


one instance of loop2 replaced with detListIerator

for detection list iterator, this is used by each detection
characteristic as well as the systemContactLists.

--- Pulsar4X/Pulsar4X.Lib/Entities/Faction.cs
+++ Pulsar4X/Pulsar4X.Lib/Entities/Faction.cs
@@ -1186,26 +1186,26 @@
                 /// <summary>
                 /// Loop through the global contacts list for the system. thermal.Count is equal to SystemContacts.Count. or should be.
                 /// </summary>
-                for (int loop2 = 0; loop2 < System.FactionDetectionLists[FactionID].Thermal.Count; loop2++)
+                for (int detListIterator = 0; detListIterator < System.FactionDetectionLists[FactionID].Thermal.Count; detListIterator++)
                 {
                     /// <summary>
                     /// I don't own loop2, and it hasn't been fully detected yet.
                     /// TODO: CHECK: ^ What does this mean?
                     /// </summary>
-                    if (this != System.SystemContactList[loop2].faction && System.FactionDetectionLists[FactionID].Thermal[loop2] != GameState.Instance.CurrentSecond &&
-                        System.FactionDetectionLists[FactionID].EM[loop2] != GameState.Instance.CurrentSecond && System.FactionDetectionLists[FactionID].Active[loop2] != GameState.Instance.CurrentSecond)
+                    if (this != System.SystemContactList[detListIterator].faction && System.FactionDetectionLists[FactionID].Thermal[detListIterator] != GameState.Instance.CurrentSecond &&
+                        System.FactionDetectionLists[FactionID].EM[detListIterator] != GameState.Instance.CurrentSecond && System.FactionDetectionLists[FactionID].Active[detListIterator] != GameState.Instance.CurrentSecond)
                     {
                         float dist;

                         // Check to see if our distance table is updated for this contact.
-                        if (!CurrentTaskGroup.Contact.DistTable.GetDistance(System.SystemContactList[loop2], out dist))
+                        if (!CurrentTaskGroup.Contact.DistTable.GetDistance(System.SystemContactList[detListIterator], out dist))
                         {
                             /// <summary>
                             /// Handle fleet interception check here.
                             /// </summary>
-                            if (GameState.SE.FleetInterceptionPreemptTick != GameState.Instance.CurrentSecond && System.SystemContactList[loop2].SSEntity == StarSystemEntityType.TaskGroup)
+                            if (GameState.SE.FleetInterceptionPreemptTick != GameState.Instance.CurrentSecond && System.SystemContactList[detListIterator].SSEntity == StarSystemEntityType.TaskGroup)
                             {
-                                TaskGroupTN TaskGroup = System.SystemContactList[loop2].Entity as TaskGroupTN;
+                                TaskGroupTN TaskGroup = System.SystemContactList[detListIterator].Entity as TaskGroupTN;
                                 /// <summary>
                                 /// player created empty taskgroups should not get checked here.
                                 /// </summary>
@@ -1236,7 +1236,7 @@
                                     GameState.SE.FleetInterceptionPreemptTick = GameState.Instance.CurrentSecond;

                                     GameState.SE.AddFleetToPreemptList(CurrentTaskGroup);
-                                    if (System.SystemContactList[loop2].SSEntity == StarSystemEntityType.TaskGroup)
+                                    if (System.SystemContactList[detListIterator].SSEntity == StarSystemEntityType.TaskGroup)
                                     {

                                         GameState.SE.AddFleetToPreemptList(TaskGroup);
@@ -1256,9 +1256,9 @@
                         /// <summary>
                         /// Handle population detection
                         /// </summary>
-                        if (System.SystemContactList[loop2].SSEntity == StarSystemEntityType.Population)
+                        if (System.SystemContactList[detListIterator].SSEntity == StarSystemEntityType.Population)
                         {
-                            Population Pop = System.SystemContactList[loop2].Entity as Population;
+                            Population Pop = System.SystemContactList[detListIterator].Entity as Population;
                             sig = Pop.ThermalSignature;
                             detection = CurrentTaskGroup.BestThermal.pSensorDef.GetPassiveDetectionRange(sig);

@@ -1273,7 +1273,7 @@
                             if (det == true)
                             {
                                 Pop.ThermalDetection[FactionID] = GameState.Instance.CurrentSecond;
-                                System.FactionDetectionLists[FactionID].Thermal[loop2] = GameState.Instance.CurrentSecond;
+                                System.FactionDetectionLists[FactionID].Thermal[detListIterator] = GameState.Instance.CurrentSecond;
                             }

                             sig = Pop.EMSignature;
@@ -1284,7 +1284,7 @@
                             if (det == true)
                             {
                                 Pop.EMDetection[FactionID] = GameState.Instance.CurrentSecond;
-                                System.FactionDetectionLists[FactionID].EM[loop2] = GameState.Instance.CurrentSecond;
+                                System.FactionDetectionLists[FactionID].EM[detListIterator] = GameState.Instance.CurrentSecond;
                             }

                             sig = Constants.ShipTN.ResolutionMax - 1;
@@ -1301,12 +1301,12 @@
                             if (det == true)
                             {
                                 Pop.ActiveDetection[FactionID] = GameState.Instance.CurrentSecond;
-                                System.FactionDetectionLists[FactionID].Active[loop2] = GameState.Instance.CurrentSecond;
+                                System.FactionDetectionLists[FactionID].Active[detListIterator] = GameState.Instance.CurrentSecond;
                             }
                         }
-                        else if (System.SystemContactList[loop2].SSEntity == StarSystemEntityType.TaskGroup)
+                        else if (System.SystemContactList[detListIterator].SSEntity == StarSystemEntityType.TaskGroup)
                         {
-                            TaskGroupTN TaskGroup = System.SystemContactList[loop2].Entity as TaskGroupTN;
+                            TaskGroupTN TaskGroup = System.SystemContactList[detListIterator].Entity as TaskGroupTN;

                             if (TaskGroup.Ships.Count != 0)
                             {
@@ -1319,7 +1319,7 @@

                                 #region Ship Thermal Detection Code

-                                if (System.FactionDetectionLists[FactionID].Thermal[loop2] != GameState.Instance.CurrentSecond)
+                                if (System.FactionDetectionLists[FactionID].Thermal[detListIterator] != GameState.Instance.CurrentSecond)
                                 {

                                     /// <summary>
@@ -1396,7 +1396,7 @@
                                                     DetShipList.Add(TaskGroup.Ships[loop3]);
                                                 }
                                             }
-                                            System.FactionDetectionLists[FactionID].Thermal[loop2] = GameState.Instance.CurrentSecond;
+                                            System.FactionDetectionLists[FactionID].Thermal[detListIterator] = GameState.Instance.CurrentSecond;

                                         }
@@ -1472,7 +1472,7 @@

                                 #region Ship EM Detection Code

-                                if (System.FactionDetectionLists[FactionID].EM[loop2] != GameState.Instance.CurrentSecond)
+                                if (System.FactionDetectionLists[FactionID].EM[detListIterator] != GameState.Instance.CurrentSecond)
                                 {
                                     noDetection = false;
                                     allDetection = false;
@@ -1546,7 +1546,7 @@
                                                     DetShipList.Add(TaskGroup.Ships[loop3]);
                                                 }
                                             }
-                                            System.FactionDetectionLists[FactionID].EM[loop2] = GameState.Instance.CurrentSecond;
+                                            System.FactionDetectionLists[FactionID].EM[detListIterator] = GameState.Instance.CurrentSecond;
                                         }
                                         else if (noDetection == false && allDetection == false)
                                         {
@@ -1583,7 +1583,7 @@
                                                             /// </summary>
                                                             if (TaskGroup.Ships[node.Next.Value].EMDetection[FactionID] == GameState.Instance.CurrentSecond)
                                                             {
-                                                                System.FactionDetectionLists[FactionID].EM[loop2] = GameState.Instance.CurrentSecond;
+                                                                System.FactionDetectionLists[FactionID].EM[detListIterator] = GameState.Instance.CurrentSecond;
                                                             }
                                                             break;
                                                         }
@@ -1640,7 +1640,7 @@

                                 #region Ship Active Detection Code

-                                if (System.FactionDetectionLists[FactionID].Active[loop2] != GameState.Instance.CurrentSecond && CurrentTaskGroup.ActiveSensorQue.Count > 0)
+                                if (System.FactionDetectionLists[FactionID].Active[detListIterator] != GameState.Instance.CurrentSecond && CurrentTaskGroup.ActiveSensorQue.Count > 0)
                                 {
                                     noDetection = false;
                                     allDetection = false;
@@ -1705,7 +1705,7 @@
                                             /// Be sure to erase the factionDetectionSystem entry first, to track down everywhere this overbloated thing is.
                                             /// update, not happening. FactionDetectionList is too important.
                                             /// </summary>
-                                            System.FactionDetectionLists[FactionID].Active[loop2] = GameState.Instance.CurrentSecond;
+                                            System.FactionDetectionLists[FactionID].Active[detListIterator] = GameState.Instance.CurrentSecond;
                                         }
                                         else if (noDetection == false && allDetection == false)
                                         {
@@ -1775,9 +1775,9 @@
                             #endregion

                         }
-                        else if (System.SystemContactList[loop2].SSEntity == StarSystemEntityType.Missile)
+                        else if (System.SystemContactList[detListIterator].SSEntity == StarSystemEntityType.Missile)
                         {
-                            OrdnanceGroupTN MissileGroup = System.SystemContactList[loop2].Entity as OrdnanceGroupTN;
+                            OrdnanceGroupTN MissileGroup = System.SystemContactList[detListIterator].Entity as OrdnanceGroupTN;

                             if (MissileGroup.missiles.Count != 0)
                             {
@@ -1786,7 +1786,7 @@
                                 /// </summary>
                                 #region Missile Detection
                                 OrdnanceTN Missile = MissileGroup.missiles[0];
-                                if (System.FactionDetectionLists[FactionID].Thermal[loop2] != GameState.Instance.CurrentSecond)
+                                if (System.FactionDetectionLists[FactionID].Thermal[detListIterator] != GameState.Instance.CurrentSecond)
                                 {
                                     int ThermalSignature = (int)Math.Ceiling(Missile.missileDef.totalThermalSignature);
                                     detection = -1;
@@ -1823,11 +1823,11 @@
                                             DetMissileList.Add(MissileGroup);
                                         }

-                                        System.FactionDetectionLists[FactionID].Thermal[loop2] = GameState.Instance.CurrentSecond;
+                                        System.FactionDetectionLists[FactionID].Thermal[detListIterator] = GameState.Instance.CurrentSecond;
                                     }
                                 }

-                                if (System.FactionDetectionLists[FactionID].EM[loop2] != GameState.Instance.CurrentSecond)
+                                if (System.FactionDetectionLists[FactionID].EM[detListIterator] != GameState.Instance.CurrentSecond)
                                 {
                                     int EMSignature = 0;
                                     if (Missile.missileDef.activeStr != 0.0f)
@@ -1868,12 +1868,12 @@
                                             }

-                                            System.FactionDetectionLists[FactionID].EM[loop2] = GameState.Instance.CurrentSecond;
+                                            System.FactionDetectionLists[FactionID].EM[detListIterator] = GameState.Instance.CurrentSecond;
                                         }
                                     }
                                 }

-                                if (System.FactionDetectionLists[FactionID].Active[loop2] != GameState.Instance.CurrentSecond && CurrentTaskGroup.ActiveSensorQue.Count > 0)
+                                if (System.FactionDetectionLists[FactionID].Active[detListIterator] != GameState.Instance.CurrentSecond && CurrentTaskGroup.ActiveSensorQue.Count > 0)
                                 {
                                     int TotalCrossSection_MSP = (int)Math.Ceiling(Missile.missileDef.size);
                                     sig = -1;
@@ -1916,7 +1916,7 @@
                                             DetMissileList.Add(MissileGroup);
                                         }

-                                        System.FactionDetectionLists[FactionID].Active[loop2] = GameState.Instance.CurrentSecond;
+                                        System.FactionDetectionLists[FactionID].Active[detListIterator] = GameState.Instance.CurrentSecond;
                                     }
                                 }
                                 #endregion


Added birthday calculation.

Added birthday calculation.

--- Cheers/Cheers/Program.cs
+++ Cheers/Cheers/Program.cs
@@ -9,8 +9,9 @@

             Console.WriteLine("Hello there! What is your name?");
             string name = Console.ReadLine();
-            Console.WriteLine("Hello " + name);
-            for(int i=0; i<name.Length; i++)
+            Console.WriteLine("Hey " + name + ", what's your birthday? (MM/DD)");
+            string birthday = Console.ReadLine();
+            for (int i=0; i<name.Length; i++)
             {
                 /*This checks for upper and lower case*/
                 bool isVowel = "halfnorsemix".IndexOf(name[i].ToString(), StringComparison.InvariantCultureIgnoreCase) >= 0;
@@ -23,6 +24,28 @@
                 }
             }
             Console.WriteLine("Gooooooooooo " + name + "!");
+
+            //Birthday----------------------------
+            DateTime today = DateTime.Now;
+            DateTime convertedBD = DateTime.Parse(birthday);
+
+            int difference = (convertedBD-today).Days;
+            //difference++;
+            if (difference < 0)
+            {
+                difference = 365 + difference;
+            }
+            if(difference == 0)
+            {
+                Console.WriteLine("It's your birthday!");
+            }
+            else
+            {
+                Console.WriteLine(difference + " days till your birthday");
+            }
+
+            Console.WriteLine("Press any key to finish . . .");
+            Console.ReadKey();
         }
     }
 }


wait time algorithm updates

wait time algorithm updates

--- MOE.Common/Business/WaitTimeChart.cs
+++ MOE.Common/Business/WaitTimeChart.cs
@@ -48,7 +48,7 @@
             if (hasAdvanceDetection && hasStopBarDetection)
             {
                 detectionTypesForApproach = "Advance + Stop Bar Detection";
-                useDroppingAlgorithm = false;
+                useDroppingAlgorithm = true;
             }
             else if (hasAdvanceDetection)
             {
@@ -198,15 +198,19 @@
                             };
                         }
                     }
-                    else
-                    {
-                        var firstPhaseCall = phaseCallList.First();
+                    else if (phaseCallList.Any(x => x.EventCode == WaitTimeOptions.PHASE_CALL_REGISTERED))
+                    {
+                        var firstPhaseCall = phaseCallList.First(x => x.EventCode == WaitTimeOptions.PHASE_CALL_REGISTERED);
                         //waitTimeTrackerList.Add(new WaitTimeTracker { Time = green.Timestamp, WaitTimeSeconds = (green.Timestamp - firstPhaseCall.Timestamp).TotalSeconds });
                         waitTimeTrackerToFill = new WaitTimeTracker
                         {
                             Time = green.Timestamp,
                             WaitTimeSeconds = (green.Timestamp - firstPhaseCall.Timestamp).TotalSeconds
                         };
+                    }
+                    else
+                    {
+                        continue;
                     }

                     //Toss anything longer than 6 minutes - usually a bad value as a result of missing data


Unspecified

Unspecified

--- Purchasing.Web/Views/Order/_Vendor.cshtml
+++ Purchasing.Web/Views/Order/_Vendor.cshtml
@@ -13,7 +13,7 @@

-                    @this.Select("vendor").Options(Model.Vendors, x=>x.Id, x=>x.Name).Selected(Model.Order.Vendor != null ? Model.Order.Vendor.Id : 0).FirstOption("-- Select a vendor --").Title("Select a vendor to purchase from. Selecting 'Unspecified' indicates no specific vendor will be assocaited")
+                    @this.Select("vendor").Options(Model.Vendors, x=>x.Id, x=>x.Name).Selected(Model.Order.Vendor != null ? Model.Order.Vendor.Id : 0).FirstOption("Unspecified").Title("Select a vendor to purchase from. Selecting 'Unspecified' indicates no specific vendor will be assocaited")

                     (or)
                     Add new vendor


Revert "PgnReader: castling moves can be check(mate)"

This reverts commit 713bbafb2af4ff039b0667ac2866d6937f8fdbbf.

The check and checkmate indicators are already removed from the SAN move
when PgnReader checks for castling.

--- ChessDotNet/PgnReader.cs
+++ ChessDotNet/PgnReader.cs
@@ -47,14 +47,14 @@
                     }
                 }

-                if (new string[] { "O-O", "O-O+", "O-O#" }.Contains(move.ToUpperInvariant()))
+                if (move.ToUpperInvariant() == "O-O")
                 {
                     int r = player == Player.White ? 1 : 8;
                     origin = new Position(File.E, r);
                     destination = new Position(File.G, r);
                     piece = new King(player);
                 }
-                else if (new string[] { "O-O-O", "O-O-O+", "O-O-O#" }.Contains(move.ToUpperInvariant()))
+                else if (move.ToUpperInvariant() == "O-O-O")
                 {
                     int r = player == Player.White ? 1 : 8;
                     origin = new Position(File.E, r);


Made Input Smoother

Made Input Smoother

--- RTSGame/RTSCombatSim/ColorSchemeScreen.cs
+++ RTSGame/RTSCombatSim/ColorSchemeScreen.cs
@@ -90,9 +90,15 @@

         public override void OnEntry(GameTime gameTime) {
             input.Refresh();
-            //MouseEventDispatcher.OnMousePress += sP.OnMousePress;
-            //MouseEventDispatcher.OnMousePress += sS.OnMousePress;
-            //MouseEventDispatcher.OnMousePress += sT.OnMousePress;
+            MouseEventDispatcher.OnMousePress += sP.OnMousePress;
+            MouseEventDispatcher.OnMouseMotion += sP.OnMouseMovement;
+            MouseEventDispatcher.OnMouseRelease += sP.OnMouseRelease;
+            MouseEventDispatcher.OnMousePress += sS.OnMousePress;
+            MouseEventDispatcher.OnMouseMotion += sS.OnMouseMovement;
+            MouseEventDispatcher.OnMouseRelease += sS.OnMouseRelease;
+            MouseEventDispatcher.OnMousePress += sT.OnMousePress;
+            MouseEventDispatcher.OnMouseMotion += sT.OnMouseMovement;
+            MouseEventDispatcher.OnMouseRelease += sT.OnMouseRelease;

             // Rendering Effect
             fx = new RTSEffect(XNAEffect.Compile(G, FX_FILE_PATH));
@@ -120,9 +126,15 @@
             if(unitModel != null) DisposeUnit();
             fx.Dispose();
             camera = null;
-            //MouseEventDispatcher.OnMousePress -= sP.OnMousePress;
-            //MouseEventDispatcher.OnMousePress -= sS.OnMousePress;
-            //MouseEventDispatcher.OnMousePress -= sT.OnMousePress;
+            MouseEventDispatcher.OnMousePress -= sP.OnMousePress;
+            MouseEventDispatcher.OnMouseMotion -= sP.OnMouseMovement;
+            MouseEventDispatcher.OnMouseRelease -= sP.OnMouseRelease;
+            MouseEventDispatcher.OnMousePress -= sS.OnMousePress;
+            MouseEventDispatcher.OnMouseMotion -= sS.OnMouseMovement;
+            MouseEventDispatcher.OnMouseRelease -= sS.OnMouseRelease;
+            MouseEventDispatcher.OnMousePress -= sT.OnMousePress;
+            MouseEventDispatcher.OnMouseMotion -= sT.OnMouseMovement;
+            MouseEventDispatcher.OnMouseRelease -= sT.OnMouseRelease;
         }

         public override void Update(GameTime gameTime) {
@@ -135,16 +147,6 @@

             if(searchDone) {
                 tSearch = null;
-            }
-
-            if(input.Mouse.Current.LeftButton == ButtonState.Pressed) {
-                Vector2 r;
-                Vector2 m = new Vector2(input.Mouse.Current.X, input.Mouse.Current.Y);
-                if(wBackPanel.Inside(input.Mouse.Current.X, input.Mouse.Current.Y, out r)) {
-                    sP.OnMousePress(m, MouseButton.Left);
-                    sS.OnMousePress(m, MouseButton.Left);
-                    sT.OnMousePress(m, MouseButton.Left);
-                }
             }

             if(tSearch == null) {
@@ -315,7 +317,9 @@
         }
     }

+    #region Color Swatch Widget
     class ColorSwatch : IDisposable {
+        private int active;
         private Vector3 col;
         public Vector3 Color {
             get { return col; }
@@ -371,6 +375,7 @@
             wCol.LayerDepth = lD;

             Color = Vector3.One;
+            active = -1;
         }
         public void Dispose() {
             wBorder.Dispose();
@@ -385,16 +390,51 @@
             int y = (int)pos.Y;
             Vector2 ratio;
             if(wBorder.Inside(x, y, out ratio)) {
-                if(wR.Inside(x, y, out ratio))
+                if(wR.Inside(x, y, out ratio)) {
                     Color = new Vector3(ratio.X, col.Y, col.Z);
-                else if(wG.Inside(x, y, out ratio))
+                    active = 0;
+                }
+                else if(wG.Inside(x, y, out ratio)) {
                     Color = new Vector3(col.X, ratio.X, col.Z);
-                else if(wB.Inside(x, y, out ratio))
+                    active = 1;
+                }
+                else if(wB.Inside(x, y, out ratio)) {
                     Color = new Vector3(col.X, col.Y, ratio.X);
-            }
-        }
-    }
-
+                    active = 2;
+                }
+            }
+        }
+        public void OnMouseMovement(Vector2 pos, Vector2 d) {
+            if(active < 0) return;
+            Vector2 r;
+            int x = (int)pos.X;
+            int y = (int)pos.Y;
+            float v;
+            switch(active) {
+                case 0:
+                    wR.Inside(x, y, out r);
+                    v = MathHelper.Clamp(r.X, 0, 1);
+                    Color = new Vector3(v, col.Y, col.Z);
+                    break;
+                case 1:
+                    wG.Inside(x, y, out r);
+                    v = MathHelper.Clamp(r.X, 0, 1);
+                    Color = new Vector3(col.X, v, col.Z);
+                    break;
+                case 2:
+                    wB.Inside(x, y, out r);
+                    v = MathHelper.Clamp(r.X, 0, 1);
+                    Color = new Vector3(col.X, col.Y, v);
+                    break;
+            }
+        }
+        public void OnMouseRelease(Vector2 pos, MouseButton b) {
+            if(b == MouseButton.Left && active >= 0) active = -1;
+        }
+    }
+    #endregion
+
+    #region Full Animation Loop Controller
     class BlankAnimController : ACUnitAnimationController {
         private AnimationLoop animLoop;
         public float FrameSpeed {
@@ -413,5 +453,6 @@
             animLoop.Step(dt);
             AnimationFrame = animLoop.CurrentFrame;
         }
-    }
+    }
+    #endregion
 }


TFS\TeamBuild.cs: Fix to extract build information correctly.

--- Releases/3.5.4.0/Main3.5/TFS/TeamBuild.cs
+++ Releases/3.5.4.0/Main3.5/TFS/TeamBuild.cs
@@ -304,7 +304,7 @@
             // do the search and extract the details from the singleton expected result
             IBuildQueryResult results = this.buildServer.QueryBuilds(buildDetailSpec);

-            if (results.Failures.Length == 0 && results.Builds.Length > 1)
+            if (results.Failures.Length == 0 && results.Builds.Length >= 1)
             {
                 this.buildDetails = results.Builds[0];
                 ITaskItem ibuildDef = new TaskItem(this.BuildDefinitionName);


IncrementalKMeansClustering: implemented serialization

--- Model/IncrementalKMeansClustering.cs
+++ Model/IncrementalKMeansClustering.cs
@@ -24,7 +24,7 @@
        |
        '-----------------------------------------------------------------------
     */
-    public class IncrementalKMeansClustering : KMeansClusteringFast
+    public class IncrementalKMeansClustering : KMeansClusteringFast, ISerializable
     {
         private UnlabeledDataset<SparseVector<double>> mDataset
             = null;
@@ -43,6 +43,11 @@

         public IncrementalKMeansClustering() : this(/*initK=*/1)
         {
+        }
+
+        public IncrementalKMeansClustering(BinarySerializer reader) : this(/*initK=*/1)
+        {
+            Load(reader); // throws ArgumentNullException, serialization-related exceptions
         }

         public IncrementalBowSpace BowSpace
@@ -291,5 +296,33 @@
             clustQual /= (double)mDataset.Count;
             return clustQual;
         }
+
+        // *** ISerializable interface implementation ***
+
+        public void Save(BinarySerializer writer)
+        {
+            Utils.ThrowException(writer == null ? new ArgumentNullException("writer") : null);
+            // the following statements throw serialization-related exceptions
+            writer.WriteDouble(mEps);
+            writer.WriteInt(mTrials);
+            writer.WriteInt(mK);
+            writer.WriteObject(mCentroids);
+            writer.WriteObject(mDataset);
+            writer.WriteDouble(mQualThresh);
+            writer.WriteLong(mTopicId);
+        }
+
+        public void Load(BinarySerializer reader)
+        {
+            Utils.ThrowException(reader == null ? new ArgumentNullException("reader") : null);
+            // the following statements throw serialization-related exceptions
+            mEps = reader.ReadDouble();
+            mTrials = reader.ReadInt();
+            mK = reader.ReadInt();
+            mCentroids = reader.ReadObject<ArrayList<CentroidData>>();
+            mDataset = reader.ReadObject<UnlabeledDataset<SparseVector<double>>>();
+            mQualThresh = reader.ReadDouble();
+            mTopicId = reader.ReadLong();
+        }
     }
 }


Refactoring

Refactoring

--- MultiMiner.Utility/IdleTimeFinder.cs
+++ MultiMiner.Utility/IdleTimeFinder.cs
@@ -1,33 +1,36 @@
 using System;
 using System.Runtime.InteropServices;

-internal struct LASTINPUTINFO
+namespace MultiMiner.Utility
 {
-    public uint cbSize;
-    public uint dwTime;
-}
-
-/// <summary>
-/// Helps to find the idle time, (in ticks) spent since the last user input
-/// </summary>
-public class IdleTimeFinder
-{
-    [DllImport("User32.dll")]
-    private static extern bool GetLastInputInfo(ref LASTINPUTINFO plii);
-
-    [DllImport("Kernel32.dll")]
-    private static extern uint GetLastError();
+    internal struct LASTINPUTINFO
+    {
+        public uint cbSize;
+        public uint dwTime;
+    }

     /// <summary>
-    /// Get the last input time in ticks
+    /// Helps to find the idle time, (in ticks) spent since the last user input
     /// </summary>
-    /// <returns></returns>
-    public static uint GetLastInputTime()
+    public class IdleTimeFinder
     {
-        LASTINPUTINFO lastInPut = new LASTINPUTINFO();
-        lastInPut.cbSize = (uint)Marshal.SizeOf(lastInPut);
-        if (!GetLastInputInfo(ref lastInPut))
-            throw new Exception(GetLastError().ToString());
-        return lastInPut.dwTime;
+        [DllImport("User32.dll")]
+        private static extern bool GetLastInputInfo(ref LASTINPUTINFO plii);
+
+        [DllImport("Kernel32.dll")]
+        private static extern uint GetLastError();
+
+        /// <summary>
+        /// Get the last input time in ticks
+        /// </summary>
+        /// <returns></returns>
+        public static uint GetLastInputTime()
+        {
+            LASTINPUTINFO lastInPut = new LASTINPUTINFO();
+            lastInPut.cbSize = (uint)Marshal.SizeOf(lastInPut);
+            if (!GetLastInputInfo(ref lastInPut))
+                throw new Exception(GetLastError().ToString());
+            return lastInPut.dwTime;
+        }
     }
 }


[restguide] trying to link NSUserActivity with CoreSpotlight

--- RestaurantGuide/iOS/UserActivityHelper.cs
+++ RestaurantGuide/iOS/UserActivityHelper.cs
@@ -48,6 +48,11 @@

 			attributeSet.DisplayName = userInfo.Name;
 			attributeSet.ContentDescription = userInfo.Cuisine + " " + userInfo.Chef;
+
+			// Handoff https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/Handoff/AdoptingHandoff/AdoptingHandoff.html
+//			attributeSet.RelatedUniqueIdentifier = userInfo.Number.ToString(); // CoreSpotlight "id"
+
+
 			activity.AddUserInfoEntries(NSDictionary.FromObjectAndKey(new NSString(userInfo.Number.ToString()), ActivityKeys.Id));

 			activity.ContentAttributeSet = attributeSet;


TSI-112 added multimedia filename and mimetype as data attributes for every multimedia component link

--- Sdl.Web.Templating/Templates/ResolveRichText.cs
+++ Sdl.Web.Templating/Templates/ResolveRichText.cs
@@ -1,4 +1,5 @@
-using Sdl.Web.Tridion.Common;
+using System.Text;
+using Sdl.Web.Tridion.Common;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -22,6 +23,8 @@
     public class ResolveRichText : TemplateBase
     {
         private const string SchemaUriAttribute = "data-schemaUri";
+        private const string FileNameAttribute = "data-multimediaFileName";
+        private const string MimeTypeAttribute = "data-multimediaMimeType";
         private const string LinkPattern = @"xlink:href=\\""(tcm\:\d+\-\d+)\\""";
         private const string XhtmlPattern = " xmlns=\\\"http://www.w3.org/1999/xhtml\\\"";

@@ -77,19 +80,24 @@
                 // add semantic schema attribute for model mapping
                 if (comp != null)
                 {
-                    // multimedia schemas don't have a root element name, so lets use its title without any invalid characters
-                    string attributes = String.Format(" {0}=\"{1}\"", SchemaUriAttribute, comp.Schema.Id);
+                    // set base attributes for multimedia component
+                    string attributes = String.Empty;
+                    StringBuilder attributesBuilder = new StringBuilder();
+                    attributesBuilder.AppendFormat(" {0}=\"{1}\"", SchemaUriAttribute, comp.Schema.Id);
+                    attributesBuilder.AppendFormat(" {0}=\"{1}\"", FileNameAttribute, comp.BinaryContent.Filename);
+                    attributesBuilder.AppendFormat(" {0}=\"{1}\"", MimeTypeAttribute, comp.BinaryContent.MultimediaType.MimeType);

                     // resolve metadata into additional data-attributes
                     if (comp.Metadata != null)
                     {
                         ItemFields fields = new ItemFields(comp.Metadata, comp.MetadataSchema);
-                        attributes += ProcessFields(fields);
-                    }
-
-                    if (!String.IsNullOrEmpty(attributes))
-                    {
-                        attributes = JsonEncode(attributes).Substring(1);
+                        attributesBuilder.Append(ProcessFields(fields));
+                    }
+
+                    // encode and strip first and last character (quotes added by encode)
+                    if (attributesBuilder.Length > 0)
+                    {
+                        attributes = JsonEncode(attributesBuilder.ToString()).Substring(1);
                         attributes = attributes.Substring(0, attributes.Length - 1);
                     }
                     replaced = replaced + attributes;
@@ -101,7 +109,7 @@

         private string ProcessFields(ItemFields fields)
         {
-            string attributeString = String.Empty;
+            StringBuilder attributesBuilder = new StringBuilder();
             if (fields!=null)
             {
                 Logger.Debug(String.Join(", ", _metaFieldNames));
@@ -113,7 +121,7 @@
                         string attribute = String.Format(" data-{0}=\"{1}\"", fieldname, System.Net.WebUtility.HtmlEncode(fields.GetSingleFieldValue(fieldname)));
                         Logger.Debug("Attribute:" + attribute);
                         // TODO: XML encode the value
-                        attributeString += attribute;
+                        attributesBuilder.Append(attribute);
                     }
                 }

@@ -121,12 +129,12 @@
                 {
                     if (field is EmbeddedSchemaField)
                     {
-                        attributeString+=ProcessFields(((EmbeddedSchemaField)field).Value);
-                    }
-                }
-            }
-            Logger.Debug("attributes:" + attributeString);
-            return attributeString;
+                        attributesBuilder.Append(ProcessFields(((EmbeddedSchemaField)field).Value));
+                    }
+                }
+            }
+            Logger.Debug("attributes:" + attributesBuilder);
+            return attributesBuilder.ToString();
         }

         private XmlDocument ResolveXmlContent(string content)
@@ -161,9 +169,12 @@
                     // resolve multimedia component
                     if (comp != null)
                     {
-                        // multimedia schemas don't have a root element name, so lets use its title without any invalid characters
+                        // set base attributes for multimedia component
                         link.SetAttribute(SchemaUriAttribute, comp.Schema.Id);
-
+                        link.SetAttribute(FileNameAttribute, comp.BinaryContent.Filename);
+                        link.SetAttribute(MimeTypeAttribute, comp.BinaryContent.MultimediaType.MimeType);
+
+                        // resolve metadata into additional data-attributes
                         if (comp.Metadata != null)
                         {
                             ItemFields fields = new ItemFields(comp.Metadata, comp.MetadataSchema);


image-metadata anonymizers

image-metadata anonymizers

--- Sensus.Shared/Probes/Apps/ImageMetadataDatum.cs
+++ Sensus.Shared/Probes/Apps/ImageMetadataDatum.cs
@@ -12,6 +12,8 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.

+using Sensus.Anonymization;
+using Sensus.Anonymization.Anonymizers;
 using System;
 using System.Collections.Generic;
 using System.Text;
@@ -56,10 +58,14 @@
 		public int? Flash { get; set; }
 		public double? FNumber { get; set; }
 		public double? ExposureTime { get; set; }
+		[Anonymizable("Software:", typeof(StringHashAnonymizer), false)]
 		public string Software { get; set; }
+		[Anonymizable(null, new Type[] { typeof(DoubleRoundingTenthsAnonymizer), typeof(DoubleRoundingHundredthsAnonymizer), typeof(DoubleRoundingThousandthsAnonymizer) }, -1)]
 		public double? Latitude { get; set; }
+		[Anonymizable(null, new Type[] { typeof(LongitudeParticipantOffsetGpsAnonymizer), typeof(LongitudeStudyOffsetGpsAnonymizer), typeof(DoubleRoundingTenthsAnonymizer), typeof(DoubleRoundingHundredthsAnonymizer), typeof(DoubleRoundingThousandthsAnonymizer) }, -1)]
 		public double? Longitude { get; set; }
 		public string MimeType { get; set; }
+		[Anonymizable("Image:", typeof(StringHashAnonymizer), false)]
 		public string ImageBase64 { get; set; }
 	}
 }


cleanup

cleanup

--- SnapMD.VirtualCare.Sdk/Interfaces/IWebClient.cs
+++ SnapMD.VirtualCare.Sdk/Interfaces/IWebClient.cs
@@ -22,7 +22,5 @@
         string DownloadString(string address);

         string DownloadString(Uri address);
-
-        //WebResponse GetWebResponse(WebRequest request, IAsyncResult result);
     }
 }


Fix up LogViewer so that it scrolls on new items

--- SolidworksAddinFramework.Wpf/ScrollOnNewItem.cs
+++ SolidworksAddinFramework.Wpf/ScrollOnNewItem.cs
@@ -3,11 +3,14 @@
 using System.Collections.Specialized;
 using System.ComponentModel;
 using System.Linq;
+using System.Reactive.Disposables;
+using System.Reactive.Linq;
 using System.Text;
 using System.Threading.Tasks;
 using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Interactivity;
+using ReactiveUI;

 namespace SolidworksAddinFramework.Wpf
 {
@@ -28,20 +31,31 @@
             AssociatedObject.Unloaded -= OnUnLoaded;
         }

+        private IDisposable d;
         private void OnLoaded(object sender, RoutedEventArgs e)
         {
-            var incc = AssociatedObject.ItemsSource as INotifyCollectionChanged;
-            if (incc == null) return;
+            var d0 = new SerialDisposable();
+            var d1 = AssociatedObject
+                .WhenAnyValue(p => p.ItemsSource)
+                .Select
+                (o =>
+                 {
+                     var incc = o as INotifyCollectionChanged;
+                     if (incc == null)
+                         return Disposable.Empty;
+                     incc.CollectionChanged += OnCollectionChanged;
+                     return Disposable.Create(() => incc.CollectionChanged -= OnCollectionChanged);
+                 }).Subscribe(d=>d0.Disposable=d);

-            incc.CollectionChanged += OnCollectionChanged;
+            d = new CompositeDisposable(d0,d1);
+
+
+
         }

         private void OnUnLoaded(object sender, RoutedEventArgs e)
         {
-            var incc = AssociatedObject.ItemsSource as INotifyCollectionChanged;
-            if (incc == null) return;
-
-            incc.CollectionChanged -= OnCollectionChanged;
+            d.Dispose();
         }

         private void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)


Rework the server class.

Rework the server class.

--- Common/Network/Server.cs
+++ Common/Network/Server.cs
@@ -34,65 +34,88 @@
 {
     public sealed class Server : IDisposable
     {
+        private readonly Func<string, int, bool> _clientConnected;
+        private readonly Func<string, int, bool> _clientDisconnected;
+        private readonly Func<string, int, byte[], bool> _messageReceived;
+
+        private readonly ConcurrentDictionary<string, Client> _clients;
+
         private readonly TcpListener _listener;
+        private readonly CancellationToken _token;

         private readonly CancellationTokenSource _tokenSource;
-        private readonly CancellationToken _token;
-
-        private readonly Func<string, bool> _clientConnected;
-        private readonly Func<string, bool> _clientDisconnected;
-        private readonly Func<string, byte[], bool> _messageReceived;
-
-        public int ActiveClients { get; private set; }
-        private readonly ConcurrentDictionary<string, Client> _clients;

         /// <summary>
-        /// Initialize the TCP server.
+        ///     Instantiates the server.
         /// </summary>
-        /// <param name="listenerIp">The IP address on which the server should listen, nullable</param>
-        /// <param name="listenerPort">The TCP port on which the server should listen.</param>
+        /// <param name="listenerIp">The IP address on which the server should listen, nullable.</param>
+        /// <param name="listenerPort">The port on which the server should listen.</param>
         /// <param name="clientConnected">Function to be called when a client connects.</param>
         /// <param name="clientDisconnected">Function to be called when a client disconnects.</param>
         /// <param name="messageReceived">Function to be called when a message is received.</param>
-        public Server(string listenerIp, int listenerPort, Func<string, bool> clientConnected, Func<string, bool> clientDisconnected,
-            Func<string, byte[], bool> messageReceived)
-        {
-            if (listenerPort < 1) throw new ArgumentOutOfRangeException(nameof(listenerPort));
-
+        public Server(string listenerIp, int listenerPort, Func<string, int, bool> clientConnected,
+            Func<string, int, bool> clientDisconnected, Func<string, int, byte[], bool> messageReceived)
+        {
+            string listenerIp1;
+            IPAddress listenerAddress;
             _clientConnected = clientConnected;
             _clientDisconnected = clientDisconnected;
             _messageReceived = messageReceived ?? throw new ArgumentNullException(nameof(messageReceived));

-            var listenerIpAddress = string.IsNullOrEmpty(listenerIp) ? IPAddress.Any : IPAddress.Parse(listenerIp);
-
-            _listener = new TcpListener(listenerIpAddress, listenerPort);
-
+            if (string.IsNullOrEmpty(listenerIp))
+            {
+                listenerAddress = IPAddress.Any;
+                listenerIp1 = listenerAddress.ToString();
+            }
+            else
+            {
+                listenerAddress = IPAddress.Parse(listenerIp);
+                listenerIp1 = listenerIp;
+            }
+
+            if (listenerPort < 1) throw new ArgumentOutOfRangeException(nameof(listenerPort));
+            var listenerPort1 = listenerPort;
+
+            LogManager.Instance.Log(LogManager.LogType.Info, $"Server starting on {listenerIp1}:{listenerPort1}.");
+
+            _listener = new TcpListener(listenerAddress, listenerPort1);
             _tokenSource = new CancellationTokenSource();
             _token = _tokenSource.Token;

-            ActiveClients = 0;
             _clients = new ConcurrentDictionary<string, Client>();

-            Task.Run(AcceptConnections, _token);
+            Task.Run(AcceptConnections, _token).ConfigureAwait(false);
+        }
+
+        public void Dispose()
+        {
+            _tokenSource?.Dispose();
         }

         /// <summary>
-        /// Send data to the specified client, asynchronously.
+        ///     Send data to the specified client, asynchronously.
         /// </summary>
-        /// <param name="ipPort">IP:Port of the recipient client.</param>
+        /// <param name="ip">The IP address of the client.</param>
+        /// <param name="port">The port of the client.</param>
         /// <param name="data">Byte array containing data.</param>
-        /// <returns>Task with Boolean indicating if the message was sent successfully.</returns>
-        public async Task<bool> SendAsync(string ipPort, byte[] data)
-        {
-            if (_clients.TryGetValue(ipPort, out var client)) return await MessageWriteAsync(client, data);
-
-            LogManager.Instance.Log(LogManager.LogType.Error, "Unable to send message to client (" + ipPort + ").");
+        /// <returns>Boolean indicating if the message was sent successfully.</returns>
+        public async Task<bool> SendAsync(string ip, int port, byte[] data)
+        {
+            if (_clients.TryGetValue(new Guid(ip + ":" + port).ToString(), out var client))
+                return await SendAsync(client, data).ConfigureAwait(false);
+
             return false;
         }

-        public void Dispose()
-        {
-            _tokenSource.Cancel();
+        /// <summary>
+        ///     Send data to the specified client, asynchronously.
+        /// </summary>
+        /// <param name="client">The <see cref="Client" />.</param>
+        /// <param name="data">Byte array containing data.</param>
+        /// <returns>Boolean indicating if the message was sent successfully.</returns>
+        public async Task<bool> SendAsync(Client client, byte[] data)
+        {
+            return await MessageWriteAsync(client, data).ConfigureAwait(false);
         }

         private async Task AcceptConnections()
@@ -100,39 +123,35 @@
             _listener.Start();

             while (!_token.IsCancellationRequested)
-            {
-                var client = await _listener.AcceptTcpClientAsync();
-                client.LingerState.Enabled = false;
-
-                await Task.Run(() =>
+                try
                 {
-                    ActiveClients++;
-
-                    var currentClient = new Client(client);
-                    if (!AddClient(currentClient))
+                    var tcpClient = await _listener.AcceptTcpClientAsync();
+                    tcpClient.LingerState.Enabled = false;
+
+                    var client = new Client(tcpClient);
+
+                    if (!AddClient(client))
                     {
-                        client.Close();
+                        client.Dispose();
                         return;
                     }

-                    var dataReceiverToken = default(CancellationToken);
-
                     if (_clientConnected != null)
-                        Task.Run(() => _clientConnected(currentClient.Ip + ":" + currentClient.Port), _token);
-
-                    Task.Run(async () => await DataReceiver(currentClient, dataReceiverToken), dataReceiverToken);
-                }, _token);
-            }
-        }
-
-        private async Task DataReceiver(Client client, CancellationToken? cancellationToken = null)
+                        await Task.Run(() => _clientConnected(client.Ip, client.Port), _token).ConfigureAwait(false);
+
+                    await Task.Run(() => DataReceiver(client), _token).ConfigureAwait(false);
+                }
+                catch (Exception e)
+                {
+                    LogManager.Instance.Log(LogManager.LogType.Error, e.Message);
+                }
+        }
+
+        private async Task DataReceiver(Client client)
         {
             try
             {
-                while (true)
-                {
-                    cancellationToken?.ThrowIfCancellationRequested();
-
+                while (!_token.IsCancellationRequested)
                     try
                     {
                         if (!IsConnected(client)) break;
@@ -144,31 +163,29 @@
                             continue;
                         }

-                        if (_messageReceived != null) { }
-                            await Task.Run(() => _messageReceived(client.Ip + ":" + client.Port, data), _token);
+                        if (_messageReceived != null)
+                            await Task.Run(() => _messageReceived(client.Ip, client.Port, data), _token)
+                                .ConfigureAwait(false);
                     }
-                    catch (Exception)
+                    catch (Exception e)
                     {
-                        break;
+                        LogManager.Instance.Log(LogManager.LogType.Error, e.Message);
                     }
-                }
             }
             finally
             {
-                ActiveClients--;
                 if (!RemoveClient(client))
                     LogManager.Instance.Log(LogManager.LogType.Error,
-                        "Can't remove client (" + client.Ip + ":" + client.Port + ").");
+                        $"Can't remove client ({client.Ip}:{client.Port}).");

                 if (_clientDisconnected != null)
-                    await Task.Run(() => _clientDisconnected(client.Ip + ":" + client.Port), _token);
+                    await Task.Run(() => _clientDisconnected(client.Ip, client.Port), _token).ConfigureAwait(false);
             }
         }

         private async Task<byte[]> MessageReadAsync(Client client)
         {
             var clientStream = client.TcpClient.GetStream();
-
             if (!clientStream.CanRead || !clientStream.DataAvailable) return null;

             var readBuffer = new byte[client.TcpClient.ReceiveBufferSize];
@@ -177,12 +194,12 @@
                 do
                 {
                     var numBytesRead = await clientStream.ReadAsync(readBuffer, 0, readBuffer.Length, _token);
+
                     if (numBytesRead <= 0)
                         break;

                     await memoryStream.WriteAsync(readBuffer, 0, numBytesRead, _token);
-                }
-                while (clientStream.DataAvailable);
+                } while (clientStream.DataAvailable);

                 return memoryStream.ToArray();
             }
@@ -194,10 +211,20 @@
                 return false;

             var clientStream = client.TcpClient.GetStream();
-            await clientStream.WriteAsync(data, 0, data.Length, _token);
-            await clientStream.FlushAsync(_token);
+            await clientStream.WriteAsync(data, 0, data.Length, _token).ConfigureAwait(false);
+            await clientStream.FlushAsync(_token).ConfigureAwait(false);

             return true;
+        }
+
+        private bool AddClient(Client client)
+        {
+            return _clients.TryAdd(new Guid(client.Ip + ":" + client.Port).ToString(), client);
+        }
+
+        private bool RemoveClient(Client client)
+        {
+            return _clients.TryRemove(new Guid(client.Ip + ":" + client.Port).ToString(), out client);
         }

         private static bool IsConnected(Client client)
@@ -207,18 +234,7 @@
             if (!client.TcpClient.Client.Poll(0, SelectMode.SelectWrite) ||
                 client.TcpClient.Client.Poll(0, SelectMode.SelectError)) return false;

-            var buffer = new byte[1];
-            return client.TcpClient.Client.Receive(buffer, SocketFlags.Peek) != 0;
-        }
-
-        private bool AddClient(Client client)
-        {
-            return _clients.TryAdd(client.Ip + ":" + client.Port, client);
-        }
-
-        private bool RemoveClient(Client client)
-        {
-            return _clients.TryRemove(client.Ip + ":" + client.Port, out client);
+            return client.TcpClient.Client.Receive(new byte[1], SocketFlags.Peek) != 0;
         }
     }
-}
+}


Add Thread Safety to AllegianceManager PassXP (#3728)

This follows the same thread-safety pattern used in other parts of AllegianceManager, like HandlePlayerDelete.

The intent here is that AllegianceManager should mange its own thread safety. Callers shouldn't have to worry about if an AllegianceManager action should be thread safe or not.

--- Source/ACE.Server/Managers/AllegianceManager.cs
+++ Source/ACE.Server/Managers/AllegianceManager.cs
@@ -189,7 +189,15 @@
         /// </summary>
         public static float GameCap = 720.0f;

+        // This function can be called from multi-threaded operations
+        // We must add thread safety to prevent AllegianceManager corruption
+        // We must also protect against cross-thread operations on vassal/patron (non-concurrent collections)
         public static void PassXP(AllegianceNode vassalNode, ulong amount, bool direct)
+        {
+            WorldManager.EnqueueAction(new ActionEventDelegate(() => DoPassXP(vassalNode, amount, direct)));
+        }
+
+        private static void DoPassXP(AllegianceNode vassalNode, ulong amount, bool direct)
         {
             // http://asheron.wikia.com/wiki/Allegiance_Experience

@@ -301,7 +309,7 @@
                     onlinePatron.AddAllegianceXP();

                 // call recursively
-                PassXP(patronNode, passupAmount, false);
+                DoPassXP(patronNode, passupAmount, false);
             }
         }


fixing specific /tele coord error (#3203)

--- Source/ACE.Server/Physics/Common/BuildingObj.cs
+++ Source/ACE.Server/Physics/Common/BuildingObj.cs
@@ -1,4 +1,6 @@
 using System.Collections.Generic;
+using System.Linq;
+
 using ACE.DatLoader.Entity;
 using ACE.Server.Physics.Animation;

@@ -131,7 +133,7 @@

             var minZ = float.MaxValue;

-            foreach (var buildingCell in BuildingCells)
+            foreach (var buildingCell in BuildingCells.Where(i => i.Environment != null))
             {
                 foreach (var cellStruct in buildingCell.Environment.Cells.Values)
                 {


Optimizations for Bundles

Optimizations for Bundles

--- Source/BlogSystem.Web/App_Start/BundleConfig.cs
+++ Source/BlogSystem.Web/App_Start/BundleConfig.cs
@@ -9,6 +9,8 @@
         {
             RegisterScripts(bundles);
             RegisterStyles(bundles);
+
+            BundleTable.EnableOptimizations = true;
         }

         private static void RegisterStyles(BundleCollection bundles)


GSF.Core: Refreshed safe file watcher code.

--- Source/Libraries/GSF.Core/IO/SafeFileWatcher.cs
+++ Source/Libraries/GSF.Core/IO/SafeFileWatcher.cs
@@ -148,11 +148,11 @@
         {
             WeakReference<SafeFileWatcher> reference = new WeakReference<SafeFileWatcher>(this);

-            m_fileSystemWatcher.Changed += (sender, e) => OnChanged(reference, e);
-            m_fileSystemWatcher.Created += (sender, e) => OnCreated(reference, e);
-            m_fileSystemWatcher.Deleted += (sender, e) => OnDeleted(reference, e);
-            m_fileSystemWatcher.Renamed += (sender, e) => OnRenamed(reference, e);
-            m_fileSystemWatcher.Error += (sender, e) => OnError(reference, e);
+            m_fileSystemWatcher.Changed += (_, e) => OnChanged(reference, e);
+            m_fileSystemWatcher.Created += (_, e) => OnCreated(reference, e);
+            m_fileSystemWatcher.Deleted += (_, e) => OnDeleted(reference, e);
+            m_fileSystemWatcher.Renamed += (_, e) => OnRenamed(reference, e);
+            m_fileSystemWatcher.Error += (_, e) => OnError(reference, e);
         }

         /// <summary>
@@ -182,14 +182,8 @@
         /// </exception>
         public string Path
         {
-            get
-            {
-                return m_fileSystemWatcher.Path;
-            }
-            set
-            {
-                m_fileSystemWatcher.Path = value;
-            }
+            get => m_fileSystemWatcher.Path;
+            set => m_fileSystemWatcher.Path = value;
         }

         /// <summary>
@@ -200,14 +194,8 @@
         /// </returns>
         public string Filter
         {
-            get
-            {
-                return m_fileSystemWatcher.Filter;
-            }
-            set
-            {
-                m_fileSystemWatcher.Filter = value;
-            }
+            get => m_fileSystemWatcher.Filter;
+            set => m_fileSystemWatcher.Filter = value;
         }

         /// <summary>
@@ -219,14 +207,8 @@
         /// <exception cref="InvalidEnumArgumentException">The value that is being set is not valid.</exception>
         public NotifyFilters NotifyFilter
         {
-            get
-            {
-                return m_fileSystemWatcher.NotifyFilter;
-            }
-            set
-            {
-                m_fileSystemWatcher.NotifyFilter = value;
-            }
+            get => m_fileSystemWatcher.NotifyFilter;
+            set => m_fileSystemWatcher.NotifyFilter = value;
         }

         /// <summary>
@@ -240,14 +222,8 @@
         /// <exception cref="ArgumentException"><see cref="SafeFileWatcher.Path"/> has not been set or is invalid.</exception>
         public bool EnableRaisingEvents
         {
-            get
-            {
-                return m_fileSystemWatcher.EnableRaisingEvents;
-            }
-            set
-            {
-                m_fileSystemWatcher.EnableRaisingEvents = value;
-            }
+            get => m_fileSystemWatcher.EnableRaisingEvents;
+            set => m_fileSystemWatcher.EnableRaisingEvents = value;
         }

         /// <summary>
@@ -258,14 +234,8 @@
         /// </returns>
         public bool IncludeSubdirectories
         {
-            get
-            {
-                return m_fileSystemWatcher.IncludeSubdirectories;
-            }
-            set
-            {
-                m_fileSystemWatcher.IncludeSubdirectories = value;
-            }
+            get => m_fileSystemWatcher.IncludeSubdirectories;
+            set => m_fileSystemWatcher.IncludeSubdirectories = value;
         }

         /// <summary>
@@ -276,14 +246,8 @@
         /// </returns>
         public int InternalBufferSize
         {
-            get
-            {
-                return m_fileSystemWatcher.InternalBufferSize;
-            }
-            set
-            {
-                m_fileSystemWatcher.InternalBufferSize = value;
-            }
+            get => m_fileSystemWatcher.InternalBufferSize;
+            set => m_fileSystemWatcher.InternalBufferSize = value;
         }

         /// <summary>
@@ -294,14 +258,8 @@
         /// </returns>
         public ISynchronizeInvoke SynchronizingObject
         {
-            get
-            {
-                return m_fileSystemWatcher.SynchronizingObject;
-            }
-            set
-            {
-                m_fileSystemWatcher.SynchronizingObject = value;
-            }
+            get => m_fileSystemWatcher.SynchronizingObject;
+            set => m_fileSystemWatcher.SynchronizingObject = value;
         }

         /// <summary>
@@ -312,14 +270,8 @@
         /// </returns>
         public ISite Site
         {
-            get
-            {
-                return m_fileSystemWatcher.Site;
-            }
-            set
-            {
-                m_fileSystemWatcher.Site = value;
-            }
+            get => m_fileSystemWatcher.Site;
+            set => m_fileSystemWatcher.Site = value;
         }

         #endregion
@@ -361,10 +313,8 @@
         /// </summary>
         /// <returns>A <see cref="WaitForChangedResult"/> that contains specific information on the change that occurred.</returns>
         /// <param name="changeType">The <see cref="WatcherChangeTypes"/> to watch for.</param>
-        public WaitForChangedResult WaitForChanged(WatcherChangeTypes changeType)
-        {
-            return m_fileSystemWatcher.WaitForChanged(changeType);
-        }
+        public WaitForChangedResult WaitForChanged(WatcherChangeTypes changeType) =>
+            m_fileSystemWatcher.WaitForChanged(changeType);

         /// <summary>
         /// A synchronous method that returns a structure that contains specific information on the change that occurred, given the type of change you want to monitor and the time (in milliseconds) to wait before timing out.
@@ -372,56 +322,35 @@
         /// <returns>A <see cref="WaitForChangedResult"/> that contains specific information on the change that occurred.</returns>
         /// <param name="changeType">The <see cref="WatcherChangeTypes"/> to watch for.</param>
         /// <param name="timeout">The time (in milliseconds) to wait before timing out.</param>
-        public WaitForChangedResult WaitForChanged(WatcherChangeTypes changeType, int timeout)
-        {
-            return m_fileSystemWatcher.WaitForChanged(changeType, timeout);
-        }
+        public WaitForChangedResult WaitForChanged(WatcherChangeTypes changeType, int timeout) =>
+            m_fileSystemWatcher.WaitForChanged(changeType, timeout);

         /// <summary>
         /// Begins the initialization of a <see cref="SafeFileWatcher"/> used on a form or used by another component. The initialization occurs at run time.
         /// </summary>
-        public void BeginInit()
-        {
+        public void BeginInit() =>
             m_fileSystemWatcher.BeginInit();
-        }

         /// <summary>
         /// Ends the initialization of a <see cref="SafeFileWatcher"/> used on a form or used by another component. The initialization occurs at run time.
         /// </summary>
-        public void EndInit()
-        {
+        public void EndInit() =>
             m_fileSystemWatcher.EndInit();
-        }
-
-        private void OnChanged(FileSystemEventArgs e)
-        {
-            if ((object)Changed != null)
-                Changed(this, e);
-        }
-
-        private void OnCreated(FileSystemEventArgs e)
-        {
-            if ((object)Created != null)
-                Created(this, e);
-        }
-
-        private void OnDeleted(FileSystemEventArgs e)
-        {
-            if ((object)Deleted != null)
-                Deleted(this, e);
-        }
-
-        private void OnRenamed(RenamedEventArgs e)
-        {
-            if ((object)Renamed != null)
-                Renamed(this, e);
-        }
-
-        private void OnError(ErrorEventArgs e)
-        {
-            if ((object)Error != null)
-                Error(this, e);
-        }
+
+        private void OnChanged(FileSystemEventArgs e) =>
+            Changed?.Invoke(this, e);
+
+        private void OnCreated(FileSystemEventArgs e) =>
+            Created?.Invoke(this, e);
+
+        private void OnDeleted(FileSystemEventArgs e) =>
+            Deleted?.Invoke(this, e);
+
+        private void OnRenamed(RenamedEventArgs e) =>
+            Renamed?.Invoke(this, e);
+
+        private void OnError(ErrorEventArgs e) =>
+            Error?.Invoke(this, e);

         #endregion

@@ -430,41 +359,31 @@
         // Static Methods
         private static void OnChanged(WeakReference<SafeFileWatcher> reference, FileSystemEventArgs e)
         {
-            SafeFileWatcher instance;
-
-            if (reference.TryGetTarget(out instance))
+            if (reference.TryGetTarget(out SafeFileWatcher instance))
                 instance.OnChanged(e);
         }

         private static void OnCreated(WeakReference<SafeFileWatcher> reference, FileSystemEventArgs e)
         {
-            SafeFileWatcher instance;
-
-            if (reference.TryGetTarget(out instance))
+            if (reference.TryGetTarget(out SafeFileWatcher instance))
                 instance.OnCreated(e);
         }

         private static void OnDeleted(WeakReference<SafeFileWatcher> reference, FileSystemEventArgs e)
         {
-            SafeFileWatcher instance;
-
-            if (reference.TryGetTarget(out instance))
+            if (reference.TryGetTarget(out SafeFileWatcher instance))
                 instance.OnDeleted(e);
         }

         private static void OnRenamed(WeakReference<SafeFileWatcher> reference, RenamedEventArgs e)
         {
-            SafeFileWatcher instance;
-
-            if (reference.TryGetTarget(out instance))
+            if (reference.TryGetTarget(out SafeFileWatcher instance))
                 instance.OnRenamed(e);
         }

         private static void OnError(WeakReference<SafeFileWatcher> reference, ErrorEventArgs e)
         {
-            SafeFileWatcher instance;
-
-            if (reference.TryGetTarget(out instance))
+            if (reference.TryGetTarget(out SafeFileWatcher instance))
                 instance.OnError(e);
         }


One more bug fixed where dictionary was used like a struct lol

--- Source/RoaringFangs/Animation/ControlManager.cs
+++ Source/RoaringFangs/Animation/ControlManager.cs
@@ -249,7 +249,7 @@

         void Update()
         {
-            var target_data_previous = new Dictionary<Transform, TargetInfo>();
+
             //var groups = TransformUtils.GetComponentsInDescendants<TargetGroupBehavior>(transform, true);
             // all those yields and enumerables are cool and everything, but i'd like to be safe at least for debugging
             var groups = transform.GetComponentsInChildren<TargetGroupBehavior>(true);
@@ -283,6 +283,7 @@
             }

+            //var target_data_previous = new Dictionary<Transform, TargetInfo>();
             foreach (var target in targets_array)
             {
                 if (target.Transform != null)
@@ -298,11 +299,34 @@
                         target.Transform.gameObject.SetActive(target.Info.Active);
                     }
                     // Add to previous target data dictionary
-                    target_data_previous[target.Transform] = target.Info;
+                    TargetDataPrevious[target.Transform] = target.Info;
                 }
             }
             // Update previous value dictionary
-            TargetDataPrevious = target_data_previous;
+            //TargetDataPrevious = target_data_previous; // dafuk are you doing m8, dictionary is not a struct
+
+
+            //var target_data_previous = new Dictionary<Transform, TargetInfo>();
+            //foreach (var target in targets_array)
+            //{
+            //    if (target.Transform != null)
+            //    {
+            //        TargetInfo target_info_previous;
+            //        bool have_previous = TargetDataPrevious.TryGetValue(target.Transform, out target_info_previous);
+            //        bool active_update = !have_previous ||
+            //            target.Info.Active != target_info_previous.Active ||
+            //            target.Info.Depth != target_info_previous.Depth;
+            //        if (active_update)
+            //        {
+            //            // Update the target game object
+            //            target.Transform.gameObject.SetActive(target.Info.Active);
+            //        }
+            //        // Add to previous target data dictionary
+            //        target_data_previous[target.Transform] = target.Info;
+            //    }
+            //}
+            //// Update previous value dictionary
+            //TargetDataPrevious = target_data_previous;
         }
 #if UNITY_EDITOR
         [MenuItem("Sprites And Bones/Animation/Control Manager", false, 0)]


Stop streaming song data when playback stops

--- SOVND.Client/Modules/NowPlayingHandler.cs
+++ SOVND.Client/Modules/NowPlayingHandler.cs
@@ -12,7 +12,6 @@
     public class NowPlayingHandler : SOVNDModule
     {
         private Track playingTrack;
-        private SpotifyTrackDataPipe streamingaudio;
         private BufferedWaveProvider wave;
         private WaveFormat WaveFormat;
         private CancellationTokenSource songToken;
@@ -75,7 +74,7 @@
                 wave.BufferDuration = TimeSpan.FromSeconds(15);

                 player.Init(wave);
-                streamingaudio = new SpotifyTrackDataPipe(playingTrack.TrackPtr, wave);
+                var streamingaudio = new SpotifyTrackDataPipe(playingTrack.TrackPtr, wave);
                 await streamingaudio.StartStreaming(startTime);
                 player.Play();

@@ -93,9 +92,6 @@
         {
             if (songToken != null)
                 songToken.Cancel();
-
-            if (streamingaudio != null)
-                streamingaudio.StopStreaming();
         }
     }
 }


iOS requires main thread for enable/disable of views.

--- SensusService/Probes/User/ScriptRunner.cs
+++ SensusService/Probes/User/ScriptRunner.cs
@@ -451,7 +451,8 @@
                                     if (!(input is LabelOnlyInput) && input.Complete)
                                     {
                                         _probe.StoreDatum(new ScriptDatum(DateTimeOffset.UtcNow, input.GroupId, input.Id, input.Value, script.CurrentDatum == null ? null : script.CurrentDatum.Id));
-                                        input.Enabled = false;
+
+                                        Xamarin.Forms.Device.BeginInvokeOnMainThread(() => input.Enabled = false);
                                     }

                         inputWait.Set();


HETS-200 unit test change

HETS-200 unit test change

--- Server/test/API/InspectionApiTestsUnit.cs
+++ Server/test/API/InspectionApiTestsUnit.cs
@@ -56,7 +56,7 @@

             */

-            InspectionService _service = new InspectionService(dbAppContext.Object);
+            InspectionService _service = new InspectionService(null, dbAppContext.Object);

                     _InspectionApi = new InspectionController (_service);


Remove duplicated code; some tests impacted because 'empty file' conditions changed

--- SharpGEDParse/SharpGEDParser/GedReader.cs
+++ SharpGEDParse/SharpGEDParser/GedReader.cs
@@ -134,10 +134,9 @@
             _blockLen = 0;
             _blockPos = 0;
             _lineBreaks = LB.ERR;
-            //Lines = new List<string>();
             _sawEOF = false;

-            if (!OpenFile(instream, enc))
+            if (!OpenFile(instream))
                 return false;
             // TODO unit testing expects no 0 HEAD
             //if (!FindHead())
@@ -184,9 +183,15 @@
                 enc = _enc;
                 startwdefault = true;
             }
-
-            // Try to open the file
             _fs = new StreamReader(new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read), enc, true, BufferSize);
+            return OpenFile(_fs, startwdefault);
+        }
+
+        // TODO how to re-open the stream opened by caller?
+
+        private bool OpenFile(StreamReader instream, bool startwdefault=false)
+        {
+            _fs = instream;
             _blockLen = _fs.ReadBlock(_buffer, 0, BufferSize);
             if (startwdefault)
             {
@@ -199,44 +204,11 @@
                     BomEncoding = "Unicode"; // TODO LE vs BE
             }

-            if (_blockLen < 20)
+            if (_blockLen < 2)
             {
                 ErrorTracker(UnkRec.ErrorCode.EmptyFile, -1);
                 return false;
             }
-            return true;
-        }
-
-        // TODO how to re-open the stream opened by caller?
-
-        private bool OpenFile(StreamReader instream, Encoding enc)
-        {
-            bool startwdefault = false;
-            if (enc == null)
-            {
-                enc = _enc;
-                startwdefault = true;
-            }
-
-            // Try to open the file
-            _fs = instream;
-            _blockLen = _fs.ReadBlock(_buffer, 0, BufferSize);
-            if (startwdefault)
-            {
-                BomEncoding = _fs.CurrentEncoding.ToString();
-                if (BomEncoding.Contains("ASCII") || BomEncoding.Contains("Latin1"))
-                    BomEncoding = "None";
-                if (BomEncoding.Contains("UTF8"))
-                    BomEncoding = "UTF8";
-                if (BomEncoding.Contains("Unicode"))
-                    BomEncoding = "Unicode"; // TODO LE vs BE
-            }
-
-            //if (_blockLen < 15) // TODO arbitrary, breaking some tests?
-            //{
-            //    Errors.Add("Empty File");
-            //    return false;
-            //}
             return true;
         }


fix IntegrityCheck in Signum.Windows

fix IntegrityCheck in Signum.Windows

--- Signum.Windows/Fluent/EntityExtensions.cs
+++ Signum.Windows/Fluent/EntityExtensions.cs
@@ -47,7 +47,7 @@

             if (error != null)
             {
-                MessageBox.Show(window, NormalWindowMessage.ImpossibleToSaveIntegrityCheckFailed.NiceToString() + error.Values.SelectMany(a=>a.Values).ToString("\r\n"), NormalWindowMessage.ThereAreErrors.NiceToString(),
+                MessageBox.Show(window, NormalWindowMessage.ImpossibleToSaveIntegrityCheckFailed.NiceToString() + error.Values.SelectMany(a=>a.Errors.Values).ToString("\r\n"), NormalWindowMessage.ThereAreErrors.NiceToString(),
                     MessageBoxButton.OK, MessageBoxImage.Error);
                 return false;
             }
@@ -61,7 +61,7 @@

             var visualErrors = VisualErrors(element).DefaultText(null);

-            var entityErrors = GetErrors((Modifiable)element.DataContext)?.Values.ToString(d => d.Values.ToString("\r\n"), "\r\n");
+            var entityErrors = GetErrors((Modifiable)element.DataContext)?.Values.ToString(d => d.Errors.Values.ToString("\r\n"), "\r\n");

             return "\r\n".Combine(visualErrors, entityErrors).DefaultText(null);
         }
@@ -75,7 +75,7 @@
             return visualErrors;
         }

-        public static Dictionary<Guid, Dictionary<string, string>> GetErrors(Modifiable mod)
+        public static Dictionary<Guid, IntegrityCheck> GetErrors(Modifiable mod)
         {
             var graph = GraphExplorer.PreSaving(() => GraphExplorer.FromRoot(mod));
             var error = GraphExplorer.FullIntegrityCheck(graph);