private Boolean CreerConfigs()
        {
            Dictionary <String, ModelDoc2> ListeMdl = new Dictionary <String, ModelDoc2>()
            {
                { MdlBase.GetPathName(), MdlBase }
            };
            Dictionary <String, String> ListeMdlDisplayState = new Dictionary <string, string>()
            {
                { MdlBase.GetPathName(), MdlBase.eComposantRacine().ReferencedDisplayState }
            };

            foreach (Component2 cp in ListeComposants)
            {
                ModelDoc2 mdl = cp.GetModelDoc2();
                ListeMdl.AddIfNotExist(mdl.GetPathName(), mdl);
                ListeMdlDisplayState.AddIfNotExist(mdl.GetPathName(), cp.ReferencedDisplayState);

                foreach (Component2 cpParent in cp.eListeComposantParent())
                {
                    ModelDoc2 mdlParent = cpParent.GetModelDoc2();
                    ListeMdl.AddIfNotExist(mdlParent.GetPathName(), mdlParent);
                    ListeMdlDisplayState.AddIfNotExist(mdlParent.GetPathName(), cpParent.ReferencedDisplayState);
                }
            }

            int Options = (int)swConfigurationOptions2_e.swConfigOption_InheritProperties;

            if (SupprimerNvlFonction)
            {
                Options += (int)swConfigurationOptions2_e.swConfigOption_SuppressByDefault;
            }

            if (SupprimerNvComposant)
            {
                Options += (int)swConfigurationOptions2_e.swConfigOption_HideByDefault;
            }

            if ((ListeConfig.IsRef()) && (ListeConfig.Count > 0) && !String.IsNullOrWhiteSpace(ListeConfig[0]))
            {
                foreach (ModelDoc2 mdl in ListeMdl.Values)
                {
                    WindowLog.Ecrire(mdl.eNomAvecExt());
                    WindowLog.Ecrire(" - " + String.Join(" ", ListeConfig));
                    foreach (String nomConfig in ListeConfig)
                    {
                        String NomCurrentDisplayState = ListeMdlDisplayState[mdl.GetPathName()];

                        mdl.eAddConfiguration(nomConfig, nomConfig, "", Options);
                    }

                    WindowLog.SautDeLigne();
                }

                return(true);
            }

            return(false);
        }
Example #2
0
        public virtual IDictionary <string, object> ToDictionary()
        {
            Dictionary <string, object> result = new Dictionary <string, object>();

            result.AddIfNotExist("rel", "tooltip");
            if (Animation.HasValue)
            {
                result.AddIfNotExist("data-animation", Animation.Value ? "true" : "false");
            }
            if (Html.HasValue)
            {
                result.AddIfNotExist("data-html", Html.Value ? "true" : "false");
            }
            if (!string.IsNullOrEmpty(Placement))
            {
                result.AddIfNotExist("data-placement", Placement);
            }
            if (!string.IsNullOrEmpty(Selector))
            {
                result.AddIfNotExist("data-selector", Selector);
            }
            if (!string.IsNullOrEmpty(Title))
            {
                result.AddIfNotExist("data-title", Title);
            }
            if (!string.IsNullOrEmpty(Trigger))
            {
                result.AddIfNotExist("data-trigger", Trigger);
            }
            result.AddIfNotExist("data-placement", "right");

            return(result);
        }
        private static Dictionary <string, object> GetFieldsWithValue(Type type, object obj, string fieldName = null, BindingFlags?bindingFlags = null, bool includingBase = false)
        {
            var dic = new Dictionary <string, object>();

            //筛选BindingFlags
            BindingFlags flags = bindingFlags ?? FlagsOfAll;

            //获取字段
            FieldInfo[] fieldInfos = type.GetFields(flags);

            //筛选字段名称(精确筛选)
            if (!string.IsNullOrWhiteSpace(fieldName))
            {
                fieldInfos = fieldInfos.Where(x => x.Name == fieldName).ToArray();
            }

            //取值
            foreach (var fi in fieldInfos)
            {
                dic.Add(fi.Name, fi.GetValue(obj));
            }

            if (includingBase && (type = type.BaseType) != typeof(object))
            {
                var baseDic = GetFieldsWithValue(type, obj, fieldName, bindingFlags, true);
                dic.AddIfNotExist(baseDic);
            }

            return(dic);
        }
 public static void AddIfNotExist <TKey, TValue>(this Dictionary <TKey, TValue> dic, Dictionary <TKey, TValue> addDic)
 {
     foreach (var item in addDic)
     {
         dic.AddIfNotExist(item.Key, item.Value);
     }
 }
