VS 2008 Extending Sealed Classes?

Apr 1, 2010

Briefly, what I'm trying to do is add some methods and properties to the FileInfo class, which is sealed (NotInheritable). As far as I can tell, I have two options to do this.

1) Inherit from FileSystemInfo (the base class for FileInfo) and recreate the methods and properties added by FileInfo (essentially recreating the FileInfo class from scratch)

2) Use extension methods (??) which I just learned about two minutes ago and it being 1am, I'm going to get into this tomorrow

3) Create a wrapper class around a FileInfo object - I think that's the proper term

Ok, so I guess there are 3 options.

A) Why make a class uninheritable

B) Is creating a wrapper class "basically" the same as inheriting from an object, but at least with inheritence you don't need to create any properties and methods other than those you want to modify or add?

Am I correct when I say that a Field is a protected property that can only be accessed by the base class and inherited classes, or is the definition of a field something else?

View 2 Replies


ADVERTISEMENT

.net - Extending Sealed Intrinsic Datatypes Using CompilerServices.Extensions-No Way To Reuse?

Nov 11, 2010

I defined the following extension of the Date? data type

[Code]...

But when I moved my compiler definition to a separate DLL, I the ToObject method was no longer available from my project even though I had referenced the Class project which now contained the extension. Is this a limitation of the Compiler Extensions? HOw do you get reusability out of them?

View 1 Replies

.net - Extending Web Service Proxy Classes?

Jul 28, 2011

I need to add functionality to my web service calls so object translation and automatic retries are done and abstracted away.I would usually override the base class to add the extra functionality, but as the proxy methods aren't over-ridable I can't keep the method names the same. The only other option I can think of to do it this way is to use the 'Shadows' keyword to achieve what I want.What other methods do people use to add functionality to their web service proxy classes without modifying the generated classes?

View 1 Replies

Inheritance In Classes And Extending Subs ?

Feb 26, 2011

I've been wondering if there is anyway to extend a sub of a base class in a derived class or subclass. To date, the only thing I've been able to find is overrides and overloads functions, but to my understanding these functions just ignore your base class's sub and just allows you to run the new one with the same name.

What I want to be able to do is:

CODE:

I'm not sure whether this is possible, or if I'd simply either make a new sub in my derived class that first ran the base's class sub or whether I'd override the base class and then copy and paste the old code.

View 6 Replies

Extending Classes: Adding Shared Procedures?

Nov 2, 2009

is there anyway we could extend a shared function for a class? example:

<Extension()> Public Shared Function GetName(ByRef e As [Enum], ByVal value As Object) As String
Return [Enum].GetName(e.GetType, value)

[Code].....

however i dun hav a choice as Extension methods can be declared only within modules

View 21 Replies

Interfaces, Type Identity, Extending .net Native Classes?

Jun 18, 2010

So in a lot of frameworks there is usually some base type that you tend to extend a lot because well, it is what enables the "visual" aspect of the framework. Here in .Net it's the Control/Form... you tend to be inheriting these frequently for different things, and despite the suggestions otherwise, the team always agrees to extend explicitly and forget about composition.So now say you want to create some relationship between all of these... just a simple interface that uncovers some basic properties that all your forms and controls should have. In this case lets call it 'IProjControl'

Code:
Public Interface IProjControl
Property ProjControlId() As String

[code]....

So this interface is something you expect all your windows and dialog boxes and other some other controls implement. They all don't extend the same exact type, they all just happen to be controls.In there lies the problem... you want to enforce the contract with this interface that not only is it a 'IProjControl', but it's also a 'Control'. But we can't exactly have our interface extend Control (that doesn't make sense), and there isn't an 'IControl' interface to require implementing.

So the method I've always used is something like this:

Code:
Public Interface IProjControl
ReadOnly Property ProjControlComponent() As Control
Property ProjControlId() As String

[code]....

(if there is actually a language/compiler specific feature that allows you to require an interface implementation to be implemented by a class extending a specific type... please, do tell... but I highly doubt there is because for all intensive purposes that sounds weird).

View 12 Replies

VS 2008 Extending VB Program To Linux And UNIX?

Jan 13, 2012

I have a program built on VB.NET and C# . It calls Win32 API and another APIs we made and others (WodSSH and DevExpress).Now we plan to extend our tool to run on Linux and UNIX GUI for UNIX end-users. We have doubts whether to try to import the program somehow (I heard about Mono and Wine) or build it from scratch in Java.

View 6 Replies

Declare As A Sealed Class (non-inheritable)

Aug 16, 2010

How to declare this as a sealed class (non-inheritable) I used this in my main coding..

[Code]...

View 6 Replies

Does Making A Class NotInheritable In .NET Offer The Same (potential) Compiler Optimizations As Sealed In C#?

Jan 11, 2010

I've read that making a class sealed in C# is advisable in high-performance scenarios because it frees the compiler to make certain optimizations (e.g., inlining property getters) that it wouldn't be able to make otherwise. Is the same true for NotInheritable in VB.NET?

View 1 Replies

Use LINQ To Filter Collection Of Nested Classes To Yield Dictionary Of Unique Properties Of Those Classes?

Jan 23, 2012

I have two classes, one nested in the other. [code]Neither "Name" or "ID" are unique between operations and records.I wish to construct a dictionary using LINQ = Dictionary(Of String, Of List(Of Integer), whereby the keys are uniqe examples of Names in my collection and the values are the collective set of distinct IDs that are associated with those names.

View 2 Replies

VS 2010 Structure Classes So That The User Interfaces Though A Single Class While The Supporting Classes Are Hidden From Their View?

Jun 13, 2012

How can I structure my classes so that the user interfaces though a single class while the supporting classes are hidden from their view? I think its best understood in an example:

Public Class MyInterface
Public Economic as EconomicClass
Public Sub New()
MyBase.New()

[code].....

So you might ask why am I even separating them? It's strictly for others who will be working with this interface. I need to funnel them though a logical structure:

interface.Economic.MyMethod
interface.Currency.MyMethod
etc

This way everything is already handled for them in the background and they only need to run the method they need. I don't know if I can have it both ways in VB.NET.

View 23 Replies

C# - Extending The Base Class?

Mar 5, 2010

When you create a webpage in ASP.net, the codebase inherits System.Web.UI.Page Now when I extend the page object to check for SessionExpired for example, I create a new class and inherit from system.web.ui.page, and overwrite some functions. The problem then is that on each page, I have to replace system.web.ui.page with my custompage class. Is there a way to extend a class by adding methods or modifying its methods directly (e.g. add the sessionExpired check to System.Web.UI.Page) ?I'm using .NET 2.0

View 2 Replies

Extending A Class By Namespace?

Mar 17, 2011

I have a class within a library, with no root namespace, firstone.dll:

namespace first
public partial class one
public sub fun()

[Code]....

Is there a way to extend the class in a separate dll and still have access to the original class? I don't want to inherit the class just extend it.

View 3 Replies

VS 2010 Extending An Enum?

Jun 27, 2011

I know from .NET 3.5 onwards (or might be 3.0) we can use Exension Methods to add our own methods to any Type in the .NET Framework and this is very handy, but I'm wondering if it is possible to "extend" an Enum as well?

View 13 Replies

VS 2010 Extending DataGridView?

Aug 19, 2011

I would like to create a DataGridView that displays records that fill either 18 or 35 columns. I would like to avoid displaying all 35 columns for all records, instead showing the 17 extra columns on a second row for records that need them.How would I go about this? I'm guessing I need to create a new class that inherits from DataGridViewRow and override it's Paint or PaintCells method, but I have no experience with overriding Paint events, so I'm kind of lost after that.

View 8 Replies

VS 2010 Calling Subs And Functions Within Classes That Are Within Classes?

Oct 24, 2009

Here is some example code of what I mean:

vb
Public Class Form1
Private Sub Button1_Click(ByVal sender as Object, e as systemEventArgs) Handles Button1.Click

[Code]....

View 5 Replies

C# - Extending An Object And Any Child Collections?

Jul 30, 2009

I have an class named Foo. This class contains a collection of child objects of type FooChildBase, but I also have a further class of type FooChildTwo which inherits from FooChildBase.

Class Foo
Public Children As IList(Of FooChildBase)
End Class
Class FooChildBase

[code]....

What I would like to do is have my FooSpecial Class treat it's Children collection as if they were FooChildSpecial objects, but still be able to add FooChildTwo objects to it. Is this possible and if so how can it be done?

EDIT:I need to FooChildSpecial class to wrap any of the objects in the Children collection with the extra values, whether they are FooChildBase or FooChildTwo?

View 3 Replies

Extending Or Creating A Custom Vb Component?

Jan 11, 2010

I am wondering if I can extend a component (e.g a button ) in vb the same way I can in java which enables you to modify the component for your specific requirement or create a new one from scratch.

View 3 Replies

Extending The LoggingFacility In Castle Windsor?

Oct 31, 2011

I'm currently using the log4net portion of the Castle Windsor logging facility, like so:

objContainer.AddFacility("logging", New LoggingFacility(LoggerImplementation.Log4net)WithConfig("ConfigsLog4net.config"))

I need to pass in a couple of variables to the logger because I am using dynamic log file names. I have looked at the source code and determined that one possible course of action is to create a custom factory and facility but this is alot of work and I'm not sure it is best practice.

View 1 Replies

Derived Classes Cannot Raise Base Classes

Jul 10, 2009

I m trying to raise Click event of Textbox explictly but I m getting "Derived classes cannot raise base classes" error.[code]....

View 1 Replies

.net - ASP.net: Extending Or Adding Pieces To Existing BoundField

Nov 5, 2010

Is it possible to add a property to the existing asp:BoundField control without creating a brand new instance to which I'd have to declare <tst:BoundField></tst:BoundField>?

View 1 Replies

C# - Extending Enumeration Definition In A Child Class In .NET?

Jan 4, 2010

I have a base class which needs to define an enumeration:

BaseClass
- SomeEnum

I then need to create two derived classes from the base class and extend the values in the enumeration:

ChildClass1 : BaseClass
- SomeEnum
- SomeEnumValue1

[code]....

In C# or VB.NET can someone provide the syntax to do this?

View 3 Replies

Extending CollectionEditor - Reference It From Studio 2010?

Nov 26, 2010

As the default for visual studio 2010 is set to ".NET Framework 4 Client Profile" and as such that ill be whats available on the clients PCs. So as i'm looking at adding data binding to a listview headercolumns, i was planning on extending the CollectionEditor (if i have to), but the CollectionEditor is only available when you target the full .NET Framework. So therefore i need to create a second solution with that as a target and build my extended CollectionEditor, but how do i get Studio 2010 (not my 'client' project) to reference my extended CollectionEditor?

View 10 Replies

Extending System.Collections.Generic.List(Of T)?

Jan 27, 2010

imagine i want to add an extension method to System.Collections.Generic.List(Of T)

let's say i want to give it .GetUBound which returns Count-1

View 7 Replies

VB - Extending The XMLElement - Create An XML Database For A Class

Oct 11, 2010

I have to create an XML database for a class I'm taking, but I'm running into some problems. I'm trying to pack my data directly into the DOM using some classes I created and derived from the XMLDocument class, I'm trying to do it this way so I can easily manipulate the entries while the document is in memory and save them back to a file without having to mess around too deeply with the XMLDocument class. I'm running into some problems however when I try to typecast the elements I get from calling

Code:

XMLDocument.DocumentElement.Item

I assume that this is happening due to my derived class not being pushed into the DOM when a file is loaded, because it works just fine if I enter the data manually in code.

Code:
Option Explicit On

[CODE].............

Other than writing my own XMLReader I have no idea how to accomplish this, does anyone have an idea how I could go around doing this(other than writing my own XMLReader).

View 3 Replies

.net - Extending ENUM Valus Inherited From Base Object?

Jun 14, 2010

If I defined a ENUM in a base object with serveral default values. When I inherit from the base object I want to add more options the the ENUM list which are specific to the inheriting object.

For example my base could have a ENUM called Direction with values:
None
ALL
Stop
Start

I create a new class call Compass which inherits the base class and what to add the following to the ENUM Direction. I create a new class call Navigation which inherits the base class and what to add the following to the ENUM Direction. So, In my inheriting class haow do I extend the ENUM.

View 1 Replies

Asp.net - Extending The BoundField Class To Add <span> Tag Inside <td> Tag Rendered By Gridview?

Feb 10, 2012

I would like to add a property to the BoundField control that will change rendering as show below.

<td>My Bound Text></td>
Should become
<td><span>My Bound Text</span></td>

This is all I have so far...

Public Class BoundField
Inherits System.Web.UI.WebControls.BoundField
Dim _ellipse As Boolean[code]....

I have the same problem as this poster, however I am using a .net gridview and would like render my html to use the fix offered here.Using CSS to create table cells of a specific width with no word wrapping. EDIT I think I may be going about this all wrong, maybe you don't change the rendering by extending the BoundField, but rather add the properties to the boundfield then change the way the gridview renders its fields based on the properties of those fields.Which also leads me down the path of control adapters,

View 1 Replies

C# - Extending System.String For Custom EditTemplate (Ajax) Implementation

Sep 29, 2011

This is the following. Normally, when i have a city, i'm using some javascript to autocomplete the cities as the user type. Now i want it to make it automaticly, using the edittemplate. So i would change :

[Code]...

View 2 Replies

LINQ To SQL: Reference The Data Context When Extending A Table Object?

Jul 27, 2009

If I'm extending OnCreated for a LINQ to SQL table object, is it possible to get a reference to the data context to which the table belongs? For example, if I add a property to the data context:

Partial Class MyDataContext
Private _myValue As String
Public ReadOnly Property MyValue As String

[Code].....

I don't want the property on the data context to be Shared, because it could be different per instance. I've been pouring over the designer code to figure out where the reference might be, but no luck yet.

View 3 Replies

VS 2008 Do New Classes 'leak'?

Jul 15, 2009

If I have something like this within a sub/function:Dim a as new myclass...Does this leave a memory leak if I am constantly calling this function creating new instances of this class? Do I have to destroy it or something when I am done using it?

View 2 Replies







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