标签: explicit

Django <input>在<label>中

一些前端专家声称<input>使用<label>(隐式标签)包装是一种更好的做法(与明确的做法相比,即使它们具有for属性).

无论出于什么原因,我想看看如何以优雅的方式在技术上完成Django.

django label explicit input implicit

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

.NET - 如何在(someType)someobject中使用"as"显式转换为"as",为什么?

我明白当你使用这样的显式演员时:

(someType)someobject
Run Code Online (Sandbox Code Playgroud)

如果someobject不是真的,你可以得到一个无效的强制转换异常someType.

我也明白,当你这样投射时as:

myObject = someObject as someType
Run Code Online (Sandbox Code Playgroud)

myObjectnull如果someObject不是真的,那就是渲染someType.

这些评估方式有何不同?为什么?

.net c# casting explicit

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

使用icacls删除显式强制标签

我在Windows 7上对完整性级别和icacls进行了一些实验.我设置了强制完整性级别,以便我得到如下所示的内容:

C:\Debug>icacls test.exe
test.exe Everyone:(I)(RX)
                BUILTIN\Administrators:(I)(F)
                NT AUTHORITY\SYSTEM:(I)(F)
                Mandatory Label\Low Mandatory Level:(NW)

Successfully processed 1 files; Failed processing 0 files
Run Code Online (Sandbox Code Playgroud)

但是,我现在似乎无法删除强制标签,因为它已被明确设置.最初,输出看起来像这样:

C:\Debug>icacls wdbp.exe
wdbp.exe Everyone:(I)(RX)
         BUILTIN\Administrators:(I)(F)
         NT AUTHORITY\SYSTEM:(I)(F)

Successfully processed 1 files; Failed processing 0 files
Run Code Online (Sandbox Code Playgroud)

默认情况下,它只是从没有强制标签的目录继承.我尝试使用icacls的继承选项,并尝试删除与Label对应的SID,其中没有一个显示错误,但实际上并没有删除强制标签.

有人有主意吗?

windows acl explicit integrity levels

8
推荐指数
0
解决办法
2792
查看次数

如果删除了组件扫描,则@Autowired不起作用

我面临的问题是,如果从配置中删除组件扫描标记,注释@Autowired将不再起作用(在所有使用此批注的Java类中)

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

  <context:component-scan base-package="efco.auth" />

here are some beans...
Run Code Online (Sandbox Code Playgroud)

efco.auth包中只有一个类,这个类与以下类EfcoBasketLogic无关.

和一个使用@Autowired的类:

package efco.logic;
    public class EfcoBasketLogic extends BasketLogicImpl {

        @Autowired
        private EfcoErpService erpService;
Run Code Online (Sandbox Code Playgroud)

这个Bean在另一个spring配置文件中定义:

<bean id="BasketLogic" class="efco.logic.EfcoBasketLogic">
    <property name="documentLogic" ref="DocumentLogic" />
    <property name="stateAccess" ref="StateAccess" />
    <property name="contextAccess" ref="ContextAccess" />
  </bean>
Run Code Online (Sandbox Code Playgroud)

如您所见,未定义erpService.其他三个属性在BasketLogicImpl上并且有setter.

我做错了什么?

spring explicit autowired

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

为什么 const char* 隐式转换为 bool 而不是 std::string?

#include <iostream>
#include <string>

struct mystruct{
     mystruct(std::string s){
        
        std::cout<<__FUNCTION__ <<" String "<<s;
    }
    
     explicit mystruct(bool s) {
        
        std::cout<<__FUNCTION__<<" Bool "<<s;
    }
};


int main()
{
    
    const char* c ="hello";
    
    mystruct obj(c);

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

输出:

mystruct Bool 1
Run Code Online (Sandbox Code Playgroud)
  1. 为什么const char*隐式转换为bool而不是std::string,虽然构造函数需要explicit类型?
  2. 隐式转换优先级在这里如何应用?

c++ explicit constructor-overloading overload-resolution implicit-conversion

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

使用核心动画显式动画NSView

我正在尝试NSView使用核心动画进行滑动.我想我需要使用显式动画而不是依赖于类似的东西[[view animator] setFrame:newFrame].这主要是因为我需要设置动画委托才能在动画结束后采取行动.

我使用动画师工作得很好,但正如我所说,我需要在动画结束时收到通知.我的代码目前看起来像:

// Animate the controlView
NSRect viewRect = [controlView frame];
NSPoint startingPoint = viewRect.origin;
NSPoint endingPoint = startingPoint;
endingPoint.x += viewRect.size.width;
[[controlView layer] setPosition:NSPointToCGPoint(endingPoint)];

CABasicAnimation *controlPosAnim = [CABasicAnimation animationWithKeyPath:@"position"];
[controlPosAnim setFromValue:[NSValue valueWithPoint:startingPoint]];
[controlPosAnim setToValue:[NSValue valueWithPoint:endingPoint]];
[controlPosAnim setDelegate:self];
[[controlView layer] addAnimation:controlPosAnim forKey:@"controlViewPosition"];
Run Code Online (Sandbox Code Playgroud)

这在视觉上有效(并且我在最后得到通知),但看起来实际的controlView没有被移动.如果我使窗口刷新,controlView将消失.我试过更换

[[controlView layer] setPosition:NSPointToCGPoint(endingPoint)];
Run Code Online (Sandbox Code Playgroud)

[controlView setFrame:newFrame];
Run Code Online (Sandbox Code Playgroud)

这确实会导致视图(和图层)移动,但它会破坏某些东西,以至于我的应用程序很快就会因为seg故障而死亡.

大多数显式动画的例子似乎只是在移动a CALayer.必须有一种方法来移动NSView并且还能够设置代理.任何帮助,将不胜感激.

cocoa delegates core-animation explicit nsview

7
推荐指数
2
解决办法
8520
查看次数

实现接口隐式和显式是否有意义?

我正在攻读MS 70-515考试.在其中一个实践中,作者实现了隐式和显式的接口.显式实现只调用隐式实现.刚才列出了显式实现而没有解释.

同时拥有接口的隐式和显式实现是否有意义?我认为显式实现是多余的(在这种情况下).

public class PassTextBox : TextBox, IScriptControl
{
    public virtual IEnumerable<ScriptDescriptor> GetScriptDescriptors()
    {
        var descriptor = new ScriptControlDescriptor(
            "AjaxEnabled.PassTextBox", ClientID);
        // ...
        return new ScriptDescriptor[] {descriptor};
    }

    IEnumerable<ScriptDescriptor> IScriptControl.GetScriptDescriptors()
    {
        return GetScriptDescriptors();
    }
}
Run Code Online (Sandbox Code Playgroud)

顺便说一句,代码似乎在没有显式实现的情况下运行得很好,因为隐式实现是公开的.

它涉及MCTS Self-Paced Training Kit(考试70-515):使用Microsoft .NET Framework进行Web应用程序开发4第9章,第2课,练习3.

c# explicit interface implicit

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

我真的应该大量介绍显式关键字吗?

当我在我的代码1上使用(最近发布的)Cppcheck 1.69时,它显示了很多消息,我没有预料到;-)禁用noExplicitConstructor证明了所有这些消息都属于这种类型.

但是我发现我不是唯一一个有很多新的Cppcheck消息的人,看看LibreOffice的分析结果(我可以公开展示):

在此输入图像描述

有经验的程序员会做什么:

  • 取消支票?
  • 大量介绍explicit关键字?

1 编辑:这当然不是我的代码,而是我必须处理的代码,它是遗留代码:C和C++在几种(预)标准风格中的混合,并且它是一个相当大的代码库.

c++ explicit legacy-code cppcheck

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

(涉及显式)优先级与运算符和构造函数转换

我浏览了很多与转换相关的问题,但似乎没有人以这种方式讨论显式关键字.这是代码:

struct B;
struct A{
    /*explicit*/ A(const B&){ cout << 1; }  // *1
};
struct B{
    /*explicit*/ operator A()const{ cout << 2; } // *2
};

void foo(const A &){}

int main(void){
    B b;
    foo( /*static_cast<A>*/ (b) ); // *3
}
Run Code Online (Sandbox Code Playgroud)

结果:(Y:未注释,N:注释,X:或者)

# | *1 | *2 | *3 |output|  
1 |  N |  N |  N |error |
2 |  N |  N |  Y |  1   |
3 |  N |  Y |  N |  1   | …
Run Code Online (Sandbox Code Playgroud)

c++ explicit type-conversion

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

为什么std :: in_place_t的构造函数默认且显式?

cppreference显示以下定义std::in_place_t

struct in_place_t {
    explicit in_place_t() = default;
};
inline constexpr std::in_place_t in_place{};
Run Code Online (Sandbox Code Playgroud)

他们为什么要添加一个explicit默认的构造函数?为什么不排除它?有什么好处?

c++ explicit std explicit-constructor defaulted-functions

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