小编gra*_*der的帖子

为什么我的Type.GetFields(BindingFlags.Instance | BindingFlags.Public)不起作用?

我的代码可以看到非公开成员,但不能看到公共成员.为什么?

FieldInfo[] publicFieldInfos =
    t.GetFields(BindingFlags.Instance | BindingFlags.Public);
Run Code Online (Sandbox Code Playgroud)

没有回来.

注意:我正在尝试获取抽象类的属性以及具体类.(并阅读属性).

MSDN示例使用2个标志,(BindingFlags.Instance | BindingFlags.Public)但下面的迷你继承示例没有.

private void RunTest1()
{
    try
    {
        textBox1.Text = string.Empty;

        Type t = typeof(MyInheritedClass);

        //Look at the BindingFlags *** NonPublic ***

        int fieldCount = 0;

        while (null != t)
        {
            fieldCount += t.GetFields(BindingFlags.Instance |
            BindingFlags.NonPublic).Length;

            FieldInfo[] nonPublicFieldInfos = t.GetFields(BindingFlags.Instance |
            BindingFlags.NonPublic);

            foreach (FieldInfo field in nonPublicFieldInfos)
            {
                if (null != field)
                {
                    Console.WriteLine(field.Name);
                }
            }

            t = t.BaseType;
        }

        Console.WriteLine("\n\r------------------\n\r");

        //Look at the BindingFlags *** Public *** …
Run Code Online (Sandbox Code Playgroud)

.net c# reflection

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

System.Configuration with Separate .config文件

我从这个例子中获取了代码.

http://msdn.microsoft.com/en-us/library/2tw134k3.aspx

我在想什么(今天我一直在互联网上看)...你如何得到它在一个外部(单独)文件.

我想要的想法是:

<configuration>
  <configSections>
    <sectionGroup name="pageAppearanceGroup">
      <section
        name="pageAppearance"
        type="HelperAssembly.Configuration.PageAppearanceSection,HelperAssembly"
        allowLocation="true"
        allowDefinition="Everywhere"
      />
    </sectionGroup>
  </configSections>


  <pageAppearanceGroup fileName="SomeSeparateFile.config"/>

</configuration>
Run Code Online (Sandbox Code Playgroud)

..................

以上不起作用(当然).

以下是我上面提到的ms文章的复制/粘贴.当我把它贴在这里时,它完全正常运作.

//START HelperAssembly.csproj

namespace HelperAssembly.Configuration
{
    using System;
    using System.Collections;
    using System.Text;
    using System.Configuration;
    using System.Xml;

    public class PageAppearanceSection : ConfigurationSection
    {
        // Create a "remoteOnly" attribute.
        [ConfigurationProperty("remoteOnly", DefaultValue = "false", IsRequired = false)]
        public Boolean RemoteOnly
        {
            get
            {
                return (Boolean)this["remoteOnly"];
            }
            set
            {
                this["remoteOnly"] = value;
            }
        }

        // Create a "font" element.
        [ConfigurationProperty("font")]
        public FontElement Font …
Run Code Online (Sandbox Code Playgroud)

c# configuration-files

4
推荐指数
2
解决办法
8192
查看次数

使用黑名单(排除)和白名单(包括)的 Powershell 复制文件

我正在将一些 msbuild 脚本翻译为 powershell。

在 msbuild 中,我可以生成要(递归)复制到目标文件夹的文件的黑名单和/或白名单。

如下所示:

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="AllTargetsWrapped">

    <PropertyGroup>
        <!-- Always declare some kind of "base directory" and then work off of that in the majority of cases  -->
        <WorkingCheckout>.</WorkingCheckout>
        <WindowsSystem32Directory>c:\windows\System32</WindowsSystem32Directory>
        <ArtifactDestinationFolder>$(WorkingCheckout)\ZZZArtifacts</ArtifactDestinationFolder>
    </PropertyGroup>

    <Target Name="AllTargetsWrapped">

        <CallTarget Targets="CleanArtifactFolder" />
        <CallTarget Targets="CopyFilesToArtifactFolder" />
    </Target>

    <Target Name="CleanArtifactFolder">

        <RemoveDir Directories="$(ArtifactDestinationFolder)" Condition="Exists($(ArtifactDestinationFolder))"/>
        <MakeDir Directories="$(ArtifactDestinationFolder)" Condition="!Exists($(ArtifactDestinationFolder))"/>
        <Message Text="Cleaning done" />
    </Target>

    <Target Name="CopyFilesToArtifactFolder">

        <ItemGroup>
            <MyExcludeFiles Include="$(WindowsSystem32Directory)\**\EventViewer_EventDetails.xsl" />
        </ItemGroup>

        <ItemGroup>
            <MyIncludeFiles Include="$(WindowsSystem32Directory)\**\*.xsl" Exclude="@(MyExcludeFiles)"/>
            <MyIncludeFiles Include="$(WindowsSystem32Directory)\**\*.xslt" Exclude="@(MyExcludeFiles)"/>
            <MyIncludeFiles Include="$(WindowsSystem32Directory)\**\*.png" Exclude="@(MyExcludeFiles)"/>
            <MyIncludeFiles Include="$(WindowsSystem32Directory)\**\*.jpg" …
Run Code Online (Sandbox Code Playgroud)

powershell powershell-5.0

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

代码窗口不会突出显示"解决方案资源管理器"中的选定(通常是.cs)文件

我的Visual Studio做了一些非常奇怪的事情.

通常,当您处于"编辑窗口"并且正在更改代码时,您正在编辑的文件将在"解决方案资源管理器"中突出显示.

此外,如果所有项目都在"解决方案资源管理器"中"折叠",然后有一个文件已经打开(如同,您可以看到它的"选项卡"),当您单击该文件的选项卡时(为了能够编辑)它),解决方案资源管理器将解压缩项目并突出显示您正在编辑的文件.

我的"Solution-Explorer-Highlight-The-Current-File"功能已停止工作.

我可以从tab移动到tab到tab,而Solution-Explorer根本没有反应.

我用谷歌搜索和抨击,我要么得到50亿次点击,要么就是没有.我认为关键词太模糊了.

有人见过这个吗?

我在同一台机器上安装了VS2010,它运行得很好.

我安装了一个插件,但它安装在VS2010和VS2012中.因此,我不认为这是罪魁祸首.

visual-studio visual-studio-2012

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

正则表达式允许<和>

任何人都可以告诉我为什么这个正则表达式允许 <>

function IsValidPassword(password) {
    var regex = /^[A-Za-z0-9^\~^\!@/#^\$^\%&^\*+-_()]*$/; /* AlphaNumerics.  ~ (Tilde) (All "Shifts" 1-0)  underscore plus and minus */
    return regex.test(password);
}
Run Code Online (Sandbox Code Playgroud)

我的目标是

  • 字母数字.(上部和下部).
  • 波浪号
  • "SHIFT"区域中的所有内容,键盘上的1-0.
  • + - _

javascript regex

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

notepad++ 正则表达式查找、替换并保持匹配

好吧,在我得到“已回答”之前,我已经找到并尝试了在以下位置找到的每个排列:

使用正则表达式替换时,如何保留匹配字符串的一部分?

使用 Notepad++ Regex 查找并仅替换找到的文本的一部分

我有这些行:

new MyObject("22222,11,21),
new MyObject("22223,12,22),
new MyObject("22224,13,23),
new MyObject("22225,14,24),
Run Code Online (Sandbox Code Playgroud)

我试图将“结束引号”放在 22222、22223、22224 和 22225 周围:

new MyObject("22222",11,21),
new MyObject("22223",12,22),
new MyObject("22224",13,23),
new MyObject("22225",14,24),
Run Code Online (Sandbox Code Playgroud)

我在 notepad++ 中输入的“Find What”值有效(转义双引号加 5 位数字)。

\"\d{5}

对于“替换为”(基于我在前两篇 SOF 文章中找到的内容),我尝试过:

(这些只是为了测试一下)

aaa$1bbb
aaa$1$2bbb
aaa$1$2$3bbb
Run Code Online (Sandbox Code Playgroud)

aaa\1bbb
aaa\1\2bbb
aaa\1\2\3bbb
Run Code Online (Sandbox Code Playgroud)

显然,我想要的(以及我认为应该有效的)如下(转义双引号,然后是“1”的占位符,以及第二个转义双引号)

\"\1\"\
Run Code Online (Sandbox Code Playgroud)

或者

\"$1\"\
Run Code Online (Sandbox Code Playgroud)

我的搜索模式是“常规快递”,并且我已打开和关闭“.matches newline”。

Notepad++ v7.7.1(64位)

regex notepad++

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

是否可以通过 Kestrel 的“代码”设置“aspNetCore requestTimeout”值.......?

是否可以使用 Kestrel 设置“aspNetCore requestTimeout”值(请参阅下面的 xml).......通过“代码”?

我在 KestrelServerLimits 对象上找不到任何东西。

https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.server.kestrel.core.kestrelserverlimits?view=aspnetcore-3.1

下面是 xml 代码.......但希望在 CODE 中做到这一点,而不是通过(发布的)xml。

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
    </handlers>
    <aspNetCore requestTimeout="00:20:00"  processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
  </system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)

我想下面的(“serverOptions.Limits.KeepAliveTimeout = TimeSpan.FromSeconds(5)”)......但是这并没有控制从我的邮递员测试服务器超时。

namespace MyStuff
{
    using System;
    using Microsoft.AspNetCore.Hosting;
    using Microsoft.Extensions.Hosting;

    public class Program
    {
        public static void Main(string[] args)
        {
            CreateHostBuilder(args).Build().Run();
        }

        public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)
                .ConfigureWebHostDefaults(webBuilder =>
                {
                    webBuilder.UseStartup<Startup>();

                    webBuilder.ConfigureKestrel(serverOptions =>
                    {
                        serverOptions.Limits.KeepAliveTimeout = TimeSpan.FromSeconds(5);
                    }); …
Run Code Online (Sandbox Code Playgroud)

asp.net asp.net-web-api asp.net-core

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

如何停止现有的开放式班次转发

使用oc,我可以在开放班次中移植一个吊舱以获得本地访问权限.

oc get pods
oc port-forward MY-POD-NAME  5555:5555
Run Code Online (Sandbox Code Playgroud)

我启动它后如何阻止它?

我搜索过了

oc port-forward --help
Run Code Online (Sandbox Code Playgroud)

我没有办法获得所有"port-forwards"的列表来尝试获得一个唯一的名称.

我尝试开始收听时出现错误消息(注意,重新部署后我的pod名称不同)

无法侦听端口5555:所有侦听器都无法创建以下错误:无法创建侦听器:错误侦听tcp4 127.0.0.1:5555:绑定:地址已在使用中,无法创建侦听器:错误侦听tcp6:address [[ :: 1]]:5555:地址错误中缺少端口:无法侦听任何请求的端口:[{5555 5555}]

我钓过的网址:

https://docs.openshift.com/enterprise/3.0/dev_guide/port_forwarding.html

https://docs.openshift.com/enterprise/3.0/cli_reference/basic_cli_operations.html

openshift openshift-enterprise openshift-client-tools openshift-3

0
推荐指数
1
解决办法
354
查看次数