Tag: 属性

如何用一个值函数设置多个属性?

给定包含多个数据元素(如对象或数组)的数据,是否可以使用单个值函数在select上设置多个属性? 例如: var data = [{ 'x': 10, 'y': 20, 'r': 5 }]; d3.select('body').append('svg').selectAll('circle') .data(data) .enter().append('circle') .attr('cx cy r', function (d) { return [dx, dy, dr]; }); 代替: var data = [{ 'x': 10, 'y': 20, 'r': 5 }]; d3.select('body').append('svg').selectAll('circle') .data(data) .enter().append('circle') .attr('cx', function (d) { return dx; }); .attr('cy', function (d) { return dy; […]

C# – 从静态类获取静态属性的值

我试图循环通过一个简单的静态类中的一些静态属性,以填充他们的价值combobox,但有困难。 这是简单的课程: public static MyStaticClass() { public static string property1 = "NumberOne"; public static string property2 = "NumberTwo"; public static string property3 = "NumberThree"; } …和试图检索值的代码: Type myType = typeof(MyStaticClass); PropertyInfo[] properties = myType.GetProperties( BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly); foreach (PropertyInfo property in properties) { MyComboBox.Items.Add(property.GetValue(myType, null).ToString()); } 如果我不提供任何绑定标志,那么我得到大约57个属性,包括像System.Reflection.Module模块和其他各种我不关心的其他inheritance的东西。 我的3个声明的属性不存在。 如果我提供其他标志的各种组合,那么它总是返回0属性。 大。 我的静态类实际上是在另一个非静态类中声明的吗? 我究竟做错了什么?

如何dynamic创build新的属性

我怎样才能创build一个对象的方法内给定的参数的属性? class Foo{ public function createProperty($var_name, $val){ // here how can I create a property named "$var_name" // that takes $val as value? } } 我希望能够访问像这样的属性: $object = new Foo(); $object->createProperty('hello', 'Hiiiiiiiiiiiiiiii'); echo $object->hello; 也有可能我可以使财产公开/保护/私人? 我知道在这种情况下,它应该是公开的,但我可能想要添加一些magik方法来获得保护属性和东西:) 我想我find了一个解决scheme: protected $user_properties = array(); public function createProperty($var_name, $val){ $this->user_properties[$var_name] = $val; } public function __get($name){ if(isset($this->user_properties[$name]) return $this->user_properties[$name]; […]

Java属性反斜杠

我正在使用Java属性来读取属性文件。 一切工作正常,但属性默默滴下反斜杠。 (即) original: c:\sdjf\slkdfj.jpg after: c:sdjfslkdfj.jpg 我如何让属性不这样做? 我正在使用代码prop.getProperty(key) 我从文件中获取属性,我想避免添加双反斜杠

spring引导,logback和logging.config属性

我使用logback库实现了一个Spring启动项目的日志logging。 我想根据我的弹簧configuration文件(属性“spring.pofiles.active”)加载不同的日志loggingconfiguration文件。 我有3个文件:logback-dev.xml,logback-inte.xml和logback-prod.xml。 我正在使用弹簧启动版本1.2.2.RELEASE。 正如你可以在春季启动文档( 这里 )阅读。 它说: 可以通过在类path中包含适当的库来激活各种日志logging系统,并且可以通过在类path的根目录中或在Spring环境属性logging.config中指定的位置提供合适的configuration文件来进一步进行定制。 (注意,由于在创buildApplicationContext之前对日志进行了初始化,所以在Spring @Configuration文件中无法控制从@PropertySources进行的日志logging,系统属性和传统的Spring Boot外部configuration文件可以正常工作。 所以我试图在我的application.properties文件中设置“logging.config”属性: logging.config=classpath:/logback-${spring.profiles.active}.xml 但是,当我开始我的应用程序,我的logback- {configuration文件} .xml不加载… 我认为日志logging是所有使用spring boot的项目遇到的常见问题。 我想知道我是否在正确的方向,因为我也有其他的解决scheme,但我觉得他们不优雅(条件parsing与Janino在logback.xml文件或命令行属性)。

更新属性文件中的属性值而不删除其他值

First.properties内容: name=elango country=india phone=12345 我想从india到america改变country 。 这是我的代码: import java.io.*; public class UpdateProperty { public static void main(String args[]) throws Exception { FileOutputStream out = new FileOutputStream("First.properties"); FileInputStream in = new FileInputStream("First.properties"); Properties props = new Properties(); props.load(in); in.close(); props.setProperty("country", "america"); props.store(out, null); out.close(); } } First.properties输出内容: country=america 其他属性被删除。 我想更新一个特定的属性值,而不删除其他属性。

jquery删除html5必需的属性

嗨,我想删除jquery的'required ='“'属性。 <input type="text" id="edit-submitted-first-name" name="submitted[first_name]" value="" size="30" maxlength="128" required="" >

默认值为一个静态属性

我喜欢c#,但为什么我可以这样做: public static bool Initialized { private set; get; } 或这个 : public static bool Initialized = false; 但不是在一条线上的混合? 我只需要设置访问级别我的variables(私人设置),我需要在启动时设置为false。 我不想让这个无聊的私人_Initializedvariables,这将由公共的初始化var的getter返回。 我喜欢我的代码是美丽的。 (注意:我的variables是静态的,不能在构造函数中初始化)。 谢谢

.NET DefaultValue属性

我听说有人对DefaultValue属性做了一些不同的说明,包括: “它在任何其他用途之前设定了财产的价值。” “它不适用于自动function”。 “这只是装饰,你必须手动设置实际的默认值。” 哪个(如果有的话)是正确的? DefaultValue实际上是否设置了默认值? 有没有案件不起作用? 最好不要使用它?

Moq,SetupGet,嘲弄一个属性

我试图嘲笑一个名为UserInputEntity的类,它包含一个名为ColumnNames的属性:(它包含其他属性,我已经简化了它的问题) namespace CsvImporter.Entity { public interface IUserInputEntity { List<String> ColumnNames { get; set; } } public class UserInputEntity : IUserInputEntity { public UserInputEntity(List<String> columnNameInputs) { ColumnNames = columnNameInputs; } public List<String> ColumnNames { get; set; } } } 我有一个主持人class: namespace CsvImporter.UserInterface { public interface IMainPresenterHelper { //… } public class MainPresenterHelper:IMainPresenterHelper { //…. } public […]