Skip to content

Instantly share code, notes, and snippets.

View Insire's full-sized avatar

Peter Vietense Insire

View GitHub Profile
@Insire
Insire / DependencyObjectExtensions.cs
Created May 7, 2023 10:39
Behavior for WPF Expander using the MDIX Toolkit that enables focusing the expander content, once the expand animation completed
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Media3D;
public static class DependencyObjectExtensions
{
public static IEnumerable<DependencyObject> GetVisualDescendants(this DependencyObject visual)
@Insire
Insire / FloatingEntry.xaml
Created April 6, 2020 10:02
Xamarin.Forms: entry with floating placeholder
<?xml version="1.0" encoding="UTF-8" ?>
<ContentView x:Class="Warenannahme.Controls.FloatingEntry"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Name="this"
mc:Ignorable="d">
<ContentView.Content>
<Grid>
@Insire
Insire / getallrefs.cs
Created February 8, 2020 18:03 — forked from Cryental/getallrefs.cs
Get All References From Project File (csproj)
private static List<string> GetAllReferences(string fullPath)
{
var logger = new ConsoleLogger(LoggerVerbosity.Quiet);
var manager = BuildManager.DefaultBuildManager;
var projectInstance = new ProjectInstance(fullPath);
var result = manager.Build(new BuildParameters {DetailedSummary = false, Loggers = new List<ILogger> {logger}}, new BuildRequestData(projectInstance, new[] {"ResolveProjectReferences", "ResolveAssemblyReferences"}));
var items1 = PrintResultItems(result, "ResolveProjectReferences");
var items2 = PrintResultItems(result, "ResolveAssemblyReferences");
@Insire
Insire / msbuild target for nswag.xml
Last active March 4, 2019 18:31
msbuild target for generating a c# client from an asp.net core webapi projects controllers targeting .net 2.2
<Target Name="NSwag" AfterTargets="Build" Condition="'$(Configuration)' != 'Release' AND '$(Configuration)' != 'Debug'">
<Copy SourceFiles="@(ReferencePath)" DestinationFolder="$(OutDir)References" />
<Exec Command="$(NSwagExe_Core22) aspnetcore2swagger /assembly:$(TargetDir)InFact.Mobile.Api.dll /output:$(SolutionDir)nswag.json /runtime:NetCore22" />
<Exec Command="$(NSwagExe_Core22) swagger2csclient /input:$(SolutionDir)nswag.json /classname:InFactRestClient /namespace:InFact.RestClient /output:$(SolutionDir)InFact.Mobile.RestClient/InFactRestClient.cs " />
<RemoveDir Directories="$(OutDir)References" />
</Target>
@Insire
Insire / Program.cs
Created October 22, 2018 13:59 — forked from DanielSWolf/Program.cs
Console progress bar. Code is under the MIT License: http://opensource.org/licenses/MIT
using System;
using System.Threading;
static class Program {
static void Main() {
Console.Write("Performing some task... ");
using (var progress = new ProgressBar()) {
for (int i = 0; i <= 100; i++) {
progress.Report((double) i / 100);
@Insire
Insire / expression.cs
Last active October 12, 2018 15:07
CompareVersion via expressions
var oneVersion = new Version(1, 1, 1, 1);
var twoVersion = new Version(2, 2, 2, 2);
var tree = CreateCompareExpression();
var method = tree.Compile();
method(oneVersion,twoVersion).Dump();
Expression<Func<Version, Version, int>> CreateCompareExpression()
{
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.Serialization;
using System.Threading;
System.InvalidOperationException: Cannot combine a directory path with an absolute file path.
bei Cake.Core.IO.DirectoryPath.CombineWithFilePath(FilePath path)
bei Cake.Incubator.ProjectParserExtensions.<>c__DisplayClass14_0.<GetNetFrameworkReferences>b__9(<>f__AnonymousType20`2 <>h__TransparentIdentifier7) in C:\projects\cake-incubator\src\Cake.Incubator\ProjectParserExtensions.cs:Zeile 535.
bei System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
bei Cake.Incubator.EnumerableExtensions.<Distinct>d__4`2.MoveNext() in C:\projects\cake-incubator\src\Cake.Incubator\EnumerableExtensions.cs:Zeile 99.
bei System.Linq.Buffer`1..ctor(IEnumerable`1 source)
bei System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
bei Cake.Incubator.ProjectParserExtensions.ParseNetFramework(XDocument document, IFile projectFile, String config, String platform) in C:\projects\cake-incubator\src\Cake.Incubator\ProjectParserExtensions.cs:Zeile 223.
bei Cake.Incubator.ProjectParserExtensions.Pa
@Insire
Insire / build.cake
Created August 8, 2017 17:38
how to get the project output directories from a solution with cake
#addin Cake.Incubator
var target = Argument("target", "Default");
var solutionPath ="./WpfApp2.sln";
Task("Information")
.Does(()=>
{
Information("Parsing {0}",solutionPath);
var solution = ParseSolution(solutionPath);
using System;
using System.Threading.Tasks;
namespace Maple.Core
{
public sealed class NotifyTaskCompletion<TResult> : ObservableObject
{
private readonly IMapleLog _log;
private readonly Task<TResult> _task;