Search Results

Search found 9401 results on 377 pages for 'derived types'.

Page 18/377 | < Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >

  • C++: Throwing shared_ptr of derived and catching shared_ptr of base?

    - by hasvn
    Ok, I've been told this problem: Why can you throw a pointer to a derived class and catch a pointer to its base... but you can't do that with shared_ptrs? Example, this works: class Base {}; class Derived : public Base {}; int main() { try { throw new Derived() ; } catch( const Base2 * b ) { printf("Received a base" ) ; } return 0 ; } But this doesn't int main() { try { throw std::tr1::shared_ptr<Derived>( new Derived() ) ; } catch( const std::tr1::shared_ptr<Base> & b ) { printf("Received a base" ) ; } return 0 ; } Any ideas?

    Read the article

  • WCF- "The underlying connection was closed: The connection was closed unexpectedly"

    - by SumGuy
    Hi there. I'm recieving that wonderfuly ambiguous error message when using one of my webmethods on my WCF webservice. As that error message doesn't provide any explanation whatsoever allow me to post my theory. I believe it may have something to do with the return type I'm using I have a Types DLL which is refrenced in both the webservice and the client. In this DLL is the base class ExceptionMessages. There is a child of this class called DrawingExcepions. Here is some code: public class ExceptionMessages { public object[] ReturnValue { get; set; } } public class DrawingExceptions : ExceptionMessages { private List<DrawingException> des = new List<DrawingException>(); } public class DrawingException { public Exception ExceptionMsg { get; set; } public List<object> Errors { get; set; } } The using code: [OperationContract] ExceptionMessages createNewBom(Bom bom, DrawingFiles dfs); public ExceptionMessages createNewBOM(Bom bom, DrawingFiles dfs) { return insertAssembly(bom, dfs); } public DrawingExceptions insertAssembly(Bom bom, DrawingFiles dfs) { DrawingExceptions des = new DrawingExceptions(); foreach (DrawingFile d in dfs.drawingFiles) { DrawingException temp = insertNewDrawing(bom, d); if (temp != null) des.addDrawingException(temp); if (d.Child != null) des.addDrawingException(insertAssembly(bom, d.Child)); } return des; } Returns to: ExceptionMessages ems = client.createNewBom(bom, currentDFS); if (ems is DrawingExceptions) { } Basically the return type from the webmethod is ExceptionMessages however I would usually be sending the child class back instead. My only idea is that it's the child that's causing the error but as far as I've read, this should have no effect. Has anyone got any ideas what could be going wrong here? If any more info is required, just ask :) Thanks.

    Read the article

  • Swig typecast to derived class?

    - by Zack
    I notice that Swig provides a whole host of functions to allow for typecasting objects to their parent classes. However, in C++ one can produce a function like the following: A * getAnObject() { if(someBoolean) return (A *) new B; else return (A *) new C; } Where "A" is the parent of classes "B" and "C". One can then typecast the pointer returned into being a "B" type or "C" type at one's convenience like: B * some_var = (B *) getAnObject(); Is there some way I can typecast an object I've received from a generic-pointer-producing function at run-time in the scripting language using the wrappers? (In my case, Lua?) I have a function that could produce one of about a hundred possible classes, and I'd like to avoid writing an enormous switch structure that I'd have to maintain in C++. At the point where I receive the generic pointer, I also have a string representation of the data type I'd like to cast it to. Any thoughts? Thanks! -- EDIT -- I notice that SWIG offers to generate copy constructors for all of my classes. If I had it generate those, could I do something like the following?: var = myModule.getAnObject(); -- Function that returns an object type-cast down to a pointer of the parent class, as in the function getAnObject() above. var = myModule.ClassThatExtendsBaseClass(var); -- A copy constructor that SWIG theoretically creates for me and have var then be an instance of the inheriting class that knows it's an instance of the inheriting class?

    Read the article

  • Derived class linker - is this wrong?

    - by bobobobo
    We have this situation: A B ^ ^ | / C so class A { } class B { } class C : public A, public B { } Now, B wants to access a property in C. How do you do this? The solution I came up with is to place a pointer in B to an instance of C, which is only active (not null) if this B is in fact a C.

    Read the article

  • Ndepend CQL to query types out of assembly wildcard

    - by icelava
    In order to determine what low-level framework types a web application is directly using, one has to define each and every assembly involved. SELECT TYPES FROM ASSEMBLIES "Company.System.Framework", "Company.System.Framework.ReferenceLookup", "Company.System.Framework.Web", "Company.System.Framework.Security", "Company.System.Framework.Logging", "Company.System.Framework.DMS" WHERE IsDirectlyUsedBy "WebAssembly" I cannot find any syntax to wildcard the list of assemblies. Is there no way to shortcut this? We have a lot of framework level assemblies. i.e. Company.System.Framework.*

    Read the article

  • How to get actual type of an derived class from its parent interface

    - by Tarik
    Hello people, Lets say we have a code portion like this : IProduct product = ProductCreator.CreateProduct(); //Factory Method we have here SellThisProduct(product); //... private void SellThisProduct(IProduct product) { //..do something here } //... internal class Soda : IProduct {} internal class Book : IProduct {} How can I infer which product is actually passed into SellThisProduct() method in the method? I think if I say GetType() or something it will probably return the IProduct type. Thanks...

    Read the article

  • WPF: Sort of inconsistence in the visual appearence of WPF controls derived by Selector class

    - by msfanboy
    Hello, focused items == selected items but selected items != focused items. Have you ever wondered about that? Do you specially style the backcolor of a focused/selected item ? I ask this question because a user has an enabled button because some customer items are selected. The user is wondering now "why the heck can I delete this customers (button is enabled...) when I have just clicked on the orders control selecting some orders ready to delete (button is enabled too). The thing is the selected customer items are nearly looking grayed out in the default style... Well its sort of inconsistence to the user NOT to the programmer because WE know the behavior. Do you cope with stuff like that?

    Read the article

  • Reflecting derived classes in C#

    - by rook
    Let's assume there's a class with a virtual property (let's call it 'P'). It's overridden in a deriving class. Now I want to use something like this: obj.GetType().GetProperty("P") to get info about the overriding property. This search is ambigous, because there are two "P" properties (base and override). So I typed: obj.GetType().GetProperty("P", BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance) It returns the overriding "P" only, but what if I can't guess in compile time if there's an override at all? The latter call would return null. The case is even more complicated, if the hierarchy of inheritance is bigger. In other words, I want to get the 'top-most' override available, otherwise - the base property. What is the cleanest way to achieve the aim? Only one I know at the moment is to go through all properties and check name and declaring type.

    Read the article

  • .NET Settings File Available Types

    - by Mashmagar
    When modifying a .NET settings file, I'm given a choice of types for a setting. However, not all of the types accessible by my project appear, even in the 'Browse' window. What determines if a type can be used for a setting file setting? I have a type I created that I would like to be able to save, and I want to know what I need to change about it to use it in a settings file. (VS 2008 - .Net 3.5)

    Read the article

  • Serializing Class Derived from Generic Collection yet Deserializing the Generic Collection

    - by Stacey
    I have a Repository Class with the following method... public T Single<T>(Predicate<T> expression) { using (var list = (Models.Collectable<T>)System.Xml.Serializer.Deserialize(typeof(Models.Collectable<T>), FileName)) { return list.Find(expression); } } Where Collectable is defined.. [Serializable] public class Collectable<T> : List<T>, IDisposable { public Collectable() { } public void Dispose() { } } And an Item that uses it is defined.. [Serializable] [System.Xml.Serialization.XmlRoot("Titles")] public partial class Titles : Collectable<Title> { } The problem is when I call the method, it expects "Collectable" to be the XmlRoot, but the XmlRoot is "Titles" (all of object Title). I have several classes that are collected in .xml files like this, but it seems pointless to rewrite the basic methods for loading each up when the generic accessors do it - but how can I enforce the proper root name for each file without hard coding methods for each one? The [System.Xml.Serialization.XmlRoot] seems to be ignored. When called like this... var titles = Repository.List<Models.Title>(); I get the exception <Titlesxmlns=''> was not expected. The XML is formatted such as. .. <?xml version="1.0" encoding="utf-16"?> <Titles xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Title> <Id>442daf7d-193c-4da8-be0b-417cec9dc1c5</Id> </Title> </Titles> Here is the deserialization code. public static T Deserialize<T>(String xmlString) { System.Xml.Serialization.XmlSerializer XmlFormatSerializer = new System.Xml.Serialization.XmlSerializer(typeof(T)); StreamReader XmlStringReader = new StreamReader(xmlString); //XmlTextReader XmlFormatReader = new XmlTextReader(XmlStringReader); try { return (T)XmlFormatSerializer.Deserialize(XmlStringReader); } catch (Exception e) { throw e; } finally { XmlStringReader.Close(); } }

    Read the article

  • Passing an instantiated class to concrete class derived by Castle Windsor

    - by Tr1stan
    I have a system that I'm using to test some new architecture. I have the following setup (In MVC2 .Net - C Sharp): View < Controller < Service < Repository < DB I'm using Castle Windsor as my DI (IoC) controller, and this is working just fine in both the Service and Repo layers. However, I'm now at a point where I would like to pass an Entity Framework (DatabaseNameEntity) to the constructor to the Service, and then to the Repo, so that I have something similar to a Unit of Work pattern per request (This feels like what I'm trying to achieve anyway) - and I'm having trouble working out how this can be done using Castle Windsor. Am I going off on a silly tangent? Any pointers appreciated.

    Read the article

  • Subcontrols not visible in custom control derived from another control

    - by Gacek
    I'm trying to create a custom control by deriving from a ZedGraphControl I need to add a ProgressBar to the control, but I encountered some problems. When I create a custom control and add both, ZedGraphCOntrol and ProgressBar to it, everything is OK: MyCustomControl { ZedGraphControl ProgressBar } All elemnets are visible and working as expected. But I need to derive from ZGC and when I add a progress bar as a subcontrol of ZedGraphControl: MyCustomControl : ZedGRaphControl { ProgressBar } The progress bar is not visible. Is there any way to force the visibility of ProgressBar? Is it possible, that ZedGraphControl is not displaying its subcontrols? I tried do the same thing with a simple button and it's also not being displayed.

    Read the article

  • C++ LNK2019 error with constructors and destructors in derived classes

    - by BLH
    I have two classes, one inherited from the other. When I compile, I get the following errors: 1Entity.obj : error LNK2019: unresolved external symbol "public: __thiscall Utility::Parsables::Base::Base(void)" (??0Base@Parsables@Utility@@QAE@XZ) referenced in function "public: __thiscall Utility::Parsables::Entity::Entity(void)" (??0Entity@Parsables@Utility@@QAE@XZ) 1Entity.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall Utility::Parsables::Base::~Base(void)" (??1Base@Parsables@Utility@@UAE@XZ) referenced in function "public: virtual __thiscall Utility::Parsables::Entity::~Entity(void)" (??1Entity@Parsables@Utility@@UAE@XZ) 1D:\Programming\Projects\Caffeine\Debug\Caffeine.exe : fatal error LNK1120: 2 unresolved externals I really can't figure out what's going on.. can anyone see what I'm doing wrong? I'm using Visual C++ Express 2008. Here are the files.. "include/Utility/Parsables/Base.hpp" #ifndef CAFFEINE_UTILITY_PARSABLES_BASE_HPP #define CAFFEINE_UTILITY_PARSABLES_BASE_HPP namespace Utility { namespace Parsables { class Base { public: Base( void ); virtual ~Base( void ); }; } } #endif //CAFFEINE_UTILITY_PARSABLES_BASE_HPP "src/Utility/Parsables/Base.cpp" #include "Utility/Parsables/Base.hpp" namespace Utility { namespace Parsables { Base::Base( void ) { } Base::~Base( void ) { } } } "include/Utility/Parsables/Entity.hpp" #ifndef CAFFEINE_UTILITY_PARSABLES_ENTITY_HPP #define CAFFEINE_UTILITY_PARSABLES_ENTITY_HPP #include "Utility/Parsables/Base.hpp" namespace Utility { namespace Parsables { class Entity : public Base { public: Entity( void ); virtual ~Entity( void ); }; } } #endif //CAFFEINE_UTILITY_PARSABLES_ENTITY_HPP "src/Utility/Parsables/Entity.cpp" #include "Utility/Parsables/Entity.hpp" namespace Utility { namespace Parsables { Entity::Entity( void ) { } Entity::~Entity( void ) { } } }

    Read the article

  • Model relationship types in cakePhP

    - by kwokwai
    I have checked out the cookbook web site of cakephp that there are four types Model relationship: http://book.cakephp.org/view/79/Relationship-Types Since the one I am more familiar with is belongsTo, I am not sure when I need to use hasManay and HABTM. What will be the result to my web site if I used a wrong Model relationship type? Please advise.

    Read the article

  • Complex derived attributes in Django models

    - by rabidpebble
    What I want to do is implement submission scoring for a site with users voting on the content, much like in e.g. reddit (see the 'hot' function in http://code.reddit.com/browser/sql/functions.sql). My submission model currently keeps track of up and down vote totals. Currently, when a user votes I create and save a related Vote object and then use F() expressions to update the Submission object's voting totals. The problem is that I want to update the score for the submission at the same time, but F() expressions are limited to only simple operations (it's missing support for log(), date_part(), sign() etc.) From my limited experience with Django I can see 4 options here: extend F() somehow (haven't looked at the code yet) to support the missing SQL functions; this is my preferred option and seems to fit within the Django framework the best define a scoring function (much like reddit's 'hot' function) in my database, and have Django use the value of that function for the value of the score field; as far as I can tell, #2 is not possible wrap my two step voting process in a suitably isolated transaction so that I can calculate the voting totals in Python and then update the Submission's voting totals without fear that another vote against the submission could be added/changed in the meantime; I'm hesitant to take this route because it seems overly complex - what is a "suitably isolated transaction" in this case anyway? use raw SQL; I would prefer to avoid this entirely -- what's the point of an ORM if I have to revert to SQL for such a common use case as this! (Note that this coming from somebody who loves sprocs, but is using Django for ease of development.) Before I embark on this mission to extend F() (which I'm not sure is even possible), am I about to reinvent the wheel? Is there a more standard way to do this? It seems like such a common use case and yet in an hour of searching I have yet to find a common solution...

    Read the article

  • Multiple Connection Types for one Designer Generated TableAdapter

    - by Tim
    I have a Windows Forms application with a DataSet (.xsd) that is currently set to connect to a Sql Ce database. Compact Edition is being used so the users can use this application in the field without an internet connection, and then sync their data at day's end. I have been given a new project to create a supplemental web interface for displaying some of the same reports as the Windows Forms application so certain users can obtain reports without installing the Windows app. What I've done so far is create a new Web Project and added it to my current Solution. I have split both the reports (.rdlc) and DataSets out of the Windows Forms project into their own projects so they can be accessed by both the Windows and Web applications. So far, this is working fine. Here's my dilemma: As I said before, the DataSets are currently set up to connect to a local Sql Ce database file. This is correct for the Windows app, but for the Web application I would like to use these same TableAdapters and queries to connect to the Sql Server 2005 database. I have found that the designer generated, strongly-typed TableAdapter classes have a ConnectionModifier property that allows you to make the TableAdapter's Connection public. This exposes the Connection property and allows me to set it, however it is strongly-typed as a SqlCeConnection, whereas I would like to set it to a SqlConnection for my Web project. I'm assuming the DataSet Designer strongly-types the Connection, Command, and DataAdapter objects based on the Provider of the ConnectionString as indicated in the app.config file. Is there any way I can use some generic provider so that the DataSet Designer will use object types that can connect to both a Sql Ce database file AND the actual Sql Server 2005 database? I know that SqlCeConnection and SqlConnection both inherit from DbConnection, which implements IDbConnection. Relatively, the same goes for SqlCeCommand/SqlCommand:DbCommand:IDbCommand. It would be nice if I could just figure out a way for the designer to use the Interface types rather than the strong types, but I'm hesitant that that is possible. I hope my problem and question are clear. Any help is much appreciated. Let me know if there's anything I can clarify.

    Read the article

  • Custom HTMLControl derived from HtmlImage control not visible in VS2008 toolbox

    - by Tinvan
    I have a custom control deriving from HtmlImage control which I cant get to show up on toolbox, it says "There are no components in '...\bin\Debug\ImageCustomControl.dll' that can be placed on the toolbox.". Here is the code for the control: namespace ImageCustomControl { public class ImageHtmlControl : HtmlImage { public override void RenderControl(HtmlTextWriter writer) { this.Src = "https://somedomain.com" + this.Src; base.RenderControl(writer); } } } Here is a post back from 2003 that says its not possible, but just wanted to know if it has changed since: http://www.microsoft.com/mspress/books/sampchap/5728d.aspx Thanks in advance.

    Read the article

  • Model binding & derived model classes

    - by Richard Ev
    Does ASP.NET MVC offer any simple way to get model binding to work when you have model classes that inherit from others? In my scenario I have a View that is strongly typed to List<Person>. I have a couple of classes that inherit from Person, namely PersonTypeOne and PersonTypeTwo. I have three strongly typed partial views with names that match these class names (and render form elements for the properties of their respective models). This means that in my main View I can have the following code: <% for(int i = 0; i < Model.Count; i++) { Html.RenderPartial(Model[i].GetType().Name, Model[i]); } %> This works well, apart from when the user submits the form the relevant controller action method just gets a List<Person>, rather than a list of Person, PersonTypeOne and PersonTypeTwo. This is pretty much as expected as the form submission doesn't contain enough information to tell the default model binder to create any instances of PersonTypeOne and PersonTypeTwo classes. So, is there any way to get such functionality from the default model binder?

    Read the article

  • Forward declaration of derived inner class

    - by Loom
    I ran into problem implementing some variations of factory method. // from IFoo.h struct IFoo { struct IBar { virtual ~IBar() = 0; virtual void someMethod() = 0; }; virtual IBar *createBar() = 0; }; // from Foo.h struct Foo : IFoo { // implementation of Foo, Bar in Foo.cpp struct Bar : IBar { virtual ~Bar(); virtual void someMethod(); }; virtual Bar *createBar(); // implemented in Foo.cpp }; I'd like to place declaration of Foo::Bar in Foo.cpp. For now I cannot succeed: struct Foo : IFoo { //struct Bar; //1. error: invalid covariant return type // for ‘virtual Foo::Bar* //struct Bar : IBar; //2. error: expected ‘{’ before ‘;’ token virtual Bar *createBar(); // virtual IBar *createBar(); // Is not acceptable by-design }; Is there a trick to have just forward declaration of Boo in Foo.hpp and to have full declaration in Foo.cpp?

    Read the article

  • Interoperability when returning derived class by base class in WCF

    - by mt_serg
    I have some simple code: [DataContract] [KnownType(typeof(SpecialEvent))] public class Event { //data } [DataContract] public class SpecialEvent : Event { //data } [ServiceContract] public interface IService { [OperationContract] List<Event> GetEvents(); } [ServiceBehavior] public class Service : IService { public List<Event> GetEvents() { List<Event> events = new List<Event>(); events.Add(new Event()); events.Add(new SpecialEvent()); return events; } } I know that it works fine in case wcf to wcf. but what about interoperability? is it generate standart wsdl and any client can use the service or no?

    Read the article

  • C#/ASP.NET MVC 4 Instantiate Object Derived From Interface In Factory Method

    - by Chris
    Currently have a Factory class that features a GetSelector function, which returns a concrete implementation of ISelector. I have several different classes that implement ISelector and based on a setting I would like to receive the appropriate ISelector back. public interface ISelector { string GetValue(string Params); } public class XmlSelector : ISelector { public string GetValue(string Params) { // open XML file and get value } } public static class SelectorFactory { public static ISelector GetSelector() { return new XmlSelector(); // Needs changing to look at settings } } My question is what is the best way to store the setting? I am aware of using AppSettings etc. but I'm not sure whether I want to have to store strings in the web.config and perform a switch on it - just seems to be really tightly coupled in that if a new implementation of ISelector is made, then the Factory would need to be changed. Is there any way of perhaps storing an assembly name and instantiating based on that? Thanks, Chris

    Read the article

< Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >