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


C# OrderedDictionary.Cast方法代码示例

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


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

示例1: Apply

 public PropertyValueApplier Apply(OrderedDictionary propertyValues)
 {
     return Apply(
         propertyValues.Cast<DictionaryEntry>()
             .ToDictionary(
                 x => (string)x.Key,
                 x => x.Value
             )
     );
 }
开发者ID:chiganock,项目名称:VtecTeamFlasher,代码行数:10,代码来源:PropertyValueManager.cs

示例2: htmlToPlainText

        private static string htmlToPlainText( string html )
        {
            const string emptyString = "";
            const string singleSpace = " ";

            // Maintains insert-order. Sadly, is not generic.
            var regexToReplacements = new OrderedDictionary
                {
                    { "(\r\n|\r|\n)+", singleSpace },
                    { "\t", emptyString },
                    { @"/\*.*\*/", emptyString },
                    { @"<!--.*-->", emptyString },
                    { @"\s+", singleSpace },
                    { @"<\s*head([^>])*>.*(<\s*(/)\s*head\s*>)", emptyString },
                    { @"<\s*script([^>])*>.*(<\s*(/)\s*script\s*>)", emptyString },
                    { @"<\s*style([^>])*>.*(<\s*(/)\s*style\s*>)", emptyString },
                    { @"<\s*td([^>])*>", "\t" },
                    { @"<\s*br\s*/?>", Environment.NewLine },
                    { @"<\s*li\s*>", Environment.NewLine },
                    { @"<\s*div([^>])*>", Environment.NewLine + Environment.NewLine },
                    { @"<\s*tr([^>])*>", Environment.NewLine + Environment.NewLine },
                    { @"<\s*p([^>])*>", Environment.NewLine + Environment.NewLine },
                    { RegularExpressions.HtmlTag, emptyString },
                    { @"<![^>]*>", emptyString },
                    { @"&bull;", " * " },
                    { @"&lsaquo;", "<" },
                    { @"&rsaquo;", ">" },
                    { @"&trade;", "(tm)" },
                    { @"&frasl;", "/" },
                    { @"&lt;", "<" },
                    { @"&gt;", ">" },
                    { @"&copy;", "(c)" },
                    { @"&reg;", "(r)" },
                    { @"&(.{2,6});", emptyString },
                    { Environment.NewLine + @"\s+" + Environment.NewLine, Environment.NewLine + Environment.NewLine },
                    { @"\t\s+\t", "\t\t" },
                    { @"\t\s+" + Environment.NewLine, "\t" + Environment.NewLine },
                    { Environment.NewLine + @"\s+\t", Environment.NewLine + "\t" },
                    { Environment.NewLine + @"\t+" + Environment.NewLine, Environment.NewLine + Environment.NewLine },
                    { Environment.NewLine + @"\t+", Environment.NewLine + "\t" }
                };

            return
                regexToReplacements.Cast<DictionaryEntry>()
                    .Aggregate(
                        html,
                        ( current, regexToReplacement ) => Regex.Replace( current, (string)regexToReplacement.Key, (string)regexToReplacement.Value, RegexOptions.IgnoreCase ) )
                    .Trim();
        }
开发者ID:enduracode,项目名称:enterprise-web-library,代码行数:49,代码来源:EmailStatics.cs

