Пример #1
0
        /// <summary>
        /// Get ref objects by priority order
        /// </summary>
        /// <param name="inTarget"></param>
        /// <param name="inRefs"></param>
        /// <returns></returns>
        public virtual List <string> GetRefs(string inTarget, string inRefs)
        {
            List <string> refs = TypesHelper.StringSplit(inRefs, ";", true, true);

            //If the list contains None, don't add itself to possible matches
            if (refs.Contains("None"))
            {
                refs.Remove("None");
            }
            else //Add itself to possible matches
            {
                bool offsettedSelf = false;
                for (int i = 0; i < refs.Count; i++)
                {
                    if (refs[i].StartsWith("+"))
                    {
                        refs[i]       = GetHimself(inTarget) + refs[i];
                        offsettedSelf = true;
                        break;
                    }
                }

                if (!offsettedSelf)
                {
                    refs.Add(GetHimself(inTarget));
                }
            }

            return(refs);
        }
        /// <summary>
        /// Helper for Dictionary Deserialization
        /// </summary>
        /// <param name="inDic">The serialized Dictionary</param>
        /// <returns>The Dictionary</returns>
        public static SortedDictionary <string, string> DeserializeSortedDictionary(string inDic)
        {
            SortedDictionary <string, string> dic = new SortedDictionary <string, string>();

            if (string.IsNullOrEmpty(inDic))
            {
                return(dic);
            }

            List <string> stringSplit = TypesHelper.StringSplit(inDic, "|DicItem|", false, true);

            foreach (string stringItem in stringSplit)
            {
                List <string> itemSplit = TypesHelper.StringSplit(stringItem, ":DicValue:", false, false);

                if (itemSplit.Count == 2)
                {
                    dic.Add(itemSplit[0], itemSplit[1]);
                }
            }

            return(dic);
        }