Skip to content

Instantly share code, notes, and snippets.

View alanjuden's full-sized avatar

Alan Juden alanjuden

View GitHub Profile
ByteConversion.GetString(2147483648, ByteUnit.Byte); //Returns "2 GB"
ByteConversion.GetString(2048, ByteUnit.Megabyte, ByteUnit.Byte); //Returns "2147483648 B"
ByteConversion.GetString(2147483648, ByteUnit.Byte, ByteUnit.Megabyte); //Returns "2048 MB"
public enum ByteUnit
{
[System.ComponentModel.Description("B")]
Byte = 0,
[System.ComponentModel.Description("kB")]
Kilobyte = 1,
[System.ComponentModel.Description("MB")]
Megabyte = 2,
using System;
using System.Reflection;
using System.ComponentModel;
namespace YourNamespace
{
public static class Missing
{
public static string GetDescription(this Enum value)
{
public class ByteConversion
{
///
/// Converts your number from the specified fromUnit to the toUnit
///
///Number to convert
///ByteUnit that the number is already in.
///ByteUnit that you want to convert your number too.
///
public static double Convert(double number, ByteUnit fromUnit, ByteUnit toUnit)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Epc
{
public class TestTaskHost : TaskHost
{
public List<Task> Tasks { get; set; }
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Epc
{
public abstract class Task
{
public abstract string TaskName { get; }
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Epc
{
public interface TaskHost
{
bool IsClosing { get; set; }
using System;
using System.Text;
public static class ExceptionExtensions
{
public static string ExceptionToString(this Exception ex)
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("Date/Time: " + DateTime.UtcNow.ToString());
@alanjuden
alanjuden / ReportController.cs
Last active November 9, 2016 20:44
Custom ReportViewer ReportController Example
public class ReportController : AlanJuden.MvcReportViewer.ReportController
{
protected override ICredentials NetworkCredentials
{
get
{
//Custom Domain authentication (be sure to pull the info from a config file)
//return new System.Net.NetworkCredential("username", "password", "domain");
//Default domain credentials (windows authentication)
@alanjuden
alanjuden / ReportViewer.cshtml
Last active November 11, 2016 04:16
Custom ReportViewer View Example
@model AlanJuden.MvcReportViewer.ReportViewerModel
@using AlanJuden.MvcReportViewer
@{
ViewBag.Title = "ReportViewer";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>ReportViewer</h2>