Search Results

Search found 1017 results on 41 pages for 'kevin pang'.

Page 4/41 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Using ReadOnlyCollection preventing me from setting up a bi-directional many-to-many relationship

    - by Kevin Pang
    I'm using NHibernate to persist a many-to-many relation between Users and Networks. I've set up both the User and Network class as follows, exposing each's collections as ReadOnlyCollections to prevent direct access to the underlying lists. I'm trying to make sure that the only way a User can be added to a Network is by using its "JoinNetwork" function. However, I can't seem to figure out how to add the User to the Network's list of users since its collection is readonly. public class User { private ISet<Network> _Networks = new HashedSet<Network>(); public ReadOnlyCollection<Network> Networks { get { return new List<Network>(_Networks).AsReadOnly(); } } public void JoinNetwork(Network network) { _Networks.Add(network); // How do I add the current user to the Network's list of users? } } public class Network { private ISet<User> _Users = new HashedSet<User>(); public ReadOnlyCollection<User> Users { get { return new List<User>(_Users).AsReadOnly(); } } }

    Read the article

  • Fluent NHibernate question

    - by Kevin Pang
    Let's say you have two tables, "Users" and "UserRoles". Here's how the two tables are structured (table - columns): Users - UserID (int) UserRoles - UserID (int), Role (string) What I want is for my "User" class in my domain to have an IList of roles. How do I construct my Fluent NHibernate mapping to achieve this?

    Read the article

  • Why does Visual Studio sometimes add a number when creating page events in codebehinds?

    - by Kevin Pang
    When writing up a codebehind in Visual Studio for ASP.NET web forms applications, I often use the dropdowns at the top of the window to autogenerate page event handlers (e.g. Page_Load, Page_PreRender). I've noticed that sometimes Visual Studio likes to add numbers to these function names like "Page_Load1" or "Page_PreRender2". Programatically speaking, this has no effect on the code. But stylistically, I find it a bit ugly. Is there any way to get rid of this behavior?

    Read the article

  • Altering lazy-loaded object's private variables

    - by Kevin Pang
    I'm running into an issue with private setters when using NHibernate and lazy-loading. Let's say I have a class that looks like this: public class User { public int Foo {get; private set;} public IList<User> Friends {get; set;} public void SetFirstFriendsFoo() { // This line works in a unit test but does nothing during a live run with // a lazy-loaded Friends list Users(0).Foo = 1; } } The SetFirstFriendsFoo call works perfectly inside a unit test (as it should since objects of the same type can access each others private properties). However, when running live with a lazy-loaded Friends list, the SetFirstFriendsFoo call silently fails. I'm guessing the reason for this is because at run-time, the Users(0).Foo object is no longer of type User, but of a proxy class that inherits from User since the Friends list was lazy-loaded. My question is this: shouldn't this generate a run-time exception? You get compile-time exceptions if you try to access another class's private properties, but when you run into a situation like this is looks like the app just ignores you and continues along its way.

    Read the article

  • How do you create a dropdownlist from an enum in ASP.NET MVC?

    - by Kevin Pang
    I'm trying to use the Html.DropDownList extension method but can't figure out how to use it with an enumeration. Let's say I have an enumeration like this: public enum ItemTypes { Movie = 1, Game = 2, Book = 3 } How do I go about creating a dropdown with these values using the Html.DropDownList extension method? Or is my best bet to simply create a for loop and create the html elements manually?

    Read the article

  • How do you implement paging in ASP.NET MVC?

    - by Kevin Pang
    Currently, I'm using a strategy found on many blog posts. Basically, the URL contains the page number (e.g. /Users/List/5 will give you the users on page 5 of your paged list of users). However, I'm not running into a situation where one page must list two separate paged lists. How do I go about doing this using ASP.NET MVC? Do I simply provide two url parameters (e.g. /Users/List?page1=1&page2=2)? Is there a better way by using partial views?

    Read the article

  • NHibernate session management in ASP.NET MVC

    - by Kevin Pang
    I am currently playing around with the HybridSessionBuilder class found on Jeffrey Palermo's blog post: http://jeffreypalermo.com/blog/use-this-nhibernate-wrapper-to-keep-your-repository-classes-simple/ Using this class, my repository looks like this: public class UserRepository : IUserRepository { private readonly ISessionBuilder _sessionBuilder; public UserRepository(ISessionBuilder sessionBuilder) { _sessionBuilder = sessionBuilder; } public User GetByID(string userID) { using (ISession session = _sessionBuilder.GetSession()) { return session.Get<User>(userID); } } } Is this the best way to go about managing the NHibernate session / factory? I've heard things about Unit of Work and creating a session per web request and flushing it at the end. From what I can tell, my current implementation isn't doing any of this. It is basically relying on the Repository to grab the session from the session factory and use it to run the queries. Are there any pitfalls to doing database access this way?

    Read the article

  • Checking whether an object exists in StructureMap container

    - by Kevin Pang
    I'm using StructureMap to handle the creation of NHibernate's ISessionFactory and ISession. I've scoped ISessionFactory as a singleton so that it's only created once for my web app and I've scoped ISession as a hybrid so that it will only be opened once per web request. I want to make sure that at the end of each web request, I properly dispose of ISession if it was created for that web request. I figured I could put some code in my Application_EndRequest routine to first check if an ISession was created, and if so, call ISession.Dispose. My current workaround is to just open up an ISession on Application_BeginRequest then dispose of it on Application_EndRequest, but that seems somewhat wasteful in that static file requests for images and css files and whatnot will create an ISession without ever using it. I know that the overall performance hit is negligable since ISessions are very lightweight, but it's getting annoying seeing all those ISessions being created inside NHProf.

    Read the article

  • DataTable Delete Row and AcceptChanges

    - by Pang
    DataTable DT num type name =================================== 001 A Peter 002 A Sam 003 B John public static void fun1(ref DataTable DT, String TargetType) { for (int i = 0; i < DT.Rows.Count; i++) { string type = DT.Rows[i]["type"]; if (type == TargetType) { /**Do Something**/ DT.Rows[i].Delete(); } } DT.AcceptChanges(); } My function get specific data rows in datatable according to the TargetType and use their info to do something. After the datarow is read (match the target type), it will be deleted. However, the row is deleted immediately after .Delete() execute, so the location of the next row (by i) is incorrect. For example, if TargetType is A. When i=0, the "Peter" row is deleted after .Delete executed. Then when i=1, I suppose it will locate the "Sam" row but it actually located "John" row because "Peter" row is deleted. Is there any problem in my codes?

    Read the article

  • How to verify StructureMap is disposing of objects properly

    - by Kevin Pang
    I'm currently using StructureMap to inject instances of NHibernate ISessions using the following code: ObjectFactory.Initialize(x => { x.ForRequestedType<ISession>() .CacheBy(InstanceScope.PerRequest) .TheDefault.Is.ConstructedBy(y => NHibernateSessionManager.Instance.GetSession()); }); I'm assuming that the CacheBy(InstanceScope.PerRequest) will properly dispose of the ISession it creates, but I'd like to make sure. What's the easiest way to test this?

    Read the article

  • How do you perform address validation?

    - by Kevin Pang
    Is it even possible to perform address (physical, not e-mail) validation? It seems like the sheer number of address formats, even in the US alone, would make this a fairly difficult task. On the other hand, it seems like a task that would be necessary for several business requirements.

    Read the article

  • Does HttpWebRequest automatically take care of certificate validation?

    - by Kevin Pang
    I'm using an HttpWebRequest object to access a web service via an HTTP POST. Part of the requirement is that I: Verify that the URL in the certificate matches the URL I'm posting to Verify that the certificate is valid and trusted Verify that the certificate has not expired Does HttpWebRequest automatically handle that for me? I'd assume that if any of these conditions came up, I'd get the standard "could not establish trust relationship for the SSL/TLS secure channel" exception.

    Read the article

  • What are the list of Patterns and Principals the programmer must/should know?

    - by pang
    I have been doing code for a few years and still feeling that my knowledge still not broad enough to become a professional. I have studied some books related to Design Pattern but I know there are many others. So could anyone list the one which you think it is good to learn to become a better programmer and more professional? Programming Languages I work on : C# , Ruby, Javascript

    Read the article

  • Preventing dictionary attacks on a web application

    - by Kevin Pang
    What's the best way to prevent a dictionary attack? I've thought up several implementations but they all seem to have some flaw in them: Lock out a user after X failed login attempts. Problem: easy to turn into a denial of service attack, locking out many users in a short amount of time. Incrementally increase response time per failed login attempt on a username. Problem: dictionary attacks might use the same password but different usernames. Incrementally increase response time per failed login attempt from an IP address. Problem: easy to get around by spoofing IP address. Incrementally increase response time per failed login attempt within a session. Problem: easy to get around by creating a dictionary attack that fires up a new session on each attempt.

    Read the article

  • How to handle JSON response using SBJSON iPhone?

    - by Jay Mehta
    I am receiving the below response from my web service? Can any one has idea how to handle it using SBJSON? { "match_details" : { "score" : 86-1 "over" : 1.1 "runrate" : 73.71 "team_name" : England "short_name" : ENG "extra_run" : 50 } "players" : { "key_0" : { "is_out" : 2 "runs" : 4 "balls" : 2 "four" : 1 "six" : 0 "batsman_name" : Ajmal Shahzad * "wicket_info" : not out } "key_1" : { "is_out" : 1 "runs" : 12 "balls" : 6 "four" : 2 "six" : 0 "batsman_name" : Andrew Strauss "wicket_info" : c. Kevin b.Kevin } "key_2" : { "is_out" : 2 "runs" : 20 "balls" : 7 "four" : 4 "six" : 0 "batsman_name" : Chris Tremlett * "wicket_info" : not out } } "fow" : { "0" : 40-1 } } I have done something like this:

    Read the article

  • jquery buttonset()

    - by Kevin
    Hi - I'm using the jquery buttonset() on a set of radio buttons (to tart them up). I'd like to be able to set the selected radio button on another user event. I've been looking into this and while I can set the selected radio button, but I cannot also (easily) update the UI to indicate what the selected radio button is. From what I can tell, I need to call this to set the radio button at index n to be checked $('input[name="transactionsRadio"]')[n].checked = true; And then do some convoluted jquery selector calls to remove the ui-state-active from one lable and apply it to the new label. Is this really the most optimal way to do this ? I had expected an equivalent method to the 'activate' method that is available for the jquery Accordian control. Any more elegant solution would be appreciated! Thanks, Kevin.

    Read the article

  • iPhone SDK mySQL

    - by Kevin
    Hello everybody, I'm starting on a new iPhone project, and this application mostly relies on mySQL. I have a mysql database running on my computer, and I need this application to send queries to the server to gain information. One example is creating and logging into an account. I have successfully done this on my windows vb.net application, but I know that objective c will be harder. This is basically getting text from the sql database and displaying it on the iPhone application. If someone could simply help me on that, I'll easily get started. So I hope that you guys help me out here :). Thanks Kevin

    Read the article

  • Is anyone else receiving a QUOTA_EXCEEDED_ERR on their iPad when accessing localStorage?

    - by Kevin
    I have a web application written in JavaScript that runs successfully on the desktop via Safari as well as on the iPhone. We are looking at porting this application to the iPad and we are running into a problem where we are seeing QUOTA_EXCEEDED_ERR when storing a relatively small amount of data within the localStorage on the device. I know what this error means, but I just don't think I'm storing all that much data. Is anyone else doing something similar? And seeing/not seeing this problem? Kevin...

    Read the article

  • URLCache - iPhone SDK

    - by Kevin
    Hello everyone.. I need some help in using the NSURLCache to download a simple file. It would need to be saved in the Documents folder of the app. I have seen the URLCache example that apple presented, but I didn't find it useful since it was an image that was being shown. In addition there was some complex code on the modification date. I actually need something when the application opens it will begin the download process. Can someone guide me through just the download process of any file? Thanks Kevin

    Read the article

  • NSData to NSString by changing the value null is returned. I need you help

    - by kevin
    *cipher.h, cipher.m all code : http://watchitlater.com/blog/2010/02/java-and-iphone-aes-interoperability Cipher.m -(NSData *)encrypt:(NSData *)plainText{ return [self transform:KCCEncrypt data:plainText; } step1. Cipher *cipher = [[Cipher alloc]initWithKey:@"1234567890"]; NSData *input = [@"kevin" dataUsingEncoding:NSUTF8StringEncoding]; NSData *data = [cipher encrypt:input]; data variables NSLog print : <4d1c4d7f 1592718c fd588cec 84053e35 step2. NSString *changeVal = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; data variables NSLog print : null NSData to NSString by changing the value null is returned. By converting NSString NSURLConnection want to transfer. I need you help

    Read the article

  • UIViewControllers - TabBarApplication - iPhone SDK

    - by Kevin
    Hello everyone, I am very new to the iPhone SDK. I need to know if in a tab bar application I need to make UIViewController classes. For example, when I make a new tab bar application there is a default FirstViewController class (.h, .m) already there. Now if I have code on the second tab, would I need to create a SecondViewController class? If not, how would I make a button on the 2nd tab, and make that button do something. I'm not really sure how to do it, because the FirstViewController works with the buttons and code, but if I make a SecondViewController, and I link everything my app crashes. If anyone could help it would be greatly appreciated. Kevin

    Read the article

  • Displaying a DHTML layer over a Silverlight UI...

    - by Kevin Grossnicklaus
    I have a MOSS 2007 publishing site which incorporates some Silverlight components on various pages. Beyond a few areas the rest of the site is SharePoint and ASPX (i.e. standard HTML/javascript). I'm looking at incorporating a dynamic/dropdown menu to the main navigation. Unfortunately on a few of the pages the menu sits close to a Silverlight area and, when a menu is pulled down it falls "behind" the Silverlight block. Is there something simple I'm not doing or is there a limitation that Silverlight always be on top of dynamic content displayed via the rest of the HTML DOM? Any ideas? -Kevin

    Read the article

  • Which Ruby gem should I use for updating a Twitter or Facebook status along with authlogic_rpx?

    - by Kevin
    Hi, My Rails webapp uses tardate's excellent authlogic_rpx gem so that users can register and sign in using their Twitter or Facebook account. Now I need to update a user Twitter or Facebook status. Which gem should I use for Twitter? and for Facebook? Or should I prefer Net::HTTP for both? Since the users authorised my app through authlogic_rpx, do I already have this authorised token to use the Twitter and Facebook APIs? If so, where can I find it? Thanks, Kevin

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >