Want To Eliminate One Level In Object Hierarchy?

Jun 7, 2010

Not sure how to do thisI have a hierarchy:

Deals at the top
Deals is a collection of Deal
Deal is a collecton of DealSlots

[code]....

View 3 Replies


ADVERTISEMENT

Flattening An Object Hierarchy Using A Shim Class - Initializing Derived Object Properties From The Base Object?

Jul 10, 2010

I am somewhat new to object oriented programming and am attempting to flatten a Linq object hierarchy by using a shim class.how to initalize a derived class with property values from a base class?I have two objects, a base object with about 100 properties, and a derived object which inherits from the base object and adds a few additional properties beyond those of the base object. My simple constructor creates the derived object, but I am looking for a way to initialize the derived object properties with values from the base object.Right now I am using reflection to iterate over the properties individually and I suspect there may be a better way. The following example shows my shim class constructor for the derived class, and two properties:

newProperty1 - a new string property of the derived class

flattenedProperty2 - a new string property of the derived class, copied from a 2nd-level object of the base class

Code example:

Public Class derivedObj
Inherits baseObj
Private _newProperty1 As String[code].......

Is this the correct constructor approach to flatten the object hierarchy using a shim class? My second question relates to initialization of properties in the derived class. The constructor above creates the derived object, but what is the best way to initialize the derived object properties with values from the base object? The following code uses reflection to iterate over the properties individually, but I suspect there may be a better way.

Code example:

' property names are in the string array fieldNames

'baseObjQuery is an ienumerable of baseObj

'derivedObjList is a list of derivedObj[code].....

Is there a simple way to initialize values for the properties in the derived object based upon the values of the common properties in the base object?

View 7 Replies

How To Save Object Hierarchy

May 5, 2010

I have created a set of classes that represent an hierarchySo when I reference like this:

Dim alldeals as deals
alldeals.Deal(5).DealSlot(3).SlotType= "SomeType"
alldeals.Deal(5).DealSlot(4).SlotType= "SomeOtherType"

[code].....

View 3 Replies

Object Hierarchy For Charting?

Jan 27, 2009

I'm looking for advice to make my code efficient in terms of execution speed and memory usage. Basically, how to lay out my objects. The program displays parts of several data series in bar- or line- charts, as well as calculated series based on these data series. The key user input will be to change what part of data series to look at, and that input should trigger instant chart update, with minimal lag.

[Code]...

View 10 Replies

Backgroundworker, Use An Object At Class Level?

Jan 11, 2010

I have a backgroundworker that needs to contact a webservice. But when I run the background worker it just hangs forever at the line where I call a method of the webservice. I suspect this is because the webservice is defined at class level.

View 17 Replies

Application-level KeyUp/KeyDown Events (not Windows Form-level)?

Apr 1, 2012

I am creating an Excel add-in written in VB.NET. I would like to bind KeyDown and KeyUp events to the spreadsheet to record when the user presses and releases the arrow keys while navigating the spreadsheetIdeally, these events would be built into Excel alongside the native SheetActivate and SheetSelectionChange events, for example. Alas, they are not.

View 1 Replies

What's The Difference Between Dim On The Member Level And Static On The Procedure Level

Jan 6, 2010

In Visual Basic 2008, there's two different ways that I know of to accomplish the same thing:The Dim on the member level:

Dim counter1 as integer = 0
Dim counter2 as integer = 180
Public Sub SampleSub1()

[code].....

View 1 Replies

Top Level SQL Table Row - Save The Top Level Automatically?

Mar 18, 2011

I have created a simple program which uses a two tier structure of SQL Tables.At the top level, one record holds the date of the activities and linked to it using its primary key as a foreign key, three subordinate tables hold time stamped records.The issue I have been unable to solve is that before adding any of the lower level records for a given date, a newly added top level record must be saved to the database.Doing this manually is simple - but can I rely on my users to remember to do this before they start plugging in the lower level data?I thought not, so I am looking to save the top level automatically.I've failed miserably but I refuse to believe that it's not possible.

View 14 Replies

How To Program The Hierarchy Like This In .Net

Mar 30, 2011

I am a beginner for using VB.NET. I have a problem in which we have several "Program", each "Program" has N "group", and each group has N "unit", shown as follows. i need to link "Program" and the corresponding "group" and "unit" together. First , the properties of lower layer depends on upper layer's properties. Second, If i delete one "Program", the cooresponding "group" and "unit" will be deleted as well.

[Code]...

View 2 Replies

Event Won't Come Through Class Hierarchy

Feb 2, 2010

I'm writing a Windows Forms application in VB.Net 2008, .NET Framework 3.5, and I am trying to handle an event created by a class that get's instantiated several times throughout the program. The thing is the events gets fired in the Functions class, but nothing's happening in the main class.I tried to change the called class by instantiating it in the beginning of the main class, by using 'WithEvents testEvent as MTO_Tool.Functions = New Functions' but that also didn't work.

Code:

' The main class:
Public Class MainScreen
WithEvents testEvent As MTO_tool.Functions
Private Sub test() Handles testEvent.SaveChanges

[code]....

View 1 Replies

Making A Shape Hierarchy?

Apr 10, 2012

I am working through my Visual Basic Book 2010 book and came across this Program example:Create 3 classes that inherit from a base class named Shape. The Shape class has an instance variable that is the name of the shape and also a CalcArea() function that must be overridden by each subclass. You will need to create the following 3 classes and use the formulas provided to calculate the areas.

Square � Area = sideLength * sideLength
Circle � Area = pi * radius * radius (use Math.Pi for the value of pi)
Triangle � Area = � * base * height

Each subclass should have a constructor that you use to set the name and the attributes required to calculate the area with. Each subclass should also override the CalcArea() function that is provided in the base class Shape. They will also need to implement the toString() method that will print out the shape name, any attributes (ex: sideLength), and the area.It also includes the Shape base class. You will need to add the 3 subclasses and add the appropriate code.

View 5 Replies

Getting All The Parent Hierarchy Until Reaching A Certain Type?

Feb 3, 2009

I could put a Textbox in a Panel then that panel is placed in a TabPage, how do I go out going through the hierarchy of the Textbox parent until reaching the TabPage? My purpose for this is if I want to focus on a Textbox then of course I would have to also select the TabPage where it is located, is there an easier way than what I am planning to do?

View 3 Replies

Regular Expression: List Hierarchy?

Jan 6, 2010

I am working on an opening search screen for a program that grabs information on a file for the user. Subfolders are defined by periods so some possible files include

FolderA.SubFolder1.SetupX.txt
FolderB.SubFolder2.SetupY.txt
FolderB.SetupX.txt
FolderA.SubFolder1.SetupZ.txt

When the search button is clicked all of these are populated into a list box currently using the following function's

[Code]...

The problem is that subfolders will continue to be created with unknown names. I'm thinking I need to use some sort of loop that counts the number of periods and then compares the directories using some sort of negative lookahead to group them. Im still unsure how I'll make it so Clicking Setup Y and hitting OK will be able to maintain that I am opening FolderB.Subfolder2.SetupY.txt and not just SetupY.txt

View 4 Replies

Multiple Level Of For Each And Linq In Each Level

Feb 12, 2011

I have multiple level of For Each and in each level, i have a Linq that is the 'In' criteria as in:

[Code]....

It will go inside each for (because the value is not nothing), however, it will only loop (next) in the very inner 'For Each t In tFor'. After it is finish inner loops, the outer Fors' or Next will not execute... even thought there are more than one values in that 'In'... like 'sFor' or 'fFor'. i've noticed while debuging, while break at the for (for example 'sFor', before stepping in), i get the error message:

"Enumeration yielded no results" when i expand the result for that variable and it will not step into it. but if i do not expand the result, it will step in. It seem that some how, once an element is accessed for that 'In' collection, it breaks (meaning does not loop for the rest of the elements) the next for that collection is this a bug or am i missing something in Linq? BTW: i believe it has something to do with the SqlDataReader in the Linq. I'm working with IAsyncResult.

View 5 Replies

Class Hierarchy - Data Design In An RPG Game

Aug 10, 2010

how to organize the classes within my RPG project that I'm making. I've tried to implement a battle system but I am not comfortable with my initial results. This is the basic layout I currently have for my classes. [Code] clsCharacter contains statistics pertaining to one character, including magic available to that character to use. Also includes what weapons that character has equipped. clsTeam contains multiple clsCharacter, as well as a list of items that each clsCharacter in the team can use. clsBattle contains two clsTeams. One team is the player and the other is the computer. Now, this is a wonderful way to organize data. However, I see limitations with this approach. For instance, to pass data from Battle to Character, it has to pass through the team class and vice-versa. Plus, if I use Properties, it transfers data as ByVal instead of ByRef, so I cannot guarantee that I'm editing the original and not a copy of the passed object (IIRC)

In addition, I feel it is just messy code to include methods within the clsCharacter class that invoke this: MyTeam.MyBattle.DoAction(). Plus, the clsCharacter might not even be in the battle at the time - I don't won't to bog down that class featuring code that is exclusive for battling when I also need to be concerned about moving around the map, saving/loading data, etc. So, any suggestions? Right now, I'm burnt out of ideas. One idea I have so far is to include a function for the clsCharacter that exports a list of all possible moves the character could make, and if the character is CPU choose the most optimal one, and if Human than wrap it up in some nifty GUI so they can choose what action to take. But at the same time, how do I use that information within the context of the battle?

View 2 Replies

Show Folders / Files Hierarchy In TreeView

Mar 5, 2008

Any code snippet they could post that will take a specified folder & show the files & subfolders hierarchy in a TreeView?

View 11 Replies

C# - LINQ To SQL To Query Parent And Count Childs In Hierarchy?

Dec 8, 2010

I'd take both C# and VB.NET suggestion.I'm using LINQ to query data. I'm trying to query the parent and count the child tags.Here's my Tags table column:

TagId (int primary)
TagName
ParentId (int Allow NULL referred to TagId column)

Here's some sample data:

[Code]...

View 3 Replies

Entity Framework 4.2 Table Per Hierarchy Group By Discriminator?

Dec 7, 2011

I am working on a project using an EF 4.2 code first model. This model contains a TPH inheritance structure for products. I need to group the polymorphic results of this inheritance model on the discriminator and am running into some issues.

The entity framework does not expose the discriminator to complete this grouping. My first question is can I get direct access to this discriminator? My reading and experience is telling me no, so I came up with this solution that sort of works. It is not performing well and I am not happy with how it will need to be maintained.

My classes look something like this (simplified):

Public MustInherit Class Product
<key()>
Public Property ProductID as integer

[Code].....

Also, this can give me easy access to shared properties (Name) but now I don't have many options to cast these into their real type, maybe a select case around TypeName.

View 1 Replies

Inheritance Hierarchy For Class Quadrilateral / Square And Rectangle

Sep 30, 2009

I have to write an inheritance hierarchy for class Quadrilateral, square and rectangle. Use Quadrilateral as base class of the hierarchy.

So for I had this:
Public MustInherit Class Quadrilateral
Public Function getName() As String
Return "Shape"
End Function

View 1 Replies

Visual Studio 2010 - Creating Hierarchy Of Files?

May 23, 2012

I'm trying to create heirarchy of classes in vb.net. I was able to achieve it in csharp by using the following tags in .csproj

<Compile Include="ClassA.cs">
<DependentUpon>ClassB.cs</DependentUpon>
</Compile>

Below snippet in the solution explorer would be as follows

I need to achieve the same in vb.net.

I'm new to vb.net. Can anybody tell me the alternative of <DependUpon> attribute used in .csproj equivalent in .vbproj. For some reason, this attribute seems to be ignored in the .vbproj even though it is displayed in the visualstudio2010 intellisence.

View 2 Replies

Eliminate Datagridview Row From Being Selected?

May 26, 2012

Is it possible to prevent any row in a grid from being highlighted? I'm familiar with the "SelectionMode" property. I manually add rows to a DGV and the 1st row is always highlighted. I'm trying to prevent this from happening.

View 2 Replies

Eliminate Decimal Points In VB?

Nov 10, 2007

How to eliminate decimal points in VB.net.what kind of function should i use.

For example, i have number x= 23.13 i only want to show x= 23 and if i have another number x=23.89 i also only want to show x= 23

[code]...

View 14 Replies

Eliminate Portion Of String?

Feb 29, 2012

Lets say I have a variable: varEmail. It contains a variable equal to the user's email address, so it might contain a value likeNow, lets say I want to get just a portion of the email address, e.g. strip off the domain, like so:

View 5 Replies

How To Eliminate Malfunction / Error

Jul 15, 2009

I am trying to get the html source of url...I AM USING THE AXWEBBROWSER AS OPPOESED TO THE CONVENTIONAL ONE..I have this code to display a textbox in my Axwebbrowser containing the Page source when the document is completed. Here is the code: [code] The maximum text length of the textbox = 99999999999..When I try to get the document.Tostring, I get this: System.__ComObject..And When I try to get the Html as a htmldocument I get nothing, and when I try just go get the document I get nothing.Does anyone know how I can eliminate this malfunction / error? Can anyone show me a different code to get the html / source of the document of the webbrowser?

View 6 Replies

How To Eliminate Muliple Records

Feb 14, 2012

I have issue is its creating mlitple records of same check number in payment headerfile1 and payment headerfile2 for diffrent invoices.

[Code]...

View 3 Replies

IDE :: Error ContextSwitchDeadlock - Eliminate?

Feb 13, 2009

when i run code after 60 sec it display following error what is this error and how to eliminate? ContextSwitchDeadlock was detected Message: The CLR has been unable to transition from COM context 0x2040a8 to COM context 0x204218 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations.

View 1 Replies

Class Hierarchy - Data Design In A RPG Game Where Classes Overlap?

Aug 19, 2010

This is a followup to the question I asked here:

[URL]

I understand the answer in the post above, which is absolutely amazing, by the way. It's about implementing interfaces with a class. However, what if a class needs to share features with another class?Yes, that class can an Interface. However, let's use this sample definition.

[code]...

Or, in other words:An equippable item can perform acts outside of its typical usage of a shield or weapon. But not all items can act as a sheid or weapon.I mean, I could create a class that implements IWeapon, IShield, IMagic, IUseableItem, etc. But there should be a better way than returning NULL when those interfaces are called.

View 2 Replies

IDE :: IntelliSense Slow When List Filtering Large DataSet Hierarchy

Nov 21, 2007

I just converted my project from VS 2005 to 2008 and started getting really bad lag only when intellisense iterates my dataset objects. The cpu maxes out one of my cores for about 2-3 seconds each time the intellisense list pops up. Is this a new feature of the 2008 ide?

View 19 Replies

C# - Eliminate These Order Dependencies From Code?

Sep 23, 2009

In ASP.Net Web Forms there are cases that I've come across that create order dependent code. As an obvious code smell I'm looking for solutions to solve this problem.

A pseudo-code example would be: Calling Code :: Page.aspx

protected void Page_Load(...) {
var control = LoadControl("ControlX.ascx");
// Ugly since the control's constructor is not used by LoadControl
control.SetDependencies(...);

[Code]...

LoadControl has two signatures, the one used above accepts a string for the control classes physical location and correctly creates the child controls. Whereas the second signature accepts the control class as a class type, and any parameters for the constructor, however the child controls are not created as detailed in TRULY Understanding Dynamic Controls.

So how can I eliminate this order dependency in the cleanest way? My first thought is that if I dynamically created the child controls in ControlX, but then that can be cumbersome for larger controls.

View 1 Replies

Eliminate Duplicate Random Numbers?

Nov 25, 2011

So basically I'm making a BINGO game on vb 2008 and i have a "call number" button. The letter and numbers get added to a list box each time. But i do not want the same number to be called. Is there a way that the program can read the items in the list box and not generate (Randomly) the same value again to be displayed in the label.This is what i have:

Callnum = Int(75 * Rnd() + 1)
lstNumbersCalled.Items.Add(lblCallLetter.Text & " " & Callnum)

[code].....

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved