Esempio n. 1
0
        public virtual void SaveLink()
        {
            DebugAssistant.Log("RegistrySettingLinkBase: save link setting");
            RegistryController regConn = new RegistryController(Id2RegKey(LinkId));

            LinkDataType linkType = RegistrySettingLinkBase <T> .LinkDataType.File;
            RegistrySettingLinkFile <T> selfType = this as RegistrySettingLinkFile <T>;

            if (selfType != null)
            {
                regConn.WriteRegKey("filePath", selfType.FilePath);
            }
            else
            {
                linkType = LinkDataType.Registry;
            }

            //Save link type
            regConn.WriteRegKey("linkType", ((int)linkType).ToString());
        }
Esempio n. 2
0
        /// <summary>
        /// Loads the link setting.
        /// </summary>
        /// <param name="linkId">The link id.</param>
        /// <returns></returns>
        private static RegistrySettingLinkBase <T> LoadLinkSetting(Guid linkId)
        {
            RegistrySettingLinkBase <T> retVal  = null;
            RegistryController          regConn = new RegistryController(Id2RegKey(linkId));
            String       regVal       = (string)regConn.ReadRegKey("linkType", LinkDataType.Registry.ToString());
            LinkDataType linkdataType = (LinkDataType)Convert.ToInt32(regVal);

            if (linkdataType == LinkDataType.File)
            {
                string filePath = (string)regConn.ReadRegKey("filePath", string.Empty);
                retVal = new RegistrySettingLinkFile <T>(linkId, filePath);
            }
            else
            {
                retVal = new RegistrySettingLinkReg <T>(linkId, Id2RegKey(linkId));
            }

            retVal.LoadSetting();

            return(retVal);
        }