GetData() public method

public GetData ( ) : byte[]
return byte[]
        /// <summary>
        /// The DisplayName of the extension node will be the computer name 
        /// published by the primary.  Note: this defaults to an empty string for localhost.
        /// </summary>
        void SetDisplayName(ScopeNode scopeNode, SharedDataItem sharedDataItem)
        {
            // get buffer containing the machine name
            string machineName = Encoding.Unicode.GetString(sharedDataItem.GetData());

            // find first null terminated string in buffer.
            if (machineName.IndexOf('\0') <= 0)
            {
                // either not found in buffer or first entry in buffer
                machineName = String.Empty;
            }
            else
            {
                machineName = machineName.Substring(0, machineName.IndexOf('\0'));
            }

            // if empty then localhost
            if (machineName == string.Empty)
            {
                scopeNode.DisplayName = "Sample Extension to (localhost)";
            }
            else
            {
                scopeNode.DisplayName = "Sample Extension to (" + machineName + ")";
            }
        }
Example #2
0
 /// <summary>This will get called when the user chooses to monitor a different computer other than
 /// the Local Machine.</summary>
 protected override void OnSharedDataChanged(SharedDataItem sharedDataItem)
 {
     // If the machine name has changed, Update the Local Name. OnInitialize will get called again!
     if (sharedDataItem.ClipboardFormatId == SnapInShared.MachineName)
     {
         MachineName = Encoding.Unicode.GetString(sharedDataItem.GetData());
     }
 }