Как делают меня настройки App.config чтения-записи с PowerShell?

Посмотрите на то, что называется OAuth2.

Создайте свой собственный для вашего сайта / конечной точки.

Постарайтесь убедиться, что все эти 6 учетных записей Facebook могут авторизоваться и выполнить рукопожатие с вашей собственной реализацией OAuth2 в рамках процесса аутентификации.

Ознакомьтесь с документацией и рекомендациями OAuth Facebook, которые необходимо соблюдать. А затем посмотрите, возможно ли это с вашим предпочтительным языком программирования.

Очевидно, что существуют определенные ограничения в использовании реализации OAuth2.

27
задан Robin 16 May 2009 в 03:23
поделиться

2 ответа

В этом примере App.config: C: \ Sample \ App.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <connectionStrings>
        <add name="dbConnectionString" 
             connectionString="Data Source=(local);Initial Catalog=Northwind;Integrated Security=True"/>
    </connectionStrings>
</configuration>

Следующий сценарий, C: \ Sample \ Script.ps1, прочитает и запишет параметр:

# get the directory of this script file
$currentDirectory = [IO.Path]::GetDirectoryName($MyInvocation.MyCommand.Path)
# get the full path and file name of the App.config file in the same directory as this script
$appConfigFile = [IO.Path]::Combine($currentDirectory, 'App.config')
# initialize the xml object
$appConfig = New-Object XML
# load the config file as an xml object
$appConfig.Load($appConfigFile)
# iterate over the settings
foreach($connectionString in $appConfig.configuration.connectionStrings.add)
{
    # write the name to the console
    'name: ' + $connectionString.name
    # write the connection string to the console
    'connectionString: ' + $connectionString.connectionString
    # change the connection string
    $connectionString.connectionString = 'Data Source=(local);Initial Catalog=MyDB;Integrated Security=True'
}
# save the updated config file
$appConfig.Save($appConfigFile)

Выполнить сценарий:

PS C:\Sample> .\Script.ps1

Вывод:

name: dbConnectionString  
connectionString: Data Source=(local);Initial Catalog=Northwind;Integrated Security=True

Обновлен C: \ Sample \ App.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <connectionStrings>
    <add name="dbConnectionString" 
         connectionString="Data Source=(local);Initial Catalog=MyDB;Integrated Security=True" />
  </connectionStrings>
</configuration>
29
ответ дан 28 November 2019 в 04:48
поделиться

Код может быть намного короче (на основе app.config Робина):

$appConfig = [xml](cat D:\temp\App.config)
$appConfig.configuration.connectionStrings.add | foreach {
    $_.connectionString = "your connection string"
}

$appConfig.Save("D:\temp\App.config")
31
ответ дан 28 November 2019 в 04:48
поделиться
Другие вопросы по тегам:

Похожие вопросы: