Main page / CORBA with MinCor.NET page

Attribute - Using IDL Attributes


Description: 
	CORBA IDL attributes may be mapped straight forward into standard .Net 
	attributes. (In contrast, the OMG IDL-to-Java mapping maps IDL attributes
	into instance variables with explicit setter & getter methods.)

Source: 
	MinCor\Demo\Attribute

Mapping: 
	CORBA IDL Attributes  <--->  .Net Attributes



Example 

The IDL (Attribute.idl):

    
    module Attribute
    {
        interface Greetings
        {
            attribute string Name;
            
            readonly attribute string City;
            
            string hello();
        };
    };
    
    (Will be compiled into Attribute.cs)


The Implementation (ServerImpl.cs):

    
    public class Greetings:	Attribute.GreetingsPOA
    {
        private string m_strCity;
        private string m_strName;
        
        public Greetings()
        {
            m_strCity = "Hamburg";
        }
        
        public override string Name
        {
            set
            {
                m_strName = value;
            }
            get
            {
                return m_strName;
            }
        }
        
        public override string City
        {
            get
            { 
                return m_strCity;
            }
        }
        
        public override string hello()
        {
            return "Greetings to " + m_strName;
        }
    }	
    
    
The Client (ClientImpl.cs):

    Write an attribute to the server:
    
    oIGreetings.Name = "John";
    
    
    Read an attribute from the server:
    
    string strTheCity = oIGreetings.City;
    
    
    Call a server method (reading a changed attribute):
    
    string srLog = "\n" + oIGreetings.hello() + " from " + strTheCity;