我对 Rails 很陌生。我是从 Rails 7 开始的,所以关于我的问题的信息仍然很少。
应用程序/模型/cocktail.rb
class Cocktail < ApplicationRecord
has_many :cocktail_ingredients, dependent: :destroy
has_many :ingredients, through: :cocktail_ingredients
accepts_nested_attributes_for :cocktail_ingredients
end
Run Code Online (Sandbox Code Playgroud)
应用程序/模型/ingredient.rb
class Ingredient < ApplicationRecord
has_many :cocktail_ingredients
has_many :cocktails, :through => :cocktail_ingredients
end
Run Code Online (Sandbox Code Playgroud)
应用程序/模型/cocktail_ingredient.rb
class CocktailIngredient < ApplicationRecord
belongs_to :cocktail
belongs_to :ingredient
end
Run Code Online (Sandbox Code Playgroud)
应用程序/控制器/cocktails_controller.rb
def new
@cocktail = Cocktail.new
@cocktail.cocktail_ingredients.build
@cocktail.ingredients.build
end
def create
@cocktail = Cocktail.new(cocktail_params)
respond_to do |format|
if @cocktail.save
format.html { redirect_to cocktail_url(@cocktail), notice: "Cocktail was successfully created." }
format.json { render :show, status: …Run Code Online (Sandbox Code Playgroud) 我有一堆字符串和pfx证书,我想存储在Azure Key保险库中,只允许用户/应用程序获取它们.将字符串存储为Secret并不难,但是如何以可以检索它的方式序列化证书并在C#中反序列化为X509Certificate2对象?
我试着将它存储为密钥.这是Azure powershell代码
$securepfxpwd = ConvertTo-SecureString -String 'superSecurePassword' -AsPlainText -Force
$key = Add-AzureKeyVaultKey -VaultName 'UltraVault' -Name 'MyCertificate' -KeyFilePath 'D:\Certificates\BlaBla.pfx' -KeyFilePassword $securepfxpwd
Run Code Online (Sandbox Code Playgroud)
但是当我试图用GetKeyAsync方法获取它时,我无法使用它.
我正在创建Visual Studio包,我启动devenv.exe并尝试构建其他解决方案.我需要实时构建输出,因此用户可以看到建立进度(输出),但我不知道如何做到这一点如果它甚至可能.
我试过这样的方式:
string rebuildLog = string.Empty;
string logFileName = System.IO.Path.GetTempFileName();
System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo();
psi.FileName = @"devenv.exe";
psi.Arguments = "\"" + config.DmsPath + "\"" + @" /rebuild" + " Release|x64 " +" /out " + logFileName;
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo = psi;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.UseShellExecute = false;
process.Start();
while (!process.StandardOutput.EndOfStream)
{
string line = process.StandardOutput.ReadLine();
MessageBox.Show(line); // just to see if it works. It should go to log form
}
rebuildLog = GetRebuildLog(logFileName);
Run Code Online (Sandbox Code Playgroud)
而且rebuildLog有输出.
有人可以帮忙吗?