w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Why can't I add this instance of a generic type to a collection?
public class Experiment<T> where T : Sample { private List<T> _Samples = new List<T>(); public IReadOnlyCollection<T> Samples { get { return _Samples.AsReadOnly(); } } public Experiment() { } public Experiment(IEnumerable<T> samples) { _Samples = samples.ToList(); } public void AddSample(T sample) { _Samples.Add(sample); sample.Experiments.Add(new Experiment<Sample>(_Samples)); // The problem lies here } } public abstract class Sample { private List<Experiment<Sample>> _Experiments = new List<Experiment<Sample>>(); public ICollection<Experiment<Sample>> Experiments { get { return _Experiments ; } } } By add

Categories : C#

chessboard type grid on windows phone 8
Create a two-level view model of rows and cells. Bind the rows to an ItemsControl, then in the item template, bind the cells to another ItemsControl. Each cell will have a property to tell if it is even or odd, so you can achieve the checkerboard pattern. You can expose game state through additional properties of the cell to display board position through data binding. Finally, since the cells will have a fixed size, wrap the whole thing in a Viewbox to fit it to your container. The view models: public class BoardViewModel { private readonly int _rows; private readonly int _columns; public BoardViewModel(int rows, int columns) { _rows = rows; _columns = columns; } public IEnumerable<RowViewModel> Rows { get {

Categories : Xaml

Ui-Bootstrap Datepicker javascript error : Type Error has no method 'getFullYear'
The error you are seeing is the result of this: "Sep 7, 2013".getFullYear() What you want is this: new Date("Sep 7, 2013").getFullYear() Somewhere you're passing angular a string instead of a date object.

Categories : Angularjs

JSF SelectManyCheckBox for enum : SEVERE: Unable to create new Collection instance for type java.util.Arrays$ArrayList
This will happen when the UISelectMany component's value being provided is created using Arrays#asList() method instead of new ArrayList(). If a model value is already prepopulated, JSF will try to use exactly the same type to put submitted values in and set the new model value. However, the java.util.Arrays$ArrayList type as returned by Arrays#asList() is internal to java.util.Arrays class and not individually instantiable as in new Arrays$ArrayList(). Hence this exception. To fix this, make sure that the value is created using new ArrayList().

Categories : JSF

Push notification for Voip (type 4) windows phone 8 limit
You don't need pay for VOIP. Concerning Push Notifications, there is a limit 500 push notifications per subscription, per day. If it is not enough you will need to pay for a certificate. More details http://msdn.microsoft.com/library/windowsphone/develop/ff941099(v=vs.105).aspx

Categories : Windows Phone 8

Check if an object is a type of collection, regardless of what Type that collection is of?
You can do this by confirming that the type is a generic type, and its generic type definition is equal to the EntityCollection<> open generic type. var type = e.PropertyType; var isEntityCollection = type.IsGenericType && type.GetGenericTypeDefinition() == typeof(EntityCollection<>);

Categories : C#

Returning Collection vs Collection
Collection<Type> getTypes(); Here, getTypes() must return a Collection<Type> (e.g. ArrayList<Type> or HashSet<Type>). Collection<? extends Type> getTypes(); Here, getTypes() can return a Collection of anything that is or extends Type, (e.g. ArrayList<SubType> or HashSet<SubType>). So anything that can be returned from the first variant can also be returned from the second. In the second, however, you don't know what the type parameter of the collection actually is; you just know that it extends Type. As for which should be preferred, it really depends on what you're trying to do, and what makes more sense logically. Bear in mind that when you have <? extends Type>, you don't actually know what ? is, and this can be hindering at times; m

Categories : Java

How to embed or customize office type ribbon tools in windows phone 8
There are no ribbon controls available out-of-the-box for Windows Phone. You should not use/implement ribbon controls on Windows Phone. Mainly because the OS was designed to have a user interaction mechanism that does not fit the ribbon model. You have very limited screen real estate and don't want to fill it with unnecessary controls. Why would you want to embed a ribbon in a TextBox?

Categories : Windows Phone 8

Create instance of generic type in Java when parameterized type passes through hierarchies?
getClass().getGenericSuperclass(); gives you the details of the super class. Therefore it will only work if you subclass a parameterized super class. It won't work if you instantiate a parameterized super class given type parameters.

Categories : Java

confused about the type of the Instance of a binary tree data type of Int Nodes in Haskell
You defined the type Tree as a parametrised type. The a after Tree in the data type's definition is this parameter. This means that there is not just one Tree type, but many different ones. For example, you can have a type Tree Integer containing integers, a type Tree Bool containing booleans and a type Tree (String -> String) containing functions from string to string. Note that it's a good thing that you can distinguish these different types. It means that when you get a value out of such a tree, you know which type of value you're going to get. If there was just one Tree type, then you wouldn't be able to find out.

Categories : Haskell

Java Pass instance type of Object to generic class type parameter
No.. generic type should be known at compile time. Generics are there to catch possible runtime exceptions at compile time itself. List<Integer> list = new ArrayList<Integer>(); //..some code String s = list.get(0); // this generates compilation error because compiler knows that list is meant to store only Integer objects and assigning the value got from list to String is definitely an error. If the generic type was determined at run-time this would have been difficult.

Categories : Java

Create instance of generic type in Java when parameterized type is contained?
The anonymous class must have the actual type parameter hard-coded in its declaration for it to work. new Parameterized<E>(){}; does not work. You are just hard-coding "E" (a type variable). So when you look at the metadata using reflection all you see is "E" (a type variable). You must create a subclass which hard-codes its superclass with an actual class as type argument at compile-time: new Parameterized<String>(){}; I tried to adapt Steve B's approach of creating an anonymous subclass: You missed the whole point of that. The point was not to create a subclass. The point was to create a subclass with the actual class of the type argument hard-coded in the superclass.

Categories : Java

How to read Values from TYPE in Oracle for the Collection (Map) type
In SQL SELECT ivkey, ivvalue FROM TABLE( pValues ); would work. If you really mean to ask how to access the collection in PL/SQL, assuming the collection is dense. FOR i IN 1..pValues.count LOOP dbms_output.put_line( 'Key = ' || pValues(i).ivkey || ' Value = ' || pValues(i).ivvalue ); END LOOP; If you expect some elements of the collection to be missing (which seems odd given your choice of PL/SQL collection), the loop gets a bit more complicated since you've got to call FIRST and NEXT to iterate through the elements. If you want to create a PL/SQL construct that is more similar to your Map in Java, you'd want something like CREATE TYPE map_t AS TABLE OF VARCHAR2(250) INDEX BY VARCHAR2(32)

Categories : Java

Haskell: Using the correct instance for a type wrapped in another type
If you look at the derived code (with -ddump-deriv) then you can see that the derived instance for ListWrap is pretty normal looking instance Show ListWrap where showsPrec a (ListWrap b) = showParen (a >= 11) $ showString "ListWrap " . showsPrec 11 b it's just passing the inner show down to showsPrec again. This suggests that the problem is that GHC is erasing the type variable d when you wrap it with ListWrap. Indeed, you could also write ListWrap as data ListWrap where ListWrap :: forall d. [(WrapperType d)] -> ListWrap which emphasizes that this is existentially typed. We can see the error more directly by deleting the instance Show (WrapperType t) and observing GHC's type error /Users/tel/tmp/foo.hs:33:52: Warning: No instance for (Show (WrapperType d))

Categories : Haskell

How to add new object/ type and type to existing Collection
Pass the collection ByRef to the other procedure. Public Sub AddAnotherObject(ByRef colSecurities As Collection) Dim objOther As SomeOtherObject Set objOther = New SomeOtherObject colSecurities.Add objOther, CStr(objOther.ID) End Sub When you get back to the calling procedure, the collection's count will be one higher and the object will be in the collection. The opposite of ByRef is ByVal. Changes to a variable passed ByVal are lost once the procedure ends.

Categories : Excel

Collection of a Type using a Generic Type of any kind
Simple approach Just add another interface that is not generic: public interface IServiceInvokerUntyped { } public interface IServiceInvoker<TServiceContract> : IServiceInvokerUntyped { } Declare the dictionary it like this: private Dictionary<string, IServiceInvokerUntyped> _serviceInvocationCollection = new Dictionary<string, IServiceInvokerUntyped>(); Variant approach If your generic type parameter can be declared as covariant: public interface IServiceInvoker<out T> : IServiceInvokerUntyped { } Declare the dictionary it like this: private Dictionary<string, IServiceInvoker<object>> _serviceInvocationCollection = new Dictionary<string, IServiceInvoker<object>>(); For contravariance, just change 'out' to 'in' and modify the

Categories : C#

Unity error--- Activation error occured while trying to get instance of type IUserRepository, key ""
Strictly I'm not sure what problem it is, according to my experience, if you download a stable sample but unable to run it,mostly it could be reference problem. So, you may check is that missing any DLL files and make sure their path is Asset/Plugins. Then, check Edit-ProjectSettings-Player-YourTargetPlatform-OtherSettings, confirm that Api Compatibility Level is set to .NET2.0(default is the subset). Hope it works, good luck :)

Categories : C#

Typescript Error Message error TS2173: Generic type references must include all type arguments
That line should have been: promise(type?: any, target?: any): JQueryPromise<any>; I'll send them a pull request. Thanks. JQueryPromise is a generic interface. i.e. it takes type parameters. Starting with TS 0.9.1.1 they are more strict about generic parameters. They must be specified from now on. This was allowed in previous versions (where the type was assumed to any implicitly) but the compiler analysis is stricter now (and the type must be specified explicitly).

Categories : Typescript

Error: Array type has incomplete element type and binary operand error
for "My first question: What does array type has incomplete element type mean?" this error occur because in c language you need to specify the array size if you are not declaring it like int arr[] = {6,1,2,3}; otherwise it should be int arr[<size of the array>]; for invalid operands to binary * error? it occurs because you are trying to multiply int and int * values consider seeing this http://forums.devshed.com/c-programming-42/dynamic-arrays-with-undeclared-size-62036.html and read some more tutorials about pointers and arrays and how to mix them

Categories : C

Cant declare an instance with type parameter that is one layer off the constraint of the type parameter
Since TypedTableBase is generic, when you use it, you have to specify the actual datatype as in public class A<T> where T:DataTable { } public class B :TypedTableBase<DataRow> { } class MyClass { A<B> asdf = new A<B>(); }

Categories : C#

How do I make an instance of generic subclass? Getting error: "Bound mismatch: The type ... is not a valid substitute for the bounded parameter ..."
In your code, Team is just a placeholder (in this context, called Type Variable) and happens to be hiding the type Team, not referencing it. In other words, that declaration is equivalent to: public class ChampionsLeague<T extends Comparable<T>> extends League<T> { So it is really only asking for a class (or interface) that implements (extends) Comparable of itself. So this example: public class Ball implements Comparable<Ball> { @Override public int compareTo(Ball o) { return 0; } } // or: public interface Ball extends Comparable<Ball> { } Will work: ChampionsLeague<Ball> test = new ChampionsLeague<Ball>(); Edit: Some possibilities to what you may be trying to achieve: // ChampionsLeague needs a type Comparable to Team public c

Categories : Java

Processing Java Error: The nested type (Node) cannot hide an enclosing type
Check if your tab or sketch name is the same as program's inner class name. Change the name of your tab/sketch and you'll be fine. Rename your sketch (foo.pde) which is also the name of the tab to something other than the class name. The main sketch in processing cannot have a nested class with the same name, other sketches (other tabs) can have classes that are the same name as the tab.

Categories : Java

Scala: higher-kinded types, type projections and type mismatch error
@ziggystar says it: Drop the bound B and use M[X] directly: class TransM[X[_]](val b: M[X]) extends M[CurriedTrans[X, M[X]]#Type] { def from[A](f: T[A]) = b.from(f.r).get } val x1 = new TransM(new ListM) You could consider to do the same for Trans and CurriedTrans. If you need the inner type of M, you can always expose it through a type member of Trans and CurriedTrans.

Categories : Scala

scala type error for class with map member typed with existential type
Unless you explicitly require getting the keys back out as the statically correct subtype (which seems unlikely), then the following will work: case class DictVariant1(data: Map[MyBaseType, Double]) val d = List((Concrete1() : MyBaseType, 3.5)).toMap val dv1 = DictVariant1(d) Using a type ascription forces Concrete1() to be seen as an instance of the base type; you'd get the same effect if you added an explicit type to d: val d : Map[MyBaseType, Double] = .... Or if you put multiple entries in such that the type inferencer picks the base type: val d = List((Concrete1(), 3.5), (Concrete2(), 4.5)).toMap The 'get' you use is always going to fail, however, because you're trying to use the whole Map as an index: it works fine if you provide a sensible key: dv1.data.get(Concrete1())

Categories : Scala

Synat error - The type of the expression must be an array type but it resolved to String
Well yes - data is a String, and you can't use an indexing expression like data[i] on a string. Perhaps you want: if (b.toString().equals(data.substring(i, i + 1)) Although it's far from clear that that's a good idea. Byte.toString probably doesn't do what you expect it to. Perhaps you actually want: if ((char) b == data.charAt(i)) ?

Categories : Java

Oracle ODAC error setting up website in IIS: type A cannot be cast to type B?
Looks like an old version of the data access DLL is installed in the GAC. Does the DLL in c:windowsmicrosoft.net... exist? If not, you may have to provide a copy of it in a bin folder and update your config to use the DLL in the bin. This assumes you want to use the new version and not the old one in the GAC.

Categories : C#

Send an html email error content type or mime type
I have tested this example in my web host and it works perfectly : <?php $from = "xxxxx@gmail.com"; $subject = "Confirm Your Email"; $message = "<html><body>"; $message .= " <center> <b>You are reiciving this email because you Signed up at Alphaladys.com</b> <br> <font color="red">Thank You, $name</font><br> <b><a href="alphaladys.com/?71860c77c6745379b0d44304d66b6a13=emailVerify&key=$key">Confirm Your Email</a></b><br> </center> <br><br>© 2013 Copyright | AlphaLadys.Com | All rights reserved. "; $message .= "</body></html>"; $headers = "From: " . $from . " "; $headers .= "Reply-To: ". $from . " "; $headers .= "MIME-Version: 1

Categories : HTML

F# error FS0193 (VS 2010) : The type 'WebRequest' is not compatible with the type 'HttpWebRequest'
The error was quite small. The :> operator will only perform casts which are known to succeed at compile time and so won't cast from HttpWebRequest.Create(url) to HttpWebRequest as this actually returns a WebRequest. As a reult you need to use let req = HttpWebRequest.Create(url) :?> HttpWebRequest instead to allow for casting in the other direction in the inheritance tree. The difference is that casts made by :?> may fail at run time (but shouldn't in this case as all urls should be http)

Categories : Visual Studio 2010

Linkage error:Loader Constraint violation: previously initiated loading for a different type with name "org/w3c/dom/Type Info"
This happened to me with the JMX MBeanServer class. Groovy was loading one of them with its classloader and so was the JVM. In your case it sounds like the TypeInfo class exists in rt.jar just fine, but another class loader loads it from that jar (or another jar) again. Running the JRE with "-verbose:class" showed that double load behavior. Then I moved the offending jar out of my classpath and it worked just fine with the one loaded by Groovy. I would recommend moving rt.jar out of your classpath, or if you need other classes inside of rt.jar try unjaring and rejaring it without the Type class. That way the classloaders will be forced to use the ones in xmlbeans-2.5.0.jar or xbean-2.1.0.jar.

Categories : Misc

Project Server Console Application Error: The type name 'LoginWindows' does not exist in the type 'ProjectServer.WebSvcLoginWindows'
The problem is likely due to either the class name (LoginWindows) or the namespace (WebSvcLoginWindows) being incorrect when you create the loginWindows variable: public static WebSvcLoginWindows.LoginWindows loginWindows = new WebSvcLoginWindows.LoginWindows(); Make sure the namespace and class name are spelled correctly and have the correct capitalisation. If the class is contained in a separate asssembly, make sure your winforms project has a reference to the other assembly. Hope that helps.

Categories : C#

Unity 3 and Error "The type name or alias "xxxxx" could not be resolved. Please check your configuration file and verify this type name."
The problem is in you config file. You are mixing two concepts with some incorrect syntax. The <assembly... /> and <namespace ... /> nodes provide an assembly and namespace search order when your <register ... /> node contains a type that cannot be found by itself. If a type cannot be found, it searches through all combinations of [namespace].Type, [assembly]. Here's where the error is: it does NOT search for Type, [assembly]. If any <namespace ... /> nodes are defined, it does NOT try appending only the assembly. So your <register type="Biblioteca.Contracts.IManterCategoriaBO" mapTo="Biblioteca.Business.ManterCategoriaBO" /> node has the type Biblioteca.Contracts.IManterCategoriaBO which does not contain the assembly, so it cannot be found. Therefore,

Categories : C#

What does the E2511 Type parameter 'T' must be a class type compiler error mean?
TObjectList<T> includes a generic constraint that T is a class. The type declaration is as follows: type TObjectList<T: class> = class(TList<T>) ... end; You might think that constraints are inherited, but that is not the case. And so you need to include the constraint in your class. Specify the constraint like so: type TSearchableObjectList<T: class> = class(TObjectList<T>) ... end;

Categories : Delphi

error: a value of type "void *" cannot be assigned to an entity of type "float *"
What is happening here is that most likely you are inadvertently compiling your code as C++ code. In C++ (as opposed to C) void * is not implicitly convertible to other pointer types. It you intend to write your code in C, make sure you compile it as C. It you intend to write your code in C++, you will have to use explicit type conversion operators to convert void * pointers to other pointer types. The conversion to long * pointer type probably happens in other translation unit (i.e. other file), which is compiled as C. That is probably why it succeeds. Note that compilers can use C and C++ mode independently for each translation unit. Many compilers will choose between C and C++ based on file extension, compiling .c files as C and .cpp files as C++.

Categories : C

c++ std::map asignation error : cannot convert ' type **' to 'type *' in assignment
void findMessageId(R * aPointerType,const int & aPKValue, int & aResult) { if (aPKValue < 0) { aResult=-1; return; } //buscar valor dentro de la lista mMessageListIterador=mListMessage->find(aPKValue); if (mMessageListIterador!=mListMessage->end()) { aResult=0; aPointerType=&mMessageListIterador->second; } else aResult=-1; return; } In this method i changed this line: aPointerType=&mMessageListIterador->second; for this: aPointerType=mMessageListIterador->second;

Categories : C++

Mongo/DataNucleus/JPA with embedded type query gives: Cannot find type of (part of) ... since symbol has no type; implicit variable?
FINE: Compilation of filter to be evaluated completely in-datastore was impossible : Invoke expression is not supported by this mapper so it is not currently implemented to convert JPQL "collField.contains(val)" (the equivalent of what you typed in for your query) into a MongoDB query, hence cant evaluate it in the datastore. Since you know what it needs converting into, you can easily enough get the code for the DataNucleus MongoDB plugin and find class QueryToMongoDBMapper and contribute support for that particular query.

Categories : Mongodb

how does Cpython implement its type Objects, i.e. type's type is always type?
The code that defines PyType_Type.ob_type = &PyType_Type involves a couple of indirections. It all starts in the function _Py_ReadyTypes() when it calls PyType_Ready(&PyType_Type). Before the function is called, the members tp_base and ob_type are both NULL. The function first sets type->tp_base to &PyBaseObject_Type (which is object in Python space) and then sets type->ob_type = PyBaseObject_Type.ob_type. The code uses Py_TYPE() which is just a macro for ob->ob_type. Since the type of object is type the code sets the type of type to type. Now you have: >>> type.__bases__ (<class 'object'>,) >>> type(object) <class 'type'> >>> type(type(object)) <class 'type'> The definition makes type an instance of object plus itself a

Categories : Python

Windows Phone navigate to new instance of same page
Pass a parameter in the page Uri, for example: NavigationService.Navigate(new Uri(String.Format("/Page1.xaml?id={0}", Guid.NewGuid().ToString()), UriKind.Relative)); Then, if you don't want to keep the previous instances in the navigation stack, you can remove the previous instance calling RemoveBackEntry method of NavigationService: NavigationService.RemoveBackEntry();

Categories : C#

Type 'MyClass' cannot inherit from a type that is not marked with DataContractAttribute or SerializableAttribute. Consider marking the base type
One approach would be to override it: public new byte[] SomeByteArray { get; set; } and then you could ignore it with the IgnoreDataMember attribute.

Categories : C#

Entity Framework 5 table-per-type update, change sub type but keep same base type
I don't have a good answer, but I can think of four "solutions" that are really workarounds: Don't use DBMS-computed values for your primary keys (if you already use natural keys, it's fine). Use DBMS-computed surrogate keys. Follow something like the state pattern. Do some evil voodoo with the object state manager. Update: There seems to be a popular consensus that trying isn't even worth it; most people thus simply use stored procedures instead to work around the problem. Changing Inherited Types in Entity Framework Entity Framework: Inheritance, change object type Changing the type of an (Entity Framework) entity that is part of an inheritance hierarchy Changing the type of an entity that is part of an inheritance hierarchy Using natural keys First, remember that the objects tr

Categories : Entity Framework

Observable collection removing item only once, when tried again doesnt work - Windows phone 8 - C#
In the case you described on your comment I think you set the DataContext to your Items. When you create a new Items-List the DataContext will be lost. So you have to reset the DataContext to the new loaded Items-List

Categories : C#



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