Пример #1
0
 /// <summary>
 /// Builds the element with a list of attributes
 /// </summary>
 /// <param name="el">The element</param>
 /// <param name="attributes">A dictionary of attributes to add to the element</param>
 public HtmlElement(String el, Dictionary<String, String> attributes )
 {
     var attrs = attributes.Aggregate("", (current, item) => current + (item.Key + "='" + item.Value + "' " ));
     this.elementStart = "<" + el + " " + attrs + ">";
     this.elementEnd = "</" + el + ">";
     this.el = el;
 }
Пример #2
0
 /// <summary>
 /// Returns the type that is used most often in a range of cells.
 /// </summary>
 /// <returns>The predominant <c>Type</c> in the range of cells.</returns>
 public static Type DetermineDataType(Range excelCells)
 {
     IDictionary<Type, int> typeCounts = new Dictionary<Type, int> ();
                 foreach (Range cell in excelCells) {
                         if (cell.Value == null) {
                                 logger.Info ("A null value was encoutered in Cell: {0}{1}",
               cell.Row,
               cell.Column);
                         } else {
                                 Type cellType = cell.Value.GetType ();
                                 if (typeCounts.ContainsKey (cellType)) {
                                         typeCounts [cellType] += 1;
                                 } else {
                                         typeCounts.Add (cellType, 1);
                                 }
                         }
                 }
                 if (typeCounts.Count == 0)
                         throw new ArgumentException ("All cells were empty. Can not proceed");
                 Type maxUsedType = typeCounts.Aggregate ((l, r) => l.Value > r.Value ? l : r).Key;
                 return maxUsedType;
 }
        private RelativeOrientation GetRelativeOrientation2(IPolycurve pFoundLineAsPolyCurve, IPolycurve inPolycurve)
        {
            //iRelativeOrientation == 1 --> closest points are original TO and found TO
            //iRelativeOrientation == 2 --> closest points are original TO and found FROM
            //iRelativeOrientation == 3 --> closest points are original FROM and found TO
            //iRelativeOrientation == 4 --> closest points are original FROM and found FROM
            
            Dictionary<int, double> dictSort2GetShortest = new Dictionary<int, double>();
            dictSort2GetShortest.Add(1, ((IProximityOperator)pFoundLineAsPolyCurve.ToPoint).ReturnDistance(inPolycurve.ToPoint));
            dictSort2GetShortest.Add(2, ((IProximityOperator)pFoundLineAsPolyCurve.FromPoint).ReturnDistance(inPolycurve.ToPoint));
            dictSort2GetShortest.Add(3, ((IProximityOperator)pFoundLineAsPolyCurve.ToPoint).ReturnDistance(inPolycurve.FromPoint));
            dictSort2GetShortest.Add(4, ((IProximityOperator)pFoundLineAsPolyCurve.FromPoint).ReturnDistance(inPolycurve.FromPoint));

            return (RelativeOrientation)dictSort2GetShortest.Aggregate((l, r) => l.Value < r.Value ? l : r).Key;
        }
Пример #4
0
 public static void PrintDictionary(Dictionary<string, string> dict)
 {
     var pS = dict.Aggregate("\n",
         (current, variable) => current + (variable.Key + "=" + variable.Value + "\n"));
     Log.Debug(pS);
 }