This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestMethod] | |
public void OnCompletedCalled() | |
{ | |
TestScheduler scheduler = new TestScheduler(); | |
ReplaySubject<TcpClient> subject = new ReplaySubject<TcpClient>(scheduler); | |
TcpListener listener = new TcpListener(IPAddress.Any, 11122); | |
listener.Start(); | |
CancellationDisposable cancel = new CancellationDisposable(); | |
bool isOk = false; | |
Func<IObservable<TcpClient>> asyncObs = Observable.FromAsyncPattern(listener.BeginAcceptTcpClient, listener.EndAcceptTcpClient); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static IObservable<byte[]> ForEveryMessage(this TcpClient self, int byteCount, CancellationToken token) | |
{ | |
return Observable.Create<byte[]>( | |
obs => | |
{ | |
NetworkStream stream = self.GetStream(); | |
byte[] buffer = new byte[byteCount]; | |
var recieving = Observable.FromAsyncPattern<byte[], int, int, int>(stream.BeginRead, stream.EndRead); | |
bool zeroBytesRead = false; | |
int remainder = byteCount; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestMethod] | |
public void BeginEndPairWithData() | |
{ | |
byte[] changingData = new byte[] { 0 }; | |
Action changeData = () => changingData = new byte[] { 1 }; | |
IAsyncResult res = changeData.BeginInvoke(changeData.EndInvoke, null); | |
res.AsyncWaitHandle.WaitOne(); | |
changingData.ShouldAllBeEquivalentTo((byte)1); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var numberList = new List<int>(); | |
numberList.AddRange(new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9 }); | |
var totalNumber = 0; | |
foreach (var item in YieldingNotFive(numberList)) | |
{ | |
totalNumber += item; | |
} | |
private IEnumerable<int> YieldingNotFive(List<int> numberList) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
namespace test | |
{ | |
public class Something | |
{ | |
public Something() | |
{ | |
OrderableItems c1 = new Car(200); | |
OrderableItems b1 = new Bus(31); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal class A | |
{ | |
public void DoSixth() | |
{ | |
} | |
public void DoFirst() | |
{ | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal class A: IFirstFive, ISecondFive | |
{ | |
public void DoSixth() | |
{ | |
} | |
public void DoFirst() | |
{ | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// wiew | |
<TreeView Name="MyTree"> | |
<TreeView.Resources> | |
<!-- would be nice, if it would be ILink for more extendability. Didn't work for some reason. Click and Children have to be added to ILink for that to work. In that case LinkViewModel should be implemented to have a clear short ILink --> | |
<HierarchicalDataTemplate DataType="{x:Type local:Link}" ItemsSource="{Binding Children}"> | |
<StackPanel> | |
<Label Content="{Binding ElementName}"/> | |
<Button Command="{Binding Click}">Press to update</Button> | |
</StackPanel> | |
</HierarchicalDataTemplate> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// usage | |
// ... | |
IUnityContainer container = new UnityContainer(); | |
container.RegisterType(typeof (IPhone), typeof (Phone)); | |
container.RegisterType(typeof (IPda), typeof (Pda)); | |
container.RegisterType(typeof (ICellPhone), typeof (CellPhone)); | |
ICellPhone cellPhone = container.Resolve<ICellPhone>() | |
// ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public partial class MainWindow : Window | |
{ | |
public MainWindow() | |
{ | |
InitializeComponent(); | |
Drawer drawer = new Drawer(); | |
//MyTree.Items.Add(new Link(new CollectionInformation(new List<IElement>()))); | |
MyTree.Items.Add( | |
new CollectionInformation(new List<IElement> | |
{ |
OlderNewer