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 static string DaySuffix(this DateTime dateTime) | |
| { | |
| return (dateTime.Day == 1) | |
| ? "st" | |
| : (dateTime.Day == 2) | |
| ? "nd" | |
| : (dateTime.Day == 3) | |
| ? "rd" | |
| : "th"; | |
| } |
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> | |
| /// Select distinct elements in collection on a given property | |
| /// </summary> | |
| /// <typeparam name="TSource"></typeparam> | |
| /// <typeparam name="TKey"></typeparam> | |
| /// <param name="source">The collection to filter</param> | |
| /// <param name="keySelector">The property to distinct collection by</param> | |
| /// <returns></returns> | |
| public static IEnumerable<TSource> DistinctBy<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector) | |
| { |
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
| [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)] | |
| public class CurrentVersionHeaderAttribute : ActionFilterAttribute | |
| { | |
| private const string _xVersion = "X-Version"; | |
| private static readonly string _version = Assembly.GetExecutingAssembly().GetName().Version.ToString(); | |
| public override void OnResultExecuted(ResultExecutedContext filterContext) | |
| { | |
| var headers = filterContext.HttpContext.Response.Headers; |
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
| void Main() | |
| { | |
| var data = @"{'id':'528c97b12314dcac5c0021b0','name':'Query','idBoard':'5268f13aa63b12236e0051d2','idCard': | |
| '528c97aa3a003a4a0c00339a','pos':16384,'checkItems':[{'state':'incomplete','id':'528c97bf7a14af624e00228d', | |
| 'name':'What ares are on or off in what page for pocket hub section','nameData':{'emoji':{}},'pos':16970}, | |
| {'state':'incomplete','id':'528c97d3e790ecc25c0035f6', | |
| 'name':'Buy now integration','nameData':null,'pos':33467}, | |
| {'state':'incomplete','id':'528c97d9205dd7a54c003598', | |
| 'name':'Buys now quantitiy integration','nameData':null,'pos':50628}, | |
| {'state':'incomplete','id':'528c97f0b52fd8ab2f003227','name':'Vote functionality integration','nameData':null,'pos':67217}, |
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 BetterDefaultModelBinder : DefaultModelBinder | |
| { | |
| protected override object CreateModel(ControllerContext controllerContext, ModelBindingContext bindingContext, Type modelType) | |
| { | |
| var model = base.CreateModel(controllerContext, bindingContext, modelType); | |
| if (model == null || model is IEnumerable) | |
| return model; | |
| foreach (var property in modelType.GetProperties(BindingFlags.Public | BindingFlags.Instance)) |
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
| protected static string RemoveAllSpecialCharacters(string input) | |
| { | |
| var r = new Regex("(?:[^a-z0-9 ]|(?<=['\"])s)", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant | RegexOptions.Compiled); | |
| return r.Replace(input, String.Empty); | |
| } | |
| protected static string RemoveSelectSpecialCharacters(string input) | |
| { | |
| var r = new Regex("[~#%&*{}:<>?|\".]", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant | RegexOptions.Compiled); | |
| return r.Replace(input, String.Empty); |
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 static class SerializationExtensions | |
| { | |
| public static string Serialize(this object obj) | |
| { | |
| using (var memoryStream = new MemoryStream()) | |
| using (var reader = new StreamReader(memoryStream)) | |
| { | |
| var serializer = new DataContractSerializer(obj.GetType()); | |
| serializer.WriteObject(memoryStream, obj); | |
| memoryStream.Position = 0; |
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 partial class DeploymentController : Controller | |
| { | |
| private DeploymentManager _manager; | |
| protected DeploymentManager Manager | |
| { | |
| get { return _manager ?? (_manager = new DeploymentManager()); } | |
| } | |
| public virtual ActionResult Delete() |
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
| PRINT 'Checking the existence of the Version table.' | |
| IF NOT EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Version]') AND type IN (N'U')) | |
| BEGIN | |
| PRINT 'The Version table does not exist.' | |
| PRINT 'Creating the Version table...' | |
| CREATE TABLE [dbo].[Version] ([Current] [nvarchar](100) NOT NULL) | |
| END | |
| PRINT 'Checking the existence of a row in the Version table.' | |
| IF NOT EXISTS (SELECT 1 FROM [dbo].[Version]) |
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.Configuration; | |
| using System.IO; | |
| using System.Net; | |
| using System.Runtime.Serialization.Json; | |
| using System.Text; | |
| using System.Web; | |
| using Think.Formica.Extensions; | |
| namespace Think.Formica.Translation |