using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using Umbraco.Core.IO;
using umbraco.businesslogic;
using umbraco.interfaces;

namespace umbraco.presentation
{
    public class EnsureSystemPathsApplicationStartupHandler : IApplicationStartupHandler
    {
        public EnsureSystemPathsApplicationStartupHandler()
        {
            EnsurePathExists(SystemDirectories.Css);
            EnsurePathExists(SystemDirectories.Data);
            EnsurePathExists(SystemDirectories.MacroScripts);
            EnsurePathExists(SystemDirectories.Masterpages);
            EnsurePathExists(SystemDirectories.Media);
            EnsurePathExists(SystemDirectories.Scripts);
            EnsurePathExists(SystemDirectories.UserControls);
            EnsurePathExists(SystemDirectories.Xslt);
			EnsurePathExists(SystemDirectories.MvcViews);
			EnsurePathExists(SystemDirectories.MvcViews + "/Partials");
			EnsurePathExists(SystemDirectories.MvcViews + "/MacroPartials");
        }

        public void EnsurePathExists(string path)
        {
            var absolutePath = IOHelper.MapPath(path);
            if (!Directory.Exists(absolutePath))
                Directory.CreateDirectory(absolutePath);
        }
    }
}

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using Umbraco.Core.IO;
using umbraco.businesslogic;
using umbraco.interfaces;

namespace umbraco.presentation
{
    public class EnsureSystemPathsApplicationStartupHandler : IApplicationStartupHandler
    {
        public EnsureSystemPathsApplicationStartupHandler()
        {
            EnsurePathExists("~/App_Code");
            EnsurePathExists("~/App_Data");
            EnsurePathExists(SystemDirectories.AppPlugins);
            EnsurePathExists(SystemDirectories.Css);
            EnsurePathExists(SystemDirectories.MacroScripts);
            EnsurePathExists(SystemDirectories.Masterpages);
            EnsurePathExists(SystemDirectories.Media);
            EnsurePathExists(SystemDirectories.Scripts);
            EnsurePathExists(SystemDirectories.UserControls);
            EnsurePathExists(SystemDirectories.Xslt);
			EnsurePathExists(SystemDirectories.MvcViews);
			EnsurePathExists(SystemDirectories.MvcViews + "/Partials");
			EnsurePathExists(SystemDirectories.MvcViews + "/MacroPartials");
        }

        public void EnsurePathExists(string path)
        {
            var absolutePath = IOHelper.MapPath(path);
            if (!Directory.Exists(absolutePath))
                Directory.CreateDirectory(absolutePath);
        }
    }
}

Add App_Code, App_Data and App_Plugins folders to be created during app startup


using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using Ooui;

namespace Tests
{
    [TestClass]
    public class CanvasTests
    {
        [TestMethod]
        public void Context2dState ()
        {
            var c = new Canvas ();
            Assert.AreEqual (1, c.StateMessages.Count);
            var c2d = c.GetContext2d ();
            Assert.AreEqual (2, c.StateMessages.Count);
            var c2d2 = c.GetContext2d ();
            Assert.AreEqual (2, c.StateMessages.Count);
            Assert.AreEqual (c2d, c2d2);
        }

        [TestMethod]
        public void DefaultWidthAndHeight ()
        {
            var c = new Canvas ();
            Assert.AreEqual (150, c.Width);
            Assert.AreEqual (150, c.Height);
        }

        [TestMethod]
        public void WidthAndHeight ()
        {
            var c = new Canvas {
                Width = 640,
                Height = 480,
            };
            Assert.AreEqual (640, c.Width);
            Assert.AreEqual (480, c.Height);
        }

        [TestMethod]
        public void CantBeNegativeOrZero ()
        {
            var c = new Canvas {
                Width = 640,
                Height = 480,
            };
            Assert.AreEqual (640, c.Width);
            Assert.AreEqual (480, c.Height);
            c.Width = 0;
            c.Height = 0;
            Assert.AreEqual (150, c.Width);
            Assert.AreEqual (150, c.Height);
        }
    }
}

using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using Ooui;

namespace Tests
{
    [TestClass]
    public class CanvasTests
    {
        [TestMethod]
        public void Context2dState ()
        {
            var c = new Canvas ();
            Assert.AreEqual (1, c.StateMessages.Count);
            var c2d = c.GetContext2d ();
            Assert.AreEqual (2, c.StateMessages.Count);
            var c2d2 = c.GetContext2d ();
            Assert.AreEqual (2, c.StateMessages.Count);
            Assert.AreEqual (c2d, c2d2);
        }

        [TestMethod]
        public void DefaultWidthAndHeight ()
        {
            var c = new Canvas ();
            Assert.AreEqual (150, c.Width);
            Assert.AreEqual (150, c.Height);
        }

        [TestMethod]
        public void WidthAndHeight ()
        {
            var c = new Canvas {
                Width = 640,
                Height = 480,
            };
            Assert.AreEqual (640, c.Width);
            Assert.AreEqual (480, c.Height);
        }

        [TestMethod]
        public void CantBeNegativeOrZero ()
        {
            var c = new Canvas {
                Width = 640,
                Height = 480,
            };
            Assert.AreEqual (640, c.Width);
            Assert.AreEqual (480, c.Height);
            c.Width = 0;
            c.Height = -100;
            Assert.AreEqual (150, c.Width);
            Assert.AreEqual (150, c.Height);
        }
    }
}

Fix Canvas negative Height test

Fix Canvas negative Height test


namespace RollGen
{
    public abstract class Dice
    {
        public abstract PartialRoll Roll(int quantity = 1);
        public abstract string RolledString(string roll);
        public abstract object CompiledObj(string rolled);
        public int Compiled(string rolled) => System.Convert.ToInt32(CompiledObj(rolled));
        public int Roll(string roll) => Compiled(RolledString(roll));
    }
}

namespace RollGen
{
    public abstract class Dice
    {
        public abstract PartialRoll Roll(int quantity = 1);
        public abstract string RolledString(string roll);
        public abstract object CompiledObj(string rolled);
        public int Compiled(string rolled) => System.Convert.ToInt32(CompiledObj(rolled));
        public T Compiled<T>(string rolled) => (T)System.Convert.ChangeType(CompiledObj(rolled), typeof(T));
        public int Roll(string roll) => Compiled(RolledString(roll));
    }
}

Add T Compiled<T> to complement int Compiled

The user can get the Compiled version of a rolled_string in any reasonable type they wish.


using System;
using Microsoft.AspNetCore.Builder;
using Criteo.Profiling.Tracing;

namespace Criteo.Profiling.Tracing.Middleware
{
    public static class TracingMiddleware
    {
        public static void UseTracing(this IApplicationBuilder app, string serviceName)
        {
            var extractor = new Middleware.ZipkinHttpTraceExtractor();
            app.Use(async (context, next) => {
                Trace trace;
                if (!extractor.TryExtract(context.Request.Headers, out trace))
                {
                    trace = Trace.Create();
                }
                Trace.Current = trace;
                trace.Record(Annotations.ServerRecv());
                trace.Record(Annotations.ServiceName(serviceName));
                trace.Record(Annotations.Rpc(context.Request.Method));
                await next.Invoke();
                trace.Record(Annotations.ServerSend());
            });
        }
    }
}

using System;
using Microsoft.AspNetCore.Builder;
using Criteo.Profiling.Tracing;

namespace Criteo.Profiling.Tracing.Middleware
{
    public static class TracingMiddleware
    {
        public static void UseTracing(this IApplicationBuilder app, string serviceName)
        {
            var extractor = new Middleware.ZipkinHttpTraceExtractor();
            app.Use(async (context, next) => {
                Trace trace;
                if (!extractor.TryExtract(context.Request.Headers, out trace))
                {
                    trace = Trace.Create();
                }
                Trace.Current = trace;
                trace.Record(Annotations.ServerRecv());
                trace.Record(Annotations.ServiceName(serviceName));
                trace.Record(Annotations.Rpc(context.Request.Method));
                try
                {
                    await next.Invoke();
                }
                catch (System.Exception e)
                {
                    trace.Record(Annotations.Tag("error", e.Message));
                    throw;
                }
                finally
                {
                    trace.Record(Annotations.ServerSend());
                }
            });
        }
    }
}

Add exception handling in middleware

Add exception handling in middleware

It allows to see errors in zipkin and be sure that
the trace is complete.


using UnityEngine;
using UnityEditor;
using System.IO;

namespace ATP.AnimationPathTools {

	public static class ScriptableObjectUtility
	{
		/// <summary>
		//	This makes it easy to create, name and place unique new ScriptableObject asset files.
		/// </summary>
		public static void CreateAsset<T> () where T : ScriptableObject
		{
			T asset = ScriptableObject.CreateInstance<T> ();

			string path = AssetDatabase.GetAssetPath (Selection.activeObject);
			if (path == "")
			{
				path = "Assets";
			}
			else if (Path.GetExtension (path) != "")
			{
				path = path.Replace (Path.GetFileName (AssetDatabase.GetAssetPath (Selection.activeObject)), "");
			}

			string assetPathAndName = AssetDatabase.GenerateUniqueAssetPath (path + "/New " + typeof(T).ToString() + ".asset");

			AssetDatabase.CreateAsset (asset, assetPathAndName);

			AssetDatabase.SaveAssets ();
			AssetDatabase.Refresh();
			EditorUtility.FocusProjectWindow ();
			Selection.activeObject = asset;
		}
	}
}

using UnityEngine;
using UnityEditor;
using System.IO;

namespace ATP.AnimationPathTools {

	public static class ScriptableObjectUtility
	{
		/// <summary>
		//	This makes it easy to create, name and place unique new ScriptableObject asset files.
		/// </summary>
		public static void CreateAsset<T> () where T : ScriptableObject
		{
			T asset = ScriptableObject.CreateInstance<T> ();

			string path = AssetDatabase.GetAssetPath (Selection.activeObject);
			if (path == "")
			{
				path = "Assets";
			}
			else if (Path.GetExtension (path) != "")
			{
				path = path.Replace (Path.GetFileName (AssetDatabase.GetAssetPath (Selection.activeObject)), "");
			}

			string assetPathAndName = AssetDatabase.GenerateUniqueAssetPath (path + "/" + typeof(T).ToString() + ".asset");

			AssetDatabase.CreateAsset (asset, assetPathAndName);

			AssetDatabase.SaveAssets ();
			AssetDatabase.Refresh();
			EditorUtility.FocusProjectWindow ();
			Selection.activeObject = asset;
		}
	}
}

Remove "New" string from asset name

Remove "New" string from asset name


namespace TensorSharp.Operations
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    public class SubtractDoubleDoubleOperation : IBinaryOperation<double, double, double>
    {
        public Tensor<double> Evaluate(Tensor<double> tensor1, Tensor<double> tensor2)
        {
            Tensor<double> result = new Tensor<double>();

            result.SetValue(tensor1.GetValue() - tensor2.GetValue());

            return result;
        }
    }
}

namespace TensorSharp.Operations
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    public class SubtractDoubleDoubleOperation : IBinaryOperation<double, double, double>
    {
        public Tensor<double> Evaluate(Tensor<double> tensor1, Tensor<double> tensor2)
        {
            double[] values1 = tensor1.GetValues();
            int l = values1.Length;

            double[] values2 = tensor2.GetValues();

            double[] newvalues = new double[l];

            for (int k = 0; k < l; k++)
                newvalues[k] = values1[k] - values2[k];

            return tensor1.CloneWithNewValues(newvalues);
        }
    }
}

Refactor Subtract Doubles Operation to use GetValues and CloneWithValues


// Copyright (C) 2020 Fievus
//
// This software may be modified and distributed under the terms
// of the MIT license.  See the LICENSE file for details.
using System;
using System.Reflection;
using System.Runtime.Loader;

namespace Carna.ConsoleRunner
{
    internal class CarnaAssemblyLoadContext : AssemblyLoadContext
    {
        private readonly AssemblyDependencyResolver assemblyDependencyResolver;

        public CarnaAssemblyLoadContext(string assemblyPath)
        {
            assemblyDependencyResolver = new AssemblyDependencyResolver(assemblyPath);
        }

        protected override Assembly Load(AssemblyName assemblyName)
        {
            var assemblyPath = assemblyDependencyResolver.ResolveAssemblyToPath(assemblyName);
            return assemblyPath == null ? null : LoadFromAssemblyPath(assemblyPath);
        }

        protected override IntPtr LoadUnmanagedDll(string unmanagedDllName)
        {
            var unmanagedDllPath = assemblyDependencyResolver.ResolveUnmanagedDllToPath(unmanagedDllName);
            return unmanagedDllPath == null ? IntPtr.Zero : LoadUnmanagedDllFromPath(unmanagedDllName);
        }
    }
}

// Copyright (C) 2020 Fievus
//
// This software may be modified and distributed under the terms
// of the MIT license.  See the LICENSE file for details.
using System;
using System.Reflection;
using System.Runtime.Loader;

namespace Carna.ConsoleRunner
{
    internal class CarnaAssemblyLoadContext : AssemblyLoadContext
    {
        private readonly AssemblyDependencyResolver assemblyDependencyResolver;

        public CarnaAssemblyLoadContext(string assemblyPath)
        {
            assemblyDependencyResolver = new AssemblyDependencyResolver(assemblyPath);
        }

        protected override Assembly Load(AssemblyName assemblyName)
        {
            var assemblyPath = assemblyDependencyResolver.ResolveAssemblyToPath(assemblyName);
            return assemblyPath == null ? null : LoadFromAssemblyPath(assemblyPath);
        }

        protected override IntPtr LoadUnmanagedDll(string unmanagedDllName)
        {
            var unmanagedDllPath = assemblyDependencyResolver.ResolveUnmanagedDllToPath(unmanagedDllName);
            return unmanagedDllPath == null ? IntPtr.Zero : LoadUnmanagedDllFromPath(unmanagedDllPath);
        }
    }
}

Fix to be able to load unmanaged dlls in the carna-runner.


using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using Census.Interfaces;

namespace Census.UmbracoObject
{
    public class Property : IUmbracoObject
    {
        public string Name { get { return "Document Type"; } }

        public List<string> BackofficePages
        {
            get { return new List<string>() {"/settings/editNodeTypeNew.aspx"}; }
        }

        DataTable IUmbracoObject.ToDataTable(object usages)
        {
            return ToDataTable(usages);
        }

        public static DataTable ToDataTable(object usages, int propertyId = 0)
        {
            var documentTypes = (IEnumerable<global::umbraco.cms.businesslogic.web.DocumentType>) usages;

            var dt = new DataTable();
            dt.Columns.Add("Name");
            dt.Columns.Add("Alias");
            dt.Columns.Add("Property");

            foreach (var documentType in documentTypes)
            {
                var row = dt.NewRow();
                row["Name"] = Helper.GenerateLink(documentType.Text, "settings", "/settings/editNodeTypeNew.aspx?id=" + documentType.Id, "settingMasterDataType.gif");
                row["Alias"] = documentType.Alias;
                if (propertyId > 0)
                {
                    var prop = documentType.PropertyTypes.FirstOrDefault(x => x.DataTypeDefinition.Id == propertyId);
                    if (prop != null)
                        row["Property"] = prop.Name;
                }
                dt.Rows.Add(row);
                row.AcceptChanges();
            }

            return dt;
        }

    }
}

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using Census.Interfaces;

namespace Census.UmbracoObject
{
    public class Property : IUmbracoObject
    {
        public string Name { get { return "Document Type"; } }

        public List<string> BackofficePages
        {
            get { return new List<string>() {"/settings/editNodeTypeNew.aspx"}; }
        }

        DataTable IUmbracoObject.ToDataTable(object usages)
        {
            return ToDataTable(usages);
        }

        public static DataTable ToDataTable(object usages, int propertyId = 0)
        {
            var documentTypes = (IEnumerable<global::umbraco.cms.businesslogic.web.DocumentType>) usages;

            var dt = new DataTable();
            dt.Columns.Add("Name");
            dt.Columns.Add("Alias");
            dt.Columns.Add("Property");

            foreach (var documentType in documentTypes)
            {
                var row = dt.NewRow();
                row["Name"] = Helper.GenerateLink(documentType.Text, "settings", "/settings/editNodeTypeNew.aspx?id=" + documentType.Id, "settingMasterDataType.gif");
                row["Alias"] = documentType.Alias;
                if (propertyId != 0)
                {
                    var prop = documentType.PropertyTypes.FirstOrDefault(x => x.DataTypeDefinition.Id == propertyId);
                    if (prop != null)
                        row["Property"] = prop.Name;
                }
                dt.Rows.Add(row);
                row.AcceptChanges();
            }

            return dt;
        }

    }
}

FIx issue looking up property aliases for built-in datatypes


// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE

using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input;

namespace osu.Game.Graphics.UserInterface
{
    /// <summary>
    /// A button with added default sound effects.
    /// </summary>
    public class OsuButton : Button
    {
        private SampleChannel sampleClick;
        private SampleChannel sampleHover;

        protected override bool OnClick(InputState state)
        {
            sampleClick?.Play();
            return base.OnClick(state);
        }

        protected override bool OnHover(InputState state)
        {
            sampleHover?.Play();
            return base.OnHover(state);
        }

        [BackgroundDependencyLoader]
        private void load(OsuColour colours, AudioManager audio)
        {
            sampleClick = audio.Sample.Get(@"UI/generic-select");
            sampleHover = audio.Sample.Get(@"UI/generic-hover");
        }
    }
}

// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE

using System.ComponentModel;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Extensions;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input;

namespace osu.Game.Graphics.UserInterface
{
    /// <summary>
    /// A button with added default sound effects.
    /// </summary>
    public class OsuButton : Button
    {
        private SampleChannel sampleClick;
        private SampleChannel sampleHover;

        protected HoverSampleSet SampleSet = HoverSampleSet.Normal;

        protected override bool OnClick(InputState state)
        {
            sampleClick?.Play();
            return base.OnClick(state);
        }

        protected override bool OnHover(InputState state)
        {
            sampleHover?.Play();
            return base.OnHover(state);
        }

        [BackgroundDependencyLoader]
        private void load(AudioManager audio)
        {
            sampleClick = audio.Sample.Get($@"UI/generic-select{SampleSet.GetDescription()}");
            sampleHover = audio.Sample.Get($@"UI/generic-hover{SampleSet.GetDescription()}");
        }

        public enum HoverSampleSet
        {
            [Description("")]
            Normal,
            [Description("-soft")]
            Soft,
            [Description("-softer")]
            Softer
        }
    }
}

Add choices of hover sample sets

Add choices of hover sample sets


using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Mlabs.Ogg.Metadata;

namespace Mlabs.Ogg
{
    public class OggReader
    {
        private readonly Stream m_fileStream;
        private readonly bool m_owns;

        public OggReader(string fileName)
        {
            if (fileName == null) throw new ArgumentNullException("fileName");
            m_fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
            m_owns = true;
        }

        public OggReader(Stream fileStream)
        {
            if (fileStream == null) throw new ArgumentNullException("fileStream");
            m_fileStream = fileStream;
            m_owns = false;
        }

        public IStreamInfo Read()
        {
            var p = new PageReader();
            var pages = p.ReadPages(m_fileStream).ToList();
            if (m_owns)
                m_fileStream.Dispose();
            return null;
        }
    }
}

using System;
using System.IO;
using System.Linq;

namespace Mlabs.Ogg
{
    public class OggReader
    {
        private readonly Stream m_fileStream;
        private readonly bool m_owns;

        public OggReader(string fileName)
        {
            if (fileName == null) throw new ArgumentNullException("fileName");
            m_fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
            m_owns = true;
        }

        public OggReader(Stream fileStream)
        {
            if (fileStream == null) throw new ArgumentNullException("fileStream");
            m_fileStream = fileStream;
            m_owns = false;
        }

        public IOggInfo Read()
        {
            long originalOffset = m_fileStream.Position;

            var p = new PageReader();
            //read pages and break them down to streams
            var pages = p.ReadPages(m_fileStream).GroupBy(e => e.StreamSerialNumber);

            if (m_owns)
            {
                m_fileStream.Dispose();
            }
            else
            {
                //if we didn't create stream rewind it, so that user won't get any surprise :)
                m_fileStream.Seek(originalOffset, SeekOrigin.Begin);
            }
            return null;
        }
    }
}

