我的代码可以看到非公开成员,但不能看到公共成员.为什么?
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) 我从这个例子中获取了代码.
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) 我正在将一些 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) 我的Visual Studio做了一些非常奇怪的事情.
通常,当您处于"编辑窗口"并且正在更改代码时,您正在编辑的文件将在"解决方案资源管理器"中突出显示.
此外,如果所有项目都在"解决方案资源管理器"中"折叠",然后有一个文件已经打开(如同,您可以看到它的"选项卡"),当您单击该文件的选项卡时(为了能够编辑)它),解决方案资源管理器将解压缩项目并突出显示您正在编辑的文件.
我的"Solution-Explorer-Highlight-The-Current-File"功能已停止工作.
我可以从tab移动到tab到tab,而Solution-Explorer根本没有反应.
我用谷歌搜索和抨击,我要么得到50亿次点击,要么就是没有.我认为关键词太模糊了.
有人见过这个吗?
我在同一台机器上安装了VS2010,它运行得很好.
我安装了一个插件,但它安装在VS2010和VS2012中.因此,我不认为这是罪魁祸首.
任何人都可以告诉我为什么这个正则表达式允许 <和>?
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)
我的目标是
好吧,在我得到“已回答”之前,我已经找到并尝试了在以下位置找到的每个排列:
使用 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位)
是否可以使用 Kestrel 设置“aspNetCore requestTimeout”值(请参阅下面的 xml).......通过“代码”?
我在 KestrelServerLimits 对象上找不到任何东西。
下面是 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) 使用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
c# ×2
regex ×2
.net ×1
asp.net ×1
asp.net-core ×1
javascript ×1
notepad++ ×1
openshift ×1
openshift-3 ×1
powershell ×1
reflection ×1