Ejemplo n.º 1
0
        /// <summary>
        /// Declare _dtnInit
        /// Dictionary<string, string> _dtnInit = new Dictionary<string, string>();
        /// </summary>
        private void setConfigForm()
        {
            try
            {
                System.Collections.Generic.Dictionary <string, string> dtnInit = new System.Collections.Generic.Dictionary <string, string>();
                dtnInit = ComVar.Func.getInitForm(ComVar.Var._Frm_Call + this.GetType().Assembly.GetName().Name, this.GetType().Name);

                for (int i = 0; i < dtnInit.Count; i++)
                {
                    setComValue(dtnInit.ElementAt(i).Key, dtnInit.ElementAt(i).Value);
                }
            }
            catch (Exception ex)
            {
                ComVar.Var.writeToLog(this.GetType().Name + "-->setConfigForm-->Err:    " + ex.ToString());
            }
        }
Ejemplo n.º 2
0
        public IEnumerable <Dog> GenerateRandom(int n)
        {
            Random random = new Random();

            for (int i = 0; i < n; i++)
            {
                int position = random.Next(0, dicts.Count - 1);
                var(_, factory) = dicts.ElementAt(position);
                yield return((Dog)factory.GetType().GetMethod("Generate").Invoke(factory, null));
            }
        }
Ejemplo n.º 3
0
 // Renvoie la liste des sous-jacents d'une option s'ils existent
 public System.Collections.Generic.List<PricingLibrary.FinancialProducts.Share> getUnderlyingShares(PricingLibrary.FinancialProducts.Option option)
 {
     System.Collections.Generic.List<PricingLibrary.FinancialProducts.Share> underlyingShares = new System.Collections.Generic.List<PricingLibrary.FinancialProducts.Share>();
     System.Collections.Generic.Dictionary<String, String> UnderlyingSharesNames = new System.Collections.Generic.Dictionary<String, String>();
     using (DataBaseDataContext mtdc = new DataBaseDataContext())
     {
         UnderlyingSharesNames = (from s in mtdc.ShareNames where (option.UnderlyingShareIds.Contains(s.id)) select s).ToDictionary(s => s.name, s => s.id);
     }
     for (int index = 0; index < UnderlyingSharesNames.Count; index++)
     {
         var item = UnderlyingSharesNames.ElementAt(index);
         String itemKey = item.Key;
         String itemValue = item.Value.TrimEnd();
         PricingLibrary.FinancialProducts.Share share = new PricingLibrary.FinancialProducts.Share(itemKey, itemValue);
         underlyingShares[index] = share;
     }
     return underlyingShares;
 }
Ejemplo n.º 4
0
 public static KeyValuePair<K,V> Next<K,V>(System.Collections.Generic.Dictionary<K,V> col, ref int index) {
     /** ElementAt from IEnumerable will create enumerator and advance it : very inefficient */
     index = (index == -2) ? rand.Next(col.Count) : (index+1) % col.Count;
     return col.ElementAt(0); // if it does what I think, this is very slow !!!!
     // return Enumerable.ElementAt(col, 0); // does not require linq
 }