小编Nil*_*iya的帖子

定义字典之间的区别

我正在使用C#(5.0).Net(4.5)开发应用程序.我想知道下面与字典变量声明之间的区别.1.

var emailtemplateValues = new Dictionary<string, object>
    {
        {"CreatorName", creatorUserInfo.UserName},
        {"ProjectName", masterProjectInfo.Title},
        {"Reason",  reason}
    };
Run Code Online (Sandbox Code Playgroud)

和2.

var emailtemplateValues = new Dictionary<string, object>()
    {
        {"CreatorName", creatorUserInfo.UserName},
        {"ProjectName", masterProjectInfo.Title},
        {"Reason",  reason}
    };
Run Code Online (Sandbox Code Playgroud)

在第二次声明我用过()之后Dictionary<string, object>.两种语法都很好,但只是渴望了解内部工作.

.net c#

5
推荐指数
3
解决办法
85
查看次数

TFS CI构建 - 在构建成功后更新自定义定义变量

我们已经设置了我的TFS CI Build,我们正在管理一个变量用于维护版本控制,我们希望在每次成功构建后更新,任何想法如何操作?

我写过PowerShell脚本

param([Int32]$currentPatchVersion)
Write-Host "Current patch version "$currentPatchVersion
$NewVersion=$currentPatchVersion + 1
Write-Host "New patch version "$NewVersion
Write-Host ("##vso[task.setvariable variable=PackageVersion.Patch;]$NewVersion")
Run Code Online (Sandbox Code Playgroud)

但它只是在飞行中应用.

我希望将其应用于永久设置.

msbuild tfs continuous-integration azure-pipelines azure-artifacts

5
推荐指数
1
解决办法
5498
查看次数

TFS构建powershell脚本步骤:无法访问$(Date:yyyyMMdd)变量

我使用TFS vNext构建系统创建了自动部署步骤.在一个步骤中,我需要访问$(Date:yyyyMMdd)一些文件版本控制的东西.

您可以在下面找到配置和错误代码段:

配置电源shell脚本步骤

排队构建时出错

那么任何想法如何在PowerShell脚本步骤中访问与日期相关的变量作为参数?

powershell tfs continuous-integration azure-pipelines

4
推荐指数
1
解决办法
1781
查看次数

C#从中心裁剪图像

我正在使用.NET(4.5)MVC(4.0)C#(5.0)开发应用程序.我想从我已经拥有的图像生成图像缩略图.现在的要求是它应该从图像中心生成最大方形部分的缩略图而不拉伸除了图像之外的整个图像是方形尺寸.

根据示例我的原始图像大小:578x700我想生成占位符大小的缩略图:200x150,185x138,140x140,89x66,80x80,45x45,28x28

我创建了我的下面的代码,但没有得到确切的结果.这是我生成缩略图的核心方法

    public string GenerateThumbnailFromImage(string imageFilePath, int thumbWidth, int thumbHeight)
    {
        try
        {
            //Check if file exist
            if (File.Exists(imageFilePath))
            {
                //bool preserveAspectRatio = true;
                string oldFilePath = imageFilePath;
                string folderPath = Path.GetDirectoryName(imageFilePath);
                string filename = Path.GetFileNameWithoutExtension(imageFilePath);

                //Rename file with thumbnail size
                filename = filename + "_" + thumbWidth.ToString() + Path.GetExtension(imageFilePath);
                imageFilePath = Path.Combine(folderPath, filename);


                using (Image image = Image.FromFile(oldFilePath))
                {
                    decimal originalWidth = image.Width;
                    decimal originalHeight = image.Height;
                    decimal requiredThumbWidth = thumbWidth;
                    decimal requiredThumbHeight = thumbHeight;
                    decimal startXPosition = …
Run Code Online (Sandbox Code Playgroud)

.net c# image-processing thumbnails

2
推荐指数
3
解决办法
9783
查看次数