当前位置: 首页>>代码示例>>C#>>正文


C# Settings.Get方法代码示例

本文整理汇总了C#中Settings.Get方法的典型用法代码示例。如果您正苦于以下问题:C# Settings.Get方法的具体用法?C# Settings.Get怎么用?C# Settings.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Settings的用法示例。


在下文中一共展示了Settings.Get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddPlace

        public static dynamic AddPlace(NewPlace place) {
            try {
                string jsonPlace = new JavaScriptSerializer().Serialize(place);
                Settings settings = new Settings();
                StringBuilder sb = new StringBuilder(settings.Get("PlacesAPIDomain"));
                sb.Append("add/json?sensor=false");
                sb.Append("&key=" + settings.Get("GoogleAPIKey"));

                byte[] byteArr = Encoding.UTF8.GetBytes(jsonPlace);

                WebRequest req = WebRequest.Create(sb.ToString());
                req.Method = "POST";
                req.ContentType = "application/json";
                req.ContentLength = byteArr.Length;

                Stream dataStream = req.GetRequestStream();
                dataStream.Write(byteArr, 0, byteArr.Length);
                dataStream.Close();

                WebResponse resp = req.GetResponse();
                string resp_status = (((HttpWebResponse)resp).StatusDescription);
                dataStream = resp.GetResponseStream();

                StreamReader reader = new StreamReader(dataStream);
                string returned_resp = reader.ReadToEnd();

                AddPlaceResponse formatted_resp = new JavaScriptSerializer().Deserialize<AddPlaceResponse>(returned_resp);
                return formatted_resp;

            } catch (Exception) {
                return "[]";
            }
        }
开发者ID:curt-labs,项目名称:CURTeCommerce,代码行数:33,代码来源:Geocoding.cs

示例2: RMICache

        /// <summary>
        /// Initializes a new instance of the <see cref="RMICache"/> class.
        /// </summary>
        /// <param name="settings"><see cref="T:TcmCDService.Configuration.Settings" /></param>
        public RMICache(Settings settings)
            : base(settings)
        {
            String host = settings.Get<String>("host");

            if (String.IsNullOrEmpty(host))
                throw new ConfigurationErrorsException("RMICache: Host is unconfigured.");

            int port = settings.Get<int>("port");

            if (port == 0)
                throw new ConfigurationErrorsException("RMICache: Port is unconfigured.");

            String instanceIdentifier = settings.Get<String>("instanceIdentifier");

            try
            {
                mConnector = new com.tridion.tcmcdservice.rmi.CacheChannelConnector(host, port, instanceIdentifier);

                // Assign ourselves as a listener interface
                mConnector.setListener(this);

                Logger.Info("RMICache: {0}", mConnector.getGUID());
            }
            catch (com.tridion.tcmcdservice.rmi.CacheException ex)
            {
                Logger.Error("RMICache", ex.fillInStackTrace());
            }
        }
开发者ID:TcmExtensions,项目名称:TcmCDService,代码行数:33,代码来源:RMICache.cs

示例3: Initialise

        /// <summary>
        /// Initialises this component
        /// </summary>
        /// <param name="settings">The settings collection.</param>
        public void Initialise(string name, Settings settings)
        {
            FileLogger.Logger.LogInformation("Initialising Monitor: {0}", name);
            if (settings == null || settings.Setting.Count == 0) throw new ApplicationException("No settings provided. This is required to Initialise the component.");
            Name = name;

            // Get the parameters for the TeamCity Connection
            // --------------------------------------------------------------------------------------
            var hostName = settings["Host"] as string;
            if (string.IsNullOrEmpty(hostName)) throw new ApplicationException("Host setting must be specified.");

            var username = settings.Get("User","guest");
            var password = settings.Get("Password","guest");
            var isGuest  = settings.Get("UseGuest",true);

            // Attempt to connect to TeamCity
            // --------------------------------------------------------------------------------------
            try {
                _client = new TeamCityClient(hostName);
                _client.Connect(username, password, isGuest);
            } catch (Exception ex) {
                throw new ApplicationException("Could not connect to TeamCity using the provided credentials.", ex);
            }

            // Build the list of Builds/Projects that we will be monitoring for THIS monitor
            // -----------------------------------------------------------------------------
            _builds = BuildMonitorProjects(settings);
            if (_builds == null || _builds.Count == 0) throw new ApplicationException("No Builds specified to Monitor.");

            IsInitialised = true;
        }
开发者ID:gitsly,项目名称:BuildStatusMonitor,代码行数:35,代码来源:TeamCityMonitor.cs

示例4: osuPostSettings

 public osuPostSettings(Settings settings)
 {
     _settings = settings;
     InitializeComponent();
     textBox_userId.Text = _settings.Get<string>(_names.osuPostLogin);
     textBox_userPassword.Text = _settings.Get<string>(_names.osuPostPassword);
     panel_settings.Enabled = _settings.Get<bool>(_names.osuPostEnabled);
     init = false;
 }
开发者ID:ColdVolcano,项目名称:StreamCompanion,代码行数:9,代码来源:osuPostSettings.cs

示例5: ModParserSettings

 public ModParserSettings(Settings settings)
 {
     _settings = settings;
     _settings.SettingUpdated += SettingUpdated;
     this.Enabled = _settings.Get<bool>(_names.EnableMemoryScanner);
     InitializeComponent();
     textBox_Mods.Text = _settings.Get<string>(_names.NoModsDisplayText);
     radioButton_longMods.Checked = _settings.Get<bool>(_names.UseLongMods);
     radioButton_shortMods.Checked = !radioButton_longMods.Checked;
     init = false;
 }
开发者ID:ColdVolcano,项目名称:StreamCompanion,代码行数:11,代码来源:ModParserSettings.cs

示例6: MemoryDataFinderSettings

        public MemoryDataFinderSettings(Settings settings)
        {
            InitializeComponent();

            _settings = settings;

            bool isFallback = _settings.Get<bool>(_names.OsuFallback);
            if (isFallback)
            {
                checkBox_EnableMemoryFinder.Enabled = false;
            }
            else
                checkBox_EnableMemoryFinder.Checked = _settings.Get<bool>(_names.EnableMemoryScanner);

            init = false;
        }
开发者ID:ColdVolcano,项目名称:StreamCompanion,代码行数:16,代码来源:MemoryDataFinderSettings.cs

示例7: GetImage

        public string GetImage() {
            try {
                string image = "";
                WebClient wc = new WebClient();
                wc.Proxy = null;
                Settings settings = new Settings();
                StringBuilder sb = new StringBuilder(settings.Get("CURTAPIDOMAIN"));
                sb.AppendFormat("GetPart?partID={0}&dataType=JSON", this.partID);

                string resp = wc.DownloadString(sb.ToString());
                APIPart part = Newtonsoft.Json.JsonConvert.DeserializeObject<APIPart>(resp);
                image = part.images.Where(x => x.size.Equals("Grande") && x.sort.ToString().Contains('a')).Select(x => x.path).FirstOrDefault<string>();

                if (image == null) {
                    foreach (APIImage img in part.images) {
                        image = img.path;
                        break;
                    }
                }

                return image;
            } catch (Exception e) {
                return e.Message;
            }
        }
开发者ID:curt-labs,项目名称:CURTeCommerce,代码行数:25,代码来源:CartItem.cs

