小编Nik*_*efi的帖子

正则表达式只接受波斯字符

我正在处理一个表单,其中一个自定义验证器应该只接受波斯语字符...我使用了以下代码:

    var myregex = new Regex(@"^[\u0600-\u06FF]+$");
    if (myregex.IsMatch(mytextBox.Text))
    {
        args.IsValid = true;
    }
    else
    {
        args.IsValid = false;
    }
Run Code Online (Sandbox Code Playgroud)

但它似乎只适用于检查阿拉伯字符而且它不包括所有波斯字符(它缺少这四个گ,چ,پ,ژ)...有没有办法解决这个问题?

c# regex asp.net unicode

44
推荐指数
4
解决办法
6822
查看次数

Azure Pipeline - 使用 YAML 将文件从一个存储库复制到另一个存储库

我喜欢使用Azure Pipeline将其中一个存储库(源存储库)中的一个文件夹复制到另一个存储库(目标存储库) (因为它们需要同步)

到目前为止,我可以使用以下命令复制同一存储库中的文件夹:

- task: CopyFiles@2
  inputs:
    SourceFolder: '$(Build.Repository.LocalPath)\MyFolder\'
    Contents: |
      **
      !**\obj\**
      !**\bin\**
    TargetFolder: '$(Build.Repository.LocalPath)\DestFolder'
    flattenFolders: false
    CleanTargetFolder: true
    OverWrite: true
    preserveTimestamp: true
Run Code Online (Sandbox Code Playgroud)

这就是我连接到另一个存储库的方式:

 resources:
   repositories:
   - repository: SourceRepo
     type: git
     name: MyCollection/SourceRepo
Run Code Online (Sandbox Code Playgroud)

但我不知道如何从源存储库获取文件并将它们放入目标存储库

yaml azure azure-pipelines

6
推荐指数
1
解决办法
2万
查看次数

选项模式 - 接口/抽象属性

我想将以下对象与ServiceCollection中的appsettings.json数据绑定,但是我无法更改类或接口的设计:

public class TransferOptions :ITransferOptions 
{
   public IConnectionInfo Source {get;set;}
   public IConnectionInfo Destination {get;set;}
}

public class ConnectionInfo : IConnectionInfo
{
   public string UserName{get;set;}
   public string Password{get;set;}
}

public interface ITransferOptions
{
   IConnectionInfo Source {get;set;}
   IConnectionInfo Destination {get;set;}
}

public interface IConnectionInfo
{
   string UserName{get;set;}
   string Password{get;set;}
}
Run Code Online (Sandbox Code Playgroud)

这是我在appsettings.json中的数据

{
"TransferOptions":{
    "Source ":{
                 "UserName":"USERNAME",
                 "Password":"PASSWORD"
              },
    "Destination":{
                 "UserName":"USERNAME",
                 "Password":"PASSWORD"
              }
   }
}
Run Code Online (Sandbox Code Playgroud)

这是我在服务提供商上的配置:

var provider=new ServiceCollection()
.Configure<TransferOptions>(options => _configuration.GetSection("TransferOptions").Bind(options))
.BuildServiceProvider();
Run Code Online (Sandbox Code Playgroud)

这是我收到错误的部分

无法创建“IConnectionInfo”类型的实例,因为它是抽象的或接口

var transferOptions =_serviceProvider.GetService<IOptions<TransferOptions>>()
Run Code Online (Sandbox Code Playgroud)

c# .net-core .net-core-configuration servicecollection

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

年,月和日参数描述波斯日历中无法表示的DateTime

我使用以下代码来呈现今天的波斯日期......我工作的网站自两个月前开始上网并且工作正常但今天我收到了以下错误:

年,月和日参数描述不可表示的DateTime.

我不知道为什么会这样......有什么方法可以解决这个问题吗?

protected void lbnChangeDate_Click(object sender, EventArgs e)
{

    PersianCalendar p = new PersianCalendar();
    DateTime date = DateTime.Now;
    int year = p.GetYear(date);
    int month = p.GetMonth(date);
    int day = p.GetDayOfMonth(date);
    DateTime d1 = new DateTime(year, month, day);
    MultiView6.SetActiveView(View12);
    txtDate.Text = DateTime.Parse(d1.ToString()).ToString("yyyy/MM/dd");

}
Run Code Online (Sandbox Code Playgroud)

c# asp.net datetime

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