GIT: perform LF normalization

This commit is contained in:
Gary Sharp
2013-02-28 17:15:46 +11:00
parent 989f08a24d
commit 7d9be5620d
729 changed files with 300734 additions and 300712 deletions
+16 -16
View File
@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework">
<parameters>
<parameter value="Data Source=.\SQLEXPRESS; Integrated Security=True; MultipleActiveResultSets=True" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework">
<parameters>
<parameter value="Data Source=.\SQLEXPRESS; Integrated Security=True; MultipleActiveResultSets=True" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
@@ -1,36 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using Disco.Models.BI.Config;
namespace Disco.Web.Extensions
{
public static class OrganisationAddressExtensions
{
public static List<SelectListItem> ToSelectListItems(this IEnumerable<OrganisationAddress> organisationAddressess, OrganisationAddress SelectedItem)
{
int? selectedId = default(int?);
if (SelectedItem != null)
selectedId = SelectedItem.Id;
return organisationAddressess.ToSelectListItems(selectedId);
}
public static List<SelectListItem> ToSelectListItems(this IEnumerable<OrganisationAddress> organisationAddressess, int? SelectedId = null, bool IncludeInstructionFirst = false, string InstructionMessage = "Select an Address")
{
var selectItems = default(List<SelectListItem>);
if (!SelectedId.HasValue)
selectItems = organisationAddressess.Select(wpd => new SelectListItem { Value = wpd.Id.Value.ToString(), Text = string.Format("{0} ({1})", wpd.Name, wpd.ShortName) }).ToList();
else
selectItems = organisationAddressess.Select(wpd => new SelectListItem { Value = wpd.Id.Value.ToString(), Text = string.Format("{0} ({1})", wpd.Name, wpd.ShortName), Selected = (SelectedId.Equals(wpd.Id)) }).ToList();
if (IncludeInstructionFirst)
selectItems.Insert(0, new SelectListItem() { Value = String.Empty, Text = String.Format("<{0}>", InstructionMessage), Selected = !SelectedId.HasValue });
return selectItems;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using Disco.Models.BI.Config;
namespace Disco.Web.Extensions
{
public static class OrganisationAddressExtensions
{
public static List<SelectListItem> ToSelectListItems(this IEnumerable<OrganisationAddress> organisationAddressess, OrganisationAddress SelectedItem)
{
int? selectedId = default(int?);
if (SelectedItem != null)
selectedId = SelectedItem.Id;
return organisationAddressess.ToSelectListItems(selectedId);
}
public static List<SelectListItem> ToSelectListItems(this IEnumerable<OrganisationAddress> organisationAddressess, int? SelectedId = null, bool IncludeInstructionFirst = false, string InstructionMessage = "Select an Address")
{
var selectItems = default(List<SelectListItem>);
if (!SelectedId.HasValue)
selectItems = organisationAddressess.Select(wpd => new SelectListItem { Value = wpd.Id.Value.ToString(), Text = string.Format("{0} ({1})", wpd.Name, wpd.ShortName) }).ToList();
else
selectItems = organisationAddressess.Select(wpd => new SelectListItem { Value = wpd.Id.Value.ToString(), Text = string.Format("{0} ({1})", wpd.Name, wpd.ShortName), Selected = (SelectedId.Equals(wpd.Id)) }).ToList();
if (IncludeInstructionFirst)
selectItems.Insert(0, new SelectListItem() { Value = String.Empty, Text = String.Format("<{0}>", InstructionMessage), Selected = !SelectedId.HasValue });
return selectItems;
}
}
}
@@ -1,29 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Disco.Web.Extensions
{
public static class UtilityExtensions
{
public static string ToJavascriptDate(this DateTime d)
{
return string.Format("new Date({0}, {1}, {2}, {3}, {4}, {5})", d.Year, d.Month - 1, d.Day, d.Hour, d.Minute, d.Second);
}
public static string ToJavascriptDate(this DateTime? d, DateTime? DefaultDate = null)
{
if (d.HasValue)
{
return ToJavascriptDate(d.Value);
}
else
{
if (DefaultDate.HasValue)
return ToJavascriptDate(DefaultDate.Value);
else
return "null";
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Disco.Web.Extensions
{
public static class UtilityExtensions
{
public static string ToJavascriptDate(this DateTime d)
{
return string.Format("new Date({0}, {1}, {2}, {3}, {4}, {5})", d.Year, d.Month - 1, d.Day, d.Hour, d.Minute, d.Second);
}
public static string ToJavascriptDate(this DateTime? d, DateTime? DefaultDate = null)
{
if (d.HasValue)
{
return ToJavascriptDate(d.Value);
}
else
{
if (DefaultDate.HasValue)
return ToJavascriptDate(DefaultDate.Value);
else
return "null";
}
}
}
}
@@ -1,32 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using Disco.Models.Repository;
namespace Disco.Web.Extensions
{
public static class DeviceBatchExtensions
{
public static List<SelectListItem> ToSelectListItems(this IEnumerable<DeviceBatch> deviceBatches, int? SelectedId = null, bool IncludeNoBatchItem = true)
{
var items = deviceBatches.Select(db => new SelectListItem() { Value = db.Id.ToString(), Text = db.Name }).ToList();
if (SelectedId.HasValue)
{
string selectedIdString = SelectedId.Value.ToString();
var selectedItem = items.Where(i => i.Value == selectedIdString).FirstOrDefault();
if (selectedItem != null)
selectedItem.Selected = true;
}
if (IncludeNoBatchItem)
items.Insert(0, new SelectListItem() { Value = string.Empty, Text = "Unknown", Selected = !SelectedId.HasValue });
return items;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using Disco.Models.Repository;
namespace Disco.Web.Extensions
{
public static class DeviceBatchExtensions
{
public static List<SelectListItem> ToSelectListItems(this IEnumerable<DeviceBatch> deviceBatches, int? SelectedId = null, bool IncludeNoBatchItem = true)
{
var items = deviceBatches.Select(db => new SelectListItem() { Value = db.Id.ToString(), Text = db.Name }).ToList();
if (SelectedId.HasValue)
{
string selectedIdString = SelectedId.Value.ToString();
var selectedItem = items.Where(i => i.Value == selectedIdString).FirstOrDefault();
if (selectedItem != null)
selectedItem.Selected = true;
}
if (IncludeNoBatchItem)
items.Insert(0, new SelectListItem() { Value = string.Empty, Text = "Unknown", Selected = !SelectedId.HasValue });
return items;
}
}
}
@@ -1,32 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using Disco.Models.Repository;
namespace Disco.Web.Extensions
{
public static class DeviceModelExtensions
{
public static List<SelectListItem> ToSelectListItems(this IEnumerable<DeviceModel> deviceModels, int? SelectedId = null, bool IncludeNoModelItem = false)
{
var items = deviceModels.Select(db => new SelectListItem() { Value = db.Id.ToString(), Text = db.Description }).ToList();
if (SelectedId.HasValue)
{
string selectedIdString = SelectedId.Value.ToString();
var selectedItem = items.Where(i => i.Value == selectedIdString).FirstOrDefault();
if (selectedItem != null)
selectedItem.Selected = true;
}
if (IncludeNoModelItem)
items.Insert(0, new SelectListItem() { Value = string.Empty, Text = "Unknown", Selected = !SelectedId.HasValue });
return items;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using Disco.Models.Repository;
namespace Disco.Web.Extensions
{
public static class DeviceModelExtensions
{
public static List<SelectListItem> ToSelectListItems(this IEnumerable<DeviceModel> deviceModels, int? SelectedId = null, bool IncludeNoModelItem = false)
{
var items = deviceModels.Select(db => new SelectListItem() { Value = db.Id.ToString(), Text = db.Description }).ToList();
if (SelectedId.HasValue)
{
string selectedIdString = SelectedId.Value.ToString();
var selectedItem = items.Where(i => i.Value == selectedIdString).FirstOrDefault();
if (selectedItem != null)
selectedItem.Selected = true;
}
if (IncludeNoModelItem)
items.Insert(0, new SelectListItem() { Value = string.Empty, Text = "Unknown", Selected = !SelectedId.HasValue });
return items;
}
}
}
@@ -1,31 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using Disco.Models.Repository;
namespace Disco.Web.Extensions
{
public static class DeviceProfileExtensions
{
public static IEnumerable<SelectListItem> ToSelectListItems(this IEnumerable<DeviceProfile> deviceProfiles, DeviceProfile SelectedDeviceProfile = null)
{
var selectedId = 1;
if (SelectedDeviceProfile != null)
selectedId = SelectedDeviceProfile.Id;
return deviceProfiles.ToSelectListItems(selectedId);
}
public static IEnumerable<SelectListItem> ToSelectListItems(this IEnumerable<DeviceProfile> deviceProfiles, int SelectedDeviceProfileId = 1)
{
return deviceProfiles.Select(dp => new SelectListItem()
{
Value = dp.Id.ToString(),
Text = dp.ToString(),
Selected = (dp.Id == SelectedDeviceProfileId)
});
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using Disco.Models.Repository;
namespace Disco.Web.Extensions
{
public static class DeviceProfileExtensions
{
public static IEnumerable<SelectListItem> ToSelectListItems(this IEnumerable<DeviceProfile> deviceProfiles, DeviceProfile SelectedDeviceProfile = null)
{
var selectedId = 1;
if (SelectedDeviceProfile != null)
selectedId = SelectedDeviceProfile.Id;
return deviceProfiles.ToSelectListItems(selectedId);
}
public static IEnumerable<SelectListItem> ToSelectListItems(this IEnumerable<DeviceProfile> deviceProfiles, int SelectedDeviceProfileId = 1)
{
return deviceProfiles.Select(dp => new SelectListItem()
{
Value = dp.Id.ToString(),
Text = dp.ToString(),
Selected = (dp.Id == SelectedDeviceProfileId)
});
}
}
}
@@ -1,20 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using Disco.Models.Repository;
namespace Disco.Web.Extensions
{
public static class DocumentTemplateExtensions
{
public static IEnumerable<SelectListItem> ToSelectListItems(this IEnumerable<DocumentTemplate> documentTemplates, string SelectedId = null)
{
if (SelectedId == null)
return documentTemplates.Select(dt => new SelectListItem { Value = dt.Id, Text = dt.Description }).ToList();
else
return documentTemplates.Select(dt => new SelectListItem { Value = dt.Id, Text = dt.Description, Selected = (SelectedId == dt.Id) }).ToList();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using Disco.Models.Repository;
namespace Disco.Web.Extensions
{
public static class DocumentTemplateExtensions
{
public static IEnumerable<SelectListItem> ToSelectListItems(this IEnumerable<DocumentTemplate> documentTemplates, string SelectedId = null)
{
if (SelectedId == null)
return documentTemplates.Select(dt => new SelectListItem { Value = dt.Id, Text = dt.Description }).ToList();
else
return documentTemplates.Select(dt => new SelectListItem { Value = dt.Id, Text = dt.Description, Selected = (SelectedId == dt.Id) }).ToList();
}
}
}
@@ -1,30 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using Disco.Models.Repository;
namespace Disco.Web.Extensions
{
public static class JobSubTypeExtensions
{
public static List<SelectListItem> ToSelectListItems(this IEnumerable<JobSubType> jobSubTypes, List<JobSubType> SelectedItems)
{
List<string> selectedIds = default(List<string>);
if (SelectedItems != null)
selectedIds = SelectedItems.Select(i => string.Format("{0}_{1}", i.JobTypeId, i.Id)).ToList();
return jobSubTypes.ToSelectListItems(selectedIds);
}
public static List<SelectListItem> ToSelectListItems(this IEnumerable<JobSubType> jobSubTypes, List<string> SelectedIds = null)
{
if (SelectedIds == null)
return jobSubTypes.Select(jst => new SelectListItem { Value = string.Format("{0}_{1}", jst.JobTypeId, jst.Id), Text = jst.Description }).ToList();
else
return jobSubTypes.Select(jst => new SelectListItem { Value = string.Format("{0}_{1}", jst.JobTypeId, jst.Id), Text = jst.Description, Selected = (SelectedIds.Contains(string.Format("{0}_{1}", jst.JobTypeId, jst.Id))) }).ToList();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using Disco.Models.Repository;
namespace Disco.Web.Extensions
{
public static class JobSubTypeExtensions
{
public static List<SelectListItem> ToSelectListItems(this IEnumerable<JobSubType> jobSubTypes, List<JobSubType> SelectedItems)
{
List<string> selectedIds = default(List<string>);
if (SelectedItems != null)
selectedIds = SelectedItems.Select(i => string.Format("{0}_{1}", i.JobTypeId, i.Id)).ToList();
return jobSubTypes.ToSelectListItems(selectedIds);
}
public static List<SelectListItem> ToSelectListItems(this IEnumerable<JobSubType> jobSubTypes, List<string> SelectedIds = null)
{
if (SelectedIds == null)
return jobSubTypes.Select(jst => new SelectListItem { Value = string.Format("{0}_{1}", jst.JobTypeId, jst.Id), Text = jst.Description }).ToList();
else
return jobSubTypes.Select(jst => new SelectListItem { Value = string.Format("{0}_{1}", jst.JobTypeId, jst.Id), Text = jst.Description, Selected = (SelectedIds.Contains(string.Format("{0}_{1}", jst.JobTypeId, jst.Id))) }).ToList();
}
}
}
@@ -1,48 +1,48 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Disco.Models.Repository;
using System.Web.Mvc;
namespace Disco.Web.Extensions
{
public static class JobTypeExtensions
{
public static List<SelectListItem> ToSelectListItems(this IEnumerable<JobType> jobTypes, JobType SelectedItem)
{
string selectedId = default(string);
if (SelectedItem != null)
selectedId = SelectedItem.Id;
return jobTypes.ToSelectListItems(selectedId);
}
public static List<SelectListItem> ToSelectListItems(this IEnumerable<JobType> jobTypes, string SelectedId = null)
{
if (SelectedId == null)
return jobTypes.Select(jt => new SelectListItem { Value = jt.Id, Text = jt.Description }).ToList();
else
return jobTypes.Select(jt => new SelectListItem { Value = jt.Id, Text = jt.Description, Selected = (SelectedId == jt.Id) }).ToList();
}
public static List<SelectListItem> ToSelectListItems(this IEnumerable<JobType> jobTypes, List<JobType> SelectedItems)
{
List<string> selectedIds = default(List<string>);
if (SelectedItems != null)
selectedIds = SelectedItems.Select(i => i.Id).ToList();
return jobTypes.ToSelectListItems(selectedIds);
}
public static List<SelectListItem> ToSelectListItems(this IEnumerable<JobType> jobTypes, List<string> SelectedIds = null)
{
if (SelectedIds == null)
return jobTypes.Select(jt => new SelectListItem { Value = jt.Id, Text = jt.Description }).ToList();
else
return jobTypes.Select(jt => new SelectListItem { Value = jt.Id, Text = jt.Description, Selected = (SelectedIds.Contains(jt.Id)) }).ToList();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Disco.Models.Repository;
using System.Web.Mvc;
namespace Disco.Web.Extensions
{
public static class JobTypeExtensions
{
public static List<SelectListItem> ToSelectListItems(this IEnumerable<JobType> jobTypes, JobType SelectedItem)
{
string selectedId = default(string);
if (SelectedItem != null)
selectedId = SelectedItem.Id;
return jobTypes.ToSelectListItems(selectedId);
}
public static List<SelectListItem> ToSelectListItems(this IEnumerable<JobType> jobTypes, string SelectedId = null)
{
if (SelectedId == null)
return jobTypes.Select(jt => new SelectListItem { Value = jt.Id, Text = jt.Description }).ToList();
else
return jobTypes.Select(jt => new SelectListItem { Value = jt.Id, Text = jt.Description, Selected = (SelectedId == jt.Id) }).ToList();
}
public static List<SelectListItem> ToSelectListItems(this IEnumerable<JobType> jobTypes, List<JobType> SelectedItems)
{
List<string> selectedIds = default(List<string>);
if (SelectedItems != null)
selectedIds = SelectedItems.Select(i => i.Id).ToList();
return jobTypes.ToSelectListItems(selectedIds);
}
public static List<SelectListItem> ToSelectListItems(this IEnumerable<JobType> jobTypes, List<string> SelectedIds = null)
{
if (SelectedIds == null)
return jobTypes.Select(jt => new SelectListItem { Value = jt.Id, Text = jt.Description }).ToList();
else
return jobTypes.Select(jt => new SelectListItem { Value = jt.Id, Text = jt.Description, Selected = (SelectedIds.Contains(jt.Id)) }).ToList();
}
}
}
@@ -1,70 +1,70 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
namespace Disco.Web.Extensions.MvcExtensions.Bundles
{
public static class BundleTable
{
private static Dictionary<string, Bundle> _bundles;
static BundleTable()
{
_bundles = new Dictionary<string, Bundle>();
}
public static void Add(Bundle Bundle)
{
_bundles[Bundle.Url] = Bundle;
}
public static int Count
{
get
{
return _bundles.Count;
}
}
internal static Bundle GetBundleFor(string Url)
{
if (_bundles.ContainsKey(Url))
{
return _bundles[Url];
}
return null;
}
public static string ResolveBundleUrl(string BundleUrl)
{
var bundle = GetBundleFor(BundleUrl);
if (bundle == null)
throw new ArgumentException(string.Format("Unknown Bundle Url: {0}", BundleUrl), "BundleUrl");
return VirtualPathUtility.ToAbsolute(bundle.VersionUrl);
}
public static string ResolveBundleHtmlElement(string BundleUrl)
{
var bundle = GetBundleFor(BundleUrl);
if (bundle == null)
throw new ArgumentException(string.Format("Unknown Bundle Url: {0}", BundleUrl), "BundleUrl");
var bundleUrl = VirtualPathUtility.ToAbsolute(bundle.VersionUrl);
switch (bundle.ContentType)
{
case "text/css":
return string.Format("<link href=\"{0}\" rel=\"stylesheet\" type=\"text/css\" />", bundleUrl);
case "text/javascript":
return string.Format("<script src=\"{0}\" type=\"text/javascript\"></script>", bundleUrl);
default:
throw new ArgumentException("Unsupported Bundle Content Type", "BundleUrl");
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
namespace Disco.Web.Extensions.MvcExtensions.Bundles
{
public static class BundleTable
{
private static Dictionary<string, Bundle> _bundles;
static BundleTable()
{
_bundles = new Dictionary<string, Bundle>();
}
public static void Add(Bundle Bundle)
{
_bundles[Bundle.Url] = Bundle;
}
public static int Count
{
get
{
return _bundles.Count;
}
}
internal static Bundle GetBundleFor(string Url)
{
if (_bundles.ContainsKey(Url))
{
return _bundles[Url];
}
return null;
}
public static string ResolveBundleUrl(string BundleUrl)
{
var bundle = GetBundleFor(BundleUrl);
if (bundle == null)
throw new ArgumentException(string.Format("Unknown Bundle Url: {0}", BundleUrl), "BundleUrl");
return VirtualPathUtility.ToAbsolute(bundle.VersionUrl);
}
public static string ResolveBundleHtmlElement(string BundleUrl)
{
var bundle = GetBundleFor(BundleUrl);
if (bundle == null)
throw new ArgumentException(string.Format("Unknown Bundle Url: {0}", BundleUrl), "BundleUrl");
var bundleUrl = VirtualPathUtility.ToAbsolute(bundle.VersionUrl);
switch (bundle.ContentType)
{
case "text/css":
return string.Format("<link href=\"{0}\" rel=\"stylesheet\" type=\"text/css\" />", bundleUrl);
case "text/javascript":
return string.Format("<script src=\"{0}\" type=\"text/javascript\"></script>", bundleUrl);
default:
throw new ArgumentException("Unsupported Bundle Content Type", "BundleUrl");
}
}
}
}
@@ -1,17 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Optimization;
namespace Disco.Web.Extensions.MvcExtensions.Bundles
{
public class BundleUnordered : IBundleOrderer
{
public IEnumerable<System.IO.FileInfo> OrderFiles(BundleContext context, IEnumerable<System.IO.FileInfo> files)
{
return files;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Optimization;
namespace Disco.Web.Extensions.MvcExtensions.Bundles
{
public class BundleUnordered : IBundleOrderer
{
public IEnumerable<System.IO.FileInfo> OrderFiles(BundleContext context, IEnumerable<System.IO.FileInfo> files)
{
return files;
}
}
}
@@ -1,63 +1,63 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Optimization;
using System.IO;
namespace Disco.Web.Extensions.MvcExtensions.Bundles
{
public class JsJoin : IBundleTransform
{
internal static string JsContentType;
static JsJoin()
{
JsContentType = "text/javascript";
}
public void Process(BundleContext context, BundleResponse response)
{
if (context == null)
throw new ArgumentNullException("context");
if (response == null)
throw new ArgumentNullException("response");
// Not Needed - the new Transforms pipeline has already loaded the content
//if (!context.EnableInstrumentation && string.IsNullOrEmpty(response.Content))
//{
// try
// {
// StringBuilder bundleContent = new StringBuilder();
// foreach (FileInfo file in response.Files)
// {
// string fileContent = File.ReadAllText(file.FullName);
// bundleContent.AppendLine(fileContent);
// }
// response.Content = bundleContent.ToString();
// }
// catch (Exception ex)
// {
// GenerateErrorResponse(response, new string[] { ex.GetType().Name, ex.Message, ex.StackTrace });
// }
//}
response.ContentType = JsContentType;
}
internal static void GenerateErrorResponse(BundleResponse bundle, ICollection<string> errors)
{
StringBuilder builder = new StringBuilder();
builder.Append("/* ");
builder.Append("Bundle creation failed [JsJoin].").Append("\r\n");
foreach (string str in errors)
{
builder.Append(str).Append("\r\n");
}
builder.Append(" */\r\n");
bundle.Content = builder.ToString();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Optimization;
using System.IO;
namespace Disco.Web.Extensions.MvcExtensions.Bundles
{
public class JsJoin : IBundleTransform
{
internal static string JsContentType;
static JsJoin()
{
JsContentType = "text/javascript";
}
public void Process(BundleContext context, BundleResponse response)
{
if (context == null)
throw new ArgumentNullException("context");
if (response == null)
throw new ArgumentNullException("response");
// Not Needed - the new Transforms pipeline has already loaded the content
//if (!context.EnableInstrumentation && string.IsNullOrEmpty(response.Content))
//{
// try
// {
// StringBuilder bundleContent = new StringBuilder();
// foreach (FileInfo file in response.Files)
// {
// string fileContent = File.ReadAllText(file.FullName);
// bundleContent.AppendLine(fileContent);
// }
// response.Content = bundleContent.ToString();
// }
// catch (Exception ex)
// {
// GenerateErrorResponse(response, new string[] { ex.GetType().Name, ex.Message, ex.StackTrace });
// }
//}
response.ContentType = JsContentType;
}
internal static void GenerateErrorResponse(BundleResponse bundle, ICollection<string> errors)
{
StringBuilder builder = new StringBuilder();
builder.Append("/* ");
builder.Append("Bundle creation failed [JsJoin].").Append("\r\n");
foreach (string str in errors)
{
builder.Append(str).Append("\r\n");
}
builder.Append(" */\r\n");
bundle.Content = builder.ToString();
}
}
}
@@ -1,140 +1,140 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.IO;
using System.Web;
using dotless.Core;
using dotless.Core.configuration;
using System.Web.Optimization;
namespace Disco.Web.Extensions.MvcExtensions.Bundles
{
public class LessCompile : IBundleTransform
{
internal static string CssContentType;
internal static readonly ILessEngine Instance;
static LessCompile()
{
CssContentType = "text/css";
Instance = new EngineFactory(new DotlessConfiguration()
{
CacheEnabled = false,
MinifyOutput = true
}).GetEngine();
}
public void Process(BundleContext context, BundleResponse response)
{
if (context == null)
throw new ArgumentNullException("context");
if (response == null)
throw new ArgumentNullException("response");
if (!context.EnableInstrumentation)
{
try
{
StringBuilder bundleContent = new StringBuilder();
Uri appRootPath = new Uri(HttpContext.Current.Request.PhysicalApplicationPath);
var restoreEnvironmentCurrentDirectory = Environment.CurrentDirectory;
foreach (FileInfo file in response.Files)
{
string fileContent = File.ReadAllText(file.FullName);
Uri fileRootPath = new Uri(file.DirectoryName + "/");
// Less Compile
Environment.CurrentDirectory = file.DirectoryName;
fileContent = Instance.TransformToCss(fileContent, file.FullName);
// Embed Images
fileContent = EmbedCssImages(fileContent, fileRootPath, appRootPath);
bundleContent.Append(fileContent);
}
if (!Environment.CurrentDirectory.Equals(restoreEnvironmentCurrentDirectory))
Environment.CurrentDirectory = restoreEnvironmentCurrentDirectory;
response.Content = bundleContent.ToString();
}
catch (Exception ex)
{
GenerateErrorResponse(response, new string[] { ex.GetType().Name, ex.Message, ex.StackTrace });
}
}
response.ContentType = CssContentType;
}
private static string EmbedCssImages(string cssContent, Uri fileRootPath, Uri appRootPath)
{
return Regex.Replace(cssContent, "url\\((.*?)\\)", m =>
{
var cssFilename = m.Groups[1].Value.Trim(new char[] { '\'', '"' });
Uri fileUri;
if (cssFilename.StartsWith("/"))
fileUri = new Uri(appRootPath, cssFilename);
else
fileUri = new Uri(fileRootPath, cssFilename);
if (File.Exists(fileUri.LocalPath))
{
var fileInfo = new FileInfo(fileUri.LocalPath);
// Ensure File is < 250kb
if (fileInfo.Length < 256000)
{
string contentType = null;
switch (fileInfo.Extension)
{
case ".png":
contentType = "image/png";
break;
case ".gif":
contentType = "image/gif";
break;
case ".jpg":
case ".jpeg":
contentType = "image/jpeg";
break;
default:
return m.Value;
}
StringBuilder sb = new StringBuilder();
sb.Append("url(data:");
sb.Append(contentType);
sb.Append(";base64,");
sb.Append(Convert.ToBase64String(File.ReadAllBytes(fileInfo.FullName)));
sb.Append(")");
return sb.ToString();
}
else
{
return string.Format("url(/{0})", appRootPath.MakeRelativeUri(fileUri).ToString());
}
}
else
{
throw new FileNotFoundException(string.Format("Unable to embed css image, file not found: '{0}' at '{1}'", cssFilename, fileUri.AbsolutePath), cssFilename);
}
});
}
internal static void GenerateErrorResponse(BundleResponse bundle, ICollection<string> errors)
{
StringBuilder builder = new StringBuilder();
builder.Append("/* ");
builder.Append("Bundle creation failed [LessCompile].").Append("\r\n");
foreach (string str in errors)
{
builder.Append(str).Append("\r\n");
}
builder.Append(" */\r\n");
bundle.Content = builder.ToString();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.IO;
using System.Web;
using dotless.Core;
using dotless.Core.configuration;
using System.Web.Optimization;
namespace Disco.Web.Extensions.MvcExtensions.Bundles
{
public class LessCompile : IBundleTransform
{
internal static string CssContentType;
internal static readonly ILessEngine Instance;
static LessCompile()
{
CssContentType = "text/css";
Instance = new EngineFactory(new DotlessConfiguration()
{
CacheEnabled = false,
MinifyOutput = true
}).GetEngine();
}
public void Process(BundleContext context, BundleResponse response)
{
if (context == null)
throw new ArgumentNullException("context");
if (response == null)
throw new ArgumentNullException("response");
if (!context.EnableInstrumentation)
{
try
{
StringBuilder bundleContent = new StringBuilder();
Uri appRootPath = new Uri(HttpContext.Current.Request.PhysicalApplicationPath);
var restoreEnvironmentCurrentDirectory = Environment.CurrentDirectory;
foreach (FileInfo file in response.Files)
{
string fileContent = File.ReadAllText(file.FullName);
Uri fileRootPath = new Uri(file.DirectoryName + "/");
// Less Compile
Environment.CurrentDirectory = file.DirectoryName;
fileContent = Instance.TransformToCss(fileContent, file.FullName);
// Embed Images
fileContent = EmbedCssImages(fileContent, fileRootPath, appRootPath);
bundleContent.Append(fileContent);
}
if (!Environment.CurrentDirectory.Equals(restoreEnvironmentCurrentDirectory))
Environment.CurrentDirectory = restoreEnvironmentCurrentDirectory;
response.Content = bundleContent.ToString();
}
catch (Exception ex)
{
GenerateErrorResponse(response, new string[] { ex.GetType().Name, ex.Message, ex.StackTrace });
}
}
response.ContentType = CssContentType;
}
private static string EmbedCssImages(string cssContent, Uri fileRootPath, Uri appRootPath)
{
return Regex.Replace(cssContent, "url\\((.*?)\\)", m =>
{
var cssFilename = m.Groups[1].Value.Trim(new char[] { '\'', '"' });
Uri fileUri;
if (cssFilename.StartsWith("/"))
fileUri = new Uri(appRootPath, cssFilename);
else
fileUri = new Uri(fileRootPath, cssFilename);
if (File.Exists(fileUri.LocalPath))
{
var fileInfo = new FileInfo(fileUri.LocalPath);
// Ensure File is < 250kb
if (fileInfo.Length < 256000)
{
string contentType = null;
switch (fileInfo.Extension)
{
case ".png":
contentType = "image/png";
break;
case ".gif":
contentType = "image/gif";
break;
case ".jpg":
case ".jpeg":
contentType = "image/jpeg";
break;
default:
return m.Value;
}
StringBuilder sb = new StringBuilder();
sb.Append("url(data:");
sb.Append(contentType);
sb.Append(";base64,");
sb.Append(Convert.ToBase64String(File.ReadAllBytes(fileInfo.FullName)));
sb.Append(")");
return sb.ToString();
}
else
{
return string.Format("url(/{0})", appRootPath.MakeRelativeUri(fileUri).ToString());
}
}
else
{
throw new FileNotFoundException(string.Format("Unable to embed css image, file not found: '{0}' at '{1}'", cssFilename, fileUri.AbsolutePath), cssFilename);
}
});
}
internal static void GenerateErrorResponse(BundleResponse bundle, ICollection<string> errors)
{
StringBuilder builder = new StringBuilder();
builder.Append("/* ");
builder.Append("Bundle creation failed [LessCompile].").Append("\r\n");
foreach (string str in errors)
{
builder.Append(str).Append("\r\n");
}
builder.Append(" */\r\n");
bundle.Content = builder.ToString();
}
}
}
@@ -1,58 +1,58 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using Newtonsoft.Json;
namespace Disco.Web.Extensions
{
public class JsonNetResult : JsonResult
{
public override void ExecuteResult(ControllerContext context)
{
if (context == null)
throw new ArgumentNullException("context");
var response = context.HttpContext.Response;
response.ContentType = !string.IsNullOrEmpty(ContentType) ? ContentType : "application/json";
if (ContentEncoding != null)
response.ContentEncoding = ContentEncoding;
if (Data == null)
return;
var serializedObject = JsonConvert.SerializeObject(Data, Formatting.Indented);
response.Write(serializedObject);
}
}
public static class JsonNetExtensions
{
public static JsonNetResult JsonNet(this Controller controller, object Data, JsonRequestBehavior JsonRequestBehavior)
{
return JsonNet(controller, Data, null, null, JsonRequestBehavior);
}
public static JsonNetResult JsonNet(this Controller controller, object Data, string ContentType, JsonRequestBehavior JsonRequestBehavior)
{
return JsonNet(controller, Data, ContentType, null, JsonRequestBehavior);
}
public static JsonNetResult JsonNet(this Controller controller, object Data, Encoding ContentEncoding, JsonRequestBehavior JsonRequestBehavior)
{
return JsonNet(controller, Data, null, ContentEncoding, JsonRequestBehavior);
}
public static JsonNetResult JsonNet(this Controller controller, object Data, string ContentType, Encoding ContentEncoding, JsonRequestBehavior JsonRequestBehavior)
{
return new JsonNetResult()
{
Data = Data,
ContentType = ContentType,
ContentEncoding = ContentEncoding,
JsonRequestBehavior = JsonRequestBehavior
};
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using Newtonsoft.Json;
namespace Disco.Web.Extensions
{
public class JsonNetResult : JsonResult
{
public override void ExecuteResult(ControllerContext context)
{
if (context == null)
throw new ArgumentNullException("context");
var response = context.HttpContext.Response;
response.ContentType = !string.IsNullOrEmpty(ContentType) ? ContentType : "application/json";
if (ContentEncoding != null)
response.ContentEncoding = ContentEncoding;
if (Data == null)
return;
var serializedObject = JsonConvert.SerializeObject(Data, Formatting.Indented);
response.Write(serializedObject);
}
}
public static class JsonNetExtensions
{
public static JsonNetResult JsonNet(this Controller controller, object Data, JsonRequestBehavior JsonRequestBehavior)
{
return JsonNet(controller, Data, null, null, JsonRequestBehavior);
}
public static JsonNetResult JsonNet(this Controller controller, object Data, string ContentType, JsonRequestBehavior JsonRequestBehavior)
{
return JsonNet(controller, Data, ContentType, null, JsonRequestBehavior);
}
public static JsonNetResult JsonNet(this Controller controller, object Data, Encoding ContentEncoding, JsonRequestBehavior JsonRequestBehavior)
{
return JsonNet(controller, Data, null, ContentEncoding, JsonRequestBehavior);
}
public static JsonNetResult JsonNet(this Controller controller, object Data, string ContentType, Encoding ContentEncoding, JsonRequestBehavior JsonRequestBehavior)
{
return new JsonNetResult()
{
Data = Data,
ContentType = ContentType,
ContentEncoding = ContentEncoding,
JsonRequestBehavior = JsonRequestBehavior
};
}
}
}
@@ -1,51 +1,51 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using System.Web;
using System.Web.WebPages;
using System.IO;
using System.Globalization;
namespace Disco.Web.Extensions
{
public static class PartialCompiledHtmlExtensions
{
#region Render Compiled Views
private static void RenderPartialCompiledInternal(this HtmlHelper htmlHelper, Type viewType, object model, TextWriter writer)
{
if (writer == null)
throw new ArgumentNullException("writer");
WebViewPage page = Activator.CreateInstance(viewType) as WebViewPage;
if (page == null)
throw new InvalidOperationException("Invalid View Type");
page.ViewContext = htmlHelper.ViewContext;
page.ViewData = new ViewDataDictionary(model);
page.InitHelpers();
HttpContextBase httpContext = htmlHelper.ViewContext.HttpContext;
page.ExecutePageHierarchy(new WebPageContext(httpContext, null, model), writer, null);
}
public static void RenderPartialCompiled(this HtmlHelper htmlHelper, Type viewType)
{
RenderPartialCompiled(htmlHelper, viewType, null);
}
public static void RenderPartialCompiled(this HtmlHelper htmlHelper, Type viewType, object model)
{
htmlHelper.RenderPartialCompiledInternal(viewType, model, htmlHelper.ViewContext.Writer);
}
public static MvcHtmlString PartialCompiled(this HtmlHelper htmlHelper, Type viewType)
{
return PartialCompiled(htmlHelper, viewType, null);
}
public static MvcHtmlString PartialCompiled(this HtmlHelper htmlHelper, Type viewType, object model)
{
using (StringWriter writer = new StringWriter(CultureInfo.CurrentCulture))
{
htmlHelper.RenderPartialCompiledInternal(viewType, model, writer);
return MvcHtmlString.Create(writer.ToString());
}
}
#endregion
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using System.Web;
using System.Web.WebPages;
using System.IO;
using System.Globalization;
namespace Disco.Web.Extensions
{
public static class PartialCompiledHtmlExtensions
{
#region Render Compiled Views
private static void RenderPartialCompiledInternal(this HtmlHelper htmlHelper, Type viewType, object model, TextWriter writer)
{
if (writer == null)
throw new ArgumentNullException("writer");
WebViewPage page = Activator.CreateInstance(viewType) as WebViewPage;
if (page == null)
throw new InvalidOperationException("Invalid View Type");
page.ViewContext = htmlHelper.ViewContext;
page.ViewData = new ViewDataDictionary(model);
page.InitHelpers();
HttpContextBase httpContext = htmlHelper.ViewContext.HttpContext;
page.ExecutePageHierarchy(new WebPageContext(httpContext, null, model), writer, null);
}
public static void RenderPartialCompiled(this HtmlHelper htmlHelper, Type viewType)
{
RenderPartialCompiled(htmlHelper, viewType, null);
}
public static void RenderPartialCompiled(this HtmlHelper htmlHelper, Type viewType, object model)
{
htmlHelper.RenderPartialCompiledInternal(viewType, model, htmlHelper.ViewContext.Writer);
}
public static MvcHtmlString PartialCompiled(this HtmlHelper htmlHelper, Type viewType)
{
return PartialCompiled(htmlHelper, viewType, null);
}
public static MvcHtmlString PartialCompiled(this HtmlHelper htmlHelper, Type viewType, object model)
{
using (StringWriter writer = new StringWriter(CultureInfo.CurrentCulture))
{
htmlHelper.RenderPartialCompiledInternal(viewType, model, writer);
return MvcHtmlString.Create(writer.ToString());
}
}
#endregion
}
}
+70 -70
View File
@@ -1,71 +1,71 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Xml.Serialization;
namespace Disco.Web.Extensions
{
/// <summary>
/// Action result that serializes the specified object into XML and outputs it to the response stream.
/// <example>
/// <![CDATA[
/// public XmlResult AsXml() {
/// List<Person> people = _peopleService.GetPeople();
/// return new XmlResult(people);
/// }
/// ]]>
/// </example>
/// </summary>
public class XmlResult : ActionResult
{
private object _objectToSerialize;
private XmlAttributeOverrides _xmlAttribueOverrides;
/// <summary>
/// Creates a new instance of the XmlResult class.
/// </summary>
/// <param name="objectToSerialize">The object to serialize to XML.</param>
public XmlResult(object objectToSerialize)
{
_objectToSerialize = objectToSerialize;
}
/// <summary>
/// Creates a new instance of the XMLResult class.
/// </summary>
/// <param name="objectToSerialize">The object to serialize to XML.</param>
/// <param name="xmlAttributeOverrides"></param>
public XmlResult(object objectToSerialize, XmlAttributeOverrides xmlAttributeOverrides)
{
_objectToSerialize = objectToSerialize;
_xmlAttribueOverrides = xmlAttributeOverrides;
}
/// <summary>
/// The object to be serialized to XML.
/// </summary>
public object ObjectToSerialize
{
get { return _objectToSerialize; }
}
/// <summary>
/// Serialises the object that was passed into the constructor to XML and writes the corresponding XML to the result stream.
/// </summary>
/// <param name="context">The controller context for the current request.</param>
public override void ExecuteResult(ControllerContext context)
{
if (_objectToSerialize != null)
{
var xs = (_xmlAttribueOverrides == null) ?
new XmlSerializer(_objectToSerialize.GetType()) :
new XmlSerializer(_objectToSerialize.GetType(), _xmlAttribueOverrides);
context.HttpContext.Response.ContentType = "text/xml";
xs.Serialize(context.HttpContext.Response.Output, _objectToSerialize);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Xml.Serialization;
namespace Disco.Web.Extensions
{
/// <summary>
/// Action result that serializes the specified object into XML and outputs it to the response stream.
/// <example>
/// <![CDATA[
/// public XmlResult AsXml() {
/// List<Person> people = _peopleService.GetPeople();
/// return new XmlResult(people);
/// }
/// ]]>
/// </example>
/// </summary>
public class XmlResult : ActionResult
{
private object _objectToSerialize;
private XmlAttributeOverrides _xmlAttribueOverrides;
/// <summary>
/// Creates a new instance of the XmlResult class.
/// </summary>
/// <param name="objectToSerialize">The object to serialize to XML.</param>
public XmlResult(object objectToSerialize)
{
_objectToSerialize = objectToSerialize;
}
/// <summary>
/// Creates a new instance of the XMLResult class.
/// </summary>
/// <param name="objectToSerialize">The object to serialize to XML.</param>
/// <param name="xmlAttributeOverrides"></param>
public XmlResult(object objectToSerialize, XmlAttributeOverrides xmlAttributeOverrides)
{
_objectToSerialize = objectToSerialize;
_xmlAttribueOverrides = xmlAttributeOverrides;
}
/// <summary>
/// The object to be serialized to XML.
/// </summary>
public object ObjectToSerialize
{
get { return _objectToSerialize; }
}
/// <summary>
/// Serialises the object that was passed into the constructor to XML and writes the corresponding XML to the result stream.
/// </summary>
/// <param name="context">The controller context for the current request.</param>
public override void ExecuteResult(ControllerContext context)
{
if (_objectToSerialize != null)
{
var xs = (_xmlAttribueOverrides == null) ?
new XmlSerializer(_objectToSerialize.GetType()) :
new XmlSerializer(_objectToSerialize.GetType(), _xmlAttribueOverrides);
context.HttpContext.Response.ContentType = "text/xml";
xs.Serialize(context.HttpContext.Response.Output, _objectToSerialize);
}
}
}
}
@@ -1,13 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace Disco.Web
{
[Authorize(Roles = "Admin")]
public class dbAdminController : dbController
{
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace Disco.Web
{
[Authorize(Roles = "Admin")]
public class dbAdminController : dbController
{
}
}
@@ -1,34 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Disco.Data.Repository;
namespace Disco.Web
{
[OutputCache(Duration = 0, Location = System.Web.UI.OutputCacheLocation.None)]
public class dbController : Controller
{
protected DiscoDataContext dbContext;
protected override void OnActionExecuting(ActionExecutingContext filterContext)
{
this.dbContext = new DiscoDataContext();
this.dbContext.Configuration.LazyLoadingEnabled = false;
base.OnActionExecuting(filterContext);
}
protected override void Dispose(bool disposing)
{
if (this.dbContext != null)
{
this.dbContext.Dispose();
this.dbContext = null;
}
base.Dispose(disposing);
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Disco.Data.Repository;
namespace Disco.Web
{
[OutputCache(Duration = 0, Location = System.Web.UI.OutputCacheLocation.None)]
public class dbController : Controller
{
protected DiscoDataContext dbContext;
protected override void OnActionExecuting(ActionExecutingContext filterContext)
{
this.dbContext = new DiscoDataContext();
this.dbContext.Configuration.LazyLoadingEnabled = false;
base.OnActionExecuting(filterContext);
}
protected override void Dispose(bool disposing)
{
if (this.dbContext != null)
{
this.dbContext.Dispose();
this.dbContext = null;
}
base.Dispose(disposing);
}
}
}