Read pages and break them down into streams If file stream was not owned by us, rewind it after reading


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using RimTrans.Builder;
using RimTrans.Builder.Crawler;

namespace RimTransLibTest {
    public static class GenHelper {
        public static void Gen_DefTypeNameOf() {
            Console.Write(DefTypeCrawler.GenCode(true, false));
        }

        public static void Gen_DefsTemplate() {
            DefinitionData coreDefinitionData = DefinitionData.Load(@"D:\Games\SteamLibrary\steamapps\common\RimWorld\Mods\Core\Defs");

            Capture capture = Capture.Parse(coreDefinitionData);
            capture.ProcessFieldNames(coreDefinitionData);
            coreDefinitionData.Save(@"D:\git\rw\RimWorld-Defs-Templates\CoreDefsProcessed");

            string sourceCodePath = @"D:\git\rw\RimWorld-Decompile\Assembly-CSharp";
            Capture templates = Capture.Parse(coreDefinitionData, sourceCodePath, true);
            templates.Save(@"D:\git\rw\RimWorld-Defs-Templates\Templates");
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using RimTrans.Builder;
using RimTrans.Builder.Crawler;

namespace RimTransLibTest {
    public static class GenHelper {
        public static void Gen_DefTypeNameOf() {
            Console.Write(DefTypeCrawler.GenCode(true, false));
        }

        public static void Gen_DefsTemplate() {
            DefinitionData coreDefinitionData = DefinitionData.Load(@"D:\Games\SteamLibrary\steamapps\common\RimWorld\Mods\Core\Defs");

            Capture capture = Capture.Parse(coreDefinitionData);
            capture.ProcessFieldNames(coreDefinitionData);
            coreDefinitionData.Save(@"C:\git\rw\RimWorld-Defs-Templates\CoreDefsProcessed");

            string sourceCodePath = @"C:\git\rw\RimWorld-Decompile\Assembly-CSharp";
            Capture templates = Capture.Parse(coreDefinitionData, sourceCodePath, true);
            templates.Save(@"C:\git\rw\RimWorld-Defs-Templates\Templates");
        }
    }
}

Change path for def template generator

Change path for def template generator


// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE

using osu.Framework.Timing;

namespace osu.Framework.Audio.Track
{
    public class TrackVirtual : Track
    {
        private readonly StopwatchClock clock = new StopwatchClock();

        private double seekOffset;

        public override bool Seek(double seek)
        {
            double current = CurrentTime;

            seekOffset = seek;
            lock (clock) clock.Restart();

            if (Length > 0 && seekOffset > Length)
                seekOffset = Length;

            return current != seekOffset;
        }

        public override void Start()
        {
            lock (clock) clock.Start();
        }

        public override void Reset()
        {
            lock (clock) clock.Reset();
            seekOffset = 0;

            base.Reset();
        }

        public override void Stop()
        {
            lock (clock) clock.Stop();
        }

        public override bool IsRunning
        {
            get
            {
                lock (clock) return clock.IsRunning;
            }
        }

        public override bool HasCompleted
        {
            get
            {
                lock (clock) return base.HasCompleted || IsLoaded && !IsRunning && CurrentTime >= Length;
            }
        }

        public override double CurrentTime
        {
            get
            {
                lock (clock) return seekOffset + clock.CurrentTime;
            }
        }

        public override void Update()
        {
            lock (clock)
            {
                if (CurrentTime >= Length)
                    Stop();
            }
        }
    }
}

// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE

using osu.Framework.Timing;

namespace osu.Framework.Audio.Track
{
    public class TrackVirtual : Track
    {
        private readonly StopwatchClock clock = new StopwatchClock();

        private double seekOffset;

        public TrackVirtual()
        {
            Length = double.MaxValue;
        }

        public override bool Seek(double seek)
        {
            double current = CurrentTime;

            seekOffset = seek;
            lock (clock) clock.Restart();

            if (Length > 0 && seekOffset > Length)
                seekOffset = Length;

            return current != seekOffset;
        }

        public override void Start()
        {
            lock (clock) clock.Start();
        }

        public override void Reset()
        {
            lock (clock) clock.Reset();
            seekOffset = 0;

            base.Reset();
        }

        public override void Stop()
        {
            lock (clock) clock.Stop();
        }

        public override bool IsRunning
        {
            get
            {
                lock (clock) return clock.IsRunning;
            }
        }

        public override bool HasCompleted
        {
            get
            {
                lock (clock) return base.HasCompleted || IsLoaded && !IsRunning && CurrentTime >= Length;
            }
        }

        public override double CurrentTime
        {
            get
            {
                lock (clock) return seekOffset + clock.CurrentTime;
            }
        }

        public override void Update()
        {
            lock (clock)
            {
                if (CurrentTime >= Length)
                    Stop();
            }
        }
    }
}

Make virtual tracks reeeeeeeaaally long

Make virtual tracks reeeeeeeaaally long


<?xml version="1.0"?>
<!-- RSS generated by Trac v<?cs var:trac.version ?> on <?cs var:trac.time ?> -->
<rss version="2.0">
 <channel><?cs
  if:project.name_encoded ?>
   <title><?cs var:project.name_encoded ?>: Revisions of <?cs var:log.path ?></title><?cs
  else ?>
   <title>Revisions of <?cs var:log.path ?></title><?cs
  /if ?>
  <link><?cs var:base_host ?><?cs var:log.log_href ?></link>
  <description>Trac Log - Revisions of <?cs var:log.path ?></description>
  <language>en-us</language>
  <generator>Trac v<?cs var:trac.version ?></generator><?cs
  each:item = log.items ?><?cs
   with:change = log.changes[item.rev] ?>
    <item>
     <author><?cs var:change.author ?></author>
     <pubDate><?cs var:change.date ?></pubDate>
     <title>Revision <?cs var:item.rev ?>: <?cs var:change.shortlog ?></title>
     <link><?cs var:base_host ?><?cs var:item.changeset_href ?></link>
     <description><?cs var:change.message ?></description>
     <category>Report</category>
    </item><?cs
   /with ?><?cs
  /each ?>
 </channel>
</rss>

<?xml version="1.0"?>
<!-- RSS generated by Trac v<?cs var:trac.version ?> on <?cs var:trac.time ?> -->
<rss version="2.0">
 <channel><?cs
  if:project.name_encoded ?>
   <title><?cs var:project.name_encoded ?>: Revisions of <?cs var:log.path ?></title><?cs
  else ?>
   <title>Revisions of <?cs var:log.path ?></title><?cs
  /if ?>
  <link><?cs var:base_host ?><?cs var:log.log_href ?></link>
  <description>Trac Log - Revisions of <?cs var:log.path ?></description>
  <language>en-us</language>
  <generator>Trac v<?cs var:trac.version ?></generator><?cs
  each:item = log.items ?><?cs
   with:change = log.changes[item.rev] ?>
    <item>
     <author><?cs var:change.author ?></author>
     <pubDate><?cs var:change.date ?></pubDate>
     <title>Revision <?cs var:item.rev ?>: <?cs var:change.shortlog ?></title>
     <link><?cs var:base_host ?><?cs var:item.changeset_href ?></link>
     <description><?cs var:change.message ?></description>
     <category>Log</category>
    </item><?cs
   /with ?><?cs
  /each ?>
 </channel>
</rss>

Fix category of revision log RSS feeds.

Fix category of revision log RSS feeds.

git-svn-id: eda3d06fcef731589ace1b284159cead3416df9b@2261 af82e41b-90c4-0310-8c96-b1721e28e2e2


namespace ZWave.CommandClasses
{
    public enum ThermostatFanModeValue : byte
    {
        AutoLow = 0x00,
        Low = 0x01,
        AutoHigh = 0x02,
        High = 0x03,
        AutoMedium = 0x04,
        Medium = 0x05,
        Circulation = 0x06,
        HumidityCirculation = 0x07,
        LeftAndRight = 0x08,
        UpAndDown = 0x09,
        Quiet = 0x0A,
        ExternalCirculation = 0x0B,
        EnergyCool = 0x0C,
        Away = 0x0D,
        Reserved = 0x0E,
        FullPower = 0x0F,
        ManufacturerSpecific = 0x1F
    };
}

namespace ZWave.CommandClasses
{
    public enum ThermostatFanModeValue : byte
    {
        AutoLow = 0x00,
        Low = 0x01,
        AutoHigh = 0x02,
        High = 0x03,
        AutoMedium = 0x04,
        Medium = 0x05,
        Circulation = 0x06,
        HumidityCirculation = 0x07,
        LeftAndRight = 0x08,
        UpAndDown = 0x09,
        Quiet = 0x0A,
        ExternalCirculation = 0x0B
    };
}

Remove these enum values that were copy-pasted by mistake.


using System;
using System.ComponentModel.DataAnnotations;

namespace VotingApplication.Web.Api.Models.DBViewModels
{
    public class PollCreationRequestModel
    {
        [Required]
        public string Name { get; set; }

        [Required]
        public string Creator { get; set; }

        [Required]
        public string VotingStrategy { get; set; }

        [EmailAddress]
        public string Email { get; set; }

        [Range(1, int.MaxValue)]
        public int MaxPoints { get; set; }

        [Range(1, int.MaxValue)]
        public int MaxPerVote { get; set; }

        public long TemplateId { get; set; }
        public bool InviteOnly { get; set; }
        public bool NamedVoting { get; set; }
        public bool RequireAuth { get; set; }
        public bool Expires { get; set; }
        public DateTimeOffset ExpiryDate { get; set; }

        public bool OptionAdding { get; set; }
    }
}

using System;
using System.ComponentModel.DataAnnotations;

namespace VotingApplication.Web.Api.Models.DBViewModels
{
    public class PollCreationRequestModel
    {
        [Required]
        public string Name { get; set; }

        [Required]
        public string Creator { get; set; }

        [Required]
        public string VotingStrategy { get; set; }

        [EmailAddress]
        public string Email { get; set; }

        [Range(1, int.MaxValue)]
        public int MaxPoints { get; set; }

        [Range(1, int.MaxValue)]
        public int MaxPerVote { get; set; }

        public long TemplateId { get; set; }
        public bool InviteOnly { get; set; }
        public bool NamedVoting { get; set; }
        public bool RequireAuth { get; set; }
        public bool Expires { get; set; }
        public DateTimeOffset? ExpiryDate { get; set; }

        public bool OptionAdding { get; set; }
    }
}

Fix expiry date on create new poll

Fix expiry date on create new poll

New polls being created with expiry date of 01/01/0001 as ExpiryDate is
not nullable in the PollCreationRequestModel.


#region

using System;
using Tabster.Core.Plugins;

#endregion

namespace TextFile
{
    public class TextFilePlugin : ITabsterPlugin
    {
        #region Implementation of ITabsterPlugin

        public string Author
        {
            get { return "Nate Shoffner"; }
        }

        public string Copyright
        {
            get { return "Copyright © Nate Shoffner 2014"; }
        }

        public string Description
        {
            get { return "Supports importing and exporting to/from text (.txt) files. "; }
        }

        public string DisplayName
        {
            get { return "Textfile support"; }
        }

        public Version Version
        {
            get { return new Version("1.0"); }
        }

        public Uri Website
        {
            get { return new Uri("http://nateshoffner.com"); }
        }

        public void Activate()
        {
            // not implemented
        }

        public void Deactivate()
        {
            // not implemented
        }

        public Type[] Types
        {
            get { return new[] {typeof (TextFileExporter), typeof (TextFileImporter)}; }
        }

        #endregion
    }
}

#region

using System;
using Tabster.Core.Plugins;

#endregion

namespace TextFile
{
    public class TextFilePlugin : ITabsterPlugin
    {
        #region Implementation of ITabsterPlugin

        public string Author
        {
            get { return "Nate Shoffner"; }
        }

        public string Copyright
        {
            get { return "Copyright © Nate Shoffner 2014"; }
        }

        public string Description
        {
            get { return "Supports importing and exporting to/from text (.txt) files. "; }
        }

        public string DisplayName
        {
            get { return "Textfile support"; }
        }

        public Version Version
        {
            get { return new Version("1.0"); }
        }

        public Uri Website
        {
            get { return new Uri("http://nateshoffner.com"); }
        }

        public void Activate()
        {
            // not implemented
        }

        public void Deactivate()
        {
            // not implemented
        }

        public void Initialize()
        {
            // not implemented
        }

        public Type[] Types
        {
            get { return new[] {typeof (TextFileExporter), typeof (TextFileImporter)}; }
        }

        #endregion
    }
}

Add Initialize() method to ITabsterPlugin


using Core;
using StructureMap;
using System;
using Xunit;

namespace Tests
{
    public class ValidationTests
    {
        [Fact]
        public void VerifyValidConfiguration()
        {
            var container = new Container(x =>
            {
                x.For<IService>().Use<Service>();
            });

            container.AssertConfigurationIsValid();
        }

        [Fact]
        public void VerifyInvalidConfiguration()
        {
            var container = new Container(x =>
            {
                x.For<IService>().Use<BrokenService>();
            });

            Assert.Throws<StructureMapConfigurationException>(
                () => container.AssertConfigurationIsValid());
        }

        public class BrokenService : IService
        {
            public string Id { get; private set; }

            [ValidationMethod]
            public void BrokenMethod()
            {
                throw new ApplicationException();
            }
        }
    }
}

using Core;
using StructureMap;
using System;
using Xunit;

namespace Tests
{
    public class ValidationTests
    {
        [Fact]
        public void MissingRequiredConstructorArgument()
        {
            var container = new Container(x =>
            {
                x.For<IService>().Use<ServiceWithCtorArg>();
            });

            Assert.Throws<StructureMapConfigurationException>(
                () => container.AssertConfigurationIsValid());
        }

        [Fact]
        public void VerifyValidConfiguration()
        {
            var container = new Container(x =>
            {
                x.For<IService>().Use<Service>();
            });

            container.AssertConfigurationIsValid();
        }

        [Fact]
        public void VerifyInvalidConfiguration()
        {
            var container = new Container(x =>
            {
                x.For<IService>().Use<BrokenService>();
            });

            Assert.Throws<StructureMapConfigurationException>(
                () => container.AssertConfigurationIsValid());
        }

        public class BrokenService : IService
        {
            public string Id { get; private set; }

            [ValidationMethod]
            public void BrokenMethod()
            {
                throw new ApplicationException();
            }
        }
    }
}

Add AssertConfigurationIsValid test for missing ctor parameter


@page
@model Disable2faModel
@{
    ViewData["Title"] = "Disable two-factor authentication (2FA)";
    ViewData["ActivePage"] = "TwoFactorAuthentication";
}

@ViewData["Title"]

        This action only disables 2FA.

        Disabling 2FA does not change the keys used in authenticator apps. If you wish to change the key
        used in an authenticator app you should reset your authenticator keys.

    <form method="post" class="form-group">
        <button class="btn btn-danger" type="submit">Disable 2FA</button>
    </form>

Use anchor tag helper instead of hard coded href


// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using osu.Framework.Graphics;
using osu.Game.Graphics.UserInterface;

namespace osu.Game.Overlays.Settings
{
    public class SettingsCheckbox : SettingsItem<bool>
    {
        private OsuCheckbox checkbox;

        protected override Drawable CreateControl() => checkbox = new OsuCheckbox();

        public override string LabelText
        {
            set => checkbox.LabelText = value;
        }
    }
}

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using osu.Framework.Graphics;
using osu.Game.Graphics.UserInterface;

namespace osu.Game.Overlays.Settings
{
    public class SettingsCheckbox : SettingsItem<bool>
    {
        private OsuCheckbox checkbox;

        private string labelText;

        protected override Drawable CreateControl() => checkbox = new OsuCheckbox();

        public override string LabelText
        {
            get => labelText;
            set => checkbox.LabelText = labelText = value;
        }
    }
}

Fix settings checkboxes not being searchable


using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;
using System.IO;
using YaTools.Yaml;
using Raven;
using Raven.Client;
using Raven.Client.Document;
using Raven.Client.Embedded;
using Raven.Storage;
using Raven.Database;

namespace Craftitude
{
    public class RepositoryCache : IDisposable
    {
        internal EmbeddableDocumentStore _db;
        internal Cache _cache;

        internal RepositoryCache(Cache cache, string cacheId)
        {
            _cache = cache;
            _db = new EmbeddableDocumentStore()
            {
                DataDirectory = Path.Combine(_cache._path, cacheId)
            };
            if (!Directory.Exists(_db.DataDirectory))
                Directory.CreateDirectory(_db.DataDirectory);
            _db.Initialize();
        }

        public void Dispose()
        {
            if (!_db.WasDisposed)
                _db.Dispose();
        }

        public void SavePackage(string id, Package package)
        {
            using (var session = _db.OpenSession())
            {
                session.Store(package, id);
            }
        }
    }
}

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;
using System.IO;
using YaTools.Yaml;
using Raven;
using Raven.Client;
using Raven.Client.Document;
using Raven.Client.Embedded;
using Raven.Storage;
using Raven.Database;

namespace Craftitude
{
    public class RepositoryCache : IDisposable
    {
        internal EmbeddableDocumentStore _db;
        internal Cache _cache;

        internal RepositoryCache(Cache cache, string cacheId)
        {
            _cache = cache;
            _db = new EmbeddableDocumentStore()
            {
                DataDirectory = Path.Combine(_cache._path, cacheId)
            };
            if (!Directory.Exists(_db.DataDirectory))
                Directory.CreateDirectory(_db.DataDirectory);
            _db.Initialize();
        }

        public void Dispose()
        {
            if (!_db.WasDisposed)
                _db.Dispose();
        }

        public void DeletePackage(string id, Package package)
        {
            using (var session = _db.OpenSession())
            {
                session.Delete(package);
                session.SaveChanges();
            }
        }

        public void SavePackage(string id, Package package)
        {
            using (var session = _db.OpenSession())
            {
                session.Store(package, id);
                session.SaveChanges();
            }
        }

        public Package[] GetPackages(params string[] IDs)
        {
            using (var session = _db.OpenSession())
            {
                return session.Load<Package>(IDs);
            }
        }

        public Package GetPackage(string ID)
        {
            using (var session = _db.OpenSession())
            {
                return session.Load<Package>(ID);
            }
        }
    }
}

Allow deletion and reading of saved package information.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Engine.Mappings
{
    public interface IMapping<T>
    {
        void print();
        T get_pos(ICoordinate coord);
        bool pos_exists(ICoordinate coord);
        bool add_to_pos(T addition, ICoordinate coord);
        bool remove_from_pos(ICoordinate coord);
    }

    public interface IMapUpdatable
    {
        bool can_move(ICoordinate startCoord, ICoordinate endCoord);
        bool move(ICoordinate startCoord, ICoordinate endCoord);
    }

    public interface IMapUpdateReadable<T>
    {
        void print();
        T get_pos(ICoordinate coord);
        bool pos_exists(ICoordinate coord);
    }

}

using Engine.Mappings.Coordinates;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Engine.Mappings
{

    public interface IMapWriteable<T>
    {
        bool can_move(ICoordinate<T> startCoord, ICoordinate<T> endCoord);
        bool move(ICoordinate<T> startCoord, ICoordinate<T> endCoord);
    }

    public interface IMapReadable<T, S>
    {
        void print();
        S get_pos(ICoordinate<T> coord);
        bool pos_exists(ICoordinate<T> coord);
    }

}

Split apart and made generic the interfaces for maps following interface segregation and CQRS


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceModel;
using System.ServiceProcess;
using System.Text;
using System.Threading.Tasks;

namespace WinSerHost
{
    public partial class Service1 : ServiceBase
    {
        public Service1()
        {
            InitializeComponent();
        }

        private ServiceHost host;

        protected override void OnStart(string[] args)
        {
            if (host != null)
            {
                host.Close();
            }
            host = new ServiceHost(typeof(BankAService.BankAService));
            host.Open();
        }

        protected override void OnStop()
        {
            if (host != null)
            {
                host.Close();
            }
            host = null;
        }
    }
}

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceModel;
using System.ServiceProcess;
using System.Text;
using System.Threading.Tasks;

namespace WinSerHost
{
    // For this service to work correctly,
    // we must run the following command in Admin mode,
    // netsh http add urlacl url=http://+:9889/BankA user="NT AUTHORITY\NETWORKSERVICE"
    public partial class Service1 : ServiceBase
    {
        public Service1()
        {
            InitializeComponent();
        }

        private ServiceHost host;

        protected override void OnStart(string[] args)
        {
            if (host != null)
            {
                host.Close();
            }
            host = new ServiceHost(typeof(BankAService.BankAService));
            host.Open();
        }

        protected override void OnStop()
        {
            if (host != null)
            {
                host.Close();
            }
            host = null;
        }
    }
}

Add command in the comment.

Add command in the comment.


using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("ZeroLog.Tests")]
[assembly: InternalsVisibleTo("ZeroLog.Benchmarks")]

#if NETCOREAPP && !NETCOREAPP2_1
[module: SkipLocalsInit]
#endif

Use SkipLocalsInit on .NET 5

Use SkipLocalsInit on .NET 5


using SnakeApp.Graphics;
using System;

namespace SnakeApp.Models
{
	public class Food
	{
		public Food()
		{
			DateCreated = DateTime.Now;
		}