示例8: SubmitBug

        public static void SubmitBug(string name, string email, string desc, string url = "", string subject = "") {

            // Validate the required fields
            if (name == null || name.Length == 0 || email == null || email.Length == 0 || desc == null || desc.Length == 0)
                throw new Exception();
            Settings settings = new Settings();
            StringBuilder sb = new StringBuilder();

            sb.Append("<p>A new bug has been submitted for the above listed domain.</p>");
            sb.Append("<hr />");
            sb.Append("<p>Submitter: " + name + " <" + email + "></p>");
            if (subject.Length > 0) {
                sb.Append("<span><strong>Subject: </strong>" + subject + "</span><br />");
            }
            if (url.Length > 0) {
                sb.Append("<span><strong>URI: </strong>" + url + "</span><br />");
            }
            sb.Append("<br /><span><strong>Bug</strong></span><br />");
            sb.Append("<p>" + desc + "</p>");
            sb.Append("<hr /><br />");
            sb.Append("<p style='font-size:11px'>If you feel this was a mistake please disregard this e-mail.</p>");

            string[] tos = { settings.Get("SupportEmail") };
            SendEmail(tos, "Bug submitted from " + HttpContext.Current.Request.Url.Host, true, sb.ToString());
        }
开发者ID:janiukjf,项目名称:CURTeCommerce,代码行数:25,代码来源:UDF.cs

示例9: NullTest

        public void NullTest()
        {
            Settings settings = new Settings();

            settings.DEBUG = true;

            int test = settings.Get<int>("foobarnotset");
            Console.WriteLine(test);
        }
开发者ID:BlackOrca,项目名称:octoawesome,代码行数:9,代码来源:SettingsManagerTests.cs

示例10: ReadWrite

        public void ReadWrite()
        {
            Settings settings = new Settings();

            settings.DEBUG = true;

            string[] testArray = new string[] {"foo", "bar"};
            settings.Set("foo", testArray);

            string[] newArray = settings.GetArray<string>("foo");

            Assert.IsTrue(testArray.SequenceEqual(newArray));

            int[] testArrayInt = new int[] { 3,5,333,456,3457};
            settings.Set("fooInt", testArrayInt);

            int[] newArrayInt = settings.GetArray<int>("fooInt");

            Assert.IsTrue(testArray.SequenceEqual(newArray));

            bool[] testArrayBool = new bool[] { true, false};
            settings.Set("fooBool", testArrayBool);

            bool[] newArrayBool = settings.GetArray<bool>("fooBool");

            Assert.IsTrue(testArray.SequenceEqual(newArray));

            String inputString = "randomStringWith§$%&/()=Charakters";
            settings.Set("inputString", inputString);

            Assert.AreEqual(inputString, settings.Get<string>("inputString"));

            int inputInt = new Random().Next();
            settings.Set("inputInt", inputInt);

            Assert.AreEqual(inputInt, settings.Get<int>("inputInt"));

            bool inputBool = true;
            settings.Set("inputBool", inputBool);

            Assert.AreEqual(inputBool, settings.Get<bool>("inputBool"));
        }
开发者ID:BlackOrca,项目名称:octoawesome,代码行数:42,代码来源:SettingsManagerTests.cs

示例11: GetYears

 internal static List<double> GetYears() {
     try {
         string year_json = "";
         WebClient wc = new WebClient();
         wc.Proxy = null;
         Settings settings = new Settings();
         year_json = wc.DownloadString(settings.Get("CURTAPIDOMAIN") + "getyear?dataType=JSON");
         List<double> years = JsonConvert.DeserializeObject<List<double>>(year_json);
         return years;
     } catch (Exception) {
         return new List<double>();
     }
 }
开发者ID:curt-labs,项目名称:CURTeCommerce,代码行数:13,代码来源:CURTAPI.cs

示例12: LoadOrder

 internal void LoadOrder() {
     try {
         Settings settings = new Settings();
         string EDIPOPreface = settings.Get("EDIPOPreface");
         string oid = this.orderID;
         if (EDIPOPreface != "") {
             oid = oid.Replace(EDIPOPreface, "");
         }
         this.order = new Cart().GetByPayment(Convert.ToInt32(oid));
     } catch {
         this.order = null;
     }
 }
开发者ID:curt-labs,项目名称:CURTeCommerce,代码行数:13,代码来源:Invoice.cs

