コード例 #1
0
ファイル: ProfileSetting.cs プロジェクト: 0anion0/IBN
        public void SaveActiveProfile()
        {
            DebugAssistant.Log("ProfileSetting: Save active profile");

            RegistryController regConn = new RegistryController(ProfileSettingRoot);

            if (SyncAppSettingLink != null)
            {
                SyncAppSettingLink.SaveLink();
                regConn.WriteRegKey(SYNC_APPLICATION_REGKEY, SyncAppSettingLink.LinkId.ToString());
            }
            if (SyncAppointmentSettingLink != null)
            {
                SyncAppointmentSettingLink.SaveLink();
                regConn.WriteRegKey(SYNC_APPOINTMENT_REGKEY, SyncAppointmentSettingLink.LinkId.ToString());
            }
            if (SyncContactSettingLink != null)
            {
                SyncContactSettingLink.SaveLink();
                regConn.WriteRegKey(SYNC_CONTACT_REGKEY, SyncContactSettingLink.LinkId.ToString());
            }
            if (SyncTaskSettingLink != null)
            {
                SyncTaskSettingLink.SaveLink();
                regConn.WriteRegKey(SYNC_TASK_REGKEY, SyncTaskSettingLink.LinkId.ToString());
            }
        }
コード例 #2
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());
        }
コード例 #3
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);
        }
コード例 #4
0
ファイル: ProfileSetting.cs プロジェクト: 0anion0/IBN
        public static UserProfileSetting LoadActiveProfile()
        {
            UserProfileSetting retVal = new UserProfileSetting();

            RegistryController regConn = new RegistryController(ProfileSettingRoot);
            string             activeSyncAppSettingLink     = (string)regConn.ReadRegKey(SYNC_APPLICATION_REGKEY, null);
            string             activeAppointmentSettingLink = (string)regConn.ReadRegKey(SYNC_APPOINTMENT_REGKEY, null);
            string             activeContactSettingLink     = (string)regConn.ReadRegKey(SYNC_CONTACT_REGKEY, null);
            string             activeTaskSettingLink        = (string)regConn.ReadRegKey(SYNC_TASK_REGKEY, null);

            //Application
            if (!string.IsNullOrEmpty(activeSyncAppSettingLink))
            {
                DebugAssistant.Log("ProfileSetting: Load sync application setting.");
                retVal.SyncAppSettingLink = RegistrySettingLinkBase <syncAppSetting> .CreateInstance(new Guid(activeSyncAppSettingLink));
            }
            else
            {
                DebugAssistant.Log("ProfileSetting: Sync application setting not found. Create default..");
                retVal.SyncAppSettingLink = RegistrySettingLinkBase <syncAppSetting> .CreateInstance();

                retVal.SyncAppSettingLink.SaveLink();
            }
            //Appointment
            if (!string.IsNullOrEmpty(activeAppointmentSettingLink))
            {
                DebugAssistant.Log("ProfileSetting: Load sync appointment setting.");
                retVal.SyncAppointmentSettingLink = RegistrySettingLinkBase <syncAppointmentSetting> .CreateInstance(new Guid(activeAppointmentSettingLink));
            }
            else
            {
                DebugAssistant.Log("ProfileSetting: Sync appointment setting not found. Create default..");
                retVal.SyncAppointmentSettingLink = RegistrySettingLinkBase <syncAppointmentSetting> .CreateInstance();

                retVal.SyncAppointmentSettingLink.SaveLink();
            }
            //Contact
            if (!string.IsNullOrEmpty(activeContactSettingLink))
            {
                retVal.SyncContactSettingLink = RegistrySettingLinkBase <syncContactSetting> .CreateInstance(new Guid(activeContactSettingLink));
            }
            else
            {
                retVal.SyncContactSettingLink = RegistrySettingLinkBase <syncContactSetting> .CreateInstance();

                retVal.SyncContactSettingLink.SaveLink();
            }
            //Task
            if (!string.IsNullOrEmpty(activeTaskSettingLink))
            {
                retVal.SyncTaskSettingLink = RegistrySettingLinkBase <syncTaskSetting> .CreateInstance(new Guid(activeTaskSettingLink));
            }
            else
            {
                retVal.SyncTaskSettingLink = RegistrySettingLinkBase <syncTaskSetting> .CreateInstance();

                retVal.SyncTaskSettingLink.SaveLink();
            }

            retVal.SaveActiveProfile();

            return(retVal);
        }
