Compartir a través de


IInterfaceInfo.Source Property

Gets a value indicating whether the interface is the source — that is, an interface that the client listens to, rather than calls.

Namespace:  Microsoft.VisualStudio.VsWizard
Assembly:  Microsoft.VisualStudio.VsWizard (in Microsoft.VisualStudio.VsWizard.dll)

Syntax

'Declaration
ReadOnly Property Source As Boolean
bool Source { get; }
property bool Source {
    bool get ();
}
abstract Source : bool with get
function get Source () : boolean

Property Value

Type: System.Boolean
true if the interface is the source; otherwise, false.

Remarks

A source interface is an interface that communicates to the client, rather than an interface the client calls (for example, by way of connection points in C++). A server calls (or multiplexes the calls if the interface allows several clients), and the client implements the handler.

Only one interface can be marked [source] in a given coclass.

Examples

// From the Visual C++ Member Variable wizard

function GenerateActiveXControlClassText(oTypeLib)
{
   var strClassText = "";

   var oInterfaces = oTypeLib.Interfaces;
   var nCount = oInterfaces.Count;

   var bGenerate_Array = new Array();
   var Name_Array = new Array();
   var Base_Array = new Array();
   var i;
   for (i = 0; i < nCount; i++)
   {
      var oInterface = oInterfaces.item(i+1);

      if (oInterface.CoClass != CONTROL_TYPE.text 
         || oInterface.Default == false 
         || oInterface.Source == true)
         continue;

      Name_Array[i] = oInterface.Name;
      Base_Array[i] = oInterface.Base;
      bGenerate_Array[i] = true;
   }
   for (i = 0; i < nCount; i++)
   {
      if (oInterface.CoClass != CONTROL_TYPE.text 
         || oInterface.Default == false 
         || oInterface.Source == true)
         continue;

      var strBase = Base_Array[i];
      if(strBase && strBase.length && 
         strBase!="IDispatch" && strBase!="IUnknown")
      {
         for(var j=0; j< nCount; j++)
         {
            if(strBase == Name_Array[j])
            {
               bGenerate_Array[j] = false;
               break;
            }
         }
      }
   }
   for (i = 0; i <  nCount; i++)
   {
      var oInterface = oInterfaces.item(i+1);
      if(!bGenerate_Array[i])
      {
         strClassText += "// Interface: " + Name_Array[i] + " not generated, because it was a base interface for others.\n\n";
      }
      else if (oInterface.Type == 2 
               && oInterface.CoClass == CONTROL_TYPE.text 
               && oInterface.Default 
               && !oInterface.Source)  // einterfaceDispinterface
      {
         strClassText += "// ";
         strClassText += Name_Array[i];
         strClassText += "\r\n\r\n// Functions\r\n//\r\n\r\n";
         strClassText += GetFuncText(oTypeLib, oInterface, strClassText);
      }
   }
   return strClassText;
}

.NET Framework Security

See Also

Reference

IInterfaceInfo Interface

Microsoft.VisualStudio.VsWizard Namespace