예제 #1
0
        protected void TestCreateProvider(LibraryPathType iLibraryType, Type iExpectedType, string iErrorMsg)
        {
            ILibraryPathsProvider vProvider = LibraryPathsProviderFactory.CreateProvider(iLibraryType);

            Assert.IsNotNull(vProvider, "Provider was not created. " + iErrorMsg);
            Assert.IsInstanceOf(iExpectedType, vProvider, "Created provider is of wrong type. " + iErrorMsg);
        }
예제 #2
0
        private static ToolStripItem CreateToolStripItem(LibraryPathType iEnumValue)
        {
            ToolStripMenuItem vItem = new ToolStripMenuItem(iEnumValue.ToString());

            vItem.Tag = iEnumValue;
            return(vItem);
        }
        protected List <string> ListPaths(LibraryPathType iType)
        {
            List <string> vResult = new List <string>();

            vResult.AddRange(ReadString(DelphiRegistryKeys.LibraryKey(iType), "Search Path").ToString().Split(';'));
            return(vResult);
        }
 public void LoadPreset(LibraryPathType aType)
 {
     ValidateModel();
     ILibraryPathsProvider vProvider = LibraryPathsProviderFactory.CreateProvider(aType);
     Model.LibraryPaths = vProvider.List();
     Model.NotifyObservers();
 }