コード例 #5
0
ファイル: ProfileSetting.cs プロジェクト: 0anion0/IBN
        public void SaveActiveProfile()
        {
            DebugAssistant.Log("ProfileSetting: Save active profile");

            RegistryController regConn = new RegistryController(ProfileSettingRoot);

            if(SyncAppSettingLink != null)
            {
                SyncAppSettingLink.SaveLink();
                regConn.WriteRegKey(SYNC_APPLICATION_REGKEY, SyncAppSettingLink.LinkId.ToString());
            }
            if(SyncAppointmentSettingLink != null)
            {
                SyncAppointmentSettingLink.SaveLink();
                regConn.WriteRegKey(SYNC_APPOINTMENT_REGKEY, SyncAppointmentSettingLink.LinkId.ToString());
            }
            if (SyncContactSettingLink != null)
            {
                SyncContactSettingLink.SaveLink();
                regConn.WriteRegKey(SYNC_CONTACT_REGKEY, SyncContactSettingLink.LinkId.ToString());
            }
            if (SyncTaskSettingLink != null)
            {
                SyncTaskSettingLink.SaveLink();
                regConn.WriteRegKey(SYNC_TASK_REGKEY, SyncTaskSettingLink.LinkId.ToString());
            }
        }
コード例 #6
0
ファイル: ProfileSetting.cs プロジェクト: 0anion0/IBN
        public static UserProfileSetting LoadActiveProfile()
        {
            UserProfileSetting retVal = new UserProfileSetting();

            RegistryController regConn = new RegistryController(ProfileSettingRoot);
            string activeSyncAppSettingLink = (string)regConn.ReadRegKey(SYNC_APPLICATION_REGKEY, null);
            string activeAppointmentSettingLink = (string)regConn.ReadRegKey(SYNC_APPOINTMENT_REGKEY, null);
            string activeContactSettingLink = (string)regConn.ReadRegKey(SYNC_CONTACT_REGKEY, null);
            string activeTaskSettingLink = (string)regConn.ReadRegKey(SYNC_TASK_REGKEY, null);
            //Application
            if (!string.IsNullOrEmpty(activeSyncAppSettingLink))
            {
                DebugAssistant.Log("ProfileSetting: Load sync application setting.");
                retVal.SyncAppSettingLink = RegistrySettingLinkBase<syncAppSetting>.CreateInstance(new Guid(activeSyncAppSettingLink));
            }
            else
            {
                DebugAssistant.Log("ProfileSetting: Sync application setting not found. Create default..");
                retVal.SyncAppSettingLink = RegistrySettingLinkBase<syncAppSetting>.CreateInstance();
                retVal.SyncAppSettingLink.SaveLink();
            }
            //Appointment
            if (!string.IsNullOrEmpty(activeAppointmentSettingLink))
            {
                DebugAssistant.Log("ProfileSetting: Load sync appointment setting.");
                retVal.SyncAppointmentSettingLink = RegistrySettingLinkBase<syncAppointmentSetting>.CreateInstance(new Guid(activeAppointmentSettingLink));
            }
            else
            {
                DebugAssistant.Log("ProfileSetting: Sync appointment setting not found. Create default..");
                retVal.SyncAppointmentSettingLink = RegistrySettingLinkBase<syncAppointmentSetting>.CreateInstance();
                retVal.SyncAppointmentSettingLink.SaveLink();

            }
            //Contact
            if (!string.IsNullOrEmpty(activeContactSettingLink))
            {
                retVal.SyncContactSettingLink = RegistrySettingLinkBase<syncContactSetting>.CreateInstance(new Guid(activeContactSettingLink));
            }
            else
            {
                retVal.SyncContactSettingLink = RegistrySettingLinkBase<syncContactSetting>.CreateInstance();
                retVal.SyncContactSettingLink.SaveLink();
            }
            //Task
            if (!string.IsNullOrEmpty(activeTaskSettingLink))
            {
                retVal.SyncTaskSettingLink = RegistrySettingLinkBase<syncTaskSetting>.CreateInstance(new Guid(activeTaskSettingLink));
            }
            else
            {
                retVal.SyncTaskSettingLink = RegistrySettingLinkBase<syncTaskSetting>.CreateInstance();
                retVal.SyncTaskSettingLink.SaveLink();
            }

            retVal.SaveActiveProfile();

            return retVal;
        }
コード例 #7
0
        public static IEnumerable <RegistrySettingLinkBase <T> > List()
        {
            RegistryController regConn = new RegistryController(SettingLinkRoot);

            return(regConn.GetSubKayNames().Select(x => RegKey2Id(x)).Select(x => LoadLinkSetting(x)));
        }