This file contains hidden or 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 interface ILoadable { } | |
public class Person : ILoadable { } | |
public interface ILoader<T> | |
where T : ILoadable | |
{ | |
void Load(T loadable); | |
} |
This file contains hidden or 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 void Test() | |
{ | |
ILoadable order = new Order(); | |
ILoader loader = new PersonLoader(); | |
loader.Load(order); //What happens here? | |
} | |
//Where Order is an ILoadable |
This file contains hidden or 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 class BaseType { | |
} | |
public class MyType : BaseType { | |
} | |
public void Test(MyType obj) { | |
if (obj is BaseType) { | |
Console.WriteLine("Base"); | |
} else { |
This file contains hidden or 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 class AsyncSerializerWrapper | |
{ | |
public AsyncSerializerWrapper(NetworkStream stream) | |
{ | |
_stream = stream; | |
} | |
private NetworkStream _stream; | |
public IAsyncResult BeginWriteObject(object obj, AsyncCallback callback) |
This file contains hidden or 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; | |
using System.Collections.Generic; | |
using System.ComponentModel; | |
using System.Data; | |
using System.Drawing; | |
using System.IO; | |
using System.Linq; | |
using System.Text; | |
using System.Threading; | |
using System.Windows.Forms; |
This file contains hidden or 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
UPDATE MyTable SET SomeColumn = 'Test' WHERE RecordDate > '01-01-2001' | |
SELECT @@ROWCOUNT AS UpdatedRecords |
This file contains hidden or 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
/// <summary> | |
/// Represents a repository context. | |
/// </summary> | |
/// <remarks> | |
/// Based on: http://www.iridescence.no/post/Linq-to-Sql-Programming-Against-an-Interface-and-the-Repository-Pattern.aspx | |
/// </remarks> | |
public interface IDataContext : IDisposable | |
{ | |
/// <summary> | |
/// Gets or sets the connection string. |
This file contains hidden or 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 d = new Dictionary<string, MyStruct>(); | |
var s = new MyStruct(); | |
s.Value = 10; | |
d["test"] = s; | |
var s2 = d["test"]; | |
s2.Value = 11; | |
//What get's written here? |
This file contains hidden or 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
SELECT * FROM | |
(SELECT TOP 25 ID, ... | |
FROM MyTable | |
ORDER BY ID DESC) AS Z | |
ORDER BY Z.ID ASC |
This file contains hidden or 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 void ExecuteAndReport(Action a) | |
{ | |
a(); | |
worker.ReportProgress((int)((float)reader.BaseStream.Position / (float)reader.BaseStream.Length) * 100); | |
} |
OlderNewer