Example #5
0
        protected override Dictionary <string, object> BuildParams(object filter = null, IEnumerable <HistoryInclude> include = null, Dictionary <string, object> @params = null)
        {
            var includeHelper = new IncludeHelper(include == null ? 1 : include.Sum(x => (int)x));

            @params = @params ?? new Dictionary <string, object>();
            @params.AddIfNotExist("output", "extend");
            @params.AddOrReplace("filter", filter);

            return(@params);
        }
        public override IDictionary<string, object> ToDictionary()
        {
            Dictionary<string, object> result = new Dictionary<string, object>();

            result.AddIfNotExist("rel", "popover");
            if (Animation.HasValue) result.AddIfNotExist("data-animation", Animation.Value ? "true" : "false");
            if (Html.HasValue) result.AddIfNotExist("data-html", Html.Value ? "true" : "false");
            if (!string.IsNullOrEmpty(Placement)) result.AddIfNotExist("data-placement", Placement);
            if (!string.IsNullOrEmpty(Selector)) result.AddIfNotExist("data-selector", Selector);
            if (!string.IsNullOrEmpty(Title)) result.AddIfNotExist("data-title", Title);
            if (!string.IsNullOrEmpty(Content)) result.AddIfNotExist("data-content", Content);
            if (!string.IsNullOrEmpty(Trigger)) result.AddIfNotExist("data-trigger", Trigger);
            result.AddIfNotExist("data-placement", "right");

            return result;
        }
Example #7
0
        public void Add_Item_IfNotExist()
        {
            var       dic = new Dictionary <int, int>();
            const int k   = 1;
            const int v   = 1;

            dic.AddIfNotExist(k, v);

            Assert.True(dic.ContainsKey(k));
            Assert.Equal(dic[k], v);
            Assert.Single(dic);
        }
Example #8
0
        public virtual IDictionary <string, object> ToDictionary()
        {
            var result = new Dictionary <string, object>();

            result.AddIfNotExist("data-toggle", _type);
            if (_animation.HasValue)
            {
                result.AddIfNotExist("data-animation", _animation.Value ? "true" : "false");
            }
            if (_html.HasValue)
            {
                result.AddIfNotExist("data-html", _html.Value ? "true" : "false");
            }
            if (!string.IsNullOrEmpty(_placement))
            {
                result.AddIfNotExist("data-placement", _placement);
            }
            if (!string.IsNullOrEmpty(_selector))
            {
                result.AddIfNotExist("data-selector", _selector);
            }
            if (!string.IsNullOrEmpty(_title))
            {
                result.AddIfNotExist("data-title", _title);
            }
            if (!string.IsNullOrEmpty(_trigger))
            {
                result.AddIfNotExist("data-trigger", _trigger);
            }
            if (_type == "popover" && !string.IsNullOrEmpty(_content))
            {
                result.AddIfNotExist("data-content", _content);
            }
            result.AddIfNotExist("data-placement", "right");
            result.AddIfNotExist("data-container", "body");

            return(result);
        }
        public virtual IDictionary <string, object> ToDictionary(HtmlHelper html)
        {
            var urlHelper = new UrlHelper(html.ViewContext.RequestContext);
            var result    = new Dictionary <string, object>();

            result.AddIfNotExist("data-provide", "typeahead");
            result.AddIfNotExist("autocomplete", "off");
            if (_result != null)
            {
                result.AddIfNotExist("data-url", urlHelper.Action(_result));
            }
            if (_taskResult != null)
            {
                result.AddIfNotExist("data-url", urlHelper.Action(_taskResult));
            }
            if (!string.IsNullOrEmpty(_actionName) || !string.IsNullOrEmpty(_controllerName))
            {
                result.AddIfNotExist("data-url", urlHelper.Action(actionName: _actionName, controllerName: _controllerName));
            }
            if (_items.HasValue)
            {
                result.AddIfNotExist("data-items", _items.Value.ToString());
            }
            if (_minLength.HasValue)
            {
                result.AddIfNotExist("data-minLength", _minLength.Value.ToString());
            }
            if (!string.IsNullOrEmpty(_source))
            {
                result.AddIfNotExist("data-source", _source);
            }
            if (!string.IsNullOrEmpty(_matcher))
            {
                result.AddIfNotExist("data-matcher", _matcher);
            }
            if (!string.IsNullOrEmpty(_sorter))
            {
                result.AddIfNotExist("data-sorter", _sorter);
            }
            if (!string.IsNullOrEmpty(_updater))
            {
                result.AddIfNotExist("data-updater", _updater);
            }
            if (!string.IsNullOrEmpty(_highlighter))
            {
                result.AddIfNotExist("data-highlighter", _highlighter);
            }

            return(result);
        }
        public virtual IDictionary<string, object> ToDictionary(HtmlHelper html)
        {
            var urlHelper = new UrlHelper(html.ViewContext.RequestContext);
            var result = new Dictionary<string, object>();

            result.AddIfNotExist("data-provide", "typeahead");
            result.AddIfNotExist("autocomplete", "off");
            if (_result != null) result.AddIfNotExist("data-url", urlHelper.Action(_result));
            if (_taskResult != null) result.AddIfNotExist("data-url", urlHelper.Action(_taskResult));
            if (!string.IsNullOrEmpty(_actionName) || !string.IsNullOrEmpty(_controllerName))
                result.AddIfNotExist("data-url", urlHelper.Action(actionName: _actionName, controllerName: _controllerName));
            if (_items.HasValue) result.AddIfNotExist("data-items", _items.Value.ToString());
            if (_minLength.HasValue) result.AddIfNotExist("data-minLength", _minLength.Value.ToString());
            if (!string.IsNullOrEmpty(_source)) result.AddIfNotExist("data-source", _source);
            if (!string.IsNullOrEmpty(_matcher)) result.AddIfNotExist("data-matcher", _matcher);
            if (!string.IsNullOrEmpty(_sorter)) result.AddIfNotExist("data-sorter", _sorter);
            if (!string.IsNullOrEmpty(_updater)) result.AddIfNotExist("data-updater", _updater);
            if (!string.IsNullOrEmpty(_highlighter)) result.AddIfNotExist("data-highlighter", _highlighter);

            return result;
        }
Example #11
0
        public override IDictionary <string, object> ToDictionary()
        {
            Dictionary <string, object> result = new Dictionary <string, object>();

            result.AddIfNotExist("data-toggle", "popover");
            if (Animation.HasValue)
            {
                result.AddIfNotExist("data-animation", Animation.Value ? "true" : "false");
            }
            if (Html.HasValue)
            {
                result.AddIfNotExist("data-html", Html.Value ? "true" : "false");
            }
            if (!string.IsNullOrEmpty(Placement))
            {
                result.AddIfNotExist("data-placement", Placement);
            }
            if (!string.IsNullOrEmpty(_titleClass))
            {
                result.AddIfNotExist("data-titleclass", _titleClass);
            }
            if (!string.IsNullOrEmpty(Selector))
            {
                result.AddIfNotExist("data-selector", Selector);
            }
            if (!string.IsNullOrEmpty(Title))
            {
                result.AddIfNotExist("data-title", Title);
            }
            if (!string.IsNullOrEmpty(Content))
            {
                result.AddIfNotExist("data-content", Content);
            }
            if (!string.IsNullOrEmpty(Trigger))
            {
                result.AddIfNotExist("data-trigger", Trigger);
            }
            result.AddIfNotExist("data-container", "body");
            result.AddIfNotExist("data-placement", "right");

            return(result);
        }
