mardi 1 avril 2014
How to get the variable with its name in C#
Vote count:
0
Want to use a variable based on its name. It is hard to describe. Here is the example
var sections = new [] {"Personnel", "General", "Medical"};
foreach (var s in sections)
{
// want to retrieve the variable "TableCellPersonnel"
(TableCell)Type.GetType(string.Format("TableCell{0}", s)).Text = "Test";
}
so that we don't have to :
TableCellPersonnel.Text="Test"
TableCellGeneral.Text="Test"
TableCellMedical.Text="Test"
So, is it possible for this kind of "reflection"?
How can i bypass restrictions to accessing Youtube?
Vote count:
-1
I am living Turkey. I know it's shame but Turkish government blocked Youtube.
I have web-site which has server in Amsterdam. I have a playlist that pulls content from Youtube. So that playlist isn't working anymore.
How can i solve this problem?
Thanks and sorry for my bad english.
How to use AND or OR in a filter?
Vote count:
0
I'm looking for how to use Filter using clauses AND or OR to make a login in my application.
//Beans
@Entity
public class Person {
@Id
@GeneratedValue
private Integer id;
@NotNull
@Size(min=5, max=50)
private String name;
private Email email;
@Size(min=8,max=8)
private String password;
@ManyToOne
private PersonType personType;
}
@Entity
public class PersonType {
@Id
@GeneratedValue
private Integer id;
@NotNull
@Size(min=5, max=50)
private String personType;
}
How to I can do a Filter that check Email and Password of Person and return a List ?
How does the mac related functions work in linux kernel, in skbuff.h?
Vote count:
0
I read the source code, but it did confuse me. For example the function sib_mac_header function, which is the third function in the code below, the sib -> head is the pointer to head of allocated buffer, and sib -> mac_header is the pointer to mac_header address in that buffer. Why the result of two address added together is the pointer to MAC ether structure??
Source code in skbuff.h is listed below:
1609 static inline void skb_reset_network_header(struct sk_buff *skb)
1610 {
1611 skb->network_header = skb->data - skb->head;
1612 }
1613
1614 static inline void skb_set_network_header(struct sk_buff *skb, const int offset)
1615 {
1616 skb_reset_network_header(skb);
1617 skb->network_header += offset;
1618 }
1619
1620 static inline unsigned char *skb_mac_header(const struct sk_buff *skb)
1621 {
1622 return skb->head + skb->mac_header;
1623 }
Sails 0.9.4, socket.io, newbie
Vote count:
0
Just getting started with Sails & Socket.io. I'm following the docs and setup a simple test project here:
According to the Sails docs, http://ift.tt/1s43pvy, socket subscriptions are setup on the first socket call:
socket.get(), socket.post(), etc. are methods available in the client-side SDK included in new Sails projects. In this example, we'll use them to talk to the backend via Socket.io. Please be aware that you can use these methods whether or not you're using CRUD blueprints.
The test project defines a quick model/controller, with CRUD methods. It connects to the socket using socket.get, and receives previously posted model instances correctly.
Posting a new instance using socket.post makes it to the Sails server and creates the new instance. However, the new instance is never sent to the connection created with socket.get.
Also, posting using a GET request from the browser hangs and never returns.
Am I reading the docs incorrectly or making some other newb mistake?
Thanks,
-- Tim
Where to define error code constants in C++
Vote count:
0
I have exported a method from a C++ DLL and then call it from a VB.net forms application. The C++ method currently has no return value (void) but I want to improve it and return an int that represents a series of error codes. (I plan to return zero if all went well.)
Where and how is the best place to define these error codes?
Should I do the following at the top of my CPP file:
#define ERR_NEGATIVE_CELL_SIZE 1
#define ERR_INVALID_FILE_PATH 2
etc
The VB.net application will also define these same codes and then show UI messages to the user based on the code.
Obviously I would prefer to throw an exception in the DLL and catch it (along with the relevant exception message) in VB.net, but this doesn't seem to be possible using the extern "C" __declspec(dllexport) method.
Happy to hear about alternative design patterns. I also plan to expose the DLL methods via a C++ console executable, so storing the error messages once in the DLL and having them available to both the console and UI applications is ideal.
1 Answer
Vote count:
0
Please avoid the preprocessor wherever possible.
For your scenario, defining an enum would be reasonable. Define it next to the function prototype.