473,805 Members | 2,017 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What Does this Mean?

I found the following class on the Web:

public class LoginRewriter : IHttpModule {

void IHttpModule.Dis pose() { }

void IHttpModule.Ini t(HttpApplicati on app) {
app.AuthorizeRe quest += new EventHandler(au thorizeRequest) ;
}

Nov 25 '07 #1
9 1967

LoginRewriter implements the interface IHttpModule; yes, you can call the
two methods implemented but there isn't a lot of implementation of Dispose()
here ...

"Jonathan Wood" <jw***@softcirc uits.comwrote in message
news:eo******** *****@TK2MSFTNG P06.phx.gbl...
>I found the following class on the Web:

public class LoginRewriter : IHttpModule {

void IHttpModule.Dis pose() { }

void IHttpModule.Ini t(HttpApplicati on app) {
app.AuthorizeRe quest += new EventHandler(au thorizeRequest) ;
}

.
.
.
}

Can someone tell me what this syntax means? Are these methods simply
exposing protected methods of the base class? If so, does that mean you
could do the following:

LoginRewriter lr = new LoginRewriter() ;
lr.Dispose();
lr.Init(...);

Thanks.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

Nov 25 '07 #2
I'm not asking about what the class does. I'm trying to understand the
syntax. What is the purpose of:

void IHttpModule.Dis pose() {}

In the class definition? It appears to override a derived method but appears
to override it with nothing. In C++, I'd just do that with Dispose() {}, but
don't see the usefullness of either.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
"Barrie Wilson" <bw*****@nowher e.comwrote in message
news:13******** *****@corp.supe rnews.com...
>
LoginRewriter implements the interface IHttpModule; yes, you can call the
two methods implemented but there isn't a lot of implementation of
Dispose() here ...

"Jonathan Wood" <jw***@softcirc uits.comwrote in message
news:eo******** *****@TK2MSFTNG P06.phx.gbl...
>>I found the following class on the Web:

public class LoginRewriter : IHttpModule {

void IHttpModule.Dis pose() { }

void IHttpModule.Ini t(HttpApplicati on app) {
app.AuthorizeRe quest += new EventHandler(au thorizeRequest) ;
}

.
.
.
}

Can someone tell me what this syntax means? Are these methods simply
exposing protected methods of the base class? If so, does that mean you
could do the following:

LoginRewrite r lr = new LoginRewriter() ;
lr.Dispose() ;
lr.Init(...) ;

Thanks.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

Nov 25 '07 #3
It's not overriding anything. If IHttpModule implements IDisposable, that's
why you are looking at a do-nothing barebones implementation of the required
member.
--
--Peter
"Inside every large program, there is a small program trying to get out."
http://www.eggheadcafe.com
http://petesbloggerama.blogspot.com
http://www.blogmetafinder.com

"Jonathan Wood" wrote:
I'm not asking about what the class does. I'm trying to understand the
syntax. What is the purpose of:

void IHttpModule.Dis pose() {}

In the class definition? It appears to override a derived method but appears
to override it with nothing. In C++, I'd just do that with Dispose() {}, but
don't see the usefullness of either.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
"Barrie Wilson" <bw*****@nowher e.comwrote in message
news:13******** *****@corp.supe rnews.com...

LoginRewriter implements the interface IHttpModule; yes, you can call the
two methods implemented but there isn't a lot of implementation of
Dispose() here ...

"Jonathan Wood" <jw***@softcirc uits.comwrote in message
news:eo******** *****@TK2MSFTNG P06.phx.gbl...
>I found the following class on the Web:

public class LoginRewriter : IHttpModule {

void IHttpModule.Dis pose() { }

void IHttpModule.Ini t(HttpApplicati on app) {
app.AuthorizeRe quest += new EventHandler(au thorizeRequest) ;
}

.
.
.
}

Can someone tell me what this syntax means? Are these methods simply
exposing protected methods of the base class? If so, does that mean you
could do the following:

LoginRewriter lr = new LoginRewriter() ;
lr.Dispose();
lr.Init(...);

Thanks.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

Nov 25 '07 #4

"Jonathan Wood" <jw***@softcirc uits.comwrote in message
news:uG******** ******@TK2MSFTN GP03.phx.gbl...
I'm not asking about what the class does. I'm trying to understand the
syntax. What is the purpose of:

void IHttpModule.Dis pose() {}

In the class definition? It appears to override a derived method but
appears to override it with nothing. In C++, I'd just do that with
Dispose() {}, but don't see the usefullness of either.
Jon,

as you can see clearly enough, Dispose() here does absolutely nothing ...
its apparent "purpose" is to comply with the rules of the road; if you
implement an interface (IHttpModule in this case) you MUST provide an
implementation of all the methods in that interface ... the compiler demands
it

I don't know in what way you're confused about the *syntax* ....

you asked:

"Are these methods simply exposing protected methods of the base class?"

since the class you found (LoginRewriter) implemented IHttpModule, there
were no methods to "expose" .. there were two methods requiring
implementation and that's what the class author provided, albeit nominally

I'm assuming your confusion stems from not recognizing that IHttpModule is
an interface ... that uppercase "I" is normally a pretty strong clue ...

HTH


Nov 26 '07 #5
Thanks. I'm coming from a C++ background and I just don't understand what
that syntax is doing.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

"Peter Bromberg [C# MVP]" <pb*******@yaho o.NoSpamMaam.co mwrote in message
news:CB******** *************** ***********@mic rosoft.com...
It's not overriding anything. If IHttpModule implements IDisposable,
that's
why you are looking at a do-nothing barebones implementation of the
required
member.
--
--Peter
"Inside every large program, there is a small program trying to get out."
http://www.eggheadcafe.com
http://petesbloggerama.blogspot.com
http://www.blogmetafinder.com

"Jonathan Wood" wrote:
>I'm not asking about what the class does. I'm trying to understand the
syntax. What is the purpose of:

void IHttpModule.Dis pose() {}

In the class definition? It appears to override a derived method but
appears
to override it with nothing. In C++, I'd just do that with Dispose() {},
but
don't see the usefullness of either.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
"Barrie Wilson" <bw*****@nowher e.comwrote in message
news:13******* ******@corp.sup ernews.com...
>
LoginRewriter implements the interface IHttpModule; yes, you can call
the
two methods implemented but there isn't a lot of implementation of
Dispose() here ...

"Jonathan Wood" <jw***@softcirc uits.comwrote in message
news:eo******** *****@TK2MSFTNG P06.phx.gbl...
I found the following class on the Web:

public class LoginRewriter : IHttpModule {

void IHttpModule.Dis pose() { }

void IHttpModule.Ini t(HttpApplicati on app) {
app.AuthorizeRe quest += new EventHandler(au thorizeRequest) ;
}

.
.
.
}

Can someone tell me what this syntax means? Are these methods simply
exposing protected methods of the base class? If so, does that mean
you
could do the following:

LoginRewrite r lr = new LoginRewriter() ;
lr.Dispose() ;
lr.Init(...) ;

Thanks.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

Nov 26 '07 #6
Barrie,
as you can see clearly enough, Dispose() here does absolutely nothing ...
its apparent "purpose" is to comply with the rules of the road; if you
implement an interface (IHttpModule in this case) you MUST provide an
implementation of all the methods in that interface ... the compiler
demands it

I don't know in what way you're confused about the *syntax* ....
My background is C++. I'm not familiar with declaring methods with the base
class name followed by a dot, and the method name.

So my guess is that you are saying that IHttpModule implements a
pure-virtual method Displose(), which the derived class must implement (even
if the implementation does nothing). But I would have thought that could be
accomplished without prefixing the method name with base class name.
you asked:

"Are these methods simply exposing protected methods of the base class?"

since the class you found (LoginRewriter) implemented IHttpModule, there
were no methods to "expose" .. there were two methods requiring
implementation and that's what the class author provided, albeit nominally
Doesn't it implement IHttpModule using inheritance? So I don't get why it's
not possible to provide some sort of access to base class methods that were
previously protected. Apparently, that's not happening here but I don't see
what your statement "there were no methods to expose" is based on.
I'm assuming your confusion stems from not recognizing that IHttpModule is
an interface ... that uppercase "I" is normally a pretty strong clue ...
In C++, it seemed like an interface was just a logical construct and was
really no different from a virtual class. Obviously, C# is different. Looks
like I don't get how. Yes, I understood the "I" prefix denoted an interface.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

Nov 26 '07 #7

"Jonathan Wood" <jw***@softcirc uits.comwrote in message
news:Ob******** ******@TK2MSFTN GP06.phx.gbl...
My background is C++. I'm not familiar with declaring methods with the
base class name followed by a dot, and the method name.
the dotted notation is only to avoid naming conflicts .. you can define an
interface at file scope or class-nested, and you can use the visibility
modifiers
So my guess is that you are saying that IHttpModule implements a
pure-virtual method Displose(), which the derived class must implement
(even if the implementation does nothing). But I would have thought that
could be accomplished without prefixing the method name with base class
name.
IHttpModule implements nothing; it declares the method signatures and says,
if you use this interface, **you** must implement the methods, properties
and events in the interface
Doesn't it implement IHttpModule using inheritance? So I don't get why
it's not possible to provide some sort of access to base class methods
that were previously protected. Apparently, that's not happening here but
I don't see what your statement "there were no methods to expose" is based
on.
because, in effect, there is nothing to inherit other than the method
signatures ... if you looked at the source for IHttpModule, you'd see
something like:

interface IHttpModule
{
void Dispose();
void Init(HttpApplic ation context);
}

that's it .. so what kind of "access to base class methods" is meaningful in
any way?
In C++, it seemed like an interface was just a logical construct and was
really no different from a virtual class. Obviously, C# is different.
Looks like I don't get how. Yes, I understood the "I" prefix denoted an
interface.
interfaces and abstract classes share common ground, although a method in an
abstract class can have implementation; often you can take your choice of
which to use

interfaces are easy to understand in formal terms; in functional and
conceptual terms it takes a fair amount of work/time to fully grasp why they
exist and the ways they're useful ... I'm not fully there yet but I know you
have to get there if you're going to lay claim to anything resembling
"expertise" .. they're important, period.

I would recommend something to read but frankly I have seen nothing yet
which does a really good job covering the topic ... best bet I think would
be Jeff Richter's "CLR via C#" ... which is something you should own and
read in any case ... that said, there is of course a ton of material
available

Coming from C# you might also go to http://www.charlespetzold.com and look
for the link to his free PDF book written just for people coming from C++



Nov 26 '07 #8
Barrie,
IHttpModule implements nothing; it declares the method signatures and
says, if you use this interface, **you** must implement the methods,
properties and events in the interface
Okay, so while an interface is similar to an inherited class, you're saying
the difference is that the interface cannot include any implementation.

And so where I asked about overriding a method, it is more accurate to say
implement since there is nothing to override.

The part that is still weird to me is that I must specify the name of the
base class when implementing a method defined in the base class. For now,
I'll just accept that I do.
interfaces are easy to understand in formal terms; in functional and
conceptual terms it takes a fair amount of work/time to fully grasp why
they exist and the ways they're useful ... I'm not fully there yet but I
know you have to get there if you're going to lay claim to anything
resembling "expertise" .. they're important, period.
I've been working with inheritance for many years, so I think I really do
have a good feel for the way interfaces are useful. It's primarily some of
the language differences that I get hung up on.
I would recommend something to read but frankly I have seen nothing yet
which does a really good job covering the topic ... best bet I think would
be Jeff Richter's "CLR via C#" ... which is something you should own and
read in any case ... that said, there is of course a ton of material
available

Coming from C# you might also go to http://www.charlespetzold.com and look
for the link to his free PDF book written just for people coming from C++
CLR via C# sounds interesting. I might take a look at that. (Of course, I
just installed VS2008 so I might want to wait for an update.)

