types

Calling typeface.js on HTML fetched by jQuery?

I have a page where I'm fetching a Wordpress main index to handle my 'news feed', imported via jQuery.ajax. I'm also using typeface.js on the same page to have better typeface control. I want to call typeface.js on the elements in the Ajax'd HTML. The problem is that I'm not sure how to do that, since the structure of it is unfamiliar...

Can you use generics methods in C# if the type is unknown until runtime?

Easiest way to explain what I mean is with a code sample. This doesn't compile, but is there any way to achieve this effect: foreach(Type someType in listOfTypes) { SomeMethod<someType>(); } Would be really convenient if that would work, but it doesn't. Is there another way to achieve the same thing as above, and why doesn't C# ...

Is there a good way to use Console.ReadKey for choosing between values without doing alot of conversion between types?

Im using Console.ReadKey() to choose from a number of options that varies from time to time. Before this initial code snippet there is a for loop that counts occurances into counter variable of type int. The point is to use Console.ReadKey() to get an int. int choice = ReadKey(); Console.WriteLine(""); if (choice < counter) { mail...

When declaring an enum, should you force the type to byte for under 256 entities?

If you have an enum in your application and you only have a few items, should you for the underlying type to be the smallest possible type? enum smaller : byte { one, two, three }; ...

Inheritance Mapping with Fluent NHibernate

Given the following scenario, I want map the type hierarchy to the database schema using Fluent NHibernate. I am using NHibernate 2.0 Type Hierarchy public abstract class Item { public virtual int ItemId { get; set; } public virtual string ItemType { get; set; } public virtual string FieldA { get; set; } } public abstra...

Determine Calling Object Type in C#

Regardless of whether or not this is a good idea, is it possible to implement an interface where the executing function is aware of the calling object's type? class A { private C; public int doC(int input) { return C.DoSomething(input); } } class B { private C; public int doC(int input) { return C.DoS...

long on a 64 bit machine

Is a long 128 bits on a 64 bit machine? Edit: Duplicate question; see http://stackoverflow.com/questions/651956/sizeofint-on-x64. ...

Single method for multiple types?

In cases where you have a function that works for many different custom types with the same implementation, is it ok to use a design pattern like this?: type1 implicitly casts to type0 type2 implicitly casts to type0 type3 implicitly casts to type0 Operate ( type0 ) and call: type1 a type2 b type3 c Operate ( a ) Operate ( b ) Oper...

How do you create subtypes in Moose?

Hi, I'm just starting to use Moose. I'm creating a simple notification object and would like to check inputs are of an 'Email' type. (Ignore for now the simple regex match). From the documentation I believe it should look like the following code: # --- contents of message.pl --- # package Message; use Moose; subtype 'Email' => as 'S...

ASP.NET MVC: How do I keep a field byte[]

I've got a field which its type is byte[]. This field will hold my entity's RecordVersion property (timestamp in the database). How do I keep this field so that when I save my entity it is available? I've tried two different things and haven't succeeded so far: This renders "System.Byte[]": <%= Html.Hidden("RecordVersion", Model.Record...

Is it possible to create method call dispatcher in C++ ?

Consider a following code: struct X { void MethodX() { ... } }; struct Y { void MethodY() { ... } }; void test () { X x; Y y; Dispatcher d; d.Register("x", x, &X::MethodX); d.Register("y", y, &Y::MethodY); d.Call("x"); d.Call("y"); } The question is how to implement Dispatcher. I don't mind X and Y may ...

Passing C# data type parameters to dll written in C++?

Still working on a problem that started from here Calling C++ dll function from C#: Of structs, strings and wchar_t arrays., but with a different approach. Following the example Calling Managed Code from Unmanaged Code and vice-versa I wrote a managed wrapper in C++ to access the unmanages class in the unmanaged C++ dll. It looks like ...

Generic classes in Java (type-safely) depending on each other

Hello! I want to create an abstract collection class (called Space) and an abstract element class (called Atom). Instances of both have to know each other (exactly typed). That's the problem. abstract class Space<A extends Atom>{ // ... } abstract class Atom<S extends Space>{ // ... } Not good: "A extends Atom" means any Atom, ...

How to prevent every malicious file upload on my server? (check file type)?

Hi guys, my proble is to avoid that users upload some malicious file on my web-server. Im working on linux environment (debian). Actually the uploads are handled via php by this code: function checkFile($nomeFile, $myExt = false){ if($myExt != false){ $goodExt = "_$myExt"."_"; }else{ $goodExt = "_.jpg_.bmp_.zip_.pdf_.gif_.doc_.xls_.csv...

What is a type inferencer?

Does it only exist in statically typed languages? And is it only there when the language is not strongly typed (i.e. does Java have one)? Also, where does it belong - in the compilation phase assuming it's a compiled language? In general, are the rules when the type is ambiguous dictated by the language specification or left up to the i...

Get Type Parameter T from an instantiated System.Type?

Good afternoon, I am somewhat lost and maybe can give me a quick push in the right direction: I have the System.Type of a certain object but need to pass that over as a Type Parameter T to another method... is that somehow possible? Or am I lost in the bigger picture there? Cheers and thanks, -J ...

Smart typedefs

I've always used typedef in embedded programming to avoid common mistakes: int8_t - 8 bit signed integer int16_t - 16 bit signed integer int32_t - 32 bit signed integer uint8_t - 8 bit unsigned integer uint16_t - 16 bit unsigned integer uint32_t - 32 bit unsigned integer The recent embedded muse (issue 177, not on the website yet) intr...

Delphi Froze when registering type library

Hi: I have created a few AUTOObjects using Delphi and its type library. It compiles without error, but when I tried to register it, Delphi froze, and doesn't return to normal. I have tried to register it in both Delphi 7 and 2006, but both get into the same problem. I tried to register a simple library in Delphi's demo, I am ruling out ...

Is there a reasonable approach to "default" type parameters in C# Generics?

In C++ templates, one can specify that a certain type parameter is a default. I.e. unless explicitly specified, it will use type T. Can this be done or approximated in C#? I'm looking for something like: public class MyTemplate<T1, T2=string> {} So that an instance of the type that doesn't explicitly specify T2: MyTemplate<int> t ...

C# Object Type Comparison

How can I compare the types of two objects declared as type. I want to know if two objects are of the same type or from the same base class. Any help is appreciated. e.g. private bool AreSame(Type a, Type b) { } ...