w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Scala: how do I access a Class[?0] type?
You are barking at the wrong tree. :) The method return type is Class[_] -- a Class whose type parameter may be anything, but you do not need to know the type parameter: the class is what you want! You can just get its string representation, for example: scala> attributes(0)._2.toString res3: String = boolean scala> attributes(1)._2.toString res4: String = class java.lang.String Or you can get the canonical name: scala> attributes(0)._2.getCanonicalName res7: String = boolean scala> attributes(1)._2.getCanonicalName res8: String = java.lang.String

Categories : Scala

Why is it not okay to access a property of a class, but it is okay to access a method of the same class?
This is referred to as encapsulation. Local variables are, generally, an implementation detail. This shouldn't be exposed because calling code (if it is correctly decoupled) only cares about what you do not how you do it. If your implementation changes variables may be removed or changed meaning calling code would need changed. Methods abstract this and allow the internals to change without affecting the exposed interface. Another reason is that direct access to variables allows calling code to alter variables that the class relies on. Methods allow creating a copy of, say, an array so that code which changes the array doesn't affect the logic of the class.

Categories : PHP

Is there any way to access Base Class Property via Derived Class object directly in PHP
Since you override $name in the child, the property will have the child's property value. You cannot access the parent value then. It wouldn't make sense any other way because the property is public, which means the property is visible to the child (and outside) and modifications to it will change the very base value. So it's effectively one and the same property and value for that instance. The only way to have two separate properties of the same name is to declare the base property private and the child property non-private and then call a method that has access to the base property, e.g. class Foo { private $name = 'foo'; public function show() { echo $this->name; } } class Bar extends Foo { public $name = 'bar'; public function show() {

Categories : PHP

class java.lang.RuntimeException/Scala class file does not contain Scala annotation
Looks like the library is configured to compile against Scala 2.9.1. Major versions of Scala are not binary compatible. I put the necessary SBT changes here: https://github.com/mpartel/prestashop-scala-client/commit/e9a1df40bfe35518aaebac899e438b9b6fa6d728

Categories : Scala

How to access the Property value of nested class in c#
Since everything involved is public, you can access this value outside the assembly as follows: public class SomeExternalClass { public void SomeMethod() { string val = a.b.result; } }

Categories : C#

How to access different property value in derived class
Override the property in derived class public class ViewModelBase { private string _aProperty = "A"; public virtual string AProperty { get { return _aProperty; } } public void DoSomething() { Console.WriteLine(AProperty); } } public class DerivedViewModel : ViewModelBase { private string _bProperty = "B"; public override string AProperty { get { return _bProperty; } } } DerivedViewModel dr = new DerivedViewModel(); dr.DoSomething();//Prints B Further take a look at Msdn Polymorphism

Categories : C#

Access to base class from Property Attribute
There is no such method -- an instance of Attribute does not know what it was decorating. But the code that creates the instance does, so depending on usage you could inject this information externally: var identityAttribute = (IdentityAttribute)Attribute.GetCustomAttribute(...); // If you can call GetCustomAttribute successfully then you can also easily // find which class defines the decorated property var baseClass = ... ; // And pass this information to GenerateValue var value = identityAttribute.GenerateValue(baseClass);

Categories : C#

VB.net Access class property from another class
Even if you could do what you are trying to do, it would be a bad idea, because you would be coupling your user control to this particular form, making it useless outside of this form. Instead you need to have your user control generate an event that the form can subscribe to and handle itself. In other words, you want to make the user control create a message that can be delivered to the form, like this: Public Class UserControlClass ' Define event that will be raised by user control to anyone interested in handling the event Public Event UC_Button1Click() ' Mechanism to allow event to be raised by user control Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click RaiseEvent UC_Button1Click() End Sub End

Categories : Vb.Net

Should I use a property to access a base class global variable?
_residentialStatus is more like a private variable, which is private to the class. You can add a protected property in ProviderRequest that encapsulates the private variable and use that in ProviderRequest.

Categories : C#

Dynamically create instance of class which can be different each time and still be able to access it's properties
object foo = Activator.CreateInstance("test"); (foo as test).name = "TestMessage"; Update: This is what you really want to do. .Net - Reflection set object property

Categories : C#

I've set a value on a class property on Form1, but when I tried to access it on Form2 it doesn't return a value, why?
I have a piece of paper, and I write my name on it. If I then get a completely different piece of paper, my name is not automatically on it. It is the same here - there are two User objects here, completely unrelated. If you want the name from the first, you need to pass that User object to the second form.

Categories : C#

If my dependency property is a class how do I get property changed to activate on a class property change?
Each one of the properties of User must also notify on change. E.g.: public class User { string _Name; public string Name { get { return _Name; } set { _Name = value; PropertyChanged("Name"); } ... } }

Categories : C#

Access dynamically created class instance variable, Kivy framework
self.mytext.append(TextInput(hint_text=t, on_text_validate=modify.callback(self))) You are calling the function instead of passing it. Use functools.partial. self.mytext.append(TextInput(hint_text=t, on_text_validate=partial(modify.callback, self)))

Categories : Python

implement a base class method to access a property of derived classes
Use polymorphism. Make your getNationalityName function virtual, and redefine it in your derived classes to return the desired string. Each time, the derived class' function will be called, returning the string of the corresponding class: //base class: class Person{ <...> public: virtual void getNationalityName(char* pNatiName); } <...> // A derived class class American : public Person{ public: void getNationalityName(char* pNatiName) { strcpy(pNatiName, m_nationalityName); } private: unsigned int m_dollar; static char[] m_nationalityName; } <...> int main() { Person * p = new American(); p->getNationalityName(<...>); // calls American::getNationalityName name even though p

Categories : C++

How to access parent's class property if the current class has been instantiated in the parent
Parent constructors are not called implicitly if the child class defines a constructor. In order to run a parent constructor, a call to parent::__construct() within the child constructor is required. If the child does not define a constructor then it may be inherited from the parent class just like a normal class method (if it was not declared as private).

Categories : PHP

Entity Framework & RIA Services - cant access protected property in shared class on client
WCF RIA does not create a member in the Web.g.cs unless the member would have been serialized. As ApplicationNumber is a protected property, WCF RIA ignores it. This explains why it compiles in the web project, but not in Silverlight. Have you tried not sharing the other partial but adding the property instead? Change it to ClassA.cs or ClassA.partial.cs and the contents to: namespace ABC.Web.Models.DomainModel { using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; public abstract partial class ClassA { // You _do_ want this serialized to the client and back // so remove the [IgnoreDataMember] atribute public virtual string ApplicationNumberAccessor { get {

Categories : C#

"error: can't find main class scala.tools.nsc.MainGenericRunner" when running scala in windows
Those weird variables are called parameter extensions. they allow you to interpret a variable as a path to a file/directory and directly resolve things from that path. For example, if %1 is a path to a file dir123456file.txt, %~f1 is the fully qualified path to file.txt, %~p1 is the path to the containing directory dir123456, %~s1 is the path in short name format dir123~1file.txt, and many others... Also, %0 is always set to the path of the currently running script. So: %~fs0 is the fully qualified path, in short name format, to the current script, %%~dpsi is the manual expansion of the FOR variable %%i to a drive letter (d option) followed by the path the containing folder (p option), in short format (s option). Now, this weird looking block of code is a workaround for KB83343

Categories : Windows

scala Duration: "This class is not meant as a general purpose representation of time, it is optimized for the needs of scala.concurrent."
Time can be represented in various ways depending on your needs. I personally have used: Long — a lot of tools take it directly Updated: java.time.* thanks to @Vladimir Matveev The package is designed by the author of Joda Time (Stephen Colebourne). He says it is designed better. Joda Time java.util.Date Separate hierarchy of classes: trait Time case class ExactTime(timeMs:Long) extends Time case object Now extends Time case object ASAP extends Time case class RelativeTime(origin:Time, deltaMs:Long) extends Time Ordered time representation: case class History[T](events:List[T]) Model time. Once I had a global object Timer with var currentTime:Long: object Timer { private var currentTimeValue:Long def currentTimeMs = currentTimeValue def currentTimeMs_=(newTime:Long) { ...

Categories : Scala

Scala import statement at top and inside scala class
The difference is: In Option 1 the import is viable for the complete scope. i.e any class/trait/function in com.somePackage can be used anywhere inside/outside the MyClass But in case of Option 2 it can only be used inside the MyClass and not outside it because scope of import is limited to inside MyClass only.

Categories : Scala

Scala Macros: Making a Map out of fields of a class in Scala
Note that this can be done much more elegantly without the toString / c.parse business: import scala.language.experimental.macros abstract class Model { def toMap[T]: Map[String, Any] = macro Macros.toMap_impl[T] } object Macros { import scala.reflect.macros.Context def toMap_impl[T: c.WeakTypeTag](c: Context) = { import c.universe._ val mapApply = Select(reify(Map).tree, newTermName("apply")) val pairs = weakTypeOf[T].declarations.collect { case m: MethodSymbol if m.isCaseAccessor => val name = c.literal(m.name.decoded) val value = c.Expr(Select(c.resetAllAttrs(c.prefix.tree), m.name)) reify(name.splice -> value.splice).tree } c.Expr[Map[String, Any]](Apply(mapApply, pairs.toList)) } } Note also that you need the c.r

Categories : Scala

How to handle property changed event of a property in One class from another class in MVVM
You can subscribe the event PropertyChanged. myModel.PropertyChanged+=(s,e)=>{ /* your handler here */}; as the @stijn comment point, unsubscribing can be required if the model became unused to avoid memory leaks.

Categories : C#

How to access a javascript object's property, when it has a dynamic number as property title?
There is example, how you can access to properties of your object with loop: http://jsfiddle.net/Y7mHB/ var names = { 15: '15', 117: '117' }; for(var key in names) { alert(key + ' ' + names[key]); }

Categories : Javascript

How to access an object literal property from another property?
I think you can wrap the config object, e.g. var config = (function() { var _url = 'http://google.com'; return { url : _url, message : 'You must go to <a href="' + _url + '">Google</a> to search!' } })();

Categories : Javascript

Is property getter called even if I access property by name?
Oops. Just tried it. Apparently i use dot notation too much, and didn't realize just how much it was doing. :P #import "NSObject.h" #include <stdio.h> @interface Test : NSObject @property (getter=myStuff) int stuff; @end @implementation Test -(int)myStuff { return 42; } -(void)setStuff:(int)value { /* don't care */ } @end int main() { @autoreleasepool { Test* test = [[Test alloc] init]; /* All these work... */ printf("test.stuff == %d ", test.stuff); printf("[test myStuff] == %d ", [test myStuff]); printf("test.myStuff == %d ", test.myStuff); /* but here, there's an exception */ printf("[test stuff] == %d ", [test stuff]); return 0; } } When i compile this (using clang in Linux), there are two warnin

Categories : Objective C

c# property setter body without declaring a class-level property variable
You need to set a field variable and store the value there, if you're going to use custom getter and setter. With the code you have right now you will be running into a stack overflow exception. When you assign something to mongoFormId, you'll execute the line this.MongoFormId = value;. This is an assignment to mongoFormId, resulting in executing the line this.MongoFormId = value;, and so on. It won't ever stop. The correct way is a field: private string _mongoFormId; public string mongoFormId { get { return this._mongoFormId; } set { this._mongoFormId = value; revalidateTransformation(); } }

Categories : C#

Scala v 2.10: How to get a new instance of a class (object) starting from the class name
There is a very simple answer: scala> def createInstance(clazzName: String) = Class.forName(clazzName).newInstance createInstance: (clazzName: String)Any scala> createInstance("java.lang.String") res0: Any = "" If it works for you, everything is fine. If it don't, we have to look into your class loader. This is usually the point when things will get dirty. Depending in what you want to do, look into: The cake pattern, if you want to combine your classes during compile time OSGi when you want to build a plugin infrastructure (look here for a very simple example) Google guice, if you really need dependency injection (e.g. when mixing Scala and Java code) and the cake pattern does not work for you

Categories : Scala

Setting property of class type with TypeConverter from Property Panel produces expanded XAML, not string
You almost there and needs only two minor adjustments on Complex class to make it work as you expect: 1) Remove default public constructor: public Complex() { } // <- delete this line 2) Add magical DesignerSerializationVisibility attribute to Real and Imaginary properties (or in general - to all properties with public setter): [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public double Real { get { return m_real; } set { m_real = value; } } [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public double Imaginary { get { return m_imag; } set { m_imag = value; } } Hope this helps.

Categories : Wpf

Giving data to a class property according to another classes property which I get from the database
Get member payments: public List<Payment> GetMemberPaymnets(int memberId) { List<Payment> Payments = new List<Payment>(); string SELECT = "SELECT ID,AMOUNT,STARTDAY,ENDDAY FROM Payments WHERE Id = @Id order by endday desc"; using (sqlConnection = new SqlConnection(sqlConnectionString_WORK)) { sqlConnection.Open(); using (SqlCommand sqlCommand = new SqlCommand(SELECT, sqlConnection)) { sqlCommand.Parameters.Add("@Id", SqlDbType.Int).Value = entity.Id; var sqlReader = sqlCommand.ExecuteReader(); while (sqlReader.Read()) { var payment = new Payment { Id = Convert.ToI

Categories : C#

Bind an control property to a property of a Class of the Window ViewModel
You have implemented INotifyPropertyChanged on your ViewModel but you never call it when Property is changed try: public class ViewModel : INotifyPropertyChanged { private foo _property; public foo Property { get{ return _property; } set{ _property = value; OnPropertyChanged(); } } .................

Categories : C#

Change print compiler phase in scala console dynamically
There's an issue https://issues.scala-lang.org/browse/SI-4594 and a PR https://github.com/scala/scala/pull/2701 For now, scala> :power ** Power User mode enabled - BEEP WHIR GYVE ** ** :phase has been set to 'typer'. ** ** scala.tools.nsc._ has been imported ** ** global._, definitions._ also imported ** ** Try :help, :vals, power.<tab> ** scala> settings.processArgumentString("-Ylog:typer") res0: (Boolean, List[String]) = (true,List()) scala> val i = 8 [log typer] [+symbol] method $line in object $read (flags: <method>) But you can't turn it off.

Categories : Scala

Play Scala Json Missing Property vs Null
You can use something like : val FooReader = ( (__ "a").readNullable[String] and (__ "b").read(Reads.optionNoError[String]) and (__ "c").readNullable[String] )(Foo) The 'Reads.optionNoError[String]' will produce a JsError if '(__ "b")' is missing. You can actually do something like : val FooReader = ( (__ "a").read(Reads.optionNoError[String]) and (__ "b").read(Reads.optionNoError[String]) and (__ "c").read(Reads.optionNoError[String]) )(Foo)

Categories : Scala

Scala. Can case class with one field be a value class?
You can have a case class that is a value class. As you can see from the example below, there is no object creation. Except of course the inevitable boxing if you would upcast to Any. Here is a little piece of scala code class ValueClass(val value:Int) extends AnyVal case class ValueCaseClass(value:Int) extends AnyVal class ValueClassTest { var x: ValueClass = new ValueClass(1) var y: ValueCaseClass = ValueCaseClass(2) def m1(x:ValueClass) = x.value def m2(x:ValueCaseClass) = x.value } And the bytecode, which does not contain the slightest trace of the two value classes. Compiled from "ValueClassTest.scala" public class ValueClassTest { public int x(); Code: 0: aload_0 1: getfield #14 // Field x:I 4: ireturn

Categories : Scala

Set the css property of a class based on its visibility property using CSS only
yes with css attributre selectors you can do it try the below css: .div-class[style*="visible"] { color: green; } .div-class[style*="hidden"] { color: red; }

Categories : CSS

I can't access property on my object via Expression.Property unless the type of the fed expression is strongly-typed
Inner is declared as an object. And clearly, an object doesn't contain a Value property. You need to "convert" that expression to the expected type before you attempt to access that property. This is equivalent to adding a cast to the expression. Func<OuterClass, object> e = Expression.Lambda<Func<OuterClass, object>>( Expression.Property( Expression.Convert(Expression.Property(p, "Inner"), typeof(InnerClass)), "Value" ), p ).Compile();

Categories : C#

Strongly typed access to csv in scala?
If you know the the # and types of fields, maybe like this?: case class Friend(id: Int, name: String) // 1, Fred val friends = scala.io.Source.fromFile("friends.csv").getLines.map { line => val fields = line.split(',') Friend(fields(0).toInt, fields(1)) }

Categories : Scala

C++-style private access in Scala?
If you try it like this abstract class Super { private def g() def f() { g() } } the compiler will give you this error messge: scala: abstract member may not have private modifier private def g() You have to declare g() at least protected.

Categories : C++

How to add a property to an entity dynamically?
The syntax is very simple for this, but the background info is more important, please read the whole answer before you reuse the snippet. The YourType can be extended with new fields using the YourType.addMember() function. See this example snippet: $data.Entity.extend('Product', { id: { type: 'int', key: true, computed: true }, Name: { type: 'string' } }); $data.EntityContext.extend('Northwind', { Products: { type: $data.EntitySet, elementType: Product}, }); Product.addMember('Description', { type:'string', key: false, computed: false, required: false }); var context = new Northwind({provider: 'webSql', databaseName: 'Northwind'}); context.onReady(function() { var product1 = new Product({ Name: 'Beer', Description: 'tasty'}); context.Products.add(pro

Categories : Javascript

no access to a java static method from scala
If you're using Scala IDE/Eclipse, sometimes the in-editor compiler does not pick when static methods become created and/or updated. Running "Clean..." on the project makes the error go away.

Categories : Scala

How to dynamically create an anonymous class that extends an abstract class in PHP?
You do have access ev(a|i)l. If you used traits to compose your class it COULD be possible to do this. <?php trait Constructor { public function __construct() { echo __METHOD__, PHP_EOL; } } trait Runner { public function run() { echo __METHOD__, PHP_EOL; } } trait Destructor { public function __destruct() { echo __METHOD__, PHP_EOL; } } $className = 'Thread'; $traits = ['Constructor','Destructor','Runner',]; $class = sprintf('class %s { use %s; }', $className, implode(', ', $traits)); eval($class); $thread = new $className; $thread->run(); This outputs ... Constructor::__construct Runner::run Destructor::__destruct So you CAN, but not sure if you SHOULD.

Categories : PHP

Can I change property of panel dynamically in Ext JS?
You will want to add a member function to your panel class to do the actual work of updating what is shown on the screen: setSomeProperty: function(prop) { this.down('#someContainer').update({someProperty: prop}); }

Categories : Extjs



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.