Skip to content

Instantly share code, notes, and snippets.

View clausjoergensen's full-sized avatar

Claus Jørgensen clausjoergensen

View GitHub Profile
@clausjoergensen
clausjoergensen / MarshallExtensions.cs
Created January 7, 2012 14:20
Marshall Extensions for System.IO.Stream
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Diagnostics.Contracts;
namespace System.Runtime.InteropServices
{
/// <summary>
public static class StringExtensions
{
public static bool TryParseInt16(this string source, Func<short, bool> condition)
{
short result = 0;
if (short.TryParse(source, out result))
return condition(result);
else
return false;
}
<ItemGroup>
<!-- Specify the folder, or files we want to include -->
<AdditionalPublishFiles Include="ListAndLabel\*.*">
<Visible>False</Visible>
</AdditionalPublishFiles>
<!-- Alternative syntax, for individual files -->
<!--
<AdditionalPublishFiles Include="ListAndLabel\cmbr15.dll;ListAndLabel\Cmct15.dll">
<Visible>False</Visible>
Example XAML:
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<ProgressBar x:Name="PART_ProgressBar" />
<Image>
<Image.Source>
<BitmapImage behaviors:ImageDownloadProgress.ProgressBar="{Binding ElementName=PART_ProgressBar}" UriSource="{Binding Image}" />
</Image.Source>
using System;
using CRUFL_MT;
using MTool.Framework;
namespace MTool.Report
{
public partial class MeterReportForm : MToolFormBase
{
public MeterReportForm()
{
[TestMethod]
public void ExecuteTest()
{
var acceptanceTestRepository = new Mock<IAcceptanceTestRepository>();
var testPointRepository = new Mock<ITestPointRepository>();
var dialogService = new Mock<IDialogService>();
var eventAggregator = new Mock<IEventAggregator>();
eventAggregator.Setup(x => x.GetEvent<TestPointUpdatedEvent>()).Returns(new TestPointUpdatedEvent());
eventAggregator.Setup(x => x.GetEvent<AcceptanceTestUpdatedEvent>()).Returns(new AcceptanceTestUpdatedEvent());
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.ItemsControl', AncestorLevel='1''. BindingExpression:Path=HorizontalContentAlignment; DataItem=null; target element is 'ChangePasswordMenuItem' (Name=''); target property is 'HorizontalContentAlignment' (type 'HorizontalAlignment')
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.ItemsControl', AncestorLevel='1''. BindingExpression:Path=VerticalContentAlignment; DataItem=null; target element is 'ChangePasswordMenuItem' (Name=''); target property is 'VerticalContentAlignment' (type 'VerticalAlignment')
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.DataGrid', AncestorLevel='1''. BindingExpression:Path=AreRowDetailsFrozen; DataItem=null; target element is 'DataGridDetailsPrese
public int TestTimeWithSampling
{
get
{
return CalculateTestTimeWithSampling();
}
}
private int CalculateTestTimeWithSampling()
{
var assembly = typeof(MeterCommunicator).Assembly;
var commands = assembly.GetTypes().Where(t => t.IsSubclassOf(typeof(CommandBase)));
var output = new StringBuilder();
foreach (var command in commands)
{
string test =
@"[TestMethod]
public void {0}Test()
private void IsAlive()
{
int counter = 0;
int threadId = Thread.CurrentThread.ManagedThreadId;
while (keepCheckingConnection)
{
Thread.Sleep(1000);
if (counter != 60)