예제 #5
0
        public void LoadPreset(LibraryPathType aType)
        {
            ValidateModel();
            ILibraryPathsProvider vProvider = LibraryPathsProviderFactory.CreateProvider(aType);

            Model.LibraryPaths = vProvider.List();
            Model.NotifyObservers();
        }
 public static bool IsProviderSupported(LibraryPathType iLibraryType)
 {
     try
     {
         ILibraryPathsProvider vProvider = LibraryPathsProviderFactory.CreateProvider(iLibraryType);
         return (vProvider != null);
     }
     catch (NotSupportedException)
     {
         return false;
     }
 }
 public static RegistryKey RootDirKey(LibraryPathType iType)
 {
     switch (iType)
     {
         case LibraryPathType.Delphi5:
             return Registry.LocalMachine.OpenSubKey(@"Software\Borland\Delphi\5.0");
         case LibraryPathType.Delphi6:
             return Registry.CurrentUser.OpenSubKey(@"Software\Borland\Delphi\6.0");
         default:
             throw new NotSupportedException("The library type " + iType.ToString() + " is not supported");
     }
 }
 public static bool IsProviderSupported(LibraryPathType iLibraryType)
 {
     try
     {
         ILibraryPathsProvider vProvider = LibraryPathsProviderFactory.CreateProvider(iLibraryType);
         return(vProvider != null);
     }
     catch (NotSupportedException)
     {
         return(false);
     }
 }
 public static RegistryKey EnvironmentPathsKey(LibraryPathType iType)
 {
     string vKey = "";
     switch (iType)
     {
         case LibraryPathType.Delphi6:
             vKey = @"Software\Borland\Delphi\6.0\Environment Variables";
             break;
         default:
             throw new NotSupportedException("The library type " + iType.ToString() + " is not supported");
     }
     return Registry.CurrentUser.OpenSubKey(vKey);
 }
        public static RegistryKey RootDirKey(LibraryPathType iType)
        {
            switch (iType)
            {
            case LibraryPathType.Delphi5:
                return(Registry.LocalMachine.OpenSubKey(@"Software\Borland\Delphi\5.0"));

            case LibraryPathType.Delphi6:
                return(Registry.CurrentUser.OpenSubKey(@"Software\Borland\Delphi\6.0"));

            default:
                throw new NotSupportedException("The library type " + iType.ToString() + " is not supported");
            }
        }
        public static ILibraryPathsProvider CreateProvider(LibraryPathType iType)
        {
            switch (iType)
            {
            case LibraryPathType.Delphi5:
            case LibraryPathType.Delphi6:
                return(new DelphiLibraryPathsProvider(iType));

            case LibraryPathType.Clipboard:
                return(new ClipboardLibraryPathsProvider());

            default:
                throw new NotSupportedException("Provider " + iType.ToString() + " is not supported, yet.");
            }
        }
        public static ILibraryPathsProvider CreateProvider(LibraryPathType iType)
        {
            switch (iType)
            {
                case LibraryPathType.Delphi5:
                case LibraryPathType.Delphi6:
                    return new DelphiLibraryPathsProvider(iType);

                case LibraryPathType.Clipboard:
                    return new ClipboardLibraryPathsProvider();

                default:
                    throw new NotSupportedException("Provider " + iType.ToString() + " is not supported, yet.");
            }
        }
        public static RegistryKey EnvironmentPathsKey(LibraryPathType iType)
        {
            string vKey = "";

            switch (iType)
            {
            case LibraryPathType.Delphi6:
                vKey = @"Software\Borland\Delphi\6.0\Environment Variables";
                break;

            default:
                throw new NotSupportedException("The library type " + iType.ToString() + " is not supported");
            }
            return(Registry.CurrentUser.OpenSubKey(vKey));
        }
 protected IDictionary<string, string> ListEnvironmentPaths(LibraryPathType iType)
 {
     Dictionary<string, string> vResult = new Dictionary<string, string>();
     try
     {
         vResult.Add("delphi", ReadString(DelphiRegistryKeys.RootDirKey(iType), "RootDir"));
         RegistryKey vKey = DelphiRegistryKeys.EnvironmentPathsKey(iType);
         foreach (string vValueName in vKey.GetValueNames())
             vResult.Add(vValueName, vKey.GetValue(vValueName).ToString());
     }
     catch (NotSupportedException)
     {
         // In this case return empty dictionary - no environment variables to return
     }
     return vResult;
 }
        protected IDictionary <string, string> ListEnvironmentPaths(LibraryPathType iType)
        {
            Dictionary <string, string> vResult = new Dictionary <string, string>();

            try
            {
                vResult.Add("delphi", ReadString(DelphiRegistryKeys.RootDirKey(iType), "RootDir"));
                RegistryKey vKey = DelphiRegistryKeys.EnvironmentPathsKey(iType);
                foreach (string vValueName in vKey.GetValueNames())
                {
                    vResult.Add(vValueName, vKey.GetValue(vValueName).ToString());
                }
            }
            catch (NotSupportedException)
            {
                // In this case return empty dictionary - no environment variables to return
            }
            return(vResult);
        }
        public static LibraryPathType[] ListSupportedProviders()
        {
            Array vLibraryTypes = Enum.GetValues(typeof(LibraryPathType));
            List<object> vSupported = new List<object>();
            for (int vLibraryTypeIdx = 0; vLibraryTypeIdx < vLibraryTypes.Length; vLibraryTypeIdx++)
            {
                LibraryPathType vType = (LibraryPathType)vLibraryTypes.GetValue(vLibraryTypeIdx);
                if (!IsProviderSupported(vType))
                    continue;

                vSupported.Add(vType);
            }

            LibraryPathType[] vResult = new LibraryPathType[vSupported.Count];
            for (int vSupportedIdx = 0; vSupportedIdx < vSupported.Count; vSupportedIdx++)
                vResult[vSupportedIdx] = (LibraryPathType)vSupported[vSupportedIdx];

            return vResult;
        }
        public static LibraryPathType[] ListSupportedProviders()
        {
            Array         vLibraryTypes = Enum.GetValues(typeof(LibraryPathType));
            List <object> vSupported    = new List <object>();

            for (int vLibraryTypeIdx = 0; vLibraryTypeIdx < vLibraryTypes.Length; vLibraryTypeIdx++)
            {
                LibraryPathType vType = (LibraryPathType)vLibraryTypes.GetValue(vLibraryTypeIdx);
                if (!IsProviderSupported(vType))
                {
                    continue;
                }

                vSupported.Add(vType);
            }

            LibraryPathType[] vResult = new LibraryPathType[vSupported.Count];
            for (int vSupportedIdx = 0; vSupportedIdx < vSupported.Count; vSupportedIdx++)
            {
                vResult[vSupportedIdx] = (LibraryPathType)vSupported[vSupportedIdx];
            }

            return(vResult);
        }
 public DelphiLibraryPathsProvider(LibraryPathType iType)
 {
     fLibraryType = iType;
 }
 public DelphiLibraryPathsProvider(LibraryPathType iType)
 {
     fLibraryType = iType;
 }
 protected void TestCreateProvider(LibraryPathType iLibraryType, Type iExpectedType, string iErrorMsg)
 {
     ILibraryPathsProvider vProvider = LibraryPathsProviderFactory.CreateProvider(iLibraryType);
     Assert.IsNotNull(vProvider, "Provider was not created. " + iErrorMsg);
     Assert.IsInstanceOf(iExpectedType, vProvider, "Created provider is of wrong type. " + iErrorMsg);
 }
 protected List<string> ListPaths(LibraryPathType iType)
 {
     List<string> vResult = new List<string>();
     vResult.AddRange(ReadString(DelphiRegistryKeys.LibraryKey(iType), "Search Path").ToString().Split(';'));
     return vResult;
 }
 private static ToolStripItem CreateToolStripItem(LibraryPathType iEnumValue)
 {
     ToolStripMenuItem vItem = new ToolStripMenuItem(iEnumValue.ToString());
     vItem.Tag = iEnumValue;
     return vItem;
 }