		public Food(byte score, Point position, byte secondsToLive) : this()
		{
			Score = score;
			Position = position;
			SecondsToLive = secondsToLive;
		}

		public Point Position { get; private set; }

		public DateTime DateCreated { get; private set; }

		public byte Score { get; private set; }

		public bool DrawnAsRotten { get; set; }

		public bool IsConsumed { get; set; }

		public byte SecondsToLive { get; set; }
	}
}

using SnakeApp.Graphics;
using System;

namespace SnakeApp.Models
{
	public class Food
	{
		public Food()
		{
			DateCreated = DateTime.Now;
		}

		public Food(byte score, Point position, byte secondsToLive) : this()
		{
			Score = score;
			Position = position;
			SecondsToLive = secondsToLive;
		}

		public Point Position { get; private set; }

		public DateTime DateCreated { get; private set; }

		public byte Score { get; private set; }

		public byte SecondsToLive { get; private set; }

		public bool DrawnAsRotten { get; set; }

		public bool IsConsumed { get; set; }
	}
}

Make the food TTL setter private.

Make the food TTL setter private.


namespace Gu.Wpf.Geometry.UiTests
{
    using Gu.Wpf.UiAutomation;
    using NUnit.Framework;

    public class MainWindowTests
    {
        [Test]
        public void ClickAllTabs()
        {
            // Just a smoke test so that we do not explode.
            using (var app = Application.Launch("Gu.Wpf.Geometry.Demo.exe"))
            {
                var window = app.MainWindow;
                var tab = window.FindTabControl();
                foreach (var tabItem in tab.Items)
                {
                    _ = tabItem.Select();
                }
            }
        }
    }
}

namespace Gu.Wpf.Geometry.UiTests
{
    using System;
    using Gu.Wpf.UiAutomation;
    using NUnit.Framework;

