小编NN_*_*NN_的帖子

log4net在编译时未通过验证

https://github.com/apache/log4net

我正在从上面的源代码编译log4net,但它没有通过验证:

[IL]:错误:[log4net.dll:log4net.Plugin.RemoteLoggingServerPlugin :: Attach] [offset 0x00000029]方法不可见.

代码还可以:

public interface ILoggerRepository
{
    ...
}

public interface IPlugin
{
    void Attach(ILoggerRepository repository);
}

public abstract class PluginSkeleton : IPlugin
{
    public virtual void Attach(ILoggerRepository repository) { }
}

public class RemoteLoggingServerPlugin : PluginSkeleton
{
    override public void Attach(ILoggerRepository repository)
    {
        base.Attach(repository);
        ...
    }
}
Run Code Online (Sandbox Code Playgroud)

https://github.com/apache/log4net/blob/trunk/src/Plugin/IPlugin.cs

https://github.com/apache/log4net/blob/trunk/src/Plugin/PluginSkeleton.cs

https://github.com/apache/log4net/blob/trunk/src/Plugin/RemoteLoggingServerPlugin.cs

调查显示它未能通话RemotingServices.Marshal():

override public void Attach(ILoggerRepository repository)
{
    base.Attach(repository);

    // Create the sink and marshal it
    m_sink = new RemoteLoggingSinkImpl(repository);

    try
    {
         **RemotingServices.Marshal(m_sink, …
Run Code Online (Sandbox Code Playgroud)

.net c# log4net open-source peverify

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

TypeScript 迭代字符串联合类型

假设我有:

class A {
 f():void{}
 g():void{}
}
const a = new A();

type AFunctions = "f" | "g";
Run Code Online (Sandbox Code Playgroud)

我想迭代 AFunctions 并生成新函数。类似于映射类型,但具有实现,当然无需手动编写所有键。

伪代码

const b: A = {
 for F in AFunctions add function F() {
   return a[f]();
  }
}
Run Code Online (Sandbox Code Playgroud)

typescript

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

TypeScript 为 Null 或未定义

我如何输入这样的函数?

function isNullOrUndefined(obj: any) {
  return typeof obj === "undefined" || obj === null;
}
Run Code Online (Sandbox Code Playgroud)

如果我返回任何内容,则意味着它可能仍然为空或未定义。我想这样使用它:

let a: string | null | undefined = undefined;
if (!isNullOrUndefined(a)) {
    const b: string = a;
}
Run Code Online (Sandbox Code Playgroud)

typescript

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

F#元编程:是否可以使IF X = 1或2语法?

我想简化表达if(x == 1 || x == 2).
我希望我能写,if(x == 1 or 2)但没有语法.
其他可能性是使用Contains或Any方法,如:if([1,2].Contains(x))但这涉及不必要的调用.

我可以创建一些允许我这样做的运算符吗?

在Nemerle语言中我可以写宏:

macro @|||(left, right)
  match (left)
    | <[ $x == $y ]> => <[ $x == $y || $x == $right ]>
    | _ => Message.Error("Error"); <[ ]>
Run Code Online (Sandbox Code Playgroud)

然后用法:

if (x == 1 ||| 2) { .. }
Run Code Online (Sandbox Code Playgroud)

我可以在F#中以这种方式创建运算符吗?

f# programming-languages metaprogramming nemerle

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