Search Results

Search found 954 results on 39 pages for 'george r'.

Page 24/39 | < Previous Page | 20 21 22 23 24 25 26 27 28 29 30 31  | Next Page >

  • Any way to allow classes implementing IEntity and downcast to have operator == comparisons?

    - by George Mauer
    Basically here's the issue. All entities in my system are identified by their type and their id. new Customer() { Id = 1} == new Customer() {Id = 1}; new Customer() { Id = 1} != new Customer() {Id = 2}; new Customer() { Id = 1} != new Product() {Id = 1}; Pretty standard scenario. Since all Entities have an Id I define an interface for all entities. public interface IEntity { int Id { get; set;} } And to simplify creation of entities I make public abstract class BaseEntity<T> : where T : IEntity { int Id { get; set;} public static bool operator ==(BaseEntity<T> e1, BaseEntity<T> e2) { if (object.ReferenceEquals(null, e1)) return false; return e1.Equals(e2); } public static bool operator !=(BaseEntity<T> e1, BaseEntity<T> e2) { return !(e1 == e2); } } where Customer and Product are something like public class Customer : BaseEntity<Customer>, IEntity {} public class Product : BaseEntity<Product>, IEntity {} I think this is hunky dory. I think all I have to do is override Equals in each entity (if I'm super clever, I can even override it only once in the BaseEntity) and everything with work. So now I'm expanding my test coverage and find that its not quite so simple! First of all , when downcasting to IEntity and using == the BaseEntity< override is not used. So what's the solution? Is there something else I can do? If not, this is seriously annoying. Upadate It would seem that there is something wrong with my tests - or rather with comparing on generics. Check this out [Test] public void when_created_manually_non_generic() { // PASSES! var e1 = new Terminal() {Id = 1}; var e2 = new Terminal() {Id = 1}; Assert.IsTrue(e1 == e2); } [Test] public void when_created_manually_generic() { // FAILS! GenericCompare(new Terminal() { Id = 1 }, new Terminal() { Id = 1 }); } private void GenericCompare<T>(T e1, T e2) where T : class, IEntity { Assert.IsTrue(e1 == e2); } Whats going on here? This is not as big a problem as I was afraid, but is still quite annoying and a completely unintuitive way for the language to behave. Update Update Ah I get it, the generic implicitly downcasts to IEntity for some reason. I stand by this being unintuitive and potentially problematic for my Domain's consumers as they need to remember that anything happening within a generic method or class needs to be compared with Equals()

    Read the article

  • Is this a valid benefit of using embedded SQL over stored procedures?

    - by George
    Here's an argument for SPs that I haven't heard. Flamers, be gentle with the down tick, Since there is overhead associated with each trip to the database server, I would suggest that a POSSIBLE reason for placing your SQL in SPs over embedded code is that you are more insulated to change without taking a performance hit. For example. Let's say you need to perform Query A that returns a scalar integer. Then, later, the requirements change and you decide that it the results of the scalar is x that then, and only then, you need to perform another query. If you performed the first query in a SP, you could easily check the result of the first query and conditionally execute the 2nd SQL in the same SP. How would you do this efficiently in embedded SQL w/o perform a separate query or an unnecessary query? Here's an example: --This SP may return 1 or two queries. SELECT @CustCount = COUNT(*) FROM CUSTOMER IF @CustCount 10 SELECT * FROM PRODUCT Can this/what is the best way to do this in embedded SQL?

    Read the article

  • How to access the members of this data in PHP?

    - by George Edison
    Okay. Now I give up. I have been playing with this for hours. I have a variable name $data. The variable contains these contents: (extracted by using var_export()) array ( 'headers' => array ( 'content-type' => 'multipart/alternative; boundary="_689e1a7d-7a0a-442a-bd6c-a1fb1dc2993e_"', ), 'ctype_parameters' => array ( 'boundary' => '_689e1a7d-7a0a-442a-bd6c-a1fb1dc2993e_', ), 'parts' => array ( 0 => stdClass::__set_state(array( 'headers' => array ( 'content-type' => 'text/plain; charset="iso-8859-1"', 'content-transfer-encoding' => 'quoted-printable', ), 'ctype_primary' => 'text', )), ), ) I removed some non-essential data. I want to access the headers value (on the second line above) - simple: $data->headers I want to access the headers value (on the fourteenth line after the stdClass:: stuff) - how? How can I possibly access the values within the stdClass::__set_state section? I tried var_export($data->parts); but all I get is NULL

    Read the article

  • Best way to display a "High Scores" Results

    - by George
    First, I would to thank everyone for all the help they provide via this website. It has gotten me to the point of almost being able to release my first iPhone app! Okay, so the last part I have is this: I have a game that allows users to save their high scores. I update a plist file which contains the users Name, Level, and score. Now I want to create a screen that will display the top 20 high scores. What would be the best way to do this? At first I thought possibly creating an HTML file with this info but am not even sure if that is possible. I would need to read the plist file, and then write it out as HTML. Is this possible? To write a file out as HTML? Or an even better question, is there a better way? Thanks in advance for any and all help! Geo...

    Read the article

  • Making div fixed vertically but glued to the page's border horizontally

    - by George
    Hi! Can you please go to: http://www.binarymark.com/Products/ColorPickerPro/default.aspx and note the page's layout. What I want to do is to stick or "glue" some small div to the right side of the page, that is so that it's just outside of the right frame of the page. However, vertically I want the div to be fixed to a Window, that is no matter how much the page is scrolled, it should remain a fixed 300px from the top edge of the window. Here's what it should look like http://www.binarymark.com/layexp.png Can you help me please? Seems easy, but I have no idea how to combine vertical fixed positioning and horizontal relative/absolute positioning and making sure it supports all major browsers. Thanks.

    Read the article

  • Get DataGridView checkbox cell value?

    - by George
    Hello guys. I'm having a strange issue here. I have a 3 column datagrid that is filled by a connection with the database. So far so good. I have an extra column, of checkbox type. I need to get it's value for perfoming a bulk operation on it. Here is the catch: When all cells are selected, it works fine. But when an user selects any cell that its not the first, software gives me a object reference exception. Here is the code public List<String> GetSelected() { List<String> selected = new List<String>(); foreach(DataGridViewRow row in datagrid.rows) { if ((Boolean)row.Cells[wantedCell].Value == true) { selected.Add(row.Cells[anotherCell]); } } } I tracked down the failure to the if-test, throwing a exception, because the value of the cell is read as null. Any thougths? Thanks

    Read the article

  • Why won't this compile and how can it be implemented so that it does?

    - by George Edison
    Here is some C++ code I'm playing around with: #include <iostream> #include <vector> #define IN , #define FOREACH(x,y) for(unsigned int i=0;i<y.size();i++) { x=y[i]; #define ENDFOREACH } using namespace std; int main() { vector<int> ints; ints.push_back(3); ints.push_back(4); ints.push_back(5); ints.push_back(6); FOREACH(int item IN ints) cout << item; ENDFOREACH return 0; } However, I get an error: macro "FOREACH" requires 2 arguments, but only 1 given The code compiles if I change the IN to a comma. How can I get the IN to take the place of a comma?

    Read the article

  • Casting Type array to Generic array?

    - by George R
    The short version of the question - why can't I do this? I'm restricted to .NET 3.5. T[] genericArray; // Obviously T should be float! genericArray = new T[3]{ 1.0f, 2.0f, 0.0f }; // Can't do this either, why the hell not genericArray = new float[3]{ 1.0f, 2.0f, 0.0f }; Longer version - I'm working with the Unity engine here, although that's not important. What is - I'm trying to throw conversion between its fixed Vector2 (2 floats) and Vector3 (3 floats) and my generic Vector< class. I can't cast types directly to a generic array. using UnityEngine; public struct Vector { private readonly T[] _axes; #region Constructors public Vector(int axisCount) { this._axes = new T[axisCount]; } public Vector(T x, T y) { this._axes = new T[2] { x, y }; } public Vector(T x, T y, T z) { this._axes = new T[3]{x, y, z}; } public Vector(Vector2 vector2) { // This doesn't work this._axes = new T[2] { vector2.x, vector2.y }; } public Vector(Vector3 vector3) { // Nor does this this._axes = new T[3] { vector3.x, vector3.y, vector3.z }; } #endregion #region Properties public T this[int i] { get { return _axes[i]; } set { _axes[i] = value; } } public T X { get { return _axes[0];} set { _axes[0] = value; } } public T Y { get { return _axes[1]; } set { _axes[1] = value; } } public T Z { get { return this._axes.Length (Vector2 vector2) { Vector vector = new Vector(vector2); return vector; } public static explicit operator Vector(Vector3 vector3) { Vector vector = new Vector(vector3); return vector; } #endregion }

    Read the article

  • How to get rid of this sliver of white between DIVs?

    - by George Edison
    I am currently having trouble getting rid of a sliver of white... Here is an example page: http://m.stackoverflow.quickmediasolutions.com/view_question.php?id=97969&site=serverfault As you can see, the answers have a sliver of white stuffed between the top of the 'button' and the content. Here is some relevant code: <!-- this is the top of the 'button' --> <div class='top'></div> <!-- right here is where the space is --> <div class='content'></div> .top { height: 5px; } .content { display: block; padding-left: 10px; }

    Read the article

  • How can I redirect all traffic from one domain to another with an .htaccess file?

    - by George Edison
    Say I have a subdomain xxx.yyy.com running Apache. The files are stored in /home/someone/public_html/xxx. What I want to do is redirect all requests to a domain name zzz.com which is using the same location for its files. (In other words, xxx.yyy.com and zzz.com are aliases for each other) I just want people accessing zzz.com, so if someone goes to xxx.yyy.com they should be redirected to zzz.com. Can this easily be done with a rewrite rule in an .htaccess file?

    Read the article

  • How do I sum values from two dictionaries in C#?

    - by George Stocker
    I have two dictionaries with the same structure: Dictionary<string, int> foo = new Dictionary<string, int>() { {"Table", 5 }, {"Chair", 3 }, {"Couch", 1 } }; Dictionary<string, int> bar = new Dictionary<string, int>() { {"Table", 4 }, {"Chair", 7 }, {"Couch", 8 } }; I'd like to sum the values of the dictionaries together and return a third dictionaries with the keys, and the total values for each key: Table, 9 Chair, 10 Couch, 9 My current solution is to loop through the dictionary and pull them out that way, but I know that solution isn't the most performant or most readable. However, I'm hitting a brick wall trying to come up with a solution in LINQ.

    Read the article

  • Is it easy to do IPC with wxWidgets?

    - by George Edison
    Is it easy to create an IPC setup with wxWidgets? I have an application that needs to detect if a previous instance is running and send a message to the running instance with a string value. Is there an easier way to do this than setting up a wxServer and wxClient-derived class?

    Read the article

  • How can you access two identically-named columns in a MySQL LEFT JOIN query?

    - by George Edison
    I have two tables. table_x: id INT(11) tag INT(11) table_tags: id INT(11) name VARCHAR(255) Then I use PHP to perform the following query: SELECT * FROM table_x LEFT JOIN table_tags ON table_x.tag = table_tags.id The only problem is: how do I access table_x.id and table_tags.id in the results? Here is the PHP code: $query = "SELECT * FROM table_x LEFT JOIN table_tags ON table_x.tag = table_tags.id"; $results = mysql_query($query); while($row = mysql_fetch_array($results)) { // how do I now access table_x.id and table_tags.id ??? }

    Read the article

  • Instrumenting a string

    - by George Polevoy
    Somewhere in C++ era i have crafted a library, which enabled string representation of the computation history. Having a math expression like: TScalar Compute(TScalar a, TScalar b, TScalar c) { return ( a + b ) * c; } I could render it's string representation: r = Compute(VerbalScalar("a", 1), VerbalScalar("b", 2), VerbalScalar("c", 3)); Assert.AreEqual(9, r.Value); Assert.AreEqual("(a+b)*c==(1+2)*3", r.History ); C++ operator overloading allowed for substitution of a simple type with a complex self-tracking entity with an internal tree representation of everything happening with the objects. Now i would like to have the same possibility for NET strings, only instead of variable names i would like to see a stack traces of all the places in code which affected a string. And i want it to work with existing code, and existing compiled assemblies. Also i want all this to hook into visual studio debugger, so i could set a breakpoint, and see everything that happened with a string. Which technology would allow this kind of things? I know it sound like an utopia, but I think visual studio code coverage tools actually do the same kind of job while instrumenting the assemblies.

    Read the article

  • How to make Chrome obey this rule?

    - by George Edison
    Here is the code: <table style='margin-left: auto; margin-right: auto; text-align: right;'> <tr> <td style='vertical-align: top;'>Title:</td> <td style='width: 400px;'><input type='text' style='border: 1px solid black; width: 100%;' /> </tr> <tr> <td style='vertical-align: top;'>Content:</td> <td><textarea style='border: 1px solid black; width: 100%;' rows='7'></textarea></td> </tr> </table> Here is what it looks like in Opera and FireFox (in Linux): But then in Chrome (also in Linux): As you can see, the first text box is not the right width :( How can I fix this?

    Read the article

  • sql data source

    - by George
    I have a table (EmployeeID,EmployeeName,ManagerID) How can I create a sqldatasource to include the ManagerName from the EmployeeName given EmployeeID = ManagerID? In my gridview after dragging a dropdownlist what bindings should I do to display the managerName? Is it possible to use it without writing custom select,insert,delete,update? If not what are the steps I need to do to write the whole thing i.e. custom grid and source? Thank you very much

    Read the article

  • How to time Java program execution speed

    - by George Mic
    Sorry if this sounds like a dumb question but how do you time the execution of a java program? I'm not sure what class I should use to do this. I'm kinda looking for something like: //Some timer starts here for (int i = 0; i < length; i++) { // Do something } //End timer here System.out.println("Total execution time: " + totalExecutionTime); Thanks

    Read the article

  • Set existing Web Service Extension to "Allow" using WiX

    - by Friend Of George
    In IIS Manager under Web Service Extensions, ASP.NET v2.0.50727 is set to "Prohibited" by default. I would like to set this to Allow during the install. I am currently using WiX Version 2. I have tried using: <Component Id="Allow_WebServiceExtension_ASP.NET_2.0" DiskId="1" Guid="02247363-E423-41E1-AC15-BEF589B65A4D"> <WebServiceExtension Id="WebServiceExtension_ASP.NET_2.0" Allow="yes" File="%SystemRoot%\Microsoft.NET\Framework\[DOTNETFRAMEWORKVER]\aspnet_isapi.dll" Description="ASP.NET v2.0.50727" UIDeletable="no" /> </Component> This adds a second ASP.NET 2.0.50727 entry and does not enable the first.

    Read the article

  • Using a CMS with an external database

    - by George Reith
    I am looking at building an external site with a CMS, probably Drupal or ExpressionEngine. The problem is that our company already has a membership database that is designed to work with our existing enterprise software. Migrating data from the database manually is not an option as modifications and new data must be accessible in real-time. Because the design of the external database will differ from the CMS's own I have decided the best way forward is to use two databases and force the CMS to use the external to read user information (cannot write to) and a local for everything else the CMS needs to do (read + write). Is this feasible with these Drupal or ExpressionEngine? Ideally I need to be able to use hooks as I do not wan't to modify core CMS files. Sifting through the docs I am not able to find what I would hook into for ether CMS. (Note: I know it is possible, but I want to know if it's feasible). Finally if there is a better way of handling this situation please also chime in. Perhaps there is something at the database level to reference a field or table in an external database? I'm clutching at straws someone can point me in the right direction I'm sure.

    Read the article

< Previous Page | 20 21 22 23 24 25 26 27 28 29 30 31  | Next Page >