views:

46

answers:

1

i am sending a value(attrname[5] = "WRM Version";) from SendAgentInfo() from a.dll It is received in sp.dll as WrmVersion.From here i am sending those values in to an interface(IResourcePolicy) located in data.dll.But the problem is data is not getting interface 'IResourcePolicy',,if it is recieved in Interface,it should display in a LISTVIEW in UI (ResourcePolicySystemsControl.cs0 in UI.dll The coding what i did is given below


code in a.dll

  public void SendAgentInfo()
      {
       string[] attrname = new string[6];
         string[] attrval = new string[6];

       attrname[5] = "WRM Version";
       .
       .
       attrval[5] = Registry.GetValue(@"HKEY_LOCAL_MACHINE\Software\syscon\Single Point Operations Windows Resource Monitor", "CurrentVersion", "0").ToString();
       }


code in sp.dll

      string wrmVersionSPURT = this_event.variableData[5].atr_value;
       .
       .
      IResourcePolicy irp = (IResourcePolicy)
       .
       .
      irp.WrmVersion = wrmVersionSPURT;
       .
       .


 code     data.dll

        public interface IResourcePolicy
   {

             string WrmVersion
      {
          get;
          set;
      }
   }


code     UI.dll



              public new IResourcePolicy Data
         {
            get
            {
               return (IResourcePolicy)base.Data;
            }
         }

       .
       .

        protected override void OnUpdate()
         {
            string func = "ResourcePolicySystemsLVI.OnUpdate";
            try
            {
               if(Data != null)
               {
                  Text = base.Data.Name;
                  if(SubItems.Count == 1)
                  {
                     SubItems.Add(((IResourcePolicy)Data).ResourcePolicyEnabled.ToString());
                     SubItems.Add(((IResourcePolicy)Data).ResourcePolicyCurrent.ToString());
                     SubItems.Add(((IResourcePolicy)Data).WrmVersion.ToString()); 

                  }
                  else
                  {
                     SubItems[1].Text = ((IResourcePolicy)Data).ResourcePolicyEnabled.ToString();
                     SubItems[2].Text = ((IResourcePolicy)Data).ResourcePolicyCurrent.ToString();
                  }
               }
               base.OnUpdate();
            }
A: 

You will need to have a class that implements IResourcePolicy that will some way get assigned to the property Data in UI.dll. Note that an interface is not an object; it merely describes the interface that is expected from a class that implements it. It cannot be used standa-alone, but must be implemented by a class in order to be used.

Fredrik Mörk