Search Results

Search found 2474 results on 99 pages for 'patrick scott'.

Page 94/99 | < Previous Page | 90 91 92 93 94 95 96 97 98 99  | Next Page >

  • How do I Unit Test Actions without Mocking that use UpdateModel?

    - by Hellfire
    I have been working my way through Scott Guthrie's excellent post on ASP.NET MVC Beta 1. In it he shows the improvements made to the UpdateModel method and how they improve unit testing. I have recreated a similar project however anytime I run a UnitTest that contains a call to UpdateModel I receive an ArgumentNullException naming the controllerContext parameter. Here's the relevant bits, starting with my model: public class Country { public Int32 ID { get; set; } public String Name { get; set; } public String Iso3166 { get; set; } } The controller action: [AcceptVerbs(HttpVerbs.Post)] public ActionResult Edit(Int32 id, FormCollection form) { using ( ModelBindingDataContext db = new ModelBindingDataContext() ) { Country country = db.Countries.Where(c => c.CountryID == id).SingleOrDefault(); try { UpdateModel(country, form); db.SubmitChanges(); return RedirectToAction("Index"); } catch { return View(country); } } } And finally my unit test that's failing: [TestMethod] public void Edit() { CountryController controller = new CountryController(); FormCollection form = new FormCollection(); form.Add("Name", "Canada"); form.Add("Iso3166", "CA"); var result = controller.Edit(2 /*Canada*/, form) as RedirectToRouteResult; Assert.IsNotNull(result, "Expected to be redirected on successful POST."); Assert.AreEqual("Show", result.RouteName, "Expected to redirect to the View action."); } ArgumentNullException is thrown by the call to UpdateModel with the message "Value cannot be null. Parameter name: controllerContext". I'm assuming that somewhere the UpdateModel requires the System.Web.Mvc.ControllerContext which isn't present during execution of the test. I'm also assuming that I'm doing something wrong somewhere and just need to pointed in the right direction. Help Please!

    Read the article

  • .net mvc pass dictionary data from view to controller

    - by Wei Ma
    A while ago, I was trying to pass a dictionary data from my view to my controller. And I was able to do so after googling on the net(remember it was one of scott hanselman's posts). The solution I had was something like <%for(int index=0; index<Model.Count(); index++){ var property= Model.ElementAt(index);%> <input type="hidden" name="<%="properties["+index+"].Key"%>"/> <input type="hidden" name="<%="properties["+index+"].Value"%>"/> <%}%> public ActionResult Process(IDictionary<string,string> properties) { doSomething(); return View(); } The code worked for awhile and then I did some refactoring and got rid of this chunk of code. Today, I ran into a situation in which I would like to pass a dictionary again. But no matter how hard I try, the properties parameter received by the action was always null. I tried the above code and <%for(int index=0; index<Model.Count(); index++){ var property= Model.ElementAt(index);%> <input type="hidden" name="<%="properties.Keys["+index+"]"%>"/> <input type="hidden" name="<%="properties.Values["+index+"]"%>"/> <%}%> Neither code worked. I googled again but couldn't find the post that helped me before. Can someone point out what I did wrong? thanks a million.

    Read the article

  • WPF Textbox & Borders - curious resizing behavior

    - by CitizenParker
    The following XAML produces a window with strange behavior around the textbox: <Window x:Class="WpfSandbox.CuriousExample" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="CuriousExample" Height="300" Width="300"> <DockPanel Margin="15"> <TextBox BorderThickness="1" BorderBrush="#FF000000"></TextBox> </DockPanel> </Window> What happens, at least during my limited testing, is that the textbox renders with an inset border pattern (top/left is black, right/bottom is grey). However, when you resize to any position except the original, the entire textbox border goes to black. Whenever you return the window to the exact number of on-screen pixels the form had when it first loaded, it's inset again. I'm guessing it isn't pixel snapping as I can easily correct the problem with this code: <Window x:Class="WpfSandbox.CuriousExample" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="CuriousExample" Height="300" Width="300"> <DockPanel Margin="15"> <Border BorderThickness="1" BorderBrush="#FF000000"> <TextBox BorderThickness="0" ></TextBox> </Border> </DockPanel> </Window> Anyone care to venture an explanation as to what I'm seeing? Or is it all in my head? Like I said, the above workaround can resolve this problem - just trying to understand what is happening here. Thanks, -Scott

    Read the article

  • Which LINQ expression is faster

    - by Vlad Bezden
    Hi All In following code public class Person { public string Name { get; set; } public uint Age { get; set; } public Person(string name, uint age) { Name = name; Age = age; } } void Main() { var data = new List<Person>{ new Person("Bill Gates", 55), new Person("Steve Ballmer", 54), new Person("Steve Jobs", 55), new Person("Scott Gu", 35)}; // 1st approach data.Where (x => x.Age > 40).ToList().ForEach(x => x.Age++); // 2nd approach data.ForEach(x => { if (x.Age > 40) x.Age++; }); data.ForEach(x => Console.WriteLine(x)); } in my understanding 2nd approach should be faster since it iterates through each item once and first approach is running 2 times: Where clause ForEach on subset of items from where clause. However internally it might be that compiler translates 1st approach to the 2nd approach anyway and they will have the same performance. Any suggestions or ideas? I could do profiling like suggested, but I want to understand what is going on compiler level if those to lines of code are the same to the compiler, or compiler will treat it literally. Thanks in advance for your help.

    Read the article

  • Custom DateTime model binder in Asp.net MVC

    - by Robert Koritnik
    I would like to write my own model binder for DateTime type. First of all I'd like to write a new attribute that I can attach to my model property like: [DateTimeFormat("d.M.yyyy")] public DateTime Birth { get; set,} This is the easy part. But the binder part is a bit more difficult. I would like to add a new model binder for type DateTime. I can either implement IModelBinder interface and write my own BindModel() method inherit from DefaultModelBinder and override BindModel() method My model has a property as seen above (Birth). So when the model tries to bind request data to this property, my model binder's BindModel(controllerContext, bindingContext) gets invoked. Everything ok, but. How do I get property attributes from controller/bindingContext, to parse my date correctly? How can I get to the PropertyDesciptor of property Birth? Edit Because of separation of concerns my model class is defined in an assembly that doesn't (and shouldn't) reference System.Web.MVC assembly. Setting custom binding (similar to Scott Hanselman's example) attributes is a no-go here.

    Read the article

  • Defining < for STL sort algorithm - operator overload, functor or standalone function?

    - by Andy
    I have a stl::list containing Widget class objects. They need to be sorted according to two members in the Widget class. For the sorting to work, I need to define a less-than comparator comparing two Widget objects. There seems to be a myriad of ways to do it. From what I can gather, one can either: a. Define a comparison operator overload in the class: bool Widget::operator< (const Widget &rhs) const b. Define a standalone function taking two Widgets: bool operator<(const Widget& lhs, const Widget& rhs); And then make the Widget class a friend of it: class Widget { // Various class definitions ... friend bool operator<(const Widget& lhs, const Widget& rhs); }; c. Define a functor and then include it as a parameter when calling the sort function: class Widget_Less : public binary_function<Widget, Widget, bool> { bool operator()(const Widget &lhs, const Widget& rhs) const; }; Does anybody know which method is better? In particular I am interested to know if I should do 1 or 2. I searched the book Effective STL by Scott Meyer but unfortunately it does not have anything to say about this. Thank you for your reply.

    Read the article

  • MVC2 Areas not Registering Correctly

    - by Geoffrey
    I believe I have my Areas setup correctly (they were working in MVC1 fine). I followed the guide here: http://odetocode.com/Blogs/scott/archive/2009/10/13/asp-net-mvc2-preview-2-areas-and-routes.aspx I've also used Haacked's Route Debugger. Which shows the correct Area/Controller registration when I run it. However when I try to go to my (AreaName)/(Controller) I get this error: "The resource cannot be found." I believe this indicates there's a problem with the routing, but I'm having trouble debugging this. Where should I set my breakpoints to catch routing errors in MVC2? I'm also using SparkViewEngine compiled against MVC2 references. Could this possibly be causing this error? I've set breakpoints on the controller in the area and it never fires off, I assumed the view engine doesn't kick in until after the controller has been initiated, but I could be wrong. The non-area landing page works fine, and I've stripped my project of all areas except one, to avoid any sort of naming conflicts. Any ideas where I can try to look next?

    Read the article

  • What is reading source on an ebook reader like?

    - by Daniel Straight
    There are a few open source projects I would really like to read through the code of to understand better / improve on. The problem is, for me, reading for a long time on the computer screen is tedious. I would love to be able to read code while lounging around and on a screen that was better on my eyes. Has anyone ever tried reading code on an ebook reader? It seems like the e-ink would make it easy on the eyes, plus it would be portable, plus it wouldn't kill any trees. In other words, it sounds perfect, but before I drop a couple benjamins on an ebook reader, I'd like to hear if anyone else has tried this and how it went. It seems Scott Hanselman discussed using the Kindle to read code, but I wouldn't necessarily want a Kindle. Has anyone had a positive experience with some other device? I realize this is not directly about programming, but it relates directly to my ability to improve my skills. I think if a good portable reading device for code exists, it could help a lot of programmers.

    Read the article

  • Complete failure to compile when include CSS Friendly Adapters

    - by david
    Background - I am trying to use the friendly adapters to override the default styling for the standard asp.net menu control that is used by an existing project. The existing project functions normally and compiles when requested without incident. Adding in the code for the for the CSS Friendly adapter and not only does it not compile, but it never even really starts. The Problem in Detail - I am using the sample code from Scott on this page: http://weblogs.asp.net/scottgu/archive/2006/09/08/CSS-Control-Adapter-Toolkit-Update.aspx. The sample project compiles fine, just within the existing project does it fail. Fails without a line number or any other traceable info. It definately appears to be related to the CSSMenuAdapter.browser file, which has been referenced by others online as the cause of similar error. I have tried addind and readding, using as a dll, using as a code file in app code, etc. I am working with aspdotnetstorefront in this case, although it is not unique to them as I have found other references in software packages online. Only thing is, no one ever says what solved the issue. I am using Windows 7, VS2008 Express and SQL Express 2008 R2. The full error msg is: Error 10 Exception of type 'System.OutOfMemoryException' was thrown. Notice that there is no file, line, or column info. Really need some help here. I have been working on this a long time. This really should have tag: cssfriendlyadapter but I could not create that.

    Read the article

  • Extensionless URLs in IIS 6

    - by Jason Marsell
    My client has asked me to build a personalized URL system so that they can send out really short URLs in postcards to customers like this: www.client.com/JasonSmith03 www.client.com/TonyAdams With these URLs, I need IIS 6 to trap the incoming request and pass that “JasonSmith03” token to my database to determine which landing page to redirect them to. I’d love to use an HttpHandler or HttpModule but they both look like they require an file extension (.aspx) in the URL. Wildcard mapping will chew up every incoming request and that’s ridiculous. ISAPI filters are just text routing files, so I can’t employ logic to call the database. According to Scott Guthrie, this would be cake if I had IIS 7, but I don’t. Can this be done using MVC? I’ve been working with MVP for the last few years, so I haven’t done any MVC and routing. I thought I remembered that MVC has the ability to use REST-style extensionless URLs. I’d be more than happy to have these personalized URLs land on a site that’s built in MVC, if it will work. Thank you!

    Read the article

  • Extension methods for encapsulation and reusability

    - by tzaman
    In C++ programming, it's generally considered good practice to "prefer non-member non-friend functions" instead of instance methods. This has been recommended by Scott Meyers in this classic Dr. Dobbs article, and repeated by Herb Sutter and Andrei Alexandrescu in C++ Coding Standards (item 44); the general argument being that if a function can do its job solely by relying on the public interface exposed by the class, it actually increases encapsulation to have it be external. While this confuses the "packaging" of the class to some extent, the benefits are generally considered worth it. Now, ever since I've started programming in C#, I've had a feeling that here is the ultimate expression of the concept that they're trying to achieve with "non-member, non-friend functions that are part of a class interface". C# adds two crucial components to the mix - the first being interfaces, and the second extension methods: Interfaces allow a class to formally specify their public contract, the methods and properties that they're exposing to the world. Any other class can choose to implement the same interface and fulfill that same contract. Extension methods can be defined on an interface, providing any functionality that can be implemented via the interface to all implementers automatically. And best of all, because of the "instance syntax" sugar and IDE support, they can be called the same way as any other instance method, eliminating the cognitive overhead! So you get the encapsulation benefits of "non-member, non-friend" functions with the convenience of members. Seems like the best of both worlds to me; the .NET library itself providing a shining example in LINQ. However, everywhere I look I see people warning against extension method overuse; even the MSDN page itself states: In general, we recommend that you implement extension methods sparingly and only when you have to. So what's the verdict? Are extension methods the acme of encapsulation and code reuse, or am I just deluding myself?

    Read the article

  • Validation L2S question

    - by user158020
    This may be a bit winded because I am new to wpf. I have created a partial class for an entity in my L2S class that is primarily used for validation. It implements the onchanging and onvalidate methods. I am trying to use the MVVM pattern, and in a window/view I have set the datacontext in the xaml: <Window.DataContext> <vm:StartViewModel /> </Window.DataContext> when a user leaves a required field in the view blank, the onchanging event of the partial class is fired when I close the form, not when I save the data. So, if a user leaves the textbox blank, the old value is retained and the onchaging method is fired, but I have no idea how to alert the user of the resulting error. here is my onchanging code in the partial class: partial void Ondocument_titleChanging(string value) { if (value.Length == 0) throw new Exception("Document title is required."); if (value.Length > 256) throw new Exception("Document title cannot be longer than 256 characters."); } throwing an exception doesn't notify the user of the error. it just allows the form to close and rejects the changes to the textbox. hope this makes sense... edit: this example was taken from Scott Guthries article here: http://aspalliance.com/1427_LINQ_to_SQL_Part_5__Binding_UI_using_the_ASPLinqDataSource_Control.5

    Read the article

  • How do I read a public twitter feed using .Net

    - by Jeff Weber
    I'm trying to read the public twitter status of a user so I can display it in my Windows Phone application. I'm using Scott Gu's example: http://weblogs.asp.net/scottgu/archive/2010/03/18/building-a-windows-phone-7-twitter-application-using-silverlight.aspx When my code comes back from the async call, I get a "System.Security.SecurityException" as soon as I try to use the e.Result. I know my uri is correct because I can plop it in the browser and get good results. Here is my relavent code: public void LoadNewsLine() { WebClient twitter = new WebClient(); twitter.DownloadStringCompleted += new DownloadStringCompletedEventHandler(twitter_DownloadStringCompleted); twitter.DownloadStringAsync(new Uri("http://api.twitter.com/1/statuses/user_timeline.xml?screen_name=krashlander")); } void twitter_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { XElement xmlTweets = XElement.Parse(e.Result); //exception thrown here! var message = from tweet in xmlTweets.Descendants("status") select tweet.Element("text").Value; //Set message and tell UI to update. //NewsLine = message.ToString(); //RaisePropertyChanged("NewsLine"); } Any ideas anyone?

    Read the article

  • why MVC instead of good old asp.net? Still not grasping why I should go this route??

    - by RJ
    I know this question has been asked before and I read all the answers but they still don't give me the answers I am looking for. I need something concrete. I volunteered to give a presentation on MVC to other developers in our group which forces me to learn it. The big question everyone has is: "What can MVC bring to the table that we can't do in asp.net or MVC can do faster. I have just gone through Nerd Dinner and actually created a complete website that sort of mimics Nerd Dinner. But as great a job that Scott Guthrie did on it, there are big gaps that aren't answered such as, how do I throw a textbox on the listing page with a button and do a simple search. In asp.net, I would throw a textbox, button and grid on the page and bind it to a sproc and away I go. What is the equivalent in MVC. I guess I need a really good tutorial on how to use MVC without using Linq-to-Sql. I know I am sort of babbling on about this but it is a very serious question that still seems to go unanswered. On a side note, the View page of MVC brings back nightmares of classic asp with all the in-line code that we got away from way back when with code behind pages. Yes, MVC has Controller and Model classes which are great but I still don't like the classic asp tags in the html. Help me out here, I really like the concept of MVC and want it to be successful but I need more!

    Read the article

  • Why would ASP.NET MVC use session state?

    - by ray247
    Recommended by the ASP.NET team to use cache instead of session, we stopped using session from working with the WebForm model the last few years. So we normally have the session turned off in the web.config <sessionState mode="Off" /> But, now when I'm testing out a ASP.NET MVC application with this setting it throw an error in class SessionStateTempDataProvider inside the mvc framework, it asked me to turn on session state, I did and it worked. Looking at the source it uses session Dictionary<string, object> tempDataDictionary = httpContext.Session[TempDataSessionStateKey] as Dictionary<string, object>; // line 20 in SessionStateTempDataProvider.cs So, why would they use session here? What am I missing? Thanks, Ray. ======================================================== Edit Sorry didn't mean for this post to debate on session vs. cache, but rather in the context of the ASP.NET MVC, I was just wondering why session is used here. In this Scott Watermasysk blog post he mentioned on turning off session too as a good practice, so I'm just wondering do I have to turn it on to use MVC from here on?

    Read the article

  • Design of std::ifstream class

    - by Nawaz
    Those of us who have seen the beauty of STL try to use it as much as possible, and also encourage others to use it wherever we see them using raw pointers and arrays. Scott Meyers have written a whole book on STL, with title Effective STL. Yet what happened to the developers of ifstream that they preferred char* over std::string. I wonder why the first parameter of ifstream::open() is of type const char*, instead of const std::string &. Please have a look at it's signature: void open(const char * filename, ios_base::openmode mode = ios_base::in ); Why this? Why not this: void open(const string & filename, ios_base::openmode mode = ios_base::in ); Is this a serious mistake with the design? Or this design is deliberate? What could be the reason? I don't see any reason why they have preferred char* over std::string. Note we could still pass char* to the latter function that takes std::string. That's not a problem! By the way, I'm aware that ifstream is a typedef, so no comment on my title.:P. It looks short that is why I used it. The actual class template is : template<class _Elem,class _Traits> class basic_ifstream;

    Read the article

  • WPF - How do I use the UserControl with a dependency property and view model?

    - by user320849
    Hello, My goal is to have a user select a year and a month. Translate the selection into a date and have the user control send the date back to my view model. That part works for me....However, I cannot get the ViewModel's initial date to set those drop downs. public static readonly DependencyProperty Date = DependencyProperty.Register("ReturnDate", typeof(DateTime), typeof(DatePicker), new FrameworkPropertyMetadata{BindsTwoWayByDefault = true,}); public DateTime ReturnDate { get { return Convert.ToDateTime(GetValue(Date)); } set { SetDropDowns(value); SetValue(Date, value); } } The SetDropDowns(value) just sets the selected items on the combo boxes, however, the program never makes it to that method. On the view I am using: <cc1:DatePicker ReturnDate="{Binding Path=StartDate, Mode=TwoWay}" IsStart="True" /> If this has been answered, then my bad. I looked around and didn't see anything that worked for me. Thus, when the program loads how do I get the value from the view model to a method in order to set the combo boxes? Thanks, -Scott

    Read the article

  • how to check null value of Integer type field in ASP.NET MVC view?

    - by Vikas
    Hi, I have integer type field in database which is having property "Not Null". when i create a view & do a validation, if i left that field blank, it will consider it as 0 so i can not compare it with 0 because if someone insert a value 0 then it will be considered as error! one another problem is that i am using Model error as described in the book "ASP.NET MVC 1.0" @ Scott Gu blog. And I am checking the value in partial class of object (created by LINQ-To-SQL). i.e public partial class Person { public bool IsValid { get { return (GetRuleViolations().Count() == 0); } } public IEnumerable<RuleViolation> GetRuleViolations() { if (String.IsNullOrEmpty(Name)) yield return new RuleViolation("Name is Required", "Name"); if (Age == 0) yield return new RuleViolation("Age is Required", "Age"); yield break; } partial void OnValidate(ChangeAction action) { if (!IsValid) throw new ApplicationException("Rule violations prevent saving"); } } There is also problem with range. Like in database if i declared as smallint i.e. short in c#, now if i exceed that range then it gives error as "A Value is reguired". so finally is there any best way for validation in ASP.NET MVC?

    Read the article

  • Problem creating a custom input element using FluentHtml (MVCContrib)

    - by seth
    Hi there, I just recently started dabbling in ASP.NET MVC 1.0 and came across the wonderful MVCContrib. I had originally gone down the path of creating some extended html helpers, but after finding FluentHTML decided to try my hand at creating a custom input element. Basically I am wanting to ultimately create several custom input elements to make it easier for some other devs on the project I'm working on to add their input fields to the page and have all of my preferred markup to render for them. So, in short, I'd like to wrap certain input elements with additional markup.. A TextBox would be wrapped in an <li /> for example. I've created my custom input elements following Tim Scott's answer in another question on here: DRY in the MVC View. So, to further elaborate, I've created my class, "TextBoxListItem": public class TextBoxListItem : TextInput<TextBox> { public TextBoxListItem (string name) : base(HtmlInputType.Text, name) { } public TextBoxListItem (string name, MemberExpression forMember, IEnumerable<IBehaviorMarker> behaviors) : base(HtmlInputType.Text, name, forMember, behaviors) { } public override string ToString() { var liBuilder = new TagBuilder(HtmlTag.ListItem); liBuilder.InnerHtml = ToString(); return liBuilder.ToString(TagRenderMode.SelfClosing); } } I've also added it to my ViewModelContainerExtensions class: public static TextBox TextBoxListItem<T>(this IViewModelContainer<T> view, Expression<Func<T, object>> expression) where T : class { return new TextBoxListItem(expression.GetNameFor(view), expression.GetMemberExpression(), view.Behaviors) .Value(expression.GetValueFrom(view.ViewModel)); } And lastly, I've added it to ViewDataContainerExtensions as well: public static TextBox TextBoxListItem(this IViewDataContainer view, string name) { return new TextBox(name).Value(view.ViewData.Eval(name)); } I'm calling it in my view like so: <%= this.TextBoxListItem("username").Label("Username:") %> Anyway, I'm not getting anything other than the standard FluentHTML TextBox, not wrapped in <li></li> elements. What am I missing here? Thanks very much for any assistance.

    Read the article

  • Attaching methods to prototype from within constructor function

    - by Matthew Taylor
    Here is the textbook standard way of describing a 'class' or constructor function in JavaScript, straight from the Definitive Guide to JavaScript: function Rectangle(w,h) { this.width = w; this.height = h; } Rectangle.prototype.area = function() { return this.width * this.height; }; I don't like the dangling prototype manipulation here, so I was trying to think of a way to encapsulate the function definition for area inside the constructor. I came up with this, which I did not expect to work: function Rectangle(w,h) { this.width = w; this.height = h; this.constructor.prototype.area = function() { return this.width * this.height; }; } I didn't expect this to work because the this reference inside the area function should be pointing to the area function itself, so I wouldn't have access to width and height from this. But it turns out I do! var rect = new Rectangle(2,3); var area = rect.area(); // great scott! it is 6 Some further testing confirmed that the this reference inside the area function actually was a reference to the object under construction, not the area function itself. function Rectangle(w,h) { this.width = w; this.height = h; var me = this; this.constructor.prototype.whatever = function() { if (this === me) { alert ('this is not what you think');} }; } Turns out the alert pops up, and this is exactly the object under construction. So what is going on here? Why is this not the this I expect it to be?

    Read the article

  • breaking datetime into constituent parts ASP.NET MVC form

    - by nick
    hi guys, i have searched the web relentlessly for this and have not found anything - which is surprising because i would think it is such a common scenario! Basically, on my model i have a DateTime field which i wish the user to populate through a form. I am using the Html helper to render all other parts of the form (along with validation) So this question is in two parts... Html Helper Firstly, is there any way to use the Html helper to split the DateTime field to be rendered as the three constituent parts of a date: day, month, year (since i do not care about the time part). This could be rendered as text boxes, drop down lists or a combination of both. Model Binding And then when the form is posted, what is the best approach for binding back up to the model? I have seen Scott Hanselmann's solution to this, but it seems a little bloated for what i need - i was hoping for a slightly more elegant solution. Is it recommended to extend DefaultModelBinder and set that as default binder (since all dates would be handled in this way) or write a class that implements IModelBionder and set it as the default binder for the DateTime type? Thanks for all the help in advance :-) i'm loving MVC but it's infuriating me that something so trivial is causing so much headaches!

    Read the article

  • Passing array of pointers to another class

    - by user310153
    Hi, I am trying to do the following: in main.cpp: // Create an array of pointers to Block objects Block *blk[64]; for (i=0; i<8; i++) { for (j=0; j<8; j++) { int x_low = i*80; int y_low = j*45; blk[j*8+i] = new Block(30, x_low+40.0f, y_low+7.5f, &b); } } And then I am trying to pass it to the graphics object I have created: Graphics g(640, 480, &b, &p, blk[0], number_of_blocks); the graphics constructor looks like: Graphics::Graphics(int width, int height, Ball *b, Paddle *p, Block *blk, int number_of_blocks) { if I look at what is contained in the array from the graphics object, only the first item exists and then all the other items are in hyperspace: for (int i=0; i<64; i++) { printf("for block %d, %f, %f ", i, (_blk+(sizeof(_blk)*i))->_x_low, (_blk+(sizeof(_blk)*i))->_y_low); printf("blah %d\n", (_blk+(sizeof(_blk)*i))); } and if I look at the addresses, they are different (6956552 rather than 2280520 when I examine the addresses in the main class using: printf(" blah %d\n", &blk[j*8*i]); I am sure there must be something subtle I am doing wrong as its like I have copied the first item from the blk array to a new address when passed to the graphics object. Does this make sense? Any ideas? Cheers, Scott

    Read the article

  • Managing My Database in Source Control

    - by Jason
    As I am working with a new database project (within VS2008), and as I have never developed a database from scratch, I immediately began looking into how to manage a database within source control (in this case, Subversion). I found some information on SO, including this post: Keeping development databases in multiple environments in sync. One of the answers in particular pointed to a number of a links, all of which had good, useful information. I was reading a series of posts by K. Scott Allen which describe how he manages database change. From my reading (and please pardon the noobishness of my question), it seems as though the database itself is never checked into a repository. Rather, scripts that can build the database, along with test data (which is also populated from scripts) is checked into the repository. Ultimately, this means that, when a developer is testing his or her app, these scripts, which are part of the build process, are run. This ensures that the database is up-to-date, but is also run locally from every developer's machine. This makes sense to me (if I am indeed reading that correctly). However, if I am missing something, I would appreciate correction or additional guidance. In addition, another question I wanted to ask - does this also mean that I should NOT check in the mdf or ldf files that are created from Visual Studio? Thanks for any help and additional insight. Always appreciated.

    Read the article

  • What is the best (Windows) program launcher?

    - by AR
    One of the biggest general productivity boosters I've used is a good program launcher. I was a long-time user of SlickRun, and I've tried a few others. My current favorite is Executor - by far the best I've used. Other options: Executor: My current favorite Vista Start Menu: Pretty good, actually, but Executor is similar (binds to Win+Z) and much more flexible. Quicksilver: For Macs only, but it seems to be the gold standard against which most other launchers are measured. Google Desktop: Press Ctrl+Ctrl and it's a quick launcher! AutoHotKey: Much,much more than just a launcher - more than I need, really. SlickRun: simple and unobtrusive Launchy: Seems to be the launcher of choice for many StackOverflow users :) Colibri: "Type Ahead - Information at the tip of your wings". Quite a cool concept. Many, many others. Scott Hanselman outlines some more here. I realize that everyone will have their own preferences, but the question is: is there anything that really stands out in terms of speed, features, and especially productivity increase?

    Read the article

  • URL path changes between dev and published version

    - by Bob Horn
    I just got Scott Hanselman's chat app with SignalR working with ASP.NET MVC 4. After hours of configuration, trial and error, and getting different versions of Windows to talk to each other on my home network, it's all working except that I'm left with one issue that I'm not sure how to handle. This line of javascript has to change, depending on if I'm running the app through Visual Studio or the published (IIS) version: Works when running within VS: var connection = $.connection('echo'); Works with published version: var connection = $.connection('ChatWithSignalR/echo'); When I run within VS, the URL is: http://localhost:9145/ And the published version is: http://localhost/ChatWithSignalR If I don't change that line of code, and try to run the app within VS, using the javascript that has ChatWithSignalR in it, I get an error like this: Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:9145/ChatWithSignalR/echo/negotiate?_=1347809290826 What can I do so that I can use the same javascript code and have it work in both scenarios? var connection = $.connection('??????'); Note, this is in my Global.asax.cs: RouteTable.Routes.MapConnection<MyConnection>("echo", "echo/{*operation}");

    Read the article

< Previous Page | 90 91 92 93 94 95 96 97 98 99  | Next Page >