Example #12
0
        public void LoadContent(ContentManager content)
        {
            spriteTextureParam = new JavaScriptSerializer().Deserialize <Dictionary <string, SpriteTextureParam> >(ReadAllText(Constants.DATA_FILES_PATH + Constants.SPRITE_DATA_FILE));
            spriteTextureParam.ForEach((name, param) => param.TextureName.NotNullThen(() => textures.AddIfNotExist(param.TextureName, null)));
            textures.Keys.ToList().ForEach(name => textures[name] = content.Load <Texture2D>(name));

            hudFont             = content.Load <SpriteFont>(Constants.HUD_FONT_SPRITE);
            promptingPointsFont = content.Load <SpriteFont>(Constants.SMALL_FONT_SPRITE);
            consoleFont         = content.Load <SpriteFont>(Constants.CONSOLE_FONT_SPRITE);
        }
 internal static V GetOrAddIfNotExist <K, V> (this Dictionary <K, V> dict, K key, V value)
 {
     dict.AddIfNotExist(key, value);
     return(dict[key]);
 }
Example #14
0
        private List <Dictionary <string, List <string> > > ParseSubAccFromFile(string file)
        {
            var removeSpecCharRegexp = new Regex(@"[^a-z0-9 ]", RegexOptions.Compiled);

            var endOfWord     = @"\b";
            var startOfWord   = @"\b";
            var wordsToRemove = "fund,class,the".Split(',')
                                .Select(x => new Regex(startOfWord + x + endOfWord, RegexOptions.Compiled))
                                .ToList();

            var removeDuplicateCharRegexp = new Regex(@"[ ]{2,}", RegexOptions.Compiled);

            var removeValInBktRegexp = new Regex(@"\(.*\)", RegexOptions.Compiled);

            string[] tikerMarkWordsArr = { "GROWTH",    "CAPITAL", "INCOME",    "INVESTMENT", "ALLOCATION", "VALUE",      "EQUITY",    "INDEX",     "INTERNATIONAL", "TOTAL",    "SMALL",       "INSTITUTIONAL",
                                           "INFLATION", "MARKET",  "SELECT",    "RETURN",     "FINANCIAL",  "ASSET",      "CORPORATE", "FUND",      "FUNDS",         "ENHANCED", "CONVERTIBLE", "RETIREMENT",   "MODERATE",
                                           "BOND",      "SHORT",   "INVESTORS", "STOCK",      "HEALTH",     "BALANCED",   "GLOBAL",    "INSIGHTS",  "GOVERNMENT",    "EMERGING", "WORLD",       "HEALTHCARE",   "TREASURY",
                                           "INFO",      "REAL",    "RESERVES",  "MARKETS",    "ENERGY",     "TECHNOLOGY", "CASH",      "RESOURCES", "COMPANY",       "LONG",     "TERM",        "APPRECIATION", "HIGH",
                                           "LARGE",     "MID",     "Portfolio" };


            var tickerMarkWordsArrRegex = tikerMarkWordsArr
                                          .Select(x => new Regex(startOfWord + x.ToLower() + endOfWord, RegexOptions.Compiled))
                                          .ToList();


            var resultIssuers = new List <Dictionary <string, List <string> > >();
            var comboList     = new Dictionary <string, List <string> >();

            var    probabilityMass = 0;
            string detectedIssuer  = null;
            string possibleIsser   = null;

            using (var stream = new FileStream(file, FileMode.Open, FileAccess.Read))
            {
                var dt = XlsxToCsvConverter.XlsxToDataTable(stream, false, 0, 0);
                prgLine.Maximum = dt.Rows.Count;

                for (int j = 0; j < dt.Columns.Count; j++)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        prgLine.Increment(1);

                        Application.DoEvents();
                        var    row              = dt.Rows[i][j];
                        string rawVal           = row.ToString().Trim();
                        string val              = rawVal.ToLower();
                        var    tickerMarksInVal = tickerMarkWordsArrRegex.Where(regex => regex.IsMatch(val)).ToList();
                        val = removeValInBktRegexp.Replace(val, "");
                        val = removeSpecCharRegexp.Replace(val, "");
                        val = wordsToRemove.Aggregate(val, (current, regex) => regex.Replace(current, ""));
                        val = removeDuplicateCharRegexp.Replace(val, "").Trim();
                        if (string.IsNullOrEmpty(val))
                        {
                            continue;
                        }

                        if (val.Length <= 100)
                        {
                            if (rawVal.Length >= 4 && rawVal.Any(char.IsLetter) && rawVal.All(x => !char.IsLetter(x) || char.IsUpper(x)))
                            {
                                possibleIsser   = detectedIssuer ?? rawVal;
                                probabilityMass = probabilityMass > 1 ? probabilityMass : 1;
                            }


                            if (tickerMarksInVal.Count > 0)
                            {
                                possibleIsser   = detectedIssuer ?? possibleIsser ?? "";
                                probabilityMass = probabilityMass > 2 ? probabilityMass : 2;
                                comboList.AddIfNotExist(possibleIsser, new List <string>());
                                comboList[possibleIsser].Add(string.Format("{0},{1},{2}", i, j, val));
                                continue;
                            }

                            if (probabilityMass > 0)
                            {
                                probabilityMass--;

                                long longVal;
                                if (val.Length > 5 && !long.TryParse(val, out longVal))
                                {
                                    comboList.AddIfNotExist(detectedIssuer ?? possibleIsser, new List <string>());
                                    comboList[detectedIssuer ?? possibleIsser].Add(string.Format("{0},{1},{2}", i, j, val));
                                }

                                continue;
                            }
                        }

                        if (comboList.Count >= 2 || comboList.Values.Sum(x => x.Count) >= 5)
                        {
                            resultIssuers.Add(comboList);
                        }

                        comboList       = new Dictionary <string, List <string> >();
                        detectedIssuer  = null;
                        possibleIsser   = null;
                        probabilityMass = 0;
                    }

                    // startNewColumn
                    if (comboList.Count >= 2 || comboList.Values.Sum(x => x.Count) >= 5)
                    {
                        resultIssuers.Add(comboList);
                    }

                    comboList       = new Dictionary <string, List <string> >();
                    detectedIssuer  = null;
                    possibleIsser   = null;
                    probabilityMass = 0;
                }


                //finalize
                if (comboList.Count >= 2 || comboList.Values.Sum(x => x.Count) >= 5)
                {
                    resultIssuers.Add(comboList);
                }
            }

            using (var fileWriter = new StreamWriter(file + "_result.csv"))
            {
                resultIssuers = resultIssuers.OrderByDescending(x => x.Keys.Count).ToList();
                var allreadyAddedSubAcc = new HashSet <string>();

                foreach (var dict in resultIssuers)
                {
                    var uniqList = dict.Values.SelectMany(x => x).Where(value => allreadyAddedSubAcc.Add(value.Split(',')[2])).ToList();
                    if (uniqList.Count() < 5)
                    {
                        continue;
                    }

                    fileWriter.WriteLine("New Combo. KeyCount {0}, ValueCount {1}", dict.Keys.Count, dict.Values.Sum(x => x.Count));

                    foreach (var issuerToValListPair in dict)
                    {
                        foreach (var value in issuerToValListPair.Value)
                        {
                            fileWriter.WriteLine("{0},{1}", issuerToValListPair.Key, value);
                        }
                    }

                    fileWriter.WriteLine();
                }
            }

            return(resultIssuers);
        }