Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Move the XML configuration file reading code into its own private method. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
5f0d62ce57e7bb495867fff9bb20d805 |
User & Date: | mistachkin 2016-07-02 00:30:39.082 |
Context
2016-07-02
| ||
03:10 | Remove superfluous comment. check-in: 7273ee5d1f user: mistachkin tags: trunk | |
00:30 | Move the XML configuration file reading code into its own private method. check-in: 5f0d62ce57 user: mistachkin tags: trunk | |
00:06 | Improve comments. check-in: 4b9b00163e user: mistachkin tags: trunk | |
Changes
Changes to System.Data.SQLite/UnsafeNativeMethods.cs.
︙ | ︙ | |||
761 762 763 764 765 766 767 768 769 770 771 772 773 774 | fileName = MaybeCombinePath(directory, XmlConfigFileName); if (File.Exists(fileName)) return fileName; return null; } ///////////////////////////////////////////////////////////////////////// /// <summary> /// Queries and returns the value of the specified setting, using the XML /// configuration file and/or the environment variables for the current /// process and/or the current system, when available. /// </summary> | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 | fileName = MaybeCombinePath(directory, XmlConfigFileName); if (File.Exists(fileName)) return fileName; return null; } ///////////////////////////////////////////////////////////////////////// /// <summary> /// Queries and returns the value of the specified setting, using the /// specified XML configuration file. /// </summary> /// <param name="fileName"> /// The name of the XML configuration file to read. /// </param> /// <param name="name"> /// The name of the setting. /// </param> /// <param name="default"> /// The value to be returned if the setting has not been set explicitly /// or cannot be determined. /// </param> /// <param name="expand"> /// Non-zero to expand any environment variable references contained in /// the setting value to be returned. This has no effect on the .NET /// Compact Framework. /// </param> /// <returns> /// The value of the setting -OR- the default value specified by /// <paramref name="default" /> if it has not been set explicitly or /// cannot be determined. By default, all references to existing /// environment variables will be expanded to their corresponding values /// within the value to be returned unless either the "No_Expand" or /// "No_Expand_<paramref name="name" />" environment variable is set [to /// anything]. /// </returns> private static string GetSettingValueViaXmlConfigFile( string fileName, /* in */ string name, /* in */ string @default, /* in */ bool expand /* in */ ) { try { if ((fileName == null) || (name == null)) return @default; XmlDocument document = new XmlDocument(); document.Load(fileName); /* throw */ XmlElement element = document.SelectSingleNode( HelperMethods.StringFormat(CultureInfo.InvariantCulture, "/configuration/appSettings/add[@key='{0}']", name)) as XmlElement; /* throw */ if (element != null) { string value = null; if (element.HasAttribute("value")) value = element.GetAttribute("value"); #if !PLATFORM_COMPACTFRAMEWORK if (expand && !String.IsNullOrEmpty(value)) value = Environment.ExpandEnvironmentVariables(value); #endif if (value != null) return value; } } #if !NET_COMPACT_20 && TRACE_SHARED catch (Exception e) #else catch (Exception) #endif { #if !NET_COMPACT_20 && TRACE_SHARED try { Trace.WriteLine(HelperMethods.StringFormat( CultureInfo.CurrentCulture, "Native library " + "pre-loader failed to get setting \"{0}\" value " + "from XML configuration file \"{1}\": {2}", name, fileName, e)); /* throw */ } catch { // do nothing. } #endif } return @default; } ///////////////////////////////////////////////////////////////////////// /// <summary> /// Queries and returns the value of the specified setting, using the XML /// configuration file and/or the environment variables for the current /// process and/or the current system, when available. /// </summary> |
︙ | ︙ | |||
811 812 813 814 815 816 817 818 819 820 821 822 823 | if (name == null) return @default; ///////////////////////////////////////////////////////////////////// #region Debug Build Only #if DEBUG DebugData.IncrementSettingReadCount(name, false); #endif #endregion ///////////////////////////////////////////////////////////////////// | > > > > > > | > | | 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 | if (name == null) return @default; ///////////////////////////////////////////////////////////////////// #region Debug Build Only #if DEBUG // // NOTE: We are about to read a setting value from the environment // or possibly from the XML configuration file; create or // increment the appropriate statistic now. // DebugData.IncrementSettingReadCount(name, false); #endif #endregion ///////////////////////////////////////////////////////////////////// bool expand = true; /* SHARED: Environment -AND- XML config file. */ ///////////////////////////////////////////////////////////////////// #if !PLATFORM_COMPACTFRAMEWORK string value = null; if (Environment.GetEnvironmentVariable("No_Expand") != null) { expand = false; } else if (Environment.GetEnvironmentVariable( HelperMethods.StringFormat(CultureInfo.InvariantCulture, |
︙ | ︙ | |||
857 858 859 860 861 862 863 864 865 866 867 868 869 | } #endif ///////////////////////////////////////////////////////////////////// #region Debug Build Only #if DEBUG DebugData.IncrementSettingReadCount(name, true); #endif #endregion ///////////////////////////////////////////////////////////////////// | > > > > > < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < | < | 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 | } #endif ///////////////////////////////////////////////////////////////////// #region Debug Build Only #if DEBUG // // NOTE: We are about to read a setting value from the XML // configuration file; create or increment the appropriate // statistic now. // DebugData.IncrementSettingReadCount(name, true); #endif #endregion ///////////////////////////////////////////////////////////////////// return GetSettingValueViaXmlConfigFile( GetXmlConfigFileName(), name, @default, expand); } ///////////////////////////////////////////////////////////////////////// #if !PLATFORM_COMPACTFRAMEWORK private static string ListToString(IList<string> list) { |
︙ | ︙ |