Search Results

Search found 40774 results on 1631 pages for 'type equivalence'.

Page 8/1631 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • Override mime type with VS Web Dev Server

    - by Douglas
    I would like to serve xbaps from the VS web dev server (cassini) to Firefox, but when served from the dev server, Firefox offers to download this file. As far as I can tell, this is because the dev server is serving the xbap file with a mime type of "application/octet-stream" instead of "application/x-ms-xbap", which works when served from IIS. Does anyone know how to change the mime type which the dev server uses for *.xbap files?

    Read the article

  • Problem with type coercion and string concatenation in JavaScript in Greasemonkey script on Firefox

    - by Yi Jiang
    I'm creating a GreaseMonkey script to improve the user interface of the 10k tools Stack Overflow uses. I have encountered an unreproducible and frankly bizarre problem that has confounded me and the others in the JavaScript room on SO Chat. We have yet to find the cause after several lengthy debugging sessions. The problematic script can be found here. Source - Install The problem occurs at line 85, the line after the 'vodoo' comment: return (t + ' (' + +(+f.offensive + +f.spam) + ')'); It might look a little weird, but the + in front of the two variables and the inner bracket is for type coercion, the inner middle + is for addition, and the other ones are for concatenation. Nothing special, but observant reader might note that type coercion on the inner bracket is unnecessary, since both are already type coerced to numbers, and type coercing result is useless when they get concatenated into a string anyway. Not so! Removing the + breaks the script, causing f.offensive and f.spam to be concatenated instead of added together. Adding further console.log only makes things more confusing: console.log(f.offensive + f.spam); // 50 console.log('' + (+f.offensive + +f.spam)); // 5, but returning this yields 50 somehow console.log('' + (+f.offensive + +f.spam) + ''); // 50 Source: http://chat.stackoverflow.com/transcript/message/203261#203261 The problem is that this is unreproducible - running scripts like console.log('a' + (+'3' + +'1') + 'b'); in the Firebug console yields the correct result, as does (function(){ return 'a' + (+'3' + +'1') + 'b'; })(); Even pulling out large chunks of the code and running them in the console does not reproduce this bug: $('.post-menu a[id^=flag-post-]').each(function(){ var f = {offensive: '4', spam: '1'}; if(f){ $(this).text(function(i, t){ // Vodoo - please do not remove the '+' in front of the inner bracket return (t + ' (' + +(+f.offensive + +f.spam) + ')'); }); } }); Tim Stone in the chatroom has reproduction instruction for those who are below 10k. This bug only appears in Firefox - Chrome does not appear to exhibit this problem, leading me to believe that this may be a problem with either Firefox's JavaScript engine, or the Greasemonkey add-on. Am I right? I can be found in the JavaScript room if you want more detail and/or want to discuss this.

    Read the article

  • How to map Duration type with JPA

    - by HDave
    I have a property field in a class that is of type javax.xml.datatype.Duration. It basically represents a time span (e.g. 4 hours and 34 minutes). JPA is telling me it is an invalid type, which doesn't shock me. Whats a good solution this? I could implement my own Duration class, but I don't know how to get JPA to "accept" it as a datatype.

    Read the article

  • Scala passing type parameters to object

    - by Shahzad Mian
    In Scala v 2.7.7 I have a file with class Something[T] extends Other { } object Something extends OtherConstructor[Something] { } This throws the error: class Something takes type parameters object Something extends OtherConstructor[Something] { However, I can't do this object Something[T] extends OtherConstructor[Something[T]] { } It throws an error: error: ';' expected but '[' found. Is it possible to send type parameters to object? Or should I change and simply use Otherconstructor

    Read the article

  • Problem in type casting in NSDate to NSString?

    - by Prash.......
    Hi, I developing an application, in which i found a ridiculous problem in type casting, I am not able to type cast NSDate to NSString. NSDate *selected =[datePicker date]; NSString *stringTypeCast = [[NSString alloc] initWithData:selected encoding:NSUTF8StringEncoding]; From ,above snippet datePicker is an object of UIDatePickerController.

    Read the article

  • Default value of a type

    - by viky
    For any given type i want to know its default value. In C#, there is a keyword called default for doing this like object obj = default(Decimal); but I have an instance of Type (called myType) and if I say this, object obj = default(myType); it doesn't work Is there any good way of doing this? I know that a huge switch block will work but thats not a good choice.

    Read the article

  • Drupal: assign block to a specific content type

    - by bert
    I made a customized template called node-mynode.tpl.php Whenever a node of type mynode is requested, then node-mynode.tpl.php is automatically used. However, now user wants to see a specific menu block in this case. Question: How can I assign a block to a specific content type? Hint: I have started to look at URL aliases with Pathauto. I suspect one solution may lie in this direction.

    Read the article

  • Type-inferring a constant in C#

    - by Andreas Grech
    In C#, the following type-inference works: var s = "abcd"; But why can't the type be inferred when the variable is a constant? The following throws a compile-time exception: const var s = "abcd"; // <= Compile time error: // Implicitly-typed local variables cannot be constant

    Read the article

  • Type hinting for functions in Clojure

    - by mikera
    I'm trying to resolve a reflection warning in Clojure that seems to result from the lack of type inference on function return values that are normal Java objects. Trivial example code that demonstrates the issue: (set! *warn-on-reflection* true) (defn foo [#^Integer x] (+ 3 x)) (.equals (foo 2) (foo 2)) => Reflection warning, NO_SOURCE_PATH:10 - call to equals can't be resolved. true What is the best way to solve this? Can this be done with type hints?

    Read the article

  • Cannot convert lambda expression to type 'string' because it is not a delegate type

    - by RememberME
    I have the following code written by another developer on 2 pages of my site. This used to work just fine, but now is giving the error "Cannot convert lambda expression to type 'string' because it is not a delegate type" on the Delete line with Ajax.ThemeRollerActionLink. I don't go into this section of the site often, and we recently upgraded from MVC 1.0 to 2.0. I'm guessing that's probably when it stopped working. I've looked up this error and the recommended fix seems to be add using System.Linq However, the page already has <%@ Import Namespace="System.Linq" %> <% Html.Grid(Model).Columns(col => { col.For(c => "<a href='" + Url.Action("Edit", new { userName = c }) + "' class=\"fg-button fg-button-icon-solo ui-state-default ui-corner-all\"><span class=\"ui-icon ui-icon-pencil\"></span></a>").Named("Edit").DoNotEncode(); col.For(c => Ajax.ThemeRollerActionLink("fg-button fg-button-icon-solo ui-state-default ui-corner-all", "ui-icon ui-icon-close", "Delete", new { userName = c }, new AjaxOptions { Confirm = "Delete User?", HttpMethod = "Delete", InsertionMode = InsertionMode.Replace, UpdateTargetId = "gridcontainer", OnSuccess = "successDeleteAssignment", OnFailure = "failureDeleteAssignment" })).Named("Delete").DoNotEncode(); col.For(c => c).Named("User"); }).Attributes(id => "userlist").Render(); %>

    Read the article

  • How to specialize template for type derived from particular type

    - by relaxxx
    I have class World which manages creation of object... After creation it calls afterCreation method and I the created object is user-defined type derived from Entity (eg. MyEntity), I want to call addEntity. I the object was something else, I want to do nothing. addEntity must be called with appropriate T, because it generates unique IDs for every derived class etc. Here is my solution: template <int v> struct ToType { enum { value = v }; }; template <typename T> void World::afterCreation(T * t) { afterCreation(t, ToType<std::is_base_of<Entity, T>::value>()); } template <typename T> void World::afterCreation(T * t, ToType<true>) { addEntity(t); //here I cant pass Entity *, I need the real type, eg. MyEntity } template <typename T> void World::afterCreation(T * t, ToType<false>) { } My question is - Can in be done better way? How can I simulate following code without ToType or similar? template <typename T> void afterCreation(){/*generic impl*/} template <typename T where T is derived from Entity> void afterCreation(){/*some specific stuff*/} "specialize" in the title is only to describe my intention, no need to solve problem with template specialization

    Read the article

  • Asp.Net MVC2 RenderAction changes page mime type?

    - by Gabe Moothart
    It appears that calling Html.RenderAction in Asp.Net MVC2 apps can alter the mime type of the page if the child action's type is different than the parent action's. The code below (testing in MVC2 RTM), which seems sensible to me, will return a result of type application/json when calling Home/Index. Instead of dispylaying the page, the browser will barf and ask you if you want to download it. My question: Am I missing something? Is this a bug? If so, what's the best workaround? controller: public class HomeController : Controller { public ActionResult Index() { ViewData[ "Message" ] = "Welcome to ASP.NET MVC!"; return View(); } [ChildActionOnly] public JsonResult States() { string[] states = new[] { "AK", "AL", "AR", "AZ", }; return Json(states, JsonRequestBehavior.AllowGet); } } view: <h2><%= Html.Encode(ViewData["Message"]) %></h2> <p> To learn more about ASP.NET MVC visit <a href="http://asp.net/mvc" title="ASP.NET MVC Website">http://asp.net/mvc</a>. </p> <script> var states = <% Html.RenderAction("States"); %>; </script>

    Read the article

  • Programmatically copying custom content type and columns from one web to another

    - by BeraCim
    Hi all: I'm experiencing a very stubborn problem when copying custom content type and its columns from one web to another within the same site. Basically, this is the code that I have: foreach (SPField field in existingWeb.Fields) { if (!destinationWeb.Fields.ContainsField(field.Title)) { destinationWeb.Fields.AddFieldAsXml(field.SchemaXml); destinationWeb.Update(); } } foreach (SPContentType existingWebCt in destinationWeb.ContentType) { SPContentType newContentType = new SPContentType(existingWebCt.Parent, destinationWeb.ContentTypes, existingWebCt.Name); foreach (SPFieldLink fieldLink in existingWebCt.FieldLinks) { SPField sourceField = existingWebCt.Fields[fieldLink.Id]; if (destinationWeb.Fields.ContainsField(sourceField.Title)) { SPFieldLink destinationWebFieldLink = new SPFieldLink(destinationWeb.Fields[sourceField.Title]); newContentType.FieldLinks.Add(destinationWebFieldLink); } } } existingWeb and destinationWeb are 2 webs within the same site. The code runs fine. But the problem is that in the SITE Content Type screen (under site settings), when I click the custom column link in the custom content type, I got an error saying: Invalid field name {UID}. The UID is the same UID as the custom column in the existing site. I checked with my web settings after completion. I can see the custom list (which I created with an item for testing purpose), but the custom column is gone from the view (though the actual data is still there... just have to check the box to get it to display). But I think that is less important... more of fyi. I've also gotten a variety of different exceptions should I copy things wrongly. Google has failed to help me out on this one. Does anyone know what I'm missing in order to get that link to work again? Thanks.

    Read the article

  • Info on type family instances

    - by yairchu
    Intro: While checking out snoyman's "persistent" library I found myself wanting ghci's (or another tool) assistance in figuring out stuff. ghci's :info doesn't seem to work as nicely with type-families and data-families as it does with "plain" types: > :info Maybe data Maybe a = Nothing | Just a -- Defined in Data.Maybe ... > :info Persist.Key Potato -- "Key Potato" defined in example below data family Persist.Key val -- Defined in Database.Persist ... (no info on the structure/identity of the actual instance) One can always look for the instance in the source code, but sometimes it could be hard to find it and it may be hidden in template-haskell generated code etc. Code example: {-# LANGUAGE FlexibleInstances, GeneralizedNewtypeDeriving, MultiParamTypeClasses, TypeFamilies, QuasiQuotes #-} import qualified Database.Persist as Persist import Database.Persist.Sqlite as PSqlite PSqlite.persistSqlite [$persist| Potato name String isTasty Bool luckyNumber Int UniqueId name |] What's going on in the code example above is that Template-Haskell is generating code for us here. All the extensions above except for QuasiQuotes are required because the generated code uses them. I found out what Persist.Key Potato is by doing: -- test.hs: test = PSqlite.persistSqlite [$persist| ... -- ghci: > :l test.hs > import Language.Haskell.TH > import Data.List > runQ test >>= putStrLn . unlines . filter (isInfixOf "Key Potato") . lines . pprint where newtype Database.Persist.Key Potato = PotatoId Int64 type PotatoId = Database.Persist.Key Potato Question: Is there an easier way to get information on instances of type families and data families, using ghci or any other tool?

    Read the article

  • Finding a MIME type for a file on windows

    - by rmeador
    Is there a way to get a file's MIME type using some system call on Windows? I'm writing an IIS extension in C++, so it must be callable from C++, and I do have access to IIS if there is some functionality exposed. Obviously, IIS itself must be able to do this, but my googling has been unable to find out how. I did find this .net related question here on SO, but that doesn't give me much hope (as neither a good solution nor a C++ solution is mentioned there). I need it so I can serve up dynamic files using the appropriate content type from my app. My plan is to first consult a list of MIME types within my app, then fall back to the system's MIME type listing (however that works; obviously it exists since it's how you associate files with programs). I only have a file extension to work with in some cases, but in other cases I may have an actual on-disk file to examine. Since these will not be user-uploaded files, I believe I can trust the extension and I'd prefer an extension-only lookup solution since it seems simpler and faster. Thanks!

    Read the article

  • Java: Generics, Class.isaAssignableFrom, and type casting

    - by bguiz
    This method that uses method-level generics, that parses the values from a custom POJO, JXlistOfKeyValuePairs (which is exactly that). The only thing is that both the keys and values in JXlistOfKeyValuePairs are Strings. This method wants to taken in, in addition to the JXlistOfKeyValuePairs instance, a Class<T> that defines which data type to convert the values to (assume that only Boolean, Integer and Float are possible). It then outputs a HashMap with the specified type for the values in its entries. This is the code that I have got, and it is obviously broken. private <T extends Object> Map<String, T> fromListOfKeyValuePairs(JXlistOfKeyValuePairs jxval, Class<T> clasz) { Map<String, T> val = new HashMap<String, T>(); List<Entry> jxents = jxval.getEntry(); T value; String str; for (Entry jxent : jxents) { str = jxent.getValue(); value = null; if (clasz.isAssignableFrom(Boolean.class)) { value = (T)(Boolean.parseBoolean(str)); } else if (clasz.isAssignableFrom(Integer.class)) { value = (T)(Integer.parseInt(str)); } else if (clasz.isAssignableFrom(Float.class)) { value = (T)(Float.parseFloat(str)); } else { logger.warn("Unsupporteded value type encountered in key-value pairs, continuing anyway: " + clasz.getName()); } val.put(jxent.getKey(), value); } return val; } This is the bit that I want to solve: if (clasz.isAssignableFrom(Boolean.class)) { value = (T)(Boolean.parseBoolean(str)); } else if (clasz.isAssignableFrom(Integer.class)) { value = (T)(Integer.parseInt(str)); } I get: Inconvertible types required: T found: Boolean Also, if possible, I would like to be able to do this with more elegant code, avoiding Class#isAssignableFrom. Any suggestions? Sample method invocation: Map<String, Boolean> foo = fromListOfKeyValuePairs(bar, Boolean.class);

    Read the article

  • Type result with Ternary operator in C#

    - by Vaccano
    I am trying to use the ternary operator, but I am getting hung up on the type it thinks the result should be. Below is an example that I have contrived to show the issue I am having: class Program { public static void OutputDateTime(DateTime? datetime) { Console.WriteLine(datetime); } public static bool IsDateTimeHappy(DateTime datetime) { if (DateTime.Compare(datetime, DateTime.Parse("1/1")) == 0) return true; return false; } static void Main(string[] args) { DateTime myDateTime = DateTime.Now; OutputDateTime(IsDateTimeHappy(myDateTime) ? null : myDateTime); Console.ReadLine(); ^ } | } | // This line has the compile issue ---------------+ On the line indicated above, I get the following compile error: Type of conditional expression cannot be determined because there is no implicit conversion between '< null ' and 'System.DateTime' I am confused because the parameter is a nullable type (DateTime?). Why does it need to convert at all? If it is null then use that, if it is a date time then use that. I was under the impression that: condition ? first_expression : second_expression; was the same as: if (condition) first_expression; else second_expression; Clearly this is not the case. What is the reasoning behind this? (NOTE: I know that if I make "myDateTime" a nullable DateTime then it will work. But why does it need it? As I stated earlier this is a contrived example. In my real example "myDateTime" is a data mapped value that cannot be made nullable.)

    Read the article

  • How to use a class's type as the type argument for an inherited collection property in C#

    - by Edelweiss Peimann
    I am trying to create a representation of various types of card that inherit from a generic card class and which all contain references to their owning decks. I tried re-declaring them, as suggested here, but it still won't convert to the specific card type. The code I currently have is as such: public class Deck<T> : List<T> where T : Card { void Shuffle() { throw new NotImplementedException("Shuffle not yet implemented."); } } public class Card { public Deck<Card> OwningDeck { get; set; } } public class FooCard : Card { public Deck<FooCard> OwningDeck { get { return (Deck<FooCard>)base.OwningDeck; } set { OwningDeck = value; } } } The compile-time error I am getting: Error 2 Cannot convert type 'Game.Cards.Deck' to 'Game.Cards.Deck' And a warning suggesting I use a new operator to specify that the hiding is intentional. Would doing so be a violation of convention? Is there a better way? My question to stackoverflow is this: Can what I am trying to do be done elegantly in the .NET type system? If so, can some examples be provided?

    Read the article

  • Using a type parameter and a pointer to the same type parameter in a function template

    - by Darel
    Hello, I've written a template function to determine the median of any vector or array of any type that can be sorted with sort. The function and a small test program are below: #include <algorithm> #include <vector> #include <iostream> using namespace::std; template <class T, class X> void median(T vec, size_t size, X& ret) { sort(vec, vec + size); size_t mid = size/2; ret = size % 2 == 0 ? (vec[mid] + vec[mid-1]) / 2 : vec[mid]; } int main() { vector<double> v; v.push_back(2); v.push_back(8); v.push_back(7); v.push_back(4); v.push_back(9); double a[5] = {2, 8, 7, 4, 9}; double r; median(v.begin(), v.size(), r); cout << r << endl; median(a, 5, r); cout << r << endl; return 0; } As you can see, the median function takes a pointer as an argument, T vec. Also in the argument list is a reference variable X ret, which is modified by the function to store the computed median value. However I don't find this a very elegant solution. T vec will always be a pointer to the same type as X ret. My initial attempts to write median had a header like this: template<class T> T median(T *vec, size_t size) { sort(vec, vec + size); size_t mid = size/2; return size % 2 == 0 ? (vec[mid] + vec[mid-1]) / 2 : vec[mid]; } I also tried: template<class T, class X> X median(T vec, size_t size) { sort(vec, vec + size); size_t mid = size/2; return size % 2 == 0 ? (vec[mid] + vec[mid-1]) / 2 : vec[mid]; } I couldn't get either of these to work. My question is, can anyone show me a working implementation of either of my alternatives? Thanks for looking!

    Read the article

  • Converting non-generic List type to Generic List type in Java 1.5

    - by Shaun F
    I have a List that is guaranteed to contain just one type object. This is created by some underlying code in a library that I cannot update. I want to create a List<ObjectType> based on the incoming List object so that my calling code is talking to List<ObjectType>. What's the best way to convert the List (or any other object collection) to a List<ObjectType>.

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >