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; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Reflection; | |
using System.Text; | |
using Autofac; | |
namespace Throwit.Business.SomeObjects | |
{ |
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
// | |
// Convert a object to byte array | |
// | |
ObjectType _theObject; // Populates from somewhere | |
BinaryFormatter formatter = new BinaryFormatter(); | |
MemoryStream ms = new MemoryStream(); | |
formatter.Serialize(ms, _theObject); | |
byte[] bytes = ms.ToArray(); | |
FileStream fs = new FileStream("dummy.bin", FileMode.Create); | |
fs.Write(bytes, 0, bytes.Length); |
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
class MainPageViewModel | |
{ | |
// a place on page | |
public string Categories { get; set; } | |
// other place on the page | |
public List<Products> Products { get; set; } | |
} | |
// Controller: | |
public class HomeController : Controller |
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 myTest = new Namespace.TheService(); | |
// var ex = ExceptionFactory.Throws<InvalidOperationException>(() => | |
// myTest.Result = myTest.Execute() ); | |
// Assert.AreEqual(myTest.Result, null); | |
// Assert.AreEqual(ex.AnyProp, "ExpectedData"); | |
public static class ExceptionFactory | |
{ | |
public static T Throws<T>(Action action) where T : Exception | |
{ |
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; | |
using System.Collections.Generic; | |
using Microsoft.VisualStudio.TestTools.UnitTesting; | |
using System.Linq; | |
namespace PageflowBreaker | |
{ | |
[TestClass] | |
public class UnitTest1 | |
{ |
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
void Main() | |
{ | |
string item = "134217963"; | |
ValueFlags vf = new ValueFlags(); | |
float _value; | |
if (float.TryParse(item, out _value)) | |
{ | |
vf.Value = _value.ToString(); | |
} |
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
/// | |
/// Function in a method that put items to queue | |
/// | |
while (!queue.QueueManager.TryAdd(ResultOfValidation, new Random().Next(20))) | |
Console.WriteLine("Some text output logging because of error."); | |
/// | |
/// Queue Class | |
/// | |
public class Queue |
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
namespace Object2Serializer | |
{ | |
/// 2011-09-21 XmlSerialization | |
/// This class content (definition) was created due to a third-partys serialized stream of text (xml alike) | |
/// With data from i.e. a database, the lists Graph and Set should be populated. And then | |
/// .GenerateXmlText() will do the whole work! Easy extendable with GenerateJson and so on. | |
/// As a little side note. There are just three lines in the Serialize-method to make a xml-standard. | |
public static partial class Program | |
{ |
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
/// <summary> | |
/// Fill gaps in referred List (based on date). | |
/// Dynamic due to a Period which add ticks to the DateTime instead of a static "Days" or dito. | |
/// </summary> | |
public static void FillGapsInArray(ref List<ObjectWithDateField> range, Period period) | |
{ | |
long ticks = PeriodParse.GetTicks(period); | |
List<ObjectWithDateField> gaps = new List<ObjectWithDateField>(); |
NewerOlder