示例3: CreatePayeTable

        private OrderedDictionary CreatePayeTable(string YearSelected, out decimal personalAllowance, out string taxCodeLetter)
        {
            OrderedDictionary payetable = new OrderedDictionary();
            personalAllowance = 0m;
            taxCodeLetter = "";
            decimal numericAmount = 0m;

            List<string> TaxCodes = ReadXML("//YearEnd[@Year='"+YearSelected+"']/PAYE/BandCodes//@letter");
            List<string> TaxCodesEndLetters = ReadXML("//YearEnd[@Year='" + YearSelected + "']/PAYE/BandEndLetters/Letter");
            List<string> TaxCodesStartLetters = ReadXML("//YearEnd[@Year='" + YearSelected + "']/PAYE/BandStartLetters/Letter");

            //If no Tax code was enter, use default and call method again.
            if (TaxCode.Text == "") {
                TaxCode.Text = ReadXML("//YearEnd[@Year='" + YearSelected + "']/PAYE/Default").First();
                payetable = CreatePayeTable(YearSelected, out personalAllowance, out taxCodeLetter);
            }
            else if (TaxCodes.Contains(TaxCode.Text)) //Checks for single rate NT, BR, D0 etc.
            {
                payetable = ReadRatesXML("//YearEnd[@Year='" + YearSelected + "']/PAYE/BandCodes/code[@letter='" + TaxCode.Text + "']");
            }
            //The case for the L (and related) codes is complex. We need to take into consideration that the personal Allowance
            //reduces by 2 after the salary goes past £100,000 (the adjusted level).
            //To do this, the rate will be increased by 1.5 post £100,000 until the personal allowance reaches 0.
            //This threshold will be 100,000 + 2 * personal allowance.
            else if (TaxCodesEndLetters.Contains(TaxCode.Text.Substring(TaxCode.Text.Length - 1, 1)))
            {
                if (decimal.TryParse(TaxCode.Text.Substring(0, TaxCode.Text.Length - 1), out numericAmount))
                {
                    personalAllowance = numericAmount * 10 + 9;
                    OrderedDictionary payetableRate = new OrderedDictionary();
                    payetableRate = ReadRatesXML("//YearEnd[@Year='" + YearSelected + "']/PAYE/Bands", personalAllowance);
                    decimal Adjusted = 0;
                    if (ReadXML("//YearEnd[@Year='" + YearSelected + "']/PAYE/Adjusted").Count == 1)
                    {
                        Adjusted = Convert.ToDecimal(ReadXML("//YearEnd[@Year='" + YearSelected + "']/PAYE/Adjusted").First());
                    }

                    if (Adjusted != 0)
                    {
                        decimal AdjustedUpper = Adjusted + 2 * (personalAllowance-9);
                        int i = 0;
                        decimal Bound = 0;
                        decimal Rate = 0;
                        decimal RateAdjusted = 0;
                        int NumberOfEntries = payetableRate.Count;
                        payetable.Add(Bound, Rate);

                        //3 stages here
                        //i. Add thresholds below the Adjusted level
                        //ii. Add thresholds between Adjusted level and Adjusted level + 2 * personal allowance
                        //iii. Add thresholds post Adjusted level + 2 * personal allowance

                        //Stage i
                        while (true) //infinite loop but breaking when either of two conditions are met
                        {
                            Bound = Convert.ToDecimal(payetableRate.Cast<DictionaryEntry>().ElementAt(i).Key);
                            Rate = Convert.ToDecimal(payetableRate[i]);
                            if (Bound < Adjusted)
                            { payetable.Add(Bound, Rate); }
                            else //break when Adjusted level is reached
                            {
                                RateAdjusted = Convert.ToDecimal(payetableRate[i - 1]) * 1.5m;
                                payetable.Add(Adjusted, RateAdjusted);
                                break;
                            }
                            if (i < NumberOfEntries - 1)
                            { i++; }
                            else  //break also when end of table is reached
                            {
                                RateAdjusted = Convert.ToDecimal(payetableRate[i]) * 1.5m;
                                payetable.Add(Adjusted, RateAdjusted);
                                break;
                            }
                        }

                        //Stage ii
                        decimal BoundAdjusted = 0;
                        while (AdjustedUpper > Bound - personalAllowance)
                        {
                            Bound = Convert.ToDecimal(payetableRate.Cast<DictionaryEntry>().ElementAt(i).Key);
                            if (Bound < Adjusted)
                            {
                                Rate = Convert.ToDecimal(payetableRate[i]);
                                payetable.Add(AdjustedUpper, Rate);
                                break;
                            }
                            if (Bound - personalAllowance < AdjustedUpper)
                            {
                                BoundAdjusted = AdjustedUpper / 3 + 2 * (Bound - personalAllowance) / 3;
                                RateAdjusted = Convert.ToDecimal(payetableRate[i]) * 1.5m;
                                payetable.Add(BoundAdjusted, RateAdjusted);
                            }
                            else
                            {
                                Rate = Convert.ToDecimal(payetableRate[i - 1]);
                                payetable.Add(AdjustedUpper, Rate);
                                break;
                            }
                            if (i < NumberOfEntries - 1)
                            { i++; }
//.........这里部分代码省略.........
开发者ID:srscrls,项目名称:payroll-calculator,代码行数:101,代码来源:MainWindow.xaml.cs

示例4: GeneratePublishHtml

		/// <summary>
		/// Generates HTML for the publishing mode
		/// </summary>
		/// <param name="content">Smart content object</param>
		/// <param name="publishingContext">Publishing context</param>
		/// <returns>Html</returns>
		public override string GeneratePublishHtml(ISmartContent content, IPublishingContext publishingContext)
		{
			// Get non-default options
			EffectiveOption[] options = DC.Crayon.Wlw.Framework.
				Options.GetEffectiveOptions(content.Properties, Options)
					.Where(p => p.Location != OptionLocation.Default)
					.ToArray();

			// Html Element
			HtmlElement preElement = new HtmlElement() { Tag = "pre" };
			OrderedDictionary classAttrParts = new OrderedDictionary(StringComparer.Ordinal);
			OrderedDictionary styleAttr = new OrderedDictionary(StringComparer.Ordinal);

			// Decode
			classAttrParts["decode"] = "true";

			// Setting Groups
			ApplyContentSettings(false, preElement, classAttrParts, styleAttr, options);
			ApplyMetricsSettings(false, preElement, classAttrParts, styleAttr, options);
			ApplyToolbarSettings(true, preElement, classAttrParts, styleAttr, options);
			ApplyLinesSettings(true, preElement, classAttrParts, styleAttr, options);
			ApplyCodeSettings(true, preElement, classAttrParts, styleAttr, options);

			// Set Class
			if (classAttrParts.Count > 0)
			{
				preElement.Attributes["class"] = string.Join(" ",
					classAttrParts.Cast<DictionaryEntry>()
					.Select(kv => string.Format(CultureInfo.InvariantCulture, "{0}:{1}", kv.Key, HtmlElement.EscapeAttributeValue(kv.Value.ToString())))
					.ToArray());
			}

			// Return
			return preElement.ToString();
		}
开发者ID:stevebeauge,项目名称:crayon-syntax-snippet-wlw,代码行数:41,代码来源:CrayonSnippetPlugin.cs


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