コード例 #1
0
 /// <summary>
 /// Extension class to extend the Computer Management snap-in property sheet
 /// </summary>
 public ExtensionToPropertySheet()
 {
     // In order to receive published data from the primary snap-in, MMC needs to know which
     // data items the extension is interested in.
     sharedDataItem = new SharedDataItem(@"MMC_SNAPIN_MACHINE_NAME");
     this.SharedData.Add(sharedDataItem);
 }
コード例 #2
0
        /// <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 + ")";
            }
        }
コード例 #3
0
 /// <summary>
 /// Respond to changes in shared information from the primary
 /// </summary>
 /// <param name="sharedDataItem">shared data</param>
 protected override void OnSharedDataChanged(SharedDataItem sharedDataItem)
 {
     // if the machine name has changed, update the extension node name
     if (sharedDataItem.ClipboardFormatId == machineNameClipboardFormatId)
     {
         SetDisplayName(extensionRootNode, sharedDataItem);
     }
 }
コード例 #4
0
        /// <summary>
        /// Update the node with the controls values
        /// </summary>
        /// <param name="sharedDataItem">Node being updated by property page</param>
        public void UpdateData(SharedDataItem sharedDataItem)
        {
            // In this sample the primary does not allow its data to be updated.
            // However, you can create primary nodes with updatable shared data
            // that would be accessed with a line such as the one below.

            // sharedDataItem.SetData(Encoding.Unicode.GetBytes(this.MachineName.Text));
            machinePropertyPage.Dirty = false;
        }
コード例 #5
0
        /// <summary>
        /// Constructor for the page.
        /// </summary>
        public MachinePropertyPage(SharedDataItem parentSharedDataItem)
        {
            sharedDataItem = parentSharedDataItem;

            // setup property page container stuff
            this.Title = "Property Sheet Extension Sample";

            // setup contained control and hand it a reference to its parent (This propertypage)
            machinePropertiesControl = new MachinePropertiesControl(this);
            this.Control = machinePropertiesControl;
        }
コード例 #6
0
        protected IDictionary <String, IModelContainer> ReadIntern(String token)
        {
            SharedDataItem sharedDataItem = DictionaryExtension.ValueOrDefault(tokenToDataDict, token);

            if (sharedDataItem == null)
            {
                return(null);
            }
            sharedDataItem.lastAccess = DateTime.Now;
            return(sharedDataItem.data);
        }
コード例 #7
0
        public String Put(IDictionary <String, IModelContainer> data)
        {
            String         token          = System.Guid.NewGuid().ToString();
            SharedDataItem sharedDataItem = new SharedDataItem(data);

            sharedDataItem.lastAccess = DateTime.Now;
            writeLock.Lock();
            try
            {
                tokenToDataDict.Add(token, sharedDataItem);
                tokenToHandOnsDict.Add(token, new IdentityHashSet <ISharedDataHandOn>());
            }
            finally
            {
                writeLock.Unlock();
            }
            return(token);
        }
コード例 #8
0
        /// <summary>
        /// The computer name is published by the primary.
        /// Note: this defaults to an empty string for localhost.
        /// </summary>
        /// <param name="sharedDataItem"></param>
        private string GetMachineName(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)
            {
                machineName = "localhost";
            }

            return(machineName);
        }
コード例 #9
0
 /// <summary>
 /// Populate control values from the SelectionObject (set in UserListView.SelectionOnChanged)
 /// </summary>
 /// <param name="sharedDataItem"></param>
 public void RefreshData(SharedDataItem sharedDataItem)
 {
     this.MachineName.Text     = GetMachineName(sharedDataItem);
     machinePropertyPage.Dirty = false;
 }
コード例 #10
0
        /// <summary>
        /// Update the node with the controls values
        /// </summary>
        /// <param name="sharedDataItem">Node being updated by property page</param>
        public void UpdateData(SharedDataItem sharedDataItem)
        {
            // In this sample the primary does not allow its data to be updated.
            // However, you can create primary nodes with updatable shared data
            // that would be accessed with a line such as the one below.

            // sharedDataItem.SetData(Encoding.Unicode.GetBytes(this.MachineName.Text));
            machinePropertyPage.Dirty = false;
        }
コード例 #11
0
 /// <summary>
 /// Populate control values from the SelectionObject (set in UserListView.SelectionOnChanged)
 /// </summary>
 /// <param name="sharedDataItem"></param>
 public void RefreshData(SharedDataItem sharedDataItem)
 {
     this.MachineName.Text = GetMachineName(sharedDataItem);
     machinePropertyPage.Dirty = false;
 }
コード例 #12
0
        /// <summary>
        /// The computer name is published by the primary.  
        /// Note: this defaults to an empty string for localhost.
        /// </summary>
        /// <param name="sharedDataItem"></param>
        private string GetMachineName(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)
            {
                machineName = "localhost";
            }

            return (machineName);
        }