D
djohnson
I am trying to port vb code from the article "Another MultiForm Framework
for the Microsoft .NET Compact Framework" located on the OpenNetCF.org
website, http://www.opennetcf.org/articles/istack.asp.
I got as far as the formstack.vb and realized there are some differences
about how interfaces are used between vb and C# that I dont quite
understand.
this being the vb inteface (IStackable)
-----------------------------------------------------
Public Interface IStackable
'Updates the data contained in the form. This should be implemented on a per
form basis
Sub UpdateData()
'Returns the form itself.
Function This() As System.Windows.Forms.Form
'Calls InitializeComponents
Sub InitUI()
End Interface
----------------------------------------------------------------------------
---
I converted to c# as
----------------------------------------------------------------------------
---
using System;
namespace Achieve_PPC
{
/// <summary>
/// Interface for form cache
/// </summary>
public interface IStackable
{
//Updates the data contained in the form. This should be implemented on a
per form basis
void UpdateData();
//Returns the form itself.
Form This();
//Calls InitializeComponents
void InitUI();
}
}
----------------------------------------------------------------------------
------
Now, With this interface can someone explain why the c# cannot access
properties and methods of the interface "This()" method?
basically in vb the code does this...
<snip>----------------------------------------------------------------------
------------
Public Sub Push(ByVal frm As System.Type)
'Only allow 1 Push at a time to maintain cache and stack integrity
Monitor.Enter(Me)
For Each sf As IStackable In InnerList
If frm.Name = sf.This.GetType().Name Then
<===========sf.This.GetType().Name
'We had it cached - ask the form to update its data and display itself
sf.UpdateData()
sf.This.Visible = True
'Push it into the stack
stack.Add(frm.Name)
Return
End If
Next
<snip>----------------------------------------------------------------------
------------
In C# I cant access methods or properties of the interfaces' methods?
as such..
----------------------------------------------------------------------------
----------------
public void Push(Type FormType)
{
// only allow 1 Push at a time to maintain cache and stack itegrity
Monitor.Enter(this);
foreach(IStackable sf in List)
{
if(sf.GetType().Name.Equals(FormType.Name)) <===========CANNOT DO
"sf.This.GetType().Name" Any Idea Why?
{
// form is cached so display cached version
sf.Visible = true;
// add it to the stack
stack.Add(FormType.Name);
return;
}
}
_____________________________________________________
I Hope this makes sense, and I apreciate any help.
Thank You,
David Johnson
for the Microsoft .NET Compact Framework" located on the OpenNetCF.org
website, http://www.opennetcf.org/articles/istack.asp.
I got as far as the formstack.vb and realized there are some differences
about how interfaces are used between vb and C# that I dont quite
understand.
this being the vb inteface (IStackable)
-----------------------------------------------------
Public Interface IStackable
'Updates the data contained in the form. This should be implemented on a per
form basis
Sub UpdateData()
'Returns the form itself.
Function This() As System.Windows.Forms.Form
'Calls InitializeComponents
Sub InitUI()
End Interface
----------------------------------------------------------------------------
---
I converted to c# as
----------------------------------------------------------------------------
---
using System;
namespace Achieve_PPC
{
/// <summary>
/// Interface for form cache
/// </summary>
public interface IStackable
{
//Updates the data contained in the form. This should be implemented on a
per form basis
void UpdateData();
//Returns the form itself.
Form This();
//Calls InitializeComponents
void InitUI();
}
}
----------------------------------------------------------------------------
------
Now, With this interface can someone explain why the c# cannot access
properties and methods of the interface "This()" method?
basically in vb the code does this...
<snip>----------------------------------------------------------------------
------------
Public Sub Push(ByVal frm As System.Type)
'Only allow 1 Push at a time to maintain cache and stack integrity
Monitor.Enter(Me)
For Each sf As IStackable In InnerList
If frm.Name = sf.This.GetType().Name Then
<===========sf.This.GetType().Name
'We had it cached - ask the form to update its data and display itself
sf.UpdateData()
sf.This.Visible = True
'Push it into the stack
stack.Add(frm.Name)
Return
End If
Next
<snip>----------------------------------------------------------------------
------------
In C# I cant access methods or properties of the interfaces' methods?
as such..
----------------------------------------------------------------------------
----------------
public void Push(Type FormType)
{
// only allow 1 Push at a time to maintain cache and stack itegrity
Monitor.Enter(this);
foreach(IStackable sf in List)
{
if(sf.GetType().Name.Equals(FormType.Name)) <===========CANNOT DO
"sf.This.GetType().Name" Any Idea Why?
{
// form is cached so display cached version
sf.Visible = true;
// add it to the stack
stack.Add(FormType.Name);
return;
}
}
_____________________________________________________
I Hope this makes sense, and I apreciate any help.
Thank You,
David Johnson