    public class MainWindowTests
    {
        [Test]
        public void ClickAllTabs()
        {
            // Just a smoke test so that we do not explode.
            using (var app = Application.Launch("Gu.Wpf.Geometry.Demo.exe"))
            {
                app.WaitForMainWindow(TimeSpan.FromSeconds(10));
                var window = app.MainWindow;
                var tab = window.FindTabControl();
                foreach (var tabItem in tab.Items)
                {
                    _ = tabItem.Select();
                }
            }
        }
    }
}

Add timeout waiting for MainWindow.

Add timeout waiting for MainWindow.

Attempt at fixing flaky UI-tests on AppVeyor.


//-----------------------------------------------------------------------
// <copyright file="ListaOperatoriResult.cs" company="CNVVF">
// Copyright (C) 2017 - CNVVF
//
// This file is part of SOVVF.
// SOVVF is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// SOVVF is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see http://www.gnu.org/licenses/.
// </copyright>
//-----------------------------------------------------------------------
using SO115App.API.Models.Classi.Autenticazione;
using SO115App.Models.Classi.Condivise;
using System;
using System.Collections.Generic;
using System.Text;

namespace SO115App.Models.Servizi.CQRS.Queries.GestioneUtente.ListaOperatori
{
    public class ListaOperatoriResult
    {
        public Paginazione Pagination { get; set; }
        public List<Utente> DataArray { get; set; }
    }
}

//-----------------------------------------------------------------------
// <copyright file="ListaOperatoriResult.cs" company="CNVVF">
// Copyright (C) 2017 - CNVVF
//
// This file is part of SOVVF.
// SOVVF is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// SOVVF is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see http://www.gnu.org/licenses/.
// </copyright>
//-----------------------------------------------------------------------
using SO115App.API.Models.Classi.Autenticazione;
using SO115App.Models.Classi.Condivise;
using System;
using System.Collections.Generic;
using System.Text;

namespace SO115App.Models.Servizi.CQRS.Queries.GestioneUtente.ListaOperatori
{
    public class ListaOperatoriResult
    {
        public Paginazione Pagination { get; set; }
        public List<Utente> DataArray { get; set; }
        public List<string> ListaSediPresenti { get; set; }
    }
}

Add - Aggiunta proprietà lista sedi alla result degli utenti nella gestione utenti


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

using System;

namespace Google.Cloud.Firestore.Admin.V1.SmokeTests
{
    public sealed class FirestoreAdminSmokeTest
    {
        private const string ProjectEnvironmentVariable = "FIRESTORE_TEST_PROJECT";

        public static int Main(string[] args)
        {
            string projectId = Environment.GetEnvironmentVariable(ProjectEnvironmentVariable);
            if (string.IsNullOrEmpty(projectId))
            {
                Console.WriteLine($"Environment variable {ProjectEnvironmentVariable} must be set.");
                return 1;
            }

            // Create client
            FirestoreAdminClient client = FirestoreAdminClient.Create();

            // Initialize request argument
            ParentName parentName = new ParentName(projectId, "(default)", "collection");

            // Call API method
            var indexes = client.ListIndexes(parentName);

            // Show the result
            foreach (var index in indexes)
            {
                Console.WriteLine(index);
            }

            // Success
            Console.WriteLine("Smoke test passed OK");
            return 0;
        }
    }
}

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

using System;

namespace Google.Cloud.Firestore.Admin.V1.SmokeTests
{
    public sealed class FirestoreAdminSmokeTest
    {
        private const string ProjectEnvironmentVariable = "FIRESTORE_TEST_PROJECT";

        public static int Main(string[] args)
        {
            string projectId = Environment.GetEnvironmentVariable(ProjectEnvironmentVariable);
            if (string.IsNullOrEmpty(projectId))
            {
                Console.WriteLine($"Environment variable {ProjectEnvironmentVariable} must be set.");
                return 1;
            }

            // Create client
            FirestoreAdminClient client = FirestoreAdminClient.Create();

            // Initialize request argument
            CollectionGroupName collectionGroupName = CollectionGroupName.FromProjectDatabaseCollection(projectId, "(default)", "collection");

            // Call API method
            var indexes = client.ListIndexes(collectionGroupName);

            // Show the result
            foreach (var index in indexes)
            {
                Console.WriteLine(index);
            }

            // Success
            Console.WriteLine("Smoke test passed OK");
            return 0;
        }
    }
}

Fix manual smoke test for Google.Cloud.Firestore.Admin.V1

(Known breaking change for resource names.)


using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MouthOfEvilController : MonoBehaviour {

	public List<EvilEyeScript> evilEyes;
	public int mouthOfEvilHealth = 12;
	private int hitsLeftInPhase;
	public int maxHitsPerPhase = 4;
	public bool isInPhase = false;

	void Awake () {
		foreach(EvilEyeScript eye in evilEyes){
			eye.isActive = false;
		}
		hitsLeftInPhase = 4;
		isInPhase = false;
	}

	// Update is called once per frame
	void Update () {

	}
}

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MouthOfEvilController : MonoBehaviour {

	public List<EvilEyeScript> evilEyes;
	public int mouthOfEvilHealth = 12;
	private int hitsLeftInPhase;
	public int maxHitsPerPhase = 4;
	public bool isInPhase = false;
	public int totalPhases;
	public int currentPhase;
	public bool isBossFightActive = false;

	void Awake () {
		foreach(EvilEyeScript eye in evilEyes){
			eye.isActive = false;
		}
		hitsLeftInPhase = 4;
		isInPhase = false;
	}

	// Update is called once per frame
	void Update () {
		if(isBossFightActive){
			if(hitsLeftInPhase <= 0){
				IteratePhase();
			}
		}
	}

	private void IteratePhase(){
		currentPhase++;
		return;
	}

	//stolen from: https://forum.unity.com/threads/make-a-sprite-flash.224086/
	IEnumerator FlashSprites(SpriteRenderer[] sprites, int numTimes, float delay, bool disable = false) {
        // number of times to loop
        for (int loop = 0; loop < numTimes; loop++) {
            // cycle through all sprites
            for (int i = 0; i < sprites.Length; i++) {
                if (disable) {
                    // for disabling
                    sprites[i].enabled = false;
                } else {
                    // for changing the alpha
                    sprites[i].color = new Color(sprites[i].color.r, sprites[i].color.g, sprites[i].color.b, 0.5f);
                }
            }

            // delay specified amount
            yield return new WaitForSeconds(delay);

            // cycle through all sprites
            for (int i = 0; i < sprites.Length; i++) {
                if (disable) {
                    // for disabling
                    sprites[i].enabled = true;
                } else {
                    // for changing the alpha
                    sprites[i].color = new Color(sprites[i].color.r, sprites[i].color.g, sprites[i].color.b, 1);
                }
            }

            // delay specified amount
            yield return new WaitForSeconds(delay);
        }
    }
}

Add non-complete boss controller script

Add non-complete boss controller script


using System;

namespace PropertyChanged
{
    /// <summary>
    /// Include a <see cref="Type"/> for notification.
    /// The INotifyPropertyChanged interface is added to the type.
    /// </summary>
    [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
    public class ImplementPropertyChangedAttribute : Attribute
    {
    }
}

using System;

namespace PropertyChanged
{
    /// <summary>
    /// Specifies that PropertyChanged Notification will be added to a class.
    /// PropertyChanged.Fody will weave the <c>INotifyPropertyChanged</c> interface and implementation into the class.
    /// When the value of a property changes, the PropertyChanged notification will be raised automatically
    /// See https://github.com/Fody/PropertyChanged for more information.
    /// </summary>
    [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
    public class ImplementPropertyChangedAttribute : Attribute
    {
    }
}

Improve the interface documentation for the attribute

I had a discussion with a coworker. It went like:
Him: "Dude that's not going to work. You need to raise PropertyChanged when changing a property. Don't you know MVVM?"
Me: "It's compile-time weaved into the code".
Him: "What are you talking about?" (looking at me like i'd be insane)
Me: "Yeah, you know, AOP. You allways need to raise the PropertyChanged event when any property on any ViewModel changes. It's too boring and i'm too lazy, so i use this (PropertyChanged.Fody) tool which is doing it for me"
Him: "That sounds strange. I don't think this can work reliably. And it's way too complicated anyway. How would i know that it works like that and what it's doing? Do we really need something that complicated for something that simple? It's just a few lines of code per property. And you know, we can use some base class and reflection so it's refactor safe. Or we can use the new net4.5 feature [CallerMemberName]"

It went on for a while. Suffice to say that i managed to convince him of PropertyChanged.Fody's merits. However, one valid concern remains:

There's still very few developers using AOP / Fody in generall. In my company we are a few dozen .net developers. Only 3-4 know it. I'm working on improving that.

But anyway, i thought that a somewhat intelligent being confronted with legacy code would at least notice the [ImplementPropertyChanged] attribute. And thus i think it's necessary that the attribute's documentation, which can be seen in VisualStudio, should contain a bit more information, including a link to the project.
Because the property may very well be how the developer get's into contact with this awesome tool for the first time!


using System;
using System.Collections.Generic;
using NBi.Xml.Constraints;
using NBi.Xml.Systems;
using NBi.NUnit.Builder.Helper;
using NBi.Core.Configuration;
using NBi.Core.Injection;
using NBi.Core.Variable;
using NBi.Core.Scalar.Resolver;

namespace NBi.NUnit.Builder
{
    abstract class AbstractScalarBuilder : AbstractTestCaseBuilder
    {
        protected AbstractSystemUnderTestXml SystemUnderTestXml { get; set; }
        protected ScalarHelper Helper { get; private set; }

        public override void Setup(AbstractSystemUnderTestXml sutXml, AbstractConstraintXml ctrXml, IConfiguration config, IDictionary<string, ITestVariable> variables, ServiceLocator serviceLocator)
        {
            base.Setup(sutXml, ctrXml, config, variables, serviceLocator);
            Helper = new ScalarHelper(ServiceLocator, Variables);
        }

        protected override void BaseSetup(AbstractSystemUnderTestXml sutXml, AbstractConstraintXml ctrXml)
        {
            if (!(sutXml is ScalarXml))
                throw new ArgumentException("System-under-test must be a 'ScalarXml'");

            SystemUnderTestXml = sutXml;
        }

        protected override void BaseBuild()
        {
            if (SystemUnderTestXml is ScalarXml)
                SystemUnderTest = InstantiateSystemUnderTest((ScalarXml)SystemUnderTestXml);
        }

        protected virtual IScalarResolver<decimal> InstantiateSystemUnderTest(ScalarXml scalarXml) => Helper.InstantiateResolver<decimal>(scalarXml);

    }
}

using System;
using System.Collections.Generic;
using NBi.Xml.Constraints;
using NBi.Xml.Systems;
using NBi.NUnit.Builder.Helper;
using NBi.Core.Configuration;
using NBi.Core.Injection;
using NBi.Core.Variable;
using NBi.Core.Scalar.Resolver;
using NBi.Xml.Settings;

namespace NBi.NUnit.Builder
{
    abstract class AbstractScalarBuilder : AbstractTestCaseBuilder
    {
        protected ScalarXml SystemUnderTestXml { get; set; }

        public override void Setup(AbstractSystemUnderTestXml sutXml, AbstractConstraintXml ctrXml, IConfiguration config, IDictionary<string, ITestVariable> variables, ServiceLocator serviceLocator)
            => base.Setup(sutXml, ctrXml, config, variables, serviceLocator);

        protected override void BaseSetup(AbstractSystemUnderTestXml sutXml, AbstractConstraintXml ctrXml)
            => SystemUnderTestXml = sutXml as ScalarXml
            ?? throw new ArgumentException("System-under-test must be a 'ScalarXml'");

        protected override void BaseBuild()
            => SystemUnderTest = InstantiateSystemUnderTest(SystemUnderTestXml);

        protected virtual IScalarResolver<decimal> InstantiateSystemUnderTest(ScalarXml scalarXml)
            => new ScalarHelper(ServiceLocator, scalarXml.Settings, SettingsXml.DefaultScope.SystemUnderTest, Variables).InstantiateResolver<decimal>(scalarXml);

    }
}

Fix issue with Scalar testing where default connection-strings where not forwarded


using System.ComponentModel;
using System.Text;
using SharpLab.Runtime.Internal;

public static class SharpLabObjectExtensions {
    // LinqPad/etc compatibility only
    [EditorBrowsable(EditorBrowsableState.Never)]
    public static void Dump<T>(this T value) {
        value.Inspect(title: "Dump");
    }

    public static void Inspect<T>(this T value, string title = "Inspect") {
        var builder = new StringBuilder();
        ObjectAppender.Append(builder, value);
        var data = new SimpleInspectionResult(title, builder);
        Output.Write(data);
    }
}

using System.ComponentModel;
using System.Text;
using SharpLab.Runtime.Internal;

public static class SharpLabObjectExtensions {
    // LinqPad/etc compatibility only
    [EditorBrowsable(EditorBrowsableState.Never)]
    public static T Dump<T>(this T value)
        => value.Inspect(title: "Dump");

    public static T Inspect<T>(this T value, string title = "Inspect") {
        var builder = new StringBuilder();
        ObjectAppender.Append(builder, value);
        var data = new SimpleInspectionResult(title, builder);
        Output.Write(data);
        return value;
    }
}

Return object from Dump/Inspect extension methods.


using System;

namespace AppHarbor.Commands
{
	public class AddConfigCommand : ICommand
	{
		public AddConfigCommand()
		{
		}

		public void Execute(string[] arguments)
		{
			throw new NotImplementedException();
		}
	}
}

using System;

namespace AppHarbor.Commands
{
	public class AddConfigCommand : ICommand
	{
		private readonly IApplicationConfiguration _applicationConfiguration;

		public AddConfigCommand(IApplicationConfiguration applicationConfiguration)
		{
			_applicationConfiguration = applicationConfiguration;
		}

		public void Execute(string[] arguments)
		{
			throw new NotImplementedException();
		}
	}
}

Initialize AppConfigCommand with an IApplicationConfiguration


using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using FluentNHibernate.Mapping;

namespace FluentNHibernate.AutoMap
{
    public class AutoMapper
    {
        private readonly List<IAutoMapper> _mappingRules;

        public AutoMapper(Conventions conventions)
        {
            _mappingRules = new List<IAutoMapper>
                                {
                                    new AutoMapIdentity(conventions),
                                    new AutoMapVersion(conventions),
                                    new AutoMapColumn(conventions),
                                    new AutoMapManyToOne(conventions),
                                    new AutoMapOneToMany(conventions),
                                };
        }

        public AutoMap<T> MergeMap<T>(AutoMap<T> map)
        {
            foreach (var property in typeof(T).GetProperties())
            {
                if (!property.PropertyType.IsEnum)
                {
                    foreach (var rule in _mappingRules)
                    {
                        if (rule.MapsProperty(property))
                        {
                            if (map.PropertiesMapped.Count(p => p.Name == property.Name) == 0)
                            {
                                rule.Map(map, property);
                                break;
                            }
                        }
                    }
                }
            }
            return map;
        }

        public AutoMap<T> Map<T>()
        {
            var classMap = (AutoMap<T>)Activator.CreateInstance(typeof(AutoMap<T>));
            return MergeMap(classMap);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using FluentNHibernate.Mapping;

namespace FluentNHibernate.AutoMap
{
    public class AutoMapper
    {
        private readonly List<IAutoMapper> _mappingRules;

        public AutoMapper(Conventions conventions)
        {
            _mappingRules = new List<IAutoMapper>
                                {
                                    new AutoMapIdentity(conventions),
                                    new AutoMapVersion(conventions),
                                    new AutoMapColumn(conventions),
                                    new AutoMapManyToOne(conventions),
                                    new AutoMapOneToMany(conventions),
                                };
        }

        public AutoMap<T> MergeMap<T>(AutoMap<T> map)
        {
            foreach (var property in typeof(T).GetProperties())
            {
                if (property.PropertyType.IsClass)
                {
                    foreach (var rule in _mappingRules)
                    {
                        if (rule.MapsProperty(property))
                        {
                            if (map.PropertiesMapped.Count(p => p.Name == property.Name) == 0)
                            {
                                rule.Map(map, property);
                                break;
                            }
                        }
                    }
                }
            }
            return map;
        }

        public AutoMap<T> Map<T>()
        {
            var classMap = (AutoMap<T>)Activator.CreateInstance(typeof(AutoMap<T>));
            return MergeMap(classMap);
        }
    }
}

Change automapper to whitelist classes rather than blacklist enums.

git-svn-id: a161142445158cf41e00e2afdd70bb78aded5464@74 48f0ce17-cc52-0410-af8c-857c09b6549b


using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ObjectPool : MonoBehaviour
{
    [SerializeField]
    private GameObject _prefab;

    private Stack<GameObject> _pool;

    public GameObject prefab
    {
        set {
            _prefab = value;
        }
    }

    //TODO: Add possibility to differentiate between prefabs
    public GameObject GetGameObject()
    {
        if (_pool != null)
        {
            if (_pool.Count > 0)
                return _pool.Pop();
            else
                return GameObject.Instantiate<GameObject>(_prefab);
        }
        else
        {
            _pool = new Stack<GameObject>();
            return GameObject.Instantiate<GameObject>(_prefab);
        }
    }

    public void Put(GameObject obj)
    {
        if (_pool == null)
            _pool = new Stack<GameObject>();

        _pool.Push(obj);
    }
}

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ObjectPool : MonoBehaviour
{
    [SerializeField]
    private GameObject _defaultPrefab;

    #region Public methods and properties

    public GameObject defaultPrefab
    {
        set
        {
            _defaultPrefab = value;
        }
    }

    //TODO: Add possibility to differentiate between prefabs
    public AudioObject GetFreeAudioObject(GameObject prefab = null)
    {
        return null;
    }

    #endregion
}

[System.Serializable]
public class PrefabBasedPool
{
    public GameObject prefab;
    public List<AudioObject> audioObjects;
}

Restructure to start implementing category based pool.


using System;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using Mono.Options;

namespace Menora
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main(string[] args)
        {
            var config = "TempConfig.json";
            var help = false;
            var minimize = false;
            var optionSet = new OptionSet();

            optionSet
                .Add("c=|config=", "Change configuration file path", (v) => config = v)
                .Add("m|minimize", "Start minimized", (v) => minimize = true)
                .Add("h|help", "Display help and exit", (v) => help = true)
                .Parse(args);

            if (help)
            {
                using (var writer = new StringWriter())
                {
                    writer.WriteLine(Application.ProductName);
                    writer.WriteLine();

                    optionSet.WriteOptionDescriptions(writer);

                    MessageBox.Show(writer.ToString(), Application.ProductName);
                }

                return;
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm(config, minimize));
        }
    }
}

using System;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using Mono.Options;

namespace Menora
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main(string[] args)
        {
            var config = "Menora.json";
            var help = false;
            var minimize = false;
            var optionSet = new OptionSet();

            optionSet
                .Add("c=|config=", "Change configuration file path", (v) => config = v)
                .Add("m|minimize", "Start minimized", (v) => minimize = true)
                .Add("h|help", "Display help and exit", (v) => help = true)
                .Parse(args);

            if (help)
            {
                using (var writer = new StringWriter())
                {
                    writer.WriteLine(Application.ProductName);
                    writer.WriteLine();

                    optionSet.WriteOptionDescriptions(writer);

                    MessageBox.Show(writer.ToString(), Application.ProductName);
                }

                return;
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm(config, minimize));
        }
    }
}

Change default configuration file name.

Change default configuration file name.


namespace Playground.Leetcode
{
    using System;
    using System.Collections.Generic;

