This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Related Properties | |
- HttpRuntime.AppDomainAppVirtualPath | |
- Request.ApplicationPath | |
Methods for getting physical file path: | |
- System.Web.HttpContext.Current.Server.MapPath() | |
Methods for generating content URL: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string MD5Hash(string str) | |
{ | |
// return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(pwd); | |
var md5 = MD5.Create(); | |
var hashedBytes = md5.ComputeHash(Encoding.UTF8.GetBytes(str)); | |
var hashedStr = String.Join("", hashedBytes.Select(x => x.ToString("x2"))); | |
return hashedStr; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<unity> | |
<namespace name="Service.Class" /> | |
<assembly name="Service" /> | |
<container> | |
<register type="IOwnExpenseDService" mapTo="OwnExpenseDService" /> | |
<register type="Model.Dal.IOwnExpenseDDal, Model" mapTo="Model.Dal.OwnExpenseDDal, Model" /> | |
</container> | |
</unity> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface IMessageService | |
{ | |
void Send(User user, string msg); | |
} | |
class EmailService : IMessageService | |
{ | |
public void Send(User user, string msg) | |
{ | |
// 寄送電子郵件給指定的 user (略) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface INotificationManager | |
{ | |
void Notify(string to, string msg); | |
} | |
public class NotificationManager : INotificationManager | |
{ | |
private readonly IMessageService _msgService = null; | |
// 從建構函式注入訊息服務物件。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IMessageService | |
{ | |
void SendMessage(string to, string msg); | |
} | |
public class EmailService : IMessageService | |
{ | |
public void SendMessage(string to, string msg) | |
{ | |
Console.WriteLine(" 透過 EmailService 發送郵件給 {0}。", to); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using System.Runtime.CompilerServices; | |
namespace ConsoleApplication1 | |
{ | |
class Program |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DemoAsyncCall | |
{ | |
public async Task ShowWebContent(string url) | |
{ | |
var client = new HttpClient(); | |
var response = await client.GetAsync(url); | |
Console.WriteLine(await response.Content.ReadAsStringAsync()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Text; | |
using Microsoft.Web.Administration; | |
void SetWebGarden(string appPoolName, int maxProcesses) | |
{ | |
ServerManager serverManager = new ServerManager(); | |
ApplicationPoolCollection applicationPools = serverManager.ApplicationPools; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- 底下是準備要被替換的文字 --> | |
<?xml version="1.0" encoding="utf-8"?> | |
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | |
<PropertyGroup> | |
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | |
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | |
<ProjectGuid>{B395A62E-B988-4370-AB66-D76A4FC49C9E}</ProjectGuid> | |
<OutputType>Exe</OutputType> | |
<AppDesignerFolder>Properties</AppDesignerFolder> |