序列化时是否可以避免列表属性标记?
//[Serializable()] - removed, unnecessary
public class Foo
{
protected List<FooBar> fooBars = new List<FooBar>();
public virtual List<FooBar> FooBars
{
get { return fooBars; }
set { fooBars = value; }
}
}
// [Serializable()] - removed, unnecessary
public class FooBar
{
public int MyProperty
{ get; set; }
}
Run Code Online (Sandbox Code Playgroud)
序列化Foo给出(评论除外):
<Foo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<FooBars> <!-- Unwanted tag -->
<FooBar>
<MyProperty>7</MyProperty>
</FooBar>
<FooBar>
<MyProperty>9</MyProperty>
</FooBar>
</FooBars>
</Foo>
Run Code Online (Sandbox Code Playgroud)
通缉输出:
<Foo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<FooBar>
<MyProperty>7</MyProperty>
</FooBar>
<FooBar>
<MyProperty>9</MyProperty>
</FooBar>
Run Code Online (Sandbox Code Playgroud)
当我对我的应用程序进行模糊处理时,防病毒软件会为混淆的应用程序提供病毒警报.
我该怎么做才能避免这种情况?
我在Windows XP Professional上使用Visual Studio 2008和.NET Reactor 3.9.8.0.
Windows和应用程序是最新的,防病毒软件在运行完整扫描时什么也找不到.
编辑:Avast Antivirus发出警报.MS Forefront没有.
编辑2:更改控制流混淆级别修复它.
如果接口继承IEquatable,则实现类可以定义Equals方法的行为.是否可以定义==操作的行为?
public interface IFoo : IEquatable
{}
public class Foo : IFoo
{
// IEquatable.Equals
public bool Equals(IFoo other)
{
// Compare by value here...
}
}
Run Code Online (Sandbox Code Playgroud)
通过比较它们的值来检查两个IFoo引用是否相等:
IFoo X = new Foo();
IFoo Y = new Foo();
if (X.Equals(Y))
{
// Do something
}
Run Code Online (Sandbox Code Playgroud)
是否有可能if (X == Y)
在Foo上使用Equals方法?