    public static class CombinationSum
    {
        // Problem number 377. https://leetcode.com/problems/combination-sum-iv/
        public static int CombinationSum4(int[] nums, int target)
        {
            //Array.Sort(nums);
            var count = 0;
            var countOfInterimSums = new Dictionary<int, int>();
            count = Helper(nums, target, countOfInterimSums);
            return count;
        }

        private static int Helper(
            int[] nums,
            int target,
            Dictionary<int, int> cache)
        {
            if (target == 0)
            {
                return 1;
            }

            if (cache.ContainsKey(target))
            {
                return cache[target];
            }

            var count = 0;
            foreach (var n in nums)
            {
                if (n > target)
                {
                }
                else
                {
                    var innerCount = Helper(nums, target - n, cache);
                    if (innerCount != 0)
                    {
                        count += innerCount;
                    }
                }
            }

            cache[target] = count;

            return count;
        }
    }
}

namespace Playground.Leetcode
{
    using System.Collections.Generic;

    public static class CombinationSum
    {
        // Problem number 377. https://leetcode.com/problems/combination-sum-iv/
        public static int CombinationSum4(int[] nums, int target)
        {
            var count = 0;
            var countOfInterimSums = new Dictionary<int, int>();
            count = Helper(nums, target, countOfInterimSums);
            return count;
        }

        private static int Helper(
            int[] nums,
            int target,
            Dictionary<int, int> cache)
        {
            if (target == 0)
            {
                return 1;
            }

            if (cache.ContainsKey(target))
            {
                return cache[target];
            }

            var count = 0;
            foreach (var n in nums)
            {
                if (n > target)
                {
                }
                else
                {
                    var innerCount = Helper(nums, target - n, cache);
                    if (innerCount != 0)
                    {
                        count += innerCount;
                    }
                }
            }

            cache[target] = count;

            return count;
        }
    }
}

Remove unnecessary using and comment.

Remove unnecessary using and comment.


using System;

namespace RepositoryExceptions.Persistence
{
    /// <summary>
    /// New exception introduced
    /// </summary>
    public class UserNotFoundException : Exception
    {
        public UserNotFoundException() : base()
        {
        }

        public UserNotFoundException(string message) : base(message)
        {
        }
    }
}

using System;

namespace RepositoryExceptions.Persistence
{
    /// <summary>
    /// New exception introduced
    /// </summary>
    public class UserNotFoundException : EntityNotFoundException
    {
        public UserNotFoundException() : base()
        {
        }

        public UserNotFoundException(string message) : base(message)
        {
        }
    }
}

Make new exception inherit from known type. Tests ok.


namespace Paydock_dotnet_sdk.Models
{
    public class ChargeRequestStripeConnect : ChargeRequestBase
	{
		public MetaData meta;
	}

	public class MetaData
	{
		public string stripe_direct_account_id;
		public string stripe_destination_account_id;
		public string stripe_transfer_group;
		public Transfer[] stripe_transfer;
	}

	public class Transfer
	{
		public decimal amount;
		public string currency;
		public string destination;
	}
}

namespace Paydock_dotnet_sdk.Models
{
    public class ChargeRequestStripeConnect : ChargeRequestBase
	{
		public MetaData meta;
		public Transfer[] transfer;
	}

	public class MetaData
	{
		public string stripe_direct_account_id;
		public decimal stripe_application_fee;
		public string stripe_destination_account_id;
		public decimal stripe_destination_amount;
	}

	public class Transfer
	{
		public string stripe_transfer_group;
		public TransferItems[] items;

		public class TransferItems
		{
			public decimal amount;
			public string currency;
			public string destination;
		}
	}
}

Update stripe connect objects based on changes to the API


// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

namespace Microsoft.AspNet.Html.Abstractions
{
    /// <summary>
    /// A builder for HTML content.
    /// </summary>
    public interface IHtmlContentBuilder : IHtmlContent
    {
        /// <summary>
        /// Appends an <see cref="IHtmlContent"/> instance.
        /// </summary>
        /// <param name="content">The <see cref="IHtmlContent"/> to append.</param>
        /// <returns>The <see cref="IHtmlContentBuilder"/>.</returns>
        IHtmlContentBuilder Append(IHtmlContent content);

        /// <summary>
        /// Appends a <see cref="string"/> value. The value is treated as unencoded as-provided, and will be HTML
        /// encoded before writing to output.
        /// </summary>
        /// <param name="content">The <see cref="string"/> to append.</param>
        /// <returns>The <see cref="IHtmlContentBuilder"/>.</returns>
        IHtmlContentBuilder Append(string unencoded);

        /// <summary>
        /// Clears the content.
        /// </summary>
        void Clear();
    }
}

// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

namespace Microsoft.AspNet.Html.Abstractions
{
    /// <summary>
    /// A builder for HTML content.
    /// </summary>
    public interface IHtmlContentBuilder : IHtmlContent
    {
        /// <summary>
        /// Appends an <see cref="IHtmlContent"/> instance.
        /// </summary>
        /// <param name="content">The <see cref="IHtmlContent"/> to append.</param>
        /// <returns>The <see cref="IHtmlContentBuilder"/>.</returns>
        IHtmlContentBuilder Append(IHtmlContent content);

        /// <summary>
        /// Appends a <see cref="string"/> value. The value is treated as unencoded as-provided, and will be HTML
        /// encoded before writing to output.
        /// </summary>
        /// <param name="content">The <see cref="string"/> to append.</param>
        /// <returns>The <see cref="IHtmlContentBuilder"/>.</returns>
        IHtmlContentBuilder Append(string unencoded);

        /// <summary>
        /// Appends an HTML encoded <see cref="string"/> value. The value is treated as HTML encoded as-provided, and
        /// no further encoding will be performed.
        /// </summary>
        /// <param name="content">The HTML encoded <see cref="string"/> to append.</param>
        /// <returns>The <see cref="IHtmlContentBuilder"/>.</returns>
        IHtmlContentBuilder AppendEncoded(string encoded);

        /// <summary>
        /// Clears the content.
        /// </summary>
        void Clear();
    }
}

Add AppendEncoded to the builder

Add AppendEncoded to the builder

This is needed because a builder may have an optimized path for an
unencoded string. There's also no 'common' encoded string implementation
so it's much more straightforward to put this on the interface.


using SOVND.Client.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace SOVND.Client.Views
{
    /// <summary>
    /// Interaction logic for NewChannel.xaml
    /// </summary>
    public partial class NewChannel : Window
    {
        public NewChannel()
        {
            InitializeComponent();
            DataContext = new NewChannelViewModel();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if(((NewChannelViewModel) DataContext).Register())
                this.Close();
        }
    }
}

using SOVND.Client.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace SOVND.Client.Views
{
    /// <summary>
    /// Interaction logic for NewChannel.xaml
    /// </summary>
    public partial class NewChannel : Window
    {
        public string ChannelName { get; private set; }

        public NewChannel()
        {
            InitializeComponent();
            DataContext = new NewChannelViewModel();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (((NewChannelViewModel) DataContext).Register())
            {
                ChannelName = ((NewChannelViewModel) DataContext).Name;
                this.Close();
            }
        }
    }
}

Return name of channel so we can subscribe to it


namespace Downlink.GitHub
{
    public class GitHubCredentials
    {
        public GitHubCredentials(string apiToken, string repoId)
        {
            Token = apiToken;
            var segs = repoId.Split('/');
            if (segs.Length != 2) throw new System.InvalidOperationException("Could not parse repository name");
            Owner = segs[0];
            Repo = segs[1];
        }

