List of my Freeware / Software
===============================
- Visual Studio Addins:
> Resharper
> Spell checker -> https://marketplace.visualstudio.com/items?itemName=EWoodruff.VisualStudioSpellChecker
> WebEssentials
> Productivity Power Tools
> NCrunch
> Snippet designer -> https://marketplace.visualstudio.com/items?itemName=vs-publisher-2795.SnippetDesigner
- Tools
> Notepad++
> Brackets
> SharpDevelop
> Agent Ransack
> Linqpad
> Fiddler
- SQL Server Addin
> Sql complete -> http://www.devart.com/dbforge/sql/sqlcomplete/
> SSMS and SSMS Boost -> http://www.ssmstoolspack.com/
- Chrome addins
> Postman
> Angular Wachters -> https://chrome.google.com/webstore/detail/angular-scope-inspector/aaglpchhlnofjbbpopfdfgllfkhnljnl?utm_source=chrome-app-launcher-info-dialog
> JSONView
> ng-inspector for AngularJS
> AngularJS Batarang
> Share it -> https://chrome.google.com/webstore/detail/addthis-share-bookmark-ne/cgbogdmdefihhljhfeiklfiedefalcde?utm_source=chrome-app-launcher-info-dialog
Popular Posts
-
Kendo UI applying SUM in footer template kendo ui - KendoUI: Grid Summary values in Footer - Stack Overflow : ", footerTemplate:...
-
MVC grid example ASP.NET MVC Flexigrid sample - CodeProject : 'via Blog this'
-
A possible way of handling distributed transaction for multiple contexts without alleviation to MSDTC??? c# - Entity Framework - Using Trans...
Saturday, December 31, 2016
Thursday, December 22, 2016
Wednesday, December 21, 2016
Monday, December 19, 2016
Home | .NET Fiddle
Home | .NET Fiddle
Using the Hex, Unicode, Decimal value of the char equivalently:
using System;
public class Program
{
public static void Main()
{
var hexValue = '\x0031';
var chr = Convert.ToChar(hexValue);
Console.WriteLine(chr);
var decimalValue = 49;
chr = Convert.ToChar(decimalValue);
Console.WriteLine(chr);
var achar = '1';
Console.WriteLine(achar);
var unicodeValue = '\u0031';
chr = Convert.ToChar(unicodeValue);
Console.WriteLine(chr);
}
}
Using the Hex, Unicode, Decimal value of the char equivalently:
using System;
public class Program
{
public static void Main()
{
var hexValue = '\x0031';
var chr = Convert.ToChar(hexValue);
Console.WriteLine(chr);
var decimalValue = 49;
chr = Convert.ToChar(decimalValue);
Console.WriteLine(chr);
var achar = '1';
Console.WriteLine(achar);
var unicodeValue = '\u0031';
chr = Convert.ToChar(unicodeValue);
Console.WriteLine(chr);
}
}
Friday, December 16, 2016
Friday, December 2, 2016
Sunday, November 20, 2016
Enable cors dynamically
http://stackoverflow.com/questions/35157306/enabling-multiple-cors-for-web-api
Saturday, November 19, 2016
Azure SDK and Tools | Visual Studio
Azure SDK and Tools | Visual Studio:
'via Blog this'
update azure sdk that fixes the error when deploying to azure!
'via Blog this'
update azure sdk that fixes the error when deploying to azure!
Friday, November 18, 2016
Sunday, November 13, 2016
Tuesday, November 8, 2016
Monday, November 7, 2016
Sunday, October 30, 2016
gitignore.io - Create Useful .gitignore Files For Your Project
gitignore.io - Create Useful .gitignore Files For Your Project
Great online tool that generate git ignore files.
Great online tool that generate git ignore files.
Friday, October 28, 2016
Learning Resources from Miscrosoft - CodeProject
Learning Resources from Miscrosoft - CodeProject
free microsoft stuff including the pluralsight
Microsoft free stuff
free microsoft stuff including the pluralsight
Microsoft free stuff
Monday, October 24, 2016
HttpClient - consuming the Web Api Service in .net
Here is an example of consuming Web Api in .Net client using pure HttpClient:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace WebApiClient
{
class Program
{
private static void Main(string[] args)
{
MainAsync().Wait();
Console.ReadLine();
}
static async Task MainAsync()
{
await ReadValues();
await AddValue();
await ReadValue(1);
await DeleteValue(2);
await DeleteValue(111); // Delete with Error
Console.ReadLine();
}
private async static Task DeleteValue(int id)
{
var url = "http://localhost:13628/api/Values/" + id;
using (var client = new HttpClient())
{
var response = await client.DeleteAsync(url);
if (response.IsSuccessStatusCode)
{
await ReadValues();
}
else
{
Console.WriteLine(response.ReasonPhrase);
Console.WriteLine(response.StatusCode);
}
}
}
private async static Task ReadValue(int id)
{
var url = "http://localhost:13628/api/Values/" + id;
using (var client = new HttpClient())
{
var httpResponseMessage = await client.GetAsync(url);
if (httpResponseMessage.IsSuccessStatusCode)
{
var jsonString = httpResponseMessage.Content.ReadAsStringAsync().Result;
var result = JsonConvert.DeserializeObject<ObjectToStore>(jsonString);
Console.WriteLine("Getting one value->" + result.Value);
}
else
{
Console.WriteLine(httpResponseMessage.StatusCode);
Console.WriteLine(httpResponseMessage.ReasonPhrase);
}
}
}
private async static Task AddValue()
{
var url = "http://localhost:13628/api/Values/";
using (var client = new HttpClient())
{
var value = new ObjectToStore() {Id = 3, Value = "value 3"};
var content = JsonConvert.SerializeObject(value);
var stringContent = new StringContent(content, Encoding.Default, "application/json"); // Note: need to include media type
var result = await client.PostAsync(url, stringContent);
if (result.IsSuccessStatusCode)
{
await ReadValues();
}
else
{
Console.WriteLine(result.StatusCode);
Console.WriteLine(result.ReasonPhrase);
}
}
}
private static async Task ReadValues()
{
var url = "http://localhost:13628/api/Values";
var client = new HttpClient();
var response = await client.GetAsync(url);
if (response.IsSuccessStatusCode)
{
var jsonString = response.Content.ReadAsStringAsync().Result;
var values = JsonConvert.DeserializeObject<List<ObjectToStore>>(jsonString);
foreach (ObjectToStore value in values)
{
Console.WriteLine(value.Value);
}
}
}
}
public class ObjectToStore
{
public int Id { get; set; }
public string Value { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace WebApiClient
{
class Program
{
private static void Main(string[] args)
{
MainAsync().Wait();
Console.ReadLine();
}
static async Task MainAsync()
{
await ReadValues();
await AddValue();
await ReadValue(1);
await DeleteValue(2);
await DeleteValue(111); // Delete with Error
Console.ReadLine();
}
private async static Task DeleteValue(int id)
{
var url = "http://localhost:13628/api/Values/" + id;
using (var client = new HttpClient())
{
var response = await client.DeleteAsync(url);
if (response.IsSuccessStatusCode)
{
await ReadValues();
}
else
{
Console.WriteLine(response.ReasonPhrase);
Console.WriteLine(response.StatusCode);
}
}
}
private async static Task ReadValue(int id)
{
var url = "http://localhost:13628/api/Values/" + id;
using (var client = new HttpClient())
{
var httpResponseMessage = await client.GetAsync(url);
if (httpResponseMessage.IsSuccessStatusCode)
{
var jsonString = httpResponseMessage.Content.ReadAsStringAsync().Result;
var result = JsonConvert.DeserializeObject<ObjectToStore>(jsonString);
Console.WriteLine("Getting one value->" + result.Value);
}
else
{
Console.WriteLine(httpResponseMessage.StatusCode);
Console.WriteLine(httpResponseMessage.ReasonPhrase);
}
}
}
private async static Task AddValue()
{
var url = "http://localhost:13628/api/Values/";
using (var client = new HttpClient())
{
var value = new ObjectToStore() {Id = 3, Value = "value 3"};
var content = JsonConvert.SerializeObject(value);
var stringContent = new StringContent(content, Encoding.Default, "application/json"); // Note: need to include media type
var result = await client.PostAsync(url, stringContent);
if (result.IsSuccessStatusCode)
{
await ReadValues();
}
else
{
Console.WriteLine(result.StatusCode);
Console.WriteLine(result.ReasonPhrase);
}
}
}
private static async Task ReadValues()
{
var url = "http://localhost:13628/api/Values";
var client = new HttpClient();
var response = await client.GetAsync(url);
if (response.IsSuccessStatusCode)
{
var jsonString = response.Content.ReadAsStringAsync().Result;
var values = JsonConvert.DeserializeObject<List<ObjectToStore>>(jsonString);
foreach (ObjectToStore value in values)
{
Console.WriteLine(value.Value);
}
}
}
}
public class ObjectToStore
{
public int Id { get; set; }
public string Value { get; set; }
}
}
Wednesday, October 19, 2016
mvc custom exception handler
custom error and message handling or global filters:
https://www.asp.net/web-api/overview/error-handling/exception-handling
Just a dirty example!!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Mail;
using System.Web;
using System.Web.Mail;
using System.Web.Mvc;
using System.Web.Routing;
namespace KidsWear.Shop.Filters
{
/// <summary>
/// Handle all exception in application level.
/// Deal with exceptions based on type.
/// Note: only handles Controller related exceptions i.e 500 code
/// </summary>
public class ExceptionActionFilter : FilterAttribute, IExceptionFilter
{
public EmailSender Emailer { get; set; }
public ExceptionActionFilter()
{
if (Emailer == null)
{
Emailer = new EmailSender();
}
}
public void OnException(ExceptionContext filterContext)
{
// if the request is AJAX return JSON else view.
if (filterContext.HttpContext.Request.Headers["X-Requested-With"] == "XMLHttpRequest")
{
HandleJasonException(filterContext);
}
// Handle the business exception
if (filterContext.Exception is BusinessException)
{
HandleBusinessException(filterContext);
}
// Handle security exception
else if (filterContext.Exception is FluentSecurity.PolicyViolationException)
{
HandleSecurityException(filterContext);
}
else
{
HandleUnExpectedExceptions(filterContext);
}
filterContext.ExceptionHandled = true;
}
private void HandleUnExpectedExceptions(ExceptionContext filterContext)
{
// Log the error using Elmah
Elmah.ErrorSignal.FromCurrentContext().Raise(filterContext.Exception);
// If all the other exceptions then show a friendly message and exception will be logged by Elmah
var msg =
"An error has happened. We appologise for any inconveniences...The system Administrator will be notified who will look at the issue and will resolve it ASAP....";
var emailData = new EmailData().WithDefaults();
emailData.Subject = filterContext.Exception.Message;
emailData.Body = filterContext.Exception.StackTrace;
filterContext.Controller.Notify(msg, NotificationType.Error);
filterContext.Result = new RedirectToRouteResult(new
System.Web.Routing.RouteValueDictionary(new
{
Controller = "Error",
Action = "Index"
}
));
Emailer.SendEmail(emailData);
}
private static void HandleSecurityException(ExceptionContext filterContext)
{
// Log the error using Elmah
Elmah.ErrorSignal.FromCurrentContext().Raise(filterContext.Exception);
filterContext.Result = new RedirectToRouteResult(new
System.Web.Routing.RouteValueDictionary(new
{
Controller = "Account",
Action = "Login"
}
));
}
private static void HandleBusinessException(ExceptionContext filterContext)
{
filterContext.Controller.Notify(filterContext.Exception.Message, NotificationType.Error);
filterContext.Result = new ViewResult
{
ViewName = filterContext.RouteData.Values["action"].ToString(),
TempData = filterContext.Controller.TempData,
ViewData = filterContext.Controller.ViewData
};
}
private static void HandleJasonException(ExceptionContext filterContext)
{
// Log the error using Elmah
Elmah.ErrorSignal.FromCurrentContext().Raise(filterContext.Exception);
filterContext.Result = new JsonResult
{
JsonRequestBehavior = JsonRequestBehavior.AllowGet,
Data = new
{
error = true,
message = filterContext.Exception.Message
}
};
}
}
}
https://www.asp.net/web-api/overview/error-handling/exception-handling
Just a dirty example!!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Mail;
using System.Web;
using System.Web.Mail;
using System.Web.Mvc;
using System.Web.Routing;
namespace KidsWear.Shop.Filters
{
/// <summary>
/// Handle all exception in application level.
/// Deal with exceptions based on type.
/// Note: only handles Controller related exceptions i.e 500 code
/// </summary>
public class ExceptionActionFilter : FilterAttribute, IExceptionFilter
{
public EmailSender Emailer { get; set; }
public ExceptionActionFilter()
{
if (Emailer == null)
{
Emailer = new EmailSender();
}
}
public void OnException(ExceptionContext filterContext)
{
// if the request is AJAX return JSON else view.
if (filterContext.HttpContext.Request.Headers["X-Requested-With"] == "XMLHttpRequest")
{
HandleJasonException(filterContext);
}
// Handle the business exception
if (filterContext.Exception is BusinessException)
{
HandleBusinessException(filterContext);
}
// Handle security exception
else if (filterContext.Exception is FluentSecurity.PolicyViolationException)
{
HandleSecurityException(filterContext);
}
else
{
HandleUnExpectedExceptions(filterContext);
}
filterContext.ExceptionHandled = true;
}
private void HandleUnExpectedExceptions(ExceptionContext filterContext)
{
// Log the error using Elmah
Elmah.ErrorSignal.FromCurrentContext().Raise(filterContext.Exception);
// If all the other exceptions then show a friendly message and exception will be logged by Elmah
var msg =
"An error has happened. We appologise for any inconveniences...The system Administrator will be notified who will look at the issue and will resolve it ASAP....";
var emailData = new EmailData().WithDefaults();
emailData.Subject = filterContext.Exception.Message;
emailData.Body = filterContext.Exception.StackTrace;
filterContext.Controller.Notify(msg, NotificationType.Error);
filterContext.Result = new RedirectToRouteResult(new
System.Web.Routing.RouteValueDictionary(new
{
Controller = "Error",
Action = "Index"
}
));
Emailer.SendEmail(emailData);
}
private static void HandleSecurityException(ExceptionContext filterContext)
{
// Log the error using Elmah
Elmah.ErrorSignal.FromCurrentContext().Raise(filterContext.Exception);
filterContext.Result = new RedirectToRouteResult(new
System.Web.Routing.RouteValueDictionary(new
{
Controller = "Account",
Action = "Login"
}
));
}
private static void HandleBusinessException(ExceptionContext filterContext)
{
filterContext.Controller.Notify(filterContext.Exception.Message, NotificationType.Error);
filterContext.Result = new ViewResult
{
ViewName = filterContext.RouteData.Values["action"].ToString(),
TempData = filterContext.Controller.TempData,
ViewData = filterContext.Controller.ViewData
};
}
private static void HandleJasonException(ExceptionContext filterContext)
{
// Log the error using Elmah
Elmah.ErrorSignal.FromCurrentContext().Raise(filterContext.Exception);
filterContext.Result = new JsonResult
{
JsonRequestBehavior = JsonRequestBehavior.AllowGet,
Data = new
{
error = true,
message = filterContext.Exception.Message
}
};
}
}
}
Thursday, October 13, 2016
Github - Notes
****************************************
GitHub
****************************************
Adding existing project to github:
https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
- Setting Git email address
git config --global user.email "rahman.mahmoodi@gmail.com"
or environment variables:
GIT_COMMITTER_EMAIL=rahman.mahmoodi@gmail.com
GIT_AUTHOR_EMAIL=rahman.mahmoodi@gmail.com
- check user and email configurations
git config --global --list
- Deleting the repository from github
[githutrepositoryurl]/settings and then under the danger zoon delete the repo.
- Find what Remote URL a local git is connected to
git config --get remote.origin.url
- git folder is stored in the root of the repository (project folder), though it is hidden. Just delete that file and it will reset the things
- Adding an existing folder to new github
echo "# ASP.NetWebAPIAdvancedTopics" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/RahmanM/ASP.NetWebAPIAdvancedTopics.git
git push -f origin master
- **** WAS getting unauthorized error for rahmanx **** needed to update the .config file in the git folder of the repository to include the user name and password in th eurls like
https://rahmanm:abcccccccc@github.com/RahmanM/ASP.NetWebAPIAdvancedTopics.git
- Adding formatting to github read me file https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet
- git text editor
> press i to go to insert mode
> type the comments
> press Esc to exit insert mode
> :wq (to save the text file and exit)
- Creating branch
git branch my-branch-name
git checkout my-branch-name
- To merge
> Go to destination branch eg master
> git merge my-branch-name
- git mergetool
GitHub
****************************************
Adding existing project to github:
https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
- Setting Git email address
git config --global user.email "rahman.mahmoodi@gmail.com"
or environment variables:
GIT_COMMITTER_EMAIL=rahman.mahmoodi@gmail.com
GIT_AUTHOR_EMAIL=rahman.mahmoodi@gmail.com
- check user and email configurations
git config --global --list
- Deleting the repository from github
[githutrepositoryurl]/settings and then under the danger zoon delete the repo.
- Find what Remote URL a local git is connected to
git config --get remote.origin.url
- git folder is stored in the root of the repository (project folder), though it is hidden. Just delete that file and it will reset the things
- Adding an existing folder to new github
echo "# ASP.NetWebAPIAdvancedTopics" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/RahmanM/ASP.NetWebAPIAdvancedTopics.git
git push -f origin master
- **** WAS getting unauthorized error for rahmanx **** needed to update the .config file in the git folder of the repository to include the user name and password in th eurls like
https://rahmanm:abcccccccc@github.com/RahmanM/ASP.NetWebAPIAdvancedTopics.git
- Adding formatting to github read me file https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet
- git text editor
> press i to go to insert mode
> type the comments
> press Esc to exit insert mode
> :wq (to save the text file and exit)
- Creating branch
git branch my-branch-name
git checkout my-branch-name
- To merge
> Go to destination branch eg master
> git merge my-branch-name
- git mergetool
Web Layout - Notes
***************************************
Website layouts design
***************************************
> Layouts
- Forms
- Carousels
- Gallaries
- Header, Navigation,Logo, Side, Footer, Hero
> Progressive enhancements
> Sectioning elements
- Div, header, footer, nav, address
> CSS Reset
- Normalize.css
> Typographic and font sizes
> Free fonts
- GoogleFonts -> https://fonts.google.com/?authuser=0
> CSS Cascading
- Inheritance : e.g. all the child elements inherit the parent element's properties
- Source e.g User Agent, Users, Authors
- Specifity e.g. classes, ids, inline styles to apply css to specific elements
>> Order of specifity is -> Universal Selectors (*) -> Type Selectors (p, h1) -> Classes (.heading) -> Attribute selectors (input[type="text"]) -> Psydo classes (:hover, :focus, :visited) -> Id selectors (#myid) -> inline selectors!!
- Importance (!important)
> Specifity Formula
- Put a number for each specifity that is found and add the numbers e.g. for
Inline Ids Class/Psuedo-class/Attribute Type Selector/Psuedo
0 1 2 1 -> #hero .myclass nth-of-type(2) h1
0 2 2 1 -> #homepage #landing h1 a:hover .red-color
> Dreamweaver css designer
- animate.css
- bootstrap popover
-- use under score templates to populate the content
- relative parent and absolute children?
- css2less.co
- CanIUse.com => Browser compatibility
***************************************
- LESS Summary
***************************************
>> Create variables @variable-name : red;
>> Create heirarchy of elements rather than repeating them many times
>> Add comments
>> Import CSS or other Less files @Import "filename.css"
>> Functions
>>> color : darken(@variable-name + 10%) , lighten, saturate, etc
>> Operations
>>> color : @font-size + 12;
>> Mixen -> functions that accepts parameter and is reusable
>>> .my-first-mixin(@size){
border-radius : @size;
}
and use it as:
#form {
broder-radius : my-first-mixin(5px);
}
CSS Positioning
====================
- Default position is Static e.g elements stack on each other in the document
- Position: Relative
-> Sets the position of the element based on its original position.
- Position: Absolute
-> Sets the position of the elements as it does not have any width and height e.g. all the other elements will move up.
-> Absolute positioning is based on document
-> Its relevant to the document, when scrolling it will move up or down
- Position : Fixed
-> Fixed position is based on the browser window. I.e. even with scrolling it will remain there
Website layouts design
***************************************
> Layouts
- Forms
- Carousels
- Gallaries
- Header, Navigation,Logo, Side, Footer, Hero
> Progressive enhancements
> Sectioning elements
- Div, header, footer, nav, address
> CSS Reset
- Normalize.css
> Typographic and font sizes
> Free fonts
- GoogleFonts -> https://fonts.google.com/?authuser=0
> CSS Cascading
- Inheritance : e.g. all the child elements inherit the parent element's properties
- Source e.g User Agent, Users, Authors
- Specifity e.g. classes, ids, inline styles to apply css to specific elements
>> Order of specifity is -> Universal Selectors (*) -> Type Selectors (p, h1) -> Classes (.heading) -> Attribute selectors (input[type="text"]) -> Psydo classes (:hover, :focus, :visited) -> Id selectors (#myid) -> inline selectors!!
- Importance (!important)
> Specifity Formula
- Put a number for each specifity that is found and add the numbers e.g. for
Inline Ids Class/Psuedo-class/Attribute Type Selector/Psuedo
0 1 2 1 -> #hero .myclass nth-of-type(2) h1
0 2 2 1 -> #homepage #landing h1 a:hover .red-color
> Dreamweaver css designer
- animate.css
- bootstrap popover
-- use under score templates to populate the content
- relative parent and absolute children?
- css2less.co
- CanIUse.com => Browser compatibility
***************************************
- LESS Summary
***************************************
>> Create variables @variable-name : red;
>> Create heirarchy of elements rather than repeating them many times
>> Add comments
>> Import CSS or other Less files @Import "filename.css"
>> Functions
>>> color : darken(@variable-name + 10%) , lighten, saturate, etc
>> Operations
>>> color : @font-size + 12;
>> Mixen -> functions that accepts parameter and is reusable
>>> .my-first-mixin(@size){
border-radius : @size;
}
and use it as:
#form {
broder-radius : my-first-mixin(5px);
}
CSS Positioning
====================
- Default position is Static e.g elements stack on each other in the document
- Position: Relative
-> Sets the position of the element based on its original position.
- Position: Absolute
-> Sets the position of the elements as it does not have any width and height e.g. all the other elements will move up.
-> Absolute positioning is based on document
-> Its relevant to the document, when scrolling it will move up or down
- Position : Fixed
-> Fixed position is based on the browser window. I.e. even with scrolling it will remain there
HTML5 - Notes
***************************************
HTML 5
***************************************
New Semantic Elements in HTML5
- <article>
- <aside>
- <details>
- <figure>
- <footer>
- <header>
- <main>
- <mark>
- <nav>
- <section>
- <summary>
- <time>
New Form elements
- Datalist, output
New Javascript
-
New Input types
- color
- date
- datetime
- datetime-local
- email
- month
- number
- range
- search
- tel
- time
- url
- week
New Media
- Audio
- Video
- Track
HTML 5
***************************************
New Semantic Elements in HTML5
- <article>
- <aside>
- <details>
- <figure>
- <footer>
- <header>
- <main>
- <mark>
- <nav>
- <section>
- <summary>
- <time>
New Form elements
- Datalist, output
New Javascript
-
New Input types
- color
- date
- datetime
- datetime-local
- month
- number
- range
- search
- tel
- time
- url
- week
New Media
- Audio
- Video
- Track
Bootstrap - Notes
********************
Bootstrap
********************
- setting up of the viewport is required for the responsive
*** Mostly Fluid Pattern ***
- container-fluid is to fill the whole page rather than the margins
- move the columns in different view ports
*** Layout Shifter Pattern ***
> Desing the page based on mobile
> push the columns and pull the columns on different sizes
col-sm-push-2 and then col-sm-pull-8
> Push and pull are related to left side of the browser
*** Layout Drop Pattern ***
- Visible-mid and hide-mid to hide and show columns based on different ports
*** Content Reflow Pattern ***
> Using media query to move the text around the image and make the <a> tag block
iamge-list a{
display: block;
}
iamge-list img{
display: inline;
}
- Same size columns in a three layout columns
> minimit.com that has the article on how to do it - basically change the display to table!!!
> img-responsive to make image responsive
Bootstrap
********************
- setting up of the viewport is required for the responsive
*** Mostly Fluid Pattern ***
- container-fluid is to fill the whole page rather than the margins
- move the columns in different view ports
*** Layout Shifter Pattern ***
> Desing the page based on mobile
> push the columns and pull the columns on different sizes
col-sm-push-2 and then col-sm-pull-8
> Push and pull are related to left side of the browser
*** Layout Drop Pattern ***
- Visible-mid and hide-mid to hide and show columns based on different ports
*** Content Reflow Pattern ***
> Using media query to move the text around the image and make the <a> tag block
iamge-list a{
display: block;
}
iamge-list img{
display: inline;
}
- Same size columns in a three layout columns
> minimit.com that has the article on how to do it - basically change the display to table!!!
> img-responsive to make image responsive
Octopus Deploy - Notes
********************
Octopus Deploy
********************
Physical Architecture:
- SQL Database
- Octopus Deploy Server
- Deployment Targets (client machines) [Tentacles (windows services that communicates to server) AND Calamari (Command line tool that execute the messages)]
Logical Concept:
- Environments e.g. Dev, Prod etc
- Roles e.g. Todo.Web and Todo.Services
- Packages e.g nuget packages
- Projects e.g a recipe for deployment i.e. Deploy project, notify users, notify in slack
- Releases
Tuesday, September 27, 2016
Thursday, September 15, 2016
Wednesday, September 14, 2016
Responsive Websites With Bootstrap 3
Responsive Websites With Bootstrap 3
arranging the columns at run time for mobile and desktop devices.
- Design the columns as per mobile device
- Push and Pull columns for the other sizes
arranging the columns at run time for mobile and desktop devices.
- Design the columns as per mobile device
- Push and Pull columns for the other sizes
Saturday, September 10, 2016
Friday, September 9, 2016
Thursday, September 8, 2016
Logging framework
http://www.codeproject.com/Articles/1126297/OneTrueError-Automated-exception-handling
Sunday, September 4, 2016
Asp.net web diary calendar
http://www.codeproject.com/Articles/1117424/Multi-user-resource-web-diary-in-Csharp-MVC-with-r
Saturday, September 3, 2016
SASS / SCSS goodness!!!
Examples of SCSS:
// Importing the "partials"
@import "_variables";
@import "_mixins";
body {
font-size: $my-font-size;
font: $font-stack;
}
// using the mixin
.box {
@include border-radius(10px);
}
// Extending the functionality by @extend
.message {
border: 1px solid #ccc;
padding: 10px;
color: #333;
}
.success {
@extend .message;
border-color: green;
}
.error {
@extend .message;
border-color: red;
}
.warning {
@extend .message;
border-color: yellow;
}
// Operators
h1 {
font-size: $my-font-size + 10px;
}
// if conditions
p {
@if 1 + 1 == 2 { border: 1px solid; }
@if 5 < 3 { border: 2px dotted; }
@if null { border: 3px double; }
}
$type: 1;
p {
@if $type == 1 {
color: blue;
} @else if $type == 2 {
color: red;
} @else if $type == 3 {
color: green;
} @else {
color: black;
}
}
// For loop
@for $i from 1 through 3 {
.item-#{$i} { width: 2em * $i; }
}
// For each
@each $animal in puma, sea-slug, egret, salamander {
.#{$animal}-icon {
background-image: url('/images/#{$animal}.png');
}
}
// ---> For each with multiple assignment
@each $animal, $color, $cursor in (puma, black, default),
(sea-slug, blue, pointer),
(egret, white, move) {
.#{$animal}-icon {
background-image: url('/images/#{$animal}.png');
border: 2px solid $color;
cursor: $cursor;
}
}
// While loop
$i: 6;
@while $i > 0 {
.item-#{$i} { width: 2em * $i; }
$i: $i - 2;
}
/*
STRING REPLACEMENT FUNCTIONS
===============================
str-length: like length but for strings
str-slice: slicing a string from index A to index B
str-insert: insert a string in a string at index A`
str-index: finds first occurence of string in string
to_lower_case: move a whole string to lower case
*/
@each $person in rahman, maria, hosha, roya {
##{$person} {
@if str-index($person, "r") == 1 { // IF STARTS WITH R
background-color: red;
}
}
}
Complied to:
/* line 10, D:/rahman/Tpg_Design/_mixins.scss */
.message, .success, .error, .warning {
border: 1px solid #ccc;
padding: 10px;
color: #333; }
/* line 16, D:/rahman/Tpg_Design/_mixins.scss */
.success {
border-color: green; }
/* line 21, D:/rahman/Tpg_Design/_mixins.scss */
.error {
border-color: red; }
/* line 26, D:/rahman/Tpg_Design/_mixins.scss */
.warning {
border-color: yellow; }
/* line 5, D:/rahman/Tpg_Design/mysass.scss */
body {
font-size: 15px;
font: Helvetica, sans-serif; }
/* line 11, D:/rahman/Tpg_Design/mysass.scss */
.box {
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
-ms-border-radius: 10px;
border-radius: 10px; }
/* line 16, D:/rahman/Tpg_Design/mysass.scss */
.message, .success, .error, .warning {
border: 1px solid #ccc;
padding: 10px;
color: #333; }
/* line 22, D:/rahman/Tpg_Design/mysass.scss */
.success {
border-color: green; }
/* line 27, D:/rahman/Tpg_Design/mysass.scss */
.error {
border-color: red; }
/* line 32, D:/rahman/Tpg_Design/mysass.scss */
.warning {
border-color: yellow; }
/* line 38, D:/rahman/Tpg_Design/mysass.scss */
h1 {
font-size: 25px; }
/* line 43, D:/rahman/Tpg_Design/mysass.scss */
p {
border: 1px solid; }
/* line 50, D:/rahman/Tpg_Design/mysass.scss */
p {
color: blue; }
/* line 63, D:/rahman/Tpg_Design/mysass.scss */
.item-1 {
width: 2em; }
/* line 63, D:/rahman/Tpg_Design/mysass.scss */
.item-2 {
width: 4em; }
/* line 63, D:/rahman/Tpg_Design/mysass.scss */
.item-3 {
width: 6em; }
/* line 69, D:/rahman/Tpg_Design/mysass.scss */
.puma-icon {
background-image: url("/images/puma.png"); }
/* line 69, D:/rahman/Tpg_Design/mysass.scss */
.sea-slug-icon {
background-image: url("/images/sea-slug.png"); }
/* line 69, D:/rahman/Tpg_Design/mysass.scss */
.egret-icon {
background-image: url("/images/egret.png"); }
/* line 69, D:/rahman/Tpg_Design/mysass.scss */
.salamander-icon {
background-image: url("/images/salamander.png"); }
/* line 79, D:/rahman/Tpg_Design/mysass.scss */
.puma-icon {
background-image: url("/images/puma.png");
border: 2px solid black;
cursor: default; }
/* line 79, D:/rahman/Tpg_Design/mysass.scss */
.sea-slug-icon {
background-image: url("/images/sea-slug.png");
border: 2px solid blue;
cursor: pointer; }
/* line 79, D:/rahman/Tpg_Design/mysass.scss */
.egret-icon {
background-image: url("/images/egret.png");
border: 2px solid white;
cursor: move; }
/* line 90, D:/rahman/Tpg_Design/mysass.scss */
.item-6 {
width: 12em; }
/* line 90, D:/rahman/Tpg_Design/mysass.scss */
.item-4 {
width: 8em; }
/* line 90, D:/rahman/Tpg_Design/mysass.scss */
.item-2 {
width: 4em; }
/*
STRING REPLACEMENT FUNCTIONS
===============================
str-length: like length but for strings
str-slice: slicing a string from index A to index B
str-insert: insert a string in a string at index A`
str-index: finds first occurence of string in string
to_lower_case: move a whole string to lower case
*/
/* line 105, D:/rahman/Tpg_Design/mysass.scss */
#rahman {
background-color: red; }
/* line 105, D:/rahman/Tpg_Design/mysass.scss */
#roya {
background-color: red; }
/* Testings */
background-color: aquamarine;
/* line 121, D:/rahman/Tpg_Design/mysass.scss */
.item1 {
font-size: 1px; }
/* line 121, D:/rahman/Tpg_Design/mysass.scss */
.item2 {
font-size: 2px; }
/* line 121, D:/rahman/Tpg_Design/mysass.scss */
.item3 {
font-size: 3px; }
/* line 121, D:/rahman/Tpg_Design/mysass.scss */
.item4 {
font-size: 4px; }
/* line 121, D:/rahman/Tpg_Design/mysass.scss */
.item5 {
font-size: 5px; }
/* line 121, D:/rahman/Tpg_Design/mysass.scss */
.item6 {
font-size: 6px; }
/* line 121, D:/rahman/Tpg_Design/mysass.scss */
.item7 {
font-size: 7px; }
/* line 121, D:/rahman/Tpg_Design/mysass.scss */
.item8 {
font-size: 8px; }
/* line 121, D:/rahman/Tpg_Design/mysass.scss */
.item9 {
font-size: 9px; }
/* line 121, D:/rahman/Tpg_Design/mysass.scss */
.item10 {
font-size: 10px; }
/* line 121, D:/rahman/Tpg_Design/mysass.scss */
.item11 {
font-size: 11px; }
/* line 121, D:/rahman/Tpg_Design/mysass.scss */
.item12 {
font-size: 12px; }
/* line 121, D:/rahman/Tpg_Design/mysass.scss */
.item13 {
font-size: 13px; }
/* line 121, D:/rahman/Tpg_Design/mysass.scss */
.item14 {
font-size: 14px; }
/* line 121, D:/rahman/Tpg_Design/mysass.scss */
.item15 {
font-size: 15px; }
/* line 121, D:/rahman/Tpg_Design/mysass.scss */
.item16 {
font-size: 16px; }
/* line 121, D:/rahman/Tpg_Design/mysass.scss */
.item17 {
font-size: 17px; }
/* line 121, D:/rahman/Tpg_Design/mysass.scss */
.item18 {
font-size: 18px; }
/* line 121, D:/rahman/Tpg_Design/mysass.scss */
.item19 {
font-size: 19px; }
/* line 121, D:/rahman/Tpg_Design/mysass.scss */
.item20 {
font-size: 20px; }
/* line 127, D:/rahman/Tpg_Design/mysass.scss */
#rahman {
background-color: red; }
/* line 127, D:/rahman/Tpg_Design/mysass.scss */
#roya {
background-color: red; }
/*# sourceMappingURL=mysass.css.map */
// Importing the "partials"
@import "_variables";
@import "_mixins";
body {
font-size: $my-font-size;
font: $font-stack;
}
// using the mixin
.box {
@include border-radius(10px);
}
// Extending the functionality by @extend
.message {
border: 1px solid #ccc;
padding: 10px;
color: #333;
}
.success {
@extend .message;
border-color: green;
}
.error {
@extend .message;
border-color: red;
}
.warning {
@extend .message;
border-color: yellow;
}
// Operators
h1 {
font-size: $my-font-size + 10px;
}
// if conditions
p {
@if 1 + 1 == 2 { border: 1px solid; }
@if 5 < 3 { border: 2px dotted; }
@if null { border: 3px double; }
}
$type: 1;
p {
@if $type == 1 {
color: blue;
} @else if $type == 2 {
color: red;
} @else if $type == 3 {
color: green;
} @else {
color: black;
}
}
// For loop
@for $i from 1 through 3 {
.item-#{$i} { width: 2em * $i; }
}
// For each
@each $animal in puma, sea-slug, egret, salamander {
.#{$animal}-icon {
background-image: url('/images/#{$animal}.png');
}
}
// ---> For each with multiple assignment
@each $animal, $color, $cursor in (puma, black, default),
(sea-slug, blue, pointer),
(egret, white, move) {
.#{$animal}-icon {
background-image: url('/images/#{$animal}.png');
border: 2px solid $color;
cursor: $cursor;
}
}
// While loop
$i: 6;
@while $i > 0 {
.item-#{$i} { width: 2em * $i; }
$i: $i - 2;
}
/*
STRING REPLACEMENT FUNCTIONS
===============================
str-length: like length but for strings
str-slice: slicing a string from index A to index B
str-insert: insert a string in a string at index A`
str-index: finds first occurence of string in string
to_lower_case: move a whole string to lower case
*/
@each $person in rahman, maria, hosha, roya {
##{$person} {
@if str-index($person, "r") == 1 { // IF STARTS WITH R
background-color: red;
}
}
}
Complied to:
/* line 10, D:/rahman/Tpg_Design/_mixins.scss */
.message, .success, .error, .warning {
border: 1px solid #ccc;
padding: 10px;
color: #333; }
/* line 16, D:/rahman/Tpg_Design/_mixins.scss */
.success {
border-color: green; }
/* line 21, D:/rahman/Tpg_Design/_mixins.scss */
.error {
border-color: red; }
/* line 26, D:/rahman/Tpg_Design/_mixins.scss */
.warning {
border-color: yellow; }
/* line 5, D:/rahman/Tpg_Design/mysass.scss */
body {
font-size: 15px;
font: Helvetica, sans-serif; }
/* line 11, D:/rahman/Tpg_Design/mysass.scss */
.box {
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
-ms-border-radius: 10px;
border-radius: 10px; }
/* line 16, D:/rahman/Tpg_Design/mysass.scss */
.message, .success, .error, .warning {
border: 1px solid #ccc;
padding: 10px;
color: #333; }
/* line 22, D:/rahman/Tpg_Design/mysass.scss */
.success {
border-color: green; }
/* line 27, D:/rahman/Tpg_Design/mysass.scss */
.error {
border-color: red; }
/* line 32, D:/rahman/Tpg_Design/mysass.scss */
.warning {
border-color: yellow; }
/* line 38, D:/rahman/Tpg_Design/mysass.scss */
h1 {
font-size: 25px; }
/* line 43, D:/rahman/Tpg_Design/mysass.scss */
p {
border: 1px solid; }
/* line 50, D:/rahman/Tpg_Design/mysass.scss */
p {
color: blue; }
/* line 63, D:/rahman/Tpg_Design/mysass.scss */
.item-1 {
width: 2em; }
/* line 63, D:/rahman/Tpg_Design/mysass.scss */
.item-2 {
width: 4em; }
/* line 63, D:/rahman/Tpg_Design/mysass.scss */
.item-3 {
width: 6em; }
/* line 69, D:/rahman/Tpg_Design/mysass.scss */
.puma-icon {
background-image: url("/images/puma.png"); }
/* line 69, D:/rahman/Tpg_Design/mysass.scss */
.sea-slug-icon {
background-image: url("/images/sea-slug.png"); }
/* line 69, D:/rahman/Tpg_Design/mysass.scss */
.egret-icon {
background-image: url("/images/egret.png"); }
/* line 69, D:/rahman/Tpg_Design/mysass.scss */
.salamander-icon {
background-image: url("/images/salamander.png"); }
/* line 79, D:/rahman/Tpg_Design/mysass.scss */
.puma-icon {
background-image: url("/images/puma.png");
border: 2px solid black;
cursor: default; }
/* line 79, D:/rahman/Tpg_Design/mysass.scss */
.sea-slug-icon {
background-image: url("/images/sea-slug.png");
border: 2px solid blue;
cursor: pointer; }
/* line 79, D:/rahman/Tpg_Design/mysass.scss */
.egret-icon {
background-image: url("/images/egret.png");
border: 2px solid white;
cursor: move; }
/* line 90, D:/rahman/Tpg_Design/mysass.scss */
.item-6 {
width: 12em; }
/* line 90, D:/rahman/Tpg_Design/mysass.scss */
.item-4 {
width: 8em; }
/* line 90, D:/rahman/Tpg_Design/mysass.scss */
.item-2 {
width: 4em; }
/*
STRING REPLACEMENT FUNCTIONS
===============================
str-length: like length but for strings
str-slice: slicing a string from index A to index B
str-insert: insert a string in a string at index A`
str-index: finds first occurence of string in string
to_lower_case: move a whole string to lower case
*/
/* line 105, D:/rahman/Tpg_Design/mysass.scss */
#rahman {
background-color: red; }
/* line 105, D:/rahman/Tpg_Design/mysass.scss */
#roya {
background-color: red; }
/* Testings */
background-color: aquamarine;
/* line 121, D:/rahman/Tpg_Design/mysass.scss */
.item1 {
font-size: 1px; }
/* line 121, D:/rahman/Tpg_Design/mysass.scss */
.item2 {
font-size: 2px; }
/* line 121, D:/rahman/Tpg_Design/mysass.scss */
.item3 {
font-size: 3px; }
/* line 121, D:/rahman/Tpg_Design/mysass.scss */
.item4 {
font-size: 4px; }
/* line 121, D:/rahman/Tpg_Design/mysass.scss */
.item5 {
font-size: 5px; }
/* line 121, D:/rahman/Tpg_Design/mysass.scss */
.item6 {
font-size: 6px; }
/* line 121, D:/rahman/Tpg_Design/mysass.scss */
.item7 {
font-size: 7px; }
/* line 121, D:/rahman/Tpg_Design/mysass.scss */
.item8 {
font-size: 8px; }
/* line 121, D:/rahman/Tpg_Design/mysass.scss */
.item9 {
font-size: 9px; }
/* line 121, D:/rahman/Tpg_Design/mysass.scss */
.item10 {
font-size: 10px; }
/* line 121, D:/rahman/Tpg_Design/mysass.scss */
.item11 {
font-size: 11px; }
/* line 121, D:/rahman/Tpg_Design/mysass.scss */
.item12 {
font-size: 12px; }
/* line 121, D:/rahman/Tpg_Design/mysass.scss */
.item13 {
font-size: 13px; }
/* line 121, D:/rahman/Tpg_Design/mysass.scss */
.item14 {
font-size: 14px; }
/* line 121, D:/rahman/Tpg_Design/mysass.scss */
.item15 {
font-size: 15px; }
/* line 121, D:/rahman/Tpg_Design/mysass.scss */
.item16 {
font-size: 16px; }
/* line 121, D:/rahman/Tpg_Design/mysass.scss */
.item17 {
font-size: 17px; }
/* line 121, D:/rahman/Tpg_Design/mysass.scss */
.item18 {
font-size: 18px; }
/* line 121, D:/rahman/Tpg_Design/mysass.scss */
.item19 {
font-size: 19px; }
/* line 121, D:/rahman/Tpg_Design/mysass.scss */
.item20 {
font-size: 20px; }
/* line 127, D:/rahman/Tpg_Design/mysass.scss */
#rahman {
background-color: red; }
/* line 127, D:/rahman/Tpg_Design/mysass.scss */
#roya {
background-color: red; }
/*# sourceMappingURL=mysass.css.map */
Monday, August 29, 2016
Run jobs in background
http://www.codeproject.com/Articles/1119633/Execute-a-Net-long-running-task-in-background-usin
Free mail merge. Net
http://www.codeproject.com/Articles/19546/MailMergeLib-A-NET-Mail-Client-Library
Sunday, August 14, 2016
CSS Positioning 101 · An A List Apart Article
CSS Positioning 101 · An A List Apart Article
great example and description of the elements positioning
great example and description of the elements positioning
Saturday, July 30, 2016
Apply Caching In Web API Using CacheCow
Apply Caching In Web API Using CacheCow
Great example of ETag in ASP.Net web api for memory caching!!!
Great example of ETag in ASP.Net web api for memory caching!!!
Friday, July 29, 2016
JSONView - Chrome Web Store
JSONView - Chrome Web Store
Chrome plugin that displays the JSON result returned from a Web API call as formatted rather than the raw JSON that Chrome shows by default.
I needed this as my result was returning Preview and Next Links and I could interactively work with the Hypermedia links!!
Chrome plugin that displays the JSON result returned from a Web API call as formatted rather than the raw JSON that Chrome shows by default.
I needed this as my result was returning Preview and Next Links and I could interactively work with the Hypermedia links!!
Web API Design | Pluralsight
Web API Design | Pluralsight
Web API Summary
=================
>> RESTful
- Resource based as URIs
- http verbs for operations
- heirarchical web data e.g. Customers/1/orders
- stateless
- Client and Server are fully separate i.e. there is no references or proxies other than the URI
- Requests are cacheable
- Hateos or hypermedia i.e the results are self documenting e.g. it includes links or uri for the other operations that can be valid on result
- Content negociation based on headers
>> Good Desing
- should be url based and using plural nouns
- should use HTTP verbs to perform operations
- should return http status codes for delete, updated item for Put, all items for Get
- ETag caching
- Paging
- Versioning
Web API Summary
=================
>> RESTful
- Resource based as URIs
- http verbs for operations
- heirarchical web data e.g. Customers/1/orders
- stateless
- Client and Server are fully separate i.e. there is no references or proxies other than the URI
- Requests are cacheable
- Hateos or hypermedia i.e the results are self documenting e.g. it includes links or uri for the other operations that can be valid on result
- Content negociation based on headers
>> Good Desing
- should be url based and using plural nouns
- should use HTTP verbs to perform operations
- should return http status codes for delete, updated item for Put, all items for Get
- ETag caching
- Paging
- Versioning
Thursday, July 28, 2016
A Better CSS: LESS and SASS
A Better CSS: LESS and SASS
LESS features in summary:
>> Create variables @variable-name : red;
>> Create heirarchy of elements rather than repeating them many times
>> Add comments // and /**/
>> Import CSS or other Less files @Import "filename.css"
>> Functions
>>> color : darken(@variable-name + 10%) , lighten, saturate, etc
>> Operations
>>> color : @font-size + 12;
>> Mixen -> functions that accepts parameter and is reusable
>>> .my-first-mixin(@size){
border-radius : @size;
}
and use it as:
#form {
broder-radius : my-first-mixin(5px);
}
>> namespaces
LESS features in summary:
>> Create variables @variable-name : red;
>> Create heirarchy of elements rather than repeating them many times
>> Add comments // and /**/
>> Import CSS or other Less files @Import "filename.css"
>> Functions
>>> color : darken(@variable-name + 10%) , lighten, saturate, etc
>> Operations
>>> color : @font-size + 12;
>> Mixen -> functions that accepts parameter and is reusable
>>> .my-first-mixin(@size){
border-radius : @size;
}
and use it as:
#form {
broder-radius : my-first-mixin(5px);
}
>> namespaces
Web Extension Pack
Web Extension Pack
This is required to be installed otherwise most of the cool features like .less preview etc will not be working in Visual Studio 2015.
This is required to be installed otherwise most of the cool features like .less preview etc will not be working in Visual Studio 2015.
Wednesday, July 27, 2016
Tuesday, July 26, 2016
Saturday, July 23, 2016
Tuesday, July 5, 2016
Sunday, July 3, 2016
Continuous Deployment to Microsoft Azure Websites | Dev Superpowers #8 | Adam Stephensen - YouTube
Continuous Deployment to Microsoft Azure Websites | Dev Superpowers #8 | Adam Stephensen - YouTube
configuring continuous integration with azure and visual studio online
configuring continuous integration with azure and visual studio online
Saturday, July 2, 2016
Monday, June 27, 2016
Passing data from controller to view mb
http://www.codeproject.com/Articles/1108855/ways-to-Bind-Multiple-Models-on-a-View-in-MVC
Saturday, June 25, 2016
Friday, June 24, 2016
Thursday, June 23, 2016
Azure Website Slow on First Request part II – Simon J.K. Pedersen's Azure & SharePoint blog
Azure Website Slow on First Request part II – Simon J.K. Pedersen's Azure & SharePoint blog
webjob to keep the website alive.
free azure website keep always one
webjob to keep the website alive.
free azure website keep always one
Tuesday, June 21, 2016
Testing, generating data automatically using AutoFixture/AutoFixture: AutoFixture is an open source library for .NET designed to minimize the 'Arrange' phase of your unit tests in order to maximize maintainability. Its primary goal is to allow developers to focus on what is being tested rather than how to setup the test scenario, by making it easier to create object graphs containing test data.
GitHub - AutoFixture/AutoFixture: AutoFixture is an open source library for .NET designed to minimize the 'Arrange' phase of your unit tests in order to maximize maintainability. Its primary goal is to allow developers to focus on what is being tested rather than how to setup the test scenario, by making it easier to create object graphs containing test data.
Testing, mocking and autofixture
Testing, mocking and autofixture
Testing Entity framework using Moq and extension method
Moq extension to transform a list to Moq of DBSet for testing the Entity Framework DbSet.
public static class Extensions { public static Mock<DbSet<T>> GetMockSet<T>(this IQueryable<T> data) where T : class { var mockSet = new Mock<DbSet<T>>(); mockSet.As<IQueryable<T>>().Setup(m => m.Provider).Returns(data.Provider); mockSet.As<IQueryable<T>>().Setup(m => m.Expression).Returns(data.Expression); mockSet.As<IQueryable<T>>().Setup(m => m.ElementType).Returns(data.ElementType); mockSet.As<IQueryable<T>>().Setup(m => m.GetEnumerator()).Returns<T>(x => data.GetEnumerator()); return mockSet; } }
To use it in the test as following:
[TestMethod] public void GetCustomer_Mocked_With_Extension() { var mockedContext = new Mock<IDbContext>(); var data = new List<Customer> { new Customer { FirstName = "Rahman", LastName = "Mahmoodi", Id = 1 } }.AsQueryable(); var mockSet = data.GetMockSet<Customer>(); // This is how to use it mockedContext.Setup(x => x.Customers).Returns(mockSet.Object); var cbo = new CustomerBusinessObject(mockedContext.Object); var c = cbo.Get(1); Assert.IsTrue(c.FirstName == "Rahman"); }
Monday, June 20, 2016
Friday, June 17, 2016
Populating combos from enum
http://www.codeproject.com/Articles/1105885/Populating-Combo-Boxes-from-Enums
Wednesday, April 20, 2016
Filters and pipeline pattern
http://www.codeproject.com/Articles/1094513/Pipeline-and-Filters-Pattern-using-Csharp
Saturday, April 16, 2016
Private nuget servers
http://feeds.hanselman.com/~/149097924/0/scotthanselman~How-to-host-your-own-NuGet-Server-and-Package-Feed.aspx
Friday, April 8, 2016
Sunday, March 27, 2016
Wrapper around NLog for DI
Using NLog with Dependency Injection | Tony Sneed's Blog
Example:
Log File:
Example:
Log File:
<?xml version="1.0" encoding="utf-8" ?> <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd" autoReload="true" throwExceptions="false" internalLogLevel="Off" internalLogFile=".\nlog-internal.log" > <!-- optional, add some variabeles https://github.com/nlog/NLog/wiki/Configuration-file#variables --> <!--<variable name="myvar" value="myvalue"/>--> <!-- See https://github.com/nlog/nlog/wiki/Configuration-file for information on customizing logging rules and outputs. --> <targets> <!-- add your targets here See https://github.com/nlog/NLog/wiki/Targets for possible targets. See https://github.com/nlog/NLog/wiki/Layout-Renderers for the possible layout renderers. --> <target xsi:type="File" name="file" fileName="${basedir}/logs/${shortdate}.log" layout="Server-Date: ${longdate}; Level: ${level}; Log-Message: ${message}; Error-Source: ${event-context:item=error-source}; Error-Class: ${event-context:item=error-class}; Error-Method: ${event-context:item=error-method}; Error-Message: ${event-context:item=error-message}; Inner-Error-Message: ${event-context:item=inner-error-message}" /> <!--Log to Sentinel logger--> <target xsi:type="NLogViewer" name="Sentinel" address="udp://127.0.0.1:9999" layout="Server-Date: ${longdate}; Level: ${level}; Log-Message: ${message}; Error-Source: ${event-context:item=error-source}; Error-Class: ${event-context:item=error-class}; Error-Method: ${event-context:item=error-method}; Error-Message: ${event-context:item=error-message}; Inner-Error-Message: ${event-context:item=inner-error-message}" /> </targets> <rules> <!-- add your logging rules here --> <!-- Write all events with minimal level of Debug (So Debug, Info, Warn, Error and Fatal, but not Trace) to "f" --> <logger name="*" minlevel="Debug" writeTo="file" /> <logger name="*" minlevel="Debug" writeTo="Sentinel" /> </rules> </nlog>
Nlogger class:
using System; using System.Diagnostics; using System.Globalization; using NLog; namespace WatchAndAct { public interface ILoggingService { void Debug(Exception exception); void Debug(string format, params object[] args); void Debug(Exception exception, string format, params object[] args); [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Error")] void Error(Exception exception); [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Error")] void Error(string format, params object[] args); [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Error")] void Error(Exception exception, string format, params object[] args); void Fatal(Exception exception); void Fatal(string format, params object[] args); void Fatal(Exception exception, string format, params object[] args); void Info(Exception exception); void Info(string format, params object[] args); void Info(Exception exception, string format, params object[] args); void Info(string info); void Trace(Exception exception); void Trace(string format, params object[] args); void Trace(Exception exception, string format, params object[] args); void Warn(Exception exception); void Warn(string format, params object[] args); void Warn(Exception exception, string format, params object[] args); } public class LoggingService : ILoggingService { private const string LoggerName = "NLogLogger"; private static readonly Logger logger; static LoggingService() { logger = GetLogger(); } public static Logger GetLogger() { var log = LogManager.GetLogger("NLogLogger", typeof(LoggingService)); return log; } public void Debug(string format, params object[] args) { this.Debug(null, format, args); } public void Debug(Exception exception, string format, params object[] args) { if (!logger.IsDebugEnabled) return; var logEvent = GetLogEvent(LoggerName, LogLevel.Debug, exception, format, args); logger.Log(typeof(LoggingService), logEvent); } public void Error(string format, params object[] args) { this.Error(null, format, args); } public void Error(Exception exception, string format, params object[] args) { if (!logger.IsErrorEnabled) return; var logEvent = GetLogEvent(LoggerName, LogLevel.Error, exception, format, args); logger.Log(typeof(LoggingService), logEvent); } public void Fatal(string format, params object[] args) { this.Fatal(null, format, args); } public void Fatal(Exception exception, string format, params object[] args) { if (!logger.IsFatalEnabled) return; var logEvent = GetLogEvent(LoggerName, LogLevel.Fatal, exception, format, args); logger.Log(typeof(LoggingService), logEvent); } public void Info(string format, params object[] args) { this.Info(null, format, args); } public void Info(Exception exception, string format, params object[] args) { if (!logger.IsInfoEnabled) return; var logEvent = GetLogEvent(LoggerName, LogLevel.Info, exception, format, args); logger.Log(typeof(LoggingService), logEvent); } public void Info(string info) { logger.Info(info); } public void Trace(string format, params object[] args) { this.Trace(null, format, args); } public void Trace(Exception exception, string format, params object[] args) { if (!logger.IsTraceEnabled) return; var logEvent = GetLogEvent(LoggerName, LogLevel.Trace, exception, format, args); logger.Log(typeof(LoggingService), logEvent); } public void Warn(string format, params object[] args) { this.Warn(null, format, args); } public void Warn(Exception exception, string format, params object[] args) { if (!logger.IsWarnEnabled) return; var logEvent = GetLogEvent(LoggerName, LogLevel.Warn, exception, format, args); logger.Log(typeof(LoggingService), logEvent); } public void Debug(Exception exception) { this.Debug(exception, string.Empty); } public void Error(Exception exception) { this.Error(exception, string.Empty); } public void Fatal(Exception exception) { this.Fatal(exception, string.Empty); } public void Info(Exception exception) { this.Info(exception, string.Empty); } public void Trace(Exception exception) { this.Trace(exception, string.Empty); } public void Warn(Exception exception) { this.Warn(exception, string.Empty); } private LogEventInfo GetLogEvent(string loggerName, LogLevel level, Exception exception, string format, object[] args) { string assemblyProp = string.Empty; string classProp = string.Empty; string methodProp = string.Empty; string messageProp = string.Empty; string innerMessageProp = string.Empty; var logEvent = new LogEventInfo (level, loggerName, string.Format(CultureInfo.InvariantCulture, format, args)); if (exception != null) { var targetSite = exception.TargetSite; if (targetSite != null) { if (targetSite.DeclaringType != null) classProp = targetSite.DeclaringType.FullName; methodProp = targetSite.Name; } messageProp = exception.Message; assemblyProp = exception.Source; logEvent.Message = messageProp; logEvent.Exception = exception; if (exception.InnerException != null) { innerMessageProp = exception.InnerException.Message; } } logEvent.Properties["error-source"] = assemblyProp; logEvent.Properties["error-class"] = classProp; logEvent.Properties["error-method"] = methodProp; logEvent.Properties["error-message"] = messageProp; logEvent.Properties["inner-error-message"] = innerMessageProp; return logEvent; } } }
Wednesday, March 23, 2016
Friday, March 11, 2016
Transaction for non database operations
http://www.chinhdo.com/20080825/transactional-file-manager/
http://stackoverflow.com/questions/21094406/where-should-i-perform-action-when-implementing-ienlistmentnotification
http://paxcel.net/blog/extending-transaction-scope-to-non-database-transactions-using-resource-manager/
http://www.codeguru.com/csharp/.net/net_data/sortinganditerating/article.php/c10993/SystemTransactions-Implement-Your-Own-Resource-Manager.htm
Tuesday, March 1, 2016
Windows service always on
http://www.codeproject.com/Articles/1080677/AlwaysOn-Windows-Service-with-Remote-Control
Monday, February 29, 2016
Monday, February 15, 2016
Row level security entity framework
http://www.codeproject.com/Articles/1078865/Row-Level-Security-in-Azure-SQL-with-Entity-Framew
Sunday, January 31, 2016
Request logging mvc and NLog
http://www.codeproject.com/Articles/1028416/RESTful-Day-sharp-Request-logging-and-Exception-ha
Sunday, January 24, 2016
Filter event log
http://www.codeproject.com/Articles/1073292/Log-Wizard-Viewing-Windows-Event-Logs-Can-Be-Fun
Thursday, January 14, 2016
Thursday, January 7, 2016
Microservices, micro
https://dzone.com/articles/microservices-architecture-what-when-how?edition=130252&utm_source=Spotlight&utm_medium=email&utm_campaign=integration%202016-01-07
Tuesday, January 5, 2016
Import images using ssis
http://www.codeproject.com/Tips/1067298/Import-Images-to-SQL-Server-using-SSIS
Subscribe to:
Posts (Atom)