Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@ -0,0 +1,19 @@
using System;
using System.Configuration;
using System.Web.Configuration;
namespace ClassLib
{
public class Host:MarshalByRefObject
{
public void Run ()
{
PagesSection c = (PagesSection) System.Web.Configuration.WebConfigurationManager.GetSection ("system.web/pages");
if (c == null)
Console.WriteLine ("null");
else
Console.WriteLine (c.StyleSheetTheme);
}
}
}

View File

@ -0,0 +1,8 @@
Program.exe: Program.cs
gmcs -out:$@ $< -r:ClassLib.dll -r:System.Configuration.dll -r:System.Web.dll
ClassLib.dll:: ClassLib.cs
gmcs -target:library -out:$@ $< -r:System.Configuration.dll -r:System.Web.dll
Program.exe: ClassLib.dll

View File

@ -0,0 +1,48 @@
using System;
using System.Web.Hosting;
using System.IO;
namespace dumb2
{
class Program
{
static void SetupAppHost (string baseDir)
{
if (File.Exists (baseDir))
File.Delete (baseDir);
Console.Write ("App base: ");
Console.WriteLine (baseDir);
Directory.CreateDirectory (baseDir);
string binDir = Path.Combine (baseDir, "bin");
Directory.CreateDirectory (binDir);
foreach (System.Reflection.Assembly a in AppDomain.CurrentDomain.GetAssemblies ()) {
if (a.GlobalAssemblyCache) continue;
string loc = a.ManifestModule.FullyQualifiedName;
if (loc.EndsWith (".exe", true, System.Globalization.CultureInfo.CurrentCulture))
continue;
string fn = Path.GetFileName (loc);
File.Copy (loc, Path.Combine (binDir, fn));
}
}
static void Main (string[] args)
{
string baseDir1 = Path.GetTempFileName ();
SetupAppHost (baseDir1);
ClassLib.Host h1 = (ClassLib.Host) ApplicationHost.CreateApplicationHost (
typeof (ClassLib.Host), "/test", baseDir1);
h1.Run ();
string baseDir2 = Path.GetTempFileName ();
SetupAppHost (baseDir2);
FileStream fs = new FileStream (Path.Combine (baseDir2, "Web.config"), FileMode.CreateNew);
StreamWriter sw = new StreamWriter (fs);
sw.Write ("<?xml version=\"1.0\"?><configuration><system.web><pages styleSheetTheme=\"White\"/></system.web></configuration>");
sw.Close ();
ClassLib.Host h2 = (ClassLib.Host) ApplicationHost.CreateApplicationHost (
typeof (ClassLib.Host), "/test", baseDir2);
h2.Run ();
}
}
}

View File

@ -0,0 +1,89 @@
<%@ Import Namespace="System.Configuration" %>
<%@ Import Namespace="System.Web.Configuration" %>
<script runat="server" language="C#" >
const string PROVIDER = "DataProtectionConfigurationProvider";
protected void btnEncrypt_Click(
object sender, EventArgs e)
{
try
{
Configuration config =
WebConfigurationManager.OpenWebConfiguration(
Request.ApplicationPath);
ConnectionStringsSection sect =
config.ConnectionStrings;
sect.SectionInformation.ProtectSection(PROVIDER);
config.Save();
lblResult.Text ="Connection string" +
" section is now encrypted in " +
"web.config file<br>";
}
catch (Exception ex)
{
lblResult.Text = "Exception: " +
ex.Message;
}
//Note that when you read the encrypted
//connection string, it is
//automatically decrypted for you
lblResult.Text+="Connection String:" +
ConfigurationManager.ConnectionStrings
["pubs"].ConnectionString;
}
protected void btnDecrypt_Click(
object sender, EventArgs e)
{
try
{
Configuration config =
WebConfigurationManager.OpenWebConfiguration(
Request.ApplicationPath);
ConnectionStringsSection sect =
config.ConnectionStrings;
if (sect.SectionInformation.IsProtected)
{
sect.SectionInformation.UnprotectSection();
config.Save();
}
lblResult.Text="Connection string" +
" is now decrypted in web.config" +
" file";
}
catch (Exception ex)
{
lblResult.Text = "Exception: " + ex.Message;
}
}
</script>
<html>
<head>
<title>Encrypting and Decrypting Connection Strings</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="btnEncrypt"
Runat="server" Text="Encrypt"
Width="96px" Height="35px"
OnClick="btnEncrypt_Click" />
<asp:Button ID="btnDecrypt"
Runat="server" Text="Decrypt"
Width="102px" Height="35px"
OnClick="btnDecrypt_Click" />
<br/><br/><br/>
<asp:Label ID="lblResult"
runat="server" Height="19px"
Width="435px"></asp:Label>
</div>
</form>
</body>
</html>

View File

@ -0,0 +1,9 @@
<configuration>
<connectionStrings>
<add name="pubs"
connectionString="localhost;integratedsecurity=true;database=pubs;" />
</connectionStrings>
<system.web>
<compilation debug="true" />
</system.web>
</configuration>

View File

@ -0,0 +1,73 @@
<%@ Import Namespace="System.Web.Configuration" %>
<script runat="server" language="C#" >
protected void add_Click (object sender, EventArgs e)
{
try
{
Configuration config =
WebConfigurationManager.OpenWebConfiguration(
Request.ApplicationPath);
ConnectionStringsSection sect =
config.ConnectionStrings;
if (sect.ConnectionStrings ["test"] != null) {
lblResult.Text = "Connection string already exists for 'test'";
}
else {
sect.ConnectionStrings.Add (new ConnectionStringSettings ("test", "test=foo;", "testProvider"));
config.Save();
lblResult.Text = "Connection string added";
}
}
catch (Exception ex)
{
lblResult.Text = "Exception: " + ex.Message;
}
// lblResult.Text+="Connection String:" +
// ConfigurationManager.ConnectionStrings
// ["test"].ConnectionString;
}
protected void remove_Click (object sender, EventArgs e)
{
try
{
Configuration config =
WebConfigurationManager.OpenWebConfiguration(
Request.ApplicationPath);
ConnectionStringsSection sect =
config.ConnectionStrings;
if (sect.ConnectionStrings ["test"] == null) {
lblResult.Text = "connection string not present";
}
else {
sect.ConnectionStrings.Remove ("test");
config.Save();
lblResult.Text = "connection string has been removed";
}
}
catch (Exception ex)
{
lblResult.Text = "Exception: " + ex.Message;
}
}
</script>
<html>
<head>
<title>Adding and Removing Connection Strings</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="add" runat="server" Text="Add" OnClick="add_Click" />
<asp:Button ID="remove" runat="server" Text="Remove" OnClick="remove_Click" />
<br/><br/><br/>
<asp:Label ID="lblResult" runat="server"></asp:Label>
</div>
</form>
</body>
</html>

View File

@ -0,0 +1 @@
<configuration><connectionStrings /></configuration>

View File

@ -0,0 +1,13 @@
<%@ Page Language="C#" %>
<%@ Import namespace="System.Web.Configuration" %>
<script runat="server">
void Page_Load ()
{
lbl.Text = WebConfigurationManager.AppSettings["testSetting"];
}
</script>
<asp:Label id="lbl" runat="server" />

View File

@ -0,0 +1,44 @@
<%@ Page Language="C#" %>
<%@ Import namespace="System.Web.Configuration" %>
<script runat="server">
void Page_Load ()
{
string value = "";
System.Configuration.Configuration c = WebConfigurationManager.OpenWebConfiguration("/toshok/configuration/twolevel");
lbl.Text = String.Format ("{0} (c.FilePath = {1}", c.AppSettings.Settings["testSetting"].Value, c.FilePath);
lbl2.Text = WebConfigurationManager.AppSettings["testSetting"];
object s = WebConfigurationManager.GetSection ("appSettings");
if (s is NameValueCollection) {
NameValueCollection col = (NameValueCollection)s;
value = String.Format ("{0} (section type = NameValueCollection)", col["testSetting"]);
}
else if (s is AppSettingsSection) {
AppSettingsSection sect = (AppSettingsSection)s;
value = String.Format ("{0} (section type = AppSettingsSection)", sect.Settings["testSetting"].Value);
}
lbl3.Text = value;
s = WebConfigurationManager.GetSection ("appSettings", "/toshok/configuration/twolevel");
if (s is NameValueCollection) {
NameValueCollection col = (NameValueCollection)s;
value = String.Format ("{0} (section type = NameValueCollection)", col["testSetting"]);
}
else if (s is AppSettingsSection) {
AppSettingsSection sect = (AppSettingsSection)s;
value = String.Format ("{0} (section type = AppSettingsSection)", sect.Settings["testSetting"].Value);
}
lbl4.Text = value;
}
</script>
<table>
<tr><td>WebConfigurationManager.OpenWebConfiguration <td><asp:Label id="lbl" runat="server" /></tr>
<tr><td>WebConfigurationManager.AppSettings <td><asp:Label id="lbl2" runat="server" /> </tr>
<tr><td>WebConfigurationManager.GetSection(string) <td><asp:Label id="lbl3" runat="server" /> </tr>
<tr><td>WebConfigurationManager.GetSection(string,string) <td><asp:Label id="lbl4" runat="server" /> </tr>
</table>

View File

@ -0,0 +1,6 @@
<configuration>
<appSettings>
<clear />
<add key="testSetting" value="hey!" />
</appSettings>
</configuration>

View File

@ -0,0 +1,5 @@
<configuration>
<appSettings>
<add key="testSetting" value="hi" />
</appSettings>
</configuration>