        public string Owner { get; }
        public string Repo { get; }
        public string Token { get; }
    }
}

namespace Downlink.GitHub
{
    public class GitHubCredentials
    {
        public GitHubCredentials(string apiToken, string repoId)
        {
            Token = apiToken;
            var segs = repoId.Split('/');
            if (segs.Length != 0) return;
            if (segs.Length != 2) throw new System.InvalidOperationException("Could not parse repository name");
            Owner = segs[0];
            Repo = segs[1];
        }

        public string Owner { get; }
        public string Repo { get; }
        public string Token { get; }
    }
}

Fix bug in GitHub backend

Fix bug in GitHub backend


using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Obvs.RabbitMQ")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Obvs.RabbitMQ")]
[assembly: AssemblyCopyright("Copyright ©  2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components.  If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("f1712ac7-e84e-400d-9cbb-c3b8945377c6")]

// Version information for an assembly consists of the following four values:
//
//      Major Version
//      Minor Version
//      Build Number
//      Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

using System.Reflection;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Obvs.RabbitMQ")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Christopher Read")]
[assembly: AssemblyProduct("Obvs.RabbitMQ")]
[assembly: AssemblyCopyright("Copyright ©  2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components.  If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("f1712ac7-e84e-400d-9cbb-c3b8945377c6")]

// Version information for an assembly consists of the following four values:
//
//      Major Version
//      Minor Version
//      Build Number
//      Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

Add author to assembly properties

Add author to assembly properties


using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;

namespace AspNetCoreMvc
{
    public class Program
    {
        public static void Main(string[] args)
        {
            BuildWebHost(args).Run();
        }

        public static IWebHost BuildWebHost(string[] args) =>
            WebHost.CreateDefaultBuilder(args)
                .UseStartup<Startup>()
                .Build();
    }
}

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;

namespace AspNetCoreMvc
{
    public class Program
    {
        public static void Main (string[] args)
        {
            BuildWebHost (args).Run ();
        }

        public static IWebHost BuildWebHost (string[] args) =>
            WebHost.CreateDefaultBuilder (args)
                   .UseConfiguration (new ConfigurationBuilder ().AddCommandLine (args).Build ())
                   .UseStartup<Startup> ()
                   .Build ();
    }
}

Use command line args when configuring the server


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;

namespace LSDStay
{
	public static class PSXFinder
	{
		public static Process FindPSX()
		{
			Process psx = Process.GetProcessesByName("psxfin").FirstOrDefault();

		}
	}
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;

namespace LSDStay
{
	public static class PSXFinder
	{
		public static Process FindPSX()
		{
			Process psx = Process.GetProcessesByName("psxfin").FirstOrDefault();
			return psx;
		}

		public static IntPtr OpenPSX(Process psx)
		{
			int PID = psx.Id;
			IntPtr psxHandle = Memory.OpenProcess((uint)Memory.ProcessAccessFlags.All, false, PID);

		}

		public static void ClosePSX(IntPtr processHandle)
		{
			int result = Memory.CloseHandle(processHandle);
			if (result == 0)
			{
				Console.WriteLine("ERROR: Could not close psx handle");
			}
		}
	}
}

Add methods for opening and closing PSX handle


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

using System;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

[assembly: AssemblyVersion("3.0.0.0")]
[assembly: AssemblyFileVersion("3.0.1.0")]
[assembly: AssemblyConfiguration("Release built on 2013-10-23 22:48")]
[assembly: AssemblyCopyright("Copyright © 2013 Autofac Contributors")]
[assembly: AssemblyDescription("Autofac.Extras.Moq 3.0.1")]

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

using System;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

[assembly: AssemblyVersion("3.0.0.0")]
[assembly: AssemblyFileVersion("3.0.1.0")]
[assembly: AssemblyConfiguration("Release built on 2013-12-03 10:23")]
[assembly: AssemblyCopyright("Copyright © 2013 Autofac Contributors")]
[assembly: AssemblyDescription("Autofac.Extras.Moq 3.0.1")]

Split WCF functionality out of Autofac.Extras.Multitenant into a separate assembly/package, Autofac.Extras.Multitenant.Wcf. Both packages are versioned 3.1.0.


using MailKit.Net.Smtp;
using MimeKit;
using System;
using System.Threading.Tasks;

namespace Blogifier.Core.Services
{
    public class MailKitService : IEmailService
    {
        private readonly IDataService _db;

        public MailKitService(IDataService db)
        {
            _db = db;
        }

        public async Task<string> SendEmail(string fromName, string fromEmail, string toEmail, string subject, string content)
        {
            try
            {
                var mailKit = await _db.CustomFields.GetMailKitModel();

                var message = new MimeMessage();
                message.From.Add(new MailboxAddress(fromName, fromEmail));
                message.To.Add(new MailboxAddress(toEmail));
                message.Subject = subject;

                var bodyBuilder = new BodyBuilder();
                bodyBuilder.HtmlBody = content;
                message.Body = bodyBuilder.ToMessageBody();

                var client = new SmtpClient();
                client.ServerCertificateValidationCallback = (s, c, h, e) => true;
                client.Connect(mailKit.EmailServer, mailKit.Port, mailKit.Options);
                client.Authenticate(mailKit.EmailAddress, mailKit.EmailPassword);
                client.Send(message);
                client.Disconnect(true);

                return await Task.FromResult("");
            }
            catch (Exception ex)
            {
                return await Task.FromResult(ex.Message);
            }
        }
    }
}

using MailKit.Net.Smtp;
using MimeKit;
using System;
using System.Threading.Tasks;

namespace Blogifier.Core.Services
{
    public class MailKitService : IEmailService
    {
        private readonly IDataService _db;

        public MailKitService(IDataService db)
        {
            _db = db;
        }

        public async Task<string> SendEmail(string fromName, string fromEmail, string toEmail, string subject, string content)
        {
            try
            {
                var mailKit = await _db.CustomFields.GetMailKitModel();

                var message = new MimeMessage();
                message.From.Add(new MailboxAddress(fromName, fromEmail));
                message.To.Add(new MailboxAddress(fromName, toEmail));
                message.Subject = subject;

                var bodyBuilder = new BodyBuilder();
                bodyBuilder.HtmlBody = content;
                message.Body = bodyBuilder.ToMessageBody();

                var client = new SmtpClient();
                client.ServerCertificateValidationCallback = (s, c, h, e) => true;
                client.Connect(mailKit.EmailServer, mailKit.Port, mailKit.Options);
                client.Authenticate(mailKit.EmailAddress, mailKit.EmailPassword);
                client.Send(message);
                client.Disconnect(true);

                return await Task.FromResult("");
            }
            catch (Exception ex)
            {
                return await Task.FromResult(ex.Message);
            }
        }
    }
}

Resolve a problem with Obsolete controller

The MailboxAddress uses an Obsolete constructor. The problem is resolved by adding the name of the sender.


using System;
using Bit.Core.Domains;
using System.Collections.Generic;
using Newtonsoft.Json;
using Bit.Core.Enums;

namespace Bit.Api.Models
{
    public class DomainsResponseModel : ResponseModel
    {
        public DomainsResponseModel(User user)
            : base("domains")
        {
            if(user == null)
            {
                throw new ArgumentNullException(nameof(user));
            }

            EquivalentDomains = user.EquivalentDomains != null ?
                JsonConvert.DeserializeObject<List<List<string>>>(user.EquivalentDomains) : null;
            GlobalEquivalentDomains = Core.Utilities.EquivalentDomains.Global;
            ExcludedGlobalEquivalentDomains = user.ExcludedGlobalEquivalentDomains != null ?
                JsonConvert.DeserializeObject<List<GlobalEquivalentDomainsType>>(user.ExcludedGlobalEquivalentDomains) : null;
        }

        public IEnumerable<IEnumerable<string>> EquivalentDomains { get; set; }
        public IDictionary<GlobalEquivalentDomainsType, IEnumerable<string>> GlobalEquivalentDomains { get; set; }
        public IEnumerable<GlobalEquivalentDomainsType> ExcludedGlobalEquivalentDomains { get; set; }
    }
}

using System;
using Bit.Core.Domains;
using System.Collections.Generic;
using Newtonsoft.Json;
using Bit.Core.Enums;
using System.Linq;

namespace Bit.Api.Models
{
    public class DomainsResponseModel : ResponseModel
    {
        public DomainsResponseModel(User user)
            : base("domains")
        {
            if(user == null)
            {
                throw new ArgumentNullException(nameof(user));
            }

            EquivalentDomains = user.EquivalentDomains != null ?
                JsonConvert.DeserializeObject<List<List<string>>>(user.EquivalentDomains) : null;

            var excludedGlobalEquivalentDomains = user.ExcludedGlobalEquivalentDomains != null ?
                JsonConvert.DeserializeObject<List<GlobalEquivalentDomainsType>>(user.ExcludedGlobalEquivalentDomains) : null;
            var globalDomains = new List<GlobalDomains>();
            foreach(var domain in Core.Utilities.EquivalentDomains.Global)
            {
                globalDomains.Add(new GlobalDomains(domain.Key, domain.Value, excludedGlobalEquivalentDomains));
            }
            GlobalEquivalentDomains = !globalDomains.Any() ? null : globalDomains;
        }

        public IEnumerable<IEnumerable<string>> EquivalentDomains { get; set; }
        public IEnumerable<GlobalDomains> GlobalEquivalentDomains { get; set; }

        public class GlobalDomains
        {
            public GlobalDomains(
                GlobalEquivalentDomainsType globalDomain,
                IEnumerable<string> domains,
                IEnumerable<GlobalEquivalentDomainsType> excludedDomains)
            {
                Type = globalDomain;
                Domains = domains;
                Excluded = excludedDomains?.Contains(globalDomain) ?? false;
            }

            public GlobalEquivalentDomainsType Type { get; set; }
            public IEnumerable<string> Domains { get; set; }
            public bool Excluded { get; set; }
        }
    }
}

Rework models for global domains

Rework models for global domains