Thanks!

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

Nov 29 '07 #9

"Jonathan Wood" <jw***@softcirc uits.comwrote in message
news:%2******** ********@TK2MSF TNGP03.phx.gbl. ..
Yes, I understand what you are saying here. I believe the code I posted
only implemented a single inheritance so I'm not sure why it specified the
base class. I guess, if nothing else, the base class name is always
optional.
don't think that's quite right either, Jon ... actually, the MS docs
indicate that using the explicit, fully-qualified name is something you
rarely need to do and should avoid ... I have not fully sorted it out at
this point because it's yet to bite me anywhere tender

from the docs:
Avoid implementing interface members explicitly without having a strong
reason to do so.
Understanding explicit implementation requires an advanced level of
expertise. For example, many developers do not know that an explicitly
implemented member is publicly callable even though its signature is
private. Because of this, explicitly implemented members do not appear in
the list of publicly visible members. Explicitly implementing a member can
also cause unnecessary boxing of value types.

Okay, I appreciate the info. I've got a stack of books on ASP.NET and some
C#, but none that focus on the CLR in a broader way. Might be useful.
it is ... it's a useful book ...


Nov 30 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

125
14874
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from software giant such as Microsoft SQL Server, Oracle, and Sybase? Is PostgreSQL reliable enough to be used for high-end commercial application? Thanks
3
29687
by: Jukka K. Korpela | last post by:
I have noticed that the meaning of visibility: collapse has been discussed on different forums, but with no consensus on what it really means. Besides, implementations differ. The specification says: "The 'visibility' property takes the value 'collapse' for row, row group, column, and column group elements. This value causes the entire row or column to be removed from the display, and the space normally taken up by the row or column to...
86
7810
by: Michael Kalina | last post by:
Because when I asked for comments on my site-design (Remember? My site, your opinion!) some of you told me never to change anything on font-sizes! What do you guys think of that: http://www.clagnut.com/blog/348/ I hope that's going to be a good discussion! Michael
44
4293
by: lester | last post by:
a pre-beginner's question: what is the pros and cons of .net, compared to ++ I am wondering what can I get if I continue to learn C# after I have learned C --> C++ --> C# ?? I think there must be many know the answer here. thanks
2
10223
by: Steve Richter | last post by:
What does the "." mean in the following sql script stmts? use GO if exists (select * from dbo.sysobjects where id = object_id(N'.') and OBJECTPROPERTY(id,N'IsUserTable') = 1) drop table . GO
121
10199
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode support IDEs are DreamWeaver 8 and Zend PHP Studio. DreamWeaver provides full support for Unicode. However, DreamWeaver is a web editor rather than a PHP IDE. It only supports basic IntelliSense (or code completion) and doesn't have anything...
51
4574
by: jacob navia | last post by:
I would like to add at the beginning of the C tutorial I am writing a short blurb about what "types" are. I came up with the following text. Please can you comment? Did I miss something? Is there something wrong in there? -------------------------------------------------------------------- Types A type is a definition for a sequence of storage bits. It gives the meaning of the data stored in memory. If we say that the object a is an
1
8747
by: Frank Rizzo | last post by:
Some of the classes in the framework are marked as thread-safe in the documentation. In particular the docs say the following: "Any public static (*Shared* in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe." What exactly does this mean? Does this mean that if I call a shared method from 2 different threads, nothing whacky will happen? Also when it says that instance members...
13
5065
by: Jason Huang | last post by:
Hi, Would someone explain the following coding more detail for me? What's the ( ) for? CurrentText = (TextBox)e.Item.Cells.Controls; Thanks. Jason
9
550
by: JoeC | last post by:
m_iWidth = (int)pBitmapInfo->bmiHeader.biWidth; m_iHeight = (int)pBitmapInfo->bmiHeader.biHeight; What does this mean? I have seen v=&var->member.thing; but what does it mean when you change the & for int?
0
10604
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10356
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10103
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7644
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6874
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5536
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4316
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3839
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3006
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.