示例13: GetVehicleParts

        internal static List<APIPart> GetVehicleParts(string year, string make, string model, string style, int cust_id = 0) {
            try {
                WebClient wc = new WebClient();
                wc.Proxy = null;
                Settings settings = new Settings();
                string url = settings.Get("CURTAPIDOMAIN");
                url += "getparts?dataType=JSON";
                url += "&cust_id=" + cust_id;
                url += "&year=" + year;
                url += "&make=" + make;
                url += "&model=" + model;
                url += "&style=" + style;
                url += "&cust_id=" + settings.Get("CURTAccount");

                string parts_json = wc.DownloadString(url);

                List<APIPart> parts = new List<APIPart>();
                parts = JsonConvert.DeserializeObject<List<APIPart>>(parts_json);
                return parts.OrderByDescending(x => x.pClass).ToList<APIPart>();
            } catch (Exception) {
                return new List<APIPart>();
            }
        }
开发者ID:curt-labs,项目名称:CURTeCommerce,代码行数:23,代码来源:CURTAPI.cs

示例14: GetCategoryParts

        internal static List<APIPart> GetCategoryParts(int id, int page = 1, int per_page = 10)
        {
            try {

                Settings settings = new Settings();
                StringBuilder sb = new StringBuilder(settings.Get("CURTAPIDOMAIN"));
                sb.Append("GetCategoryParts");
                sb.Append("?catID=" + id);
                sb.Append("&page=" + page);
                sb.Append("&perpage=" + per_page);
                sb.Append("&cust_id=" + settings.Get("CURTAccount"));
                sb.Append("&dataType=JSON");

                HttpWebRequest req = WebRequest.Create(sb.ToString()) as HttpWebRequest;
                req.Proxy = null;
                HttpWebResponse resp = req.GetResponse() as HttpWebResponse;
                string json = new StreamReader(resp.GetResponseStream()).ReadToEnd();
                List<APIPart> parts = JsonConvert.DeserializeObject<List<APIPart>>(json);
                return parts;
            } catch (Exception) {
                return new List<APIPart>();
            }
        }
开发者ID:meganmcchesney,项目名称:CURTeCommerce,代码行数:23,代码来源:CURTAPI.cs

示例15: ZeroMQBroker

        /// <summary>
        /// Initializes a new instance of the <see cref="ZeroMQBroker"/> class.
        /// </summary>
        /// <param name="settings"><see cref="T:TcmCDService.Configuration.Settings" /></param>
        public ZeroMQBroker(Settings settings)
            : base(settings)
        {
            mIdentifier = "ZeroMQ-" + Guid.NewGuid().ToString("D");
            mCancellationTokenSource = new CancellationTokenSource();
            mQueue = new BlockingCollection<ZeroMQMessage>();

            String subscriptionUri = settings.Get<String>("subscriptionUri");

            if (String.IsNullOrEmpty(subscriptionUri))
                throw new ConfigurationErrorsException("ZeroMQBroker: SubscriptionUri is unconfigured.");

            String submissionUri = settings.Get<String>("submissionUri");

            if (String.IsNullOrEmpty(submissionUri))
                throw new ConfigurationErrorsException("ZeroMQBroker: SubmissionUri is unconfigured.");

            mTopic = settings.Get<String>("topic");

            if (String.IsNullOrEmpty(mTopic))
            {
                Logger.Info("ZeroMQBroker: No topic configured, defaulting to \"TridionCacheChannel\".");
                mTopic = "TridionCacheChannel";
            }

            mSender = new Task(() =>
                {
                    SendEvents(subscriptionUri, mTopic, mCancellationTokenSource.Token);
                }, mCancellationTokenSource.Token,
                TaskCreationOptions.LongRunning);

            mReceiver = new Task(() =>
                {
                    ReceiveEvents(submissionUri, mTopic, mCancellationTokenSource.Token);
                }, mCancellationTokenSource.Token,
                TaskCreationOptions.LongRunning);
        }
开发者ID:TcmExtensions,项目名称:TcmCDService,代码行数:41,代码来源:ZeroMQBroker.cs


注:本文中的Settings.Get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。