示例#1
0
 /// <summary>
 /// Gets the named attribute. Returns an empty string if not found.
 /// </summary>
 /// <param name="name">Name of the attribute</param>
 /// <returns></returns>
 public string GetAttribute(string name, bool caseSensitive)
 {
     if (0 == AttributeCount)
     {
         return(string.Empty);
     }
     if (!caseSensitive)
     {
         name = name.ToLowerInvariant();
         if (_attributes.Contains(name))
         {
             return(_attributes[name] as string);
         }
         else
         {
             return(string.Empty);
         }
     }
     else
     {
         if (_attributesCaseSensitive.Contains(name))
         {
             return(_attributesCaseSensitive[name] as string);
         }
         else
         {
             return(string.Empty);
         }
     }
 }
示例#2
0
        private void initBiList()
        {
            string bi;

            StreamReader sr = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("AdaptiveAlgorithm.confuse_data.txt"));

            while (sr.Peek() > -1)
            {
                bi = sr.ReadLine();



                if (h.Contains(bi.Substring(0, 2) + " " + bi.Substring(3, 2)))
                {
                }
                else
                {
                    h.Add(bi.Substring(0, 2) + " " + bi.Substring(3, 2), 1);
                }

                if (h.Contains(bi.Substring(3, 2) + " " + bi.Substring(0, 2)))
                {
                }
                else
                {
                    h.Add(bi.Substring(3, 2) + " " + bi.Substring(0, 2), 1);
                }
            }
            sr.Close();
        }
示例#3
0
        /// <summary>
        /// 获取实例
        /// </summary>
        /// <param name="ip"></param>
        /// <param name="port"></param>
        /// <returns></returns>
        public static TcpHost GetInstence(string ip = "127.0.0.1", int port = 12333)
        {
            if (tcpHosts == null)
            {
                tcpHosts = new System.Collections.Specialized.HybridDictionary();
            }

            TcpHost tcpHost = null;
            var     key     = ip + ":" + port;

            lock (tcpHosts)
            {
                if (tcpHosts.Contains(key))
                {
                    tcpHost = tcpHosts[key] as TcpHost;
                }
            }

            if (tcpHost == null)
            {
                tcpHost      = new TcpHost();
                tcpHost.IP   = ip;
                tcpHost.Port = port;
                tcpHost.Connection();
                lock (tcpHosts)
                {
                    tcpHosts.Add(key, tcpHost);
                }
            }

            return(tcpHost);
        }
示例#4
0
        /// <summary>
        /// Creates a font table from a font object.  When an Insert or Append
        /// operation is performed a font is either specified or the default font
        /// is used.  In any case, on any Insert or Append, only one font is used,
        /// thus the font table will always contain a single font.  The font table
        /// should have the form ...
        ///
        /// {\fonttbl{\f0\[FAMILY]\fcharset0 [FONT_NAME];}
        /// </summary>
        /// <param name="_font"></param>
        /// <returns></returns>
        private string GetFontTable(Font _font)
        {
            StringBuilder _fontTable = new StringBuilder();

            // Append table control string
            _fontTable.Append(@"{\fonttbl{\f0");
            _fontTable.Append(@"\");

            // If the font's family corresponds to an RTF family, append the
            // RTF family name, else, append the RTF for unknown font family.
            if (rtfFontFamily.Contains(_font.FontFamily.Name))
            {
                _fontTable.Append(rtfFontFamily[_font.FontFamily.Name]);
            }
            else
            {
                _fontTable.Append(rtfFontFamily[FF_UNKNOWN]);
            }

            // \fcharset specifies the character set of a font in the font table.
            // 0 is for ANSI.
            _fontTable.Append(@"\fcharset0 ");

            // Append the name of the font
            _fontTable.Append(_font.Name);

            // Close control string
            _fontTable.Append(@";}}");

            return(_fontTable.ToString());
        }
        ///<summary>Validator deligate checks that there are no duplicate entries.</summary>
        protected void CheckDuplicate(ValidatorAttribute Source, ValidatingSerializerEventArgs e)
        {
            bool   IsValid = true;
            string key     = String.Empty;

            System.Collections.Specialized.HybridDictionary CheckList = new System.Collections.Specialized.HybridDictionary();

            foreach (InsuranceLineItem C in this)
            {
                key = C.ProductType.ToString() + " " + C.Policy + " " + C.RevenueType.ToString();
                if (CheckList.Contains(key))
                {
                    IsValid = false;
                }
                else
                {
                    CheckList.Add(key, C.RevenueType);
                }

                if (IsValid == false)
                {
                    e.Error = new ErrorInfo(Source, "Duplicates");
                }
            }
        }
示例#6
0
        /// <summary>
        /// 获取实例
        /// </summary>
        /// <param name="ip"></param>
        /// <param name="port"></param>
        /// <returns></returns>
        public static UdpHost GetInstence(string ip = "127.0.0.1", int port = 12333)
        {
            if (udpHosts == null)
            {
                udpHosts = new System.Collections.Specialized.HybridDictionary();
            }

            UdpHost udpHost = null;
            var     key     = ip + ":" + port;

            lock (udpHosts)
            {
                if (udpHosts.Contains(key))
                {
                    udpHost = udpHosts[key] as UdpHost;
                }
            }

            if (udpHost == null)
            {
                udpHost      = new UdpHost();
                udpHost.IP   = ip;
                udpHost.Port = port;
                udpHost.Receive();
                udpHost.Connection();
                lock (udpHosts)
                {
                    udpHosts.Add(key, udpHost);
                }
            }

            return(udpHost);
        }
示例#7
0
        private double simil(string biE, string biF)
        {
            if (biE.Equals(biF))
            {
                return(1);
            }
            if (h.Contains(biE + " " + biF))
            {
                if (h[biE + " " + biF].Equals(1))
                {
                    return(c_score);
                }
            }

            biE = System.Text.RegularExpressions.Regex.Replace(biE, "#", "=");
            string a1 = biE.Substring(0, 1);
            string a2 = biE.Substring(1, 1);
            string b1 = biF.Substring(0, 1);
            string b2 = biF.Substring(1, 1);

            if (a1.Equals(b1) || a2.Equals(b2))
            {
                return(p_score);
            }
            else
            {
                return(0);
            }
        }         // end simil;
示例#8
0
        public System.Collections.Generic.Dictionary <RecordType, DnsCacheMessageEntry> this[string key] {
            get {
                if (!list.Contains(key))
                {
                    return(null);
                }

                return((System.Collections.Generic.Dictionary <RecordType, DnsCacheMessageEntry>)list[key]);
            }
            set {
                if (!list.Contains(key))
                {
                    list.Add(key, value);
                }
                else
                {
                    list[key] = value;
                }
            }
        }
示例#9
0
 public string GetElementNodeValue(string element)
 {
     if (!elementValuesParsed)
     {
         ParseElementValues();
     }
     if (ElementValues.Contains(element))
     {
         return(ElementValues[element] as string);
     }
     return(null);
 }
示例#10
0
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            var settings = LogCategoryConfigSection.GetConfig();

            if (settings == null)
            {
                throw new System.Configuration.ConfigurationErrorsException("未找到日志类别配置");
            }

            var nodeGenerl = new DeluxeTreeNode("用户操作", "G")
            {
                Expanded = true
            };

            var nodeAd = new DeluxeTreeNode("活动目录同步", "AD")
            {
                Expanded     = true,
                NodeCloseImg = "../images/ad.png",
                NodeOpenImg  = "../images/ad.png"
            };

            var nodeAdReverse = new DeluxeTreeNode("活动目录反向同步", "RAD");

            this.tree.Nodes.Add(nodeGenerl);
            this.tree.Nodes.Add(nodeAd);
            this.tree.Nodes.Add(nodeAdReverse);

            System.Collections.Specialized.HybridDictionary dic = new System.Collections.Specialized.HybridDictionary();

            foreach (LogCategoryConfigurationElement item in settings.Categories)
            {
                var node = new DeluxeTreeNode(item.Title, nodeGenerl.Value + "." + item.Name);
                node.Expanded = false;
                nodeGenerl.Nodes.Add(node);
                dic.Add(item.Name, node);
            }

            var categoris = LogCategoryAdapter.Instance.LoadCategories();

            foreach (var item in categoris)
            {
                if (dic.Contains(item.Category))
                {
                    var nodeParent = (DeluxeTreeNode)dic[item.Category];

                    var node = new DeluxeTreeNode(item.Description, nodeParent.Value + "." + item.OperationType);
                    nodeParent.Nodes.Add(node);
                }
            }
        }
示例#11
0
 public System.String getEffectiveCulture(System.Globalization.CultureInfo ci)
 {
     System.String culture = System.String.Empty;
     if (!availablecultures.Contains(ci.Name) && !ci.Equals(System.Globalization.CultureInfo.InvariantCulture))
     {
         culture = this.getEffectiveCulture(ci.Parent);
     }
     else
     {
         culture = ci.Name;
     }
     return(culture);
 }
示例#12
0
		protected override void OnPreRender(EventArgs e)
		{
			base.OnPreRender(e);

			var settings = LogCategoryConfigSection.GetConfig();

			if (settings == null)
				throw new System.Configuration.ConfigurationErrorsException("未找到日志类别配置");

			var nodeGenerl = new DeluxeTreeNode("用户操作", "G")
			{
				Expanded = true
			};

			var nodeAd = new DeluxeTreeNode("活动目录同步", "AD")
			{
				Expanded = true,
				NodeCloseImg = "../images/ad.png",
				NodeOpenImg = "../images/ad.png"
			};

			var nodeAdReverse = new DeluxeTreeNode("活动目录反向同步", "RAD");

			this.tree.Nodes.Add(nodeGenerl);
			this.tree.Nodes.Add(nodeAd);
			this.tree.Nodes.Add(nodeAdReverse);

			System.Collections.Specialized.HybridDictionary dic = new System.Collections.Specialized.HybridDictionary();

			foreach (LogCategoryConfigurationElement item in settings.Categories)
			{
				var node = new DeluxeTreeNode(item.Title, nodeGenerl.Value + "." + item.Name);
				node.Expanded = false;
				nodeGenerl.Nodes.Add(node);
				dic.Add(item.Name, node);
			}

			var categoris = LogCategoryAdapter.Instance.LoadCategories();

			foreach (var item in categoris)
			{
				if (dic.Contains(item.Category))
				{
					var nodeParent = (DeluxeTreeNode)dic[item.Category];

					var node = new DeluxeTreeNode(item.Description, nodeParent.Value + "." + item.OperationType);
					nodeParent.Nodes.Add(node);
				}
			}
		}
        static void Main(string[] args)
        {
            System.Collections.Specialized.HybridDictionary hybridDictionary = new System.Collections.Specialized.HybridDictionary();
            hybridDictionary.Add("Test1", "Test@123");
            hybridDictionary.Add("Admin", "Admin@123");
            hybridDictionary.Add("Temp", "Temp@123");
            hybridDictionary.Add("Demo", "Demo@123");
            hybridDictionary.Add("Test2", "Test@123");
            hybridDictionary.Add("Test4", "Test@123");
            hybridDictionary.Add("Test3", "Test@123");
            hybridDictionary.Add("Test5", "Test@123");
            hybridDictionary.Add("Test12", "Test@123");
            hybridDictionary.Add("Test6", "Test@123");
            hybridDictionary.Add("Test7", "Test@123");
            hybridDictionary.Add("Test8", "Test@123");
            hybridDictionary.Add("Test9", "Test@123");
            hybridDictionary.Add("Test10", "Test@123");
            hybridDictionary.Add("Test11", "Test@123");

            hybridDictionary.Remove("Admin");
            if (hybridDictionary.Contains("Admin"))
            {
                Console.WriteLine("UserName already Esists");
            }
            else
            {
                hybridDictionary.Add("Admin", "Admin@123");
                Console.WriteLine("User added succesfully.");
            }
            // Copies the HybridDictionary to an array with DictionaryEntry elements.
            DictionaryEntry[] myArr = new DictionaryEntry[hybridDictionary.Count];
            hybridDictionary.CopyTo(myArr, 0);
            // Displays the values in the array.
            Console.WriteLine("Displays the elements in the array:");
            Console.WriteLine(" KEY VALUE");
            for (int i = 0; i < myArr.Length; i++)
            {
                Console.WriteLine("   {0} {1}", myArr[i].Key, myArr[i].Value);
            }
            Console.WriteLine();

            // Get a collection of the keys.
            Console.WriteLine("UserName" + ": " + "Password");
            foreach (DictionaryEntry entry in hybridDictionary)
            {
                Console.WriteLine(entry.Key + ": " + entry.Value);
            }
            Console.ReadKey();
        }
示例#14
0
        /// <summary>
        /// Parses the InnerMarkup as data nodes
        /// </summary>
        /// <returns></returns>
        protected System.Collections.Specialized.HybridDictionary ParseElementValues()
        {
            if (elementValuesParsed)
            {
                return(ElementValues);
            }
            elementValuesParsed = true;

            if (!IsParsed)
            {
                this.Parse();
            }
            if (IsEmptyTag || !InnerMarkup.Contains("<"))
            {
                _elementValues = new System.Collections.Specialized.HybridDictionary();
                return(ElementValues);
            }
            //TODO - Replace with brute force parser
            try
            {
                _elementValues = new System.Collections.Specialized.HybridDictionary();
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(this.RawTag);
                XmlNode rootElement = doc.SelectSingleNode("/*");

                for (int i = 0; i < rootElement.ChildNodes.Count; i++)
                {
                    XmlNode node = rootElement.ChildNodes.Item(i);
                    if (_elementValues.Contains(node.Name))
                    {
                        _elementValues[node.Name] += node.InnerXml;
                    }
                    else
                    {
                        _elementValues.Add(node.Name, node.InnerXml);
                    }
                }
            }
            catch
            {
                _elementValues = new System.Collections.Specialized.HybridDictionary();
                return(ElementValues);
            }
            return(ElementValues);
        }
示例#15
0
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            if (string.IsNullOrEmpty(this.ObjectSchemaType) == false)
            {
                System.Collections.Specialized.HybridDictionary dic = Util.GetSchemaCatgoryDictionary();

                if (dic.Contains(this.ObjectSchemaType))
                {
                    switch ((string)dic[this.ObjectSchemaType])
                    {
                    case "Roles":
                    case "Applications":
                    case "Groups":
                        this.Attributes["onclick"] = "return $pc.modalPopup(this);";
                        break;

                    default:
                        break;
                    }

                    if (string.IsNullOrEmpty(this.ObjectID) == false)
                    {
                        switch ((string)dic[this.ObjectSchemaType])
                        {
                        case "Organizations":
                            this.NavigateUrl = this.OUViewMode ? ("~/lists/OUExplorerView.aspx?ou=" + HttpUtility.UrlEncode(this.ObjectID)) : ("~/lists/OUExplorer.aspx?ou=" + HttpUtility.UrlEncode(this.ObjectID));
                            break;

                        case "Roles":
                            this.NavigateUrl = "~/lists/AppRoleMembers.aspx?role=" + HttpUtility.UrlEncode(this.ObjectID);
                            break;

                        case "Applications":
                            this.NavigateUrl = "~/lists/AppRoles.aspx?app=" + HttpUtility.UrlEncode(this.ObjectID);
                            break;

                        case "Groups":
                            this.NavigateUrl = "~/lists/GroupConstMembers.aspx?id=" + HttpUtility.UrlEncode(this.ObjectID);
                            break;
                        }
                    }
                }
            }
        }
示例#16
0
 private void TestAvailableCultures()
 {
     availablecultures = new System.Collections.Specialized.HybridDictionary();
     foreach (System.Globalization.CultureInfo item in System.Globalization.CultureInfo.GetCultures(System.Globalization.CultureTypes.AllCultures))
     {
         if (!item.Equals(System.Globalization.CultureInfo.InvariantCulture) && !availablecultures.Contains(item.Name) && resources.GetResourceSet(item, true, false) != null)
         {
             availablecultures.Add(item.Name, item.EnglishName);
         }
     }
 }
示例#17
0
 private void TestAvailableCultures()
 {
     availablecultures = new System.Collections.Specialized.HybridDictionary();
     foreach ( System.Globalization.CultureInfo item in System.Globalization.CultureInfo.GetCultures( System.Globalization.CultureTypes.AllCultures) )  {
         if ( !item.Equals(System.Globalization.CultureInfo.InvariantCulture) && !availablecultures.Contains(item.Name) && resources.GetResourceSet(item, true, false)!=null )
             availablecultures.Add(item.Name, item.EnglishName);
     }
 }
示例#18
0
        /// <summary>
        /// 根据关键字获取对应语言的文本
        /// </summary>
        /// <param name="key"></param>
        /// <param name="defaultvalue"></param>
        /// <param name="valueMark"></param>
        /// <returns></returns>
        public static string GetValue(string key, string defaultvalue = "", string valueMark = "value")
        {
            // 当前语言
            string currentLangFile = langPath + langFile;

            // 默认语言
            string defaultLangFile = langPath + langDefaultFile;

            //文本
            string value = defaultvalue;

            //没有key
            if (String.IsNullOrWhiteSpace(key))
            {
                return(value);
            }

            //缓存中获取
            if (dictionaryLangs == null)
            {
                dictionaryLangs = new System.Collections.Specialized.HybridDictionary();
            }

            lock (dictionaryLangs)
            {
                if (dictionaryLangs.Contains(key + valueMark))
                {
                    value = dictionaryLangs[key + valueMark].ToString();
                }
            }

            //优先获取指定的语言
            if (String.IsNullOrWhiteSpace(value) &&
                System.IO.File.Exists(currentLangFile))
            {
                value = XmlHelper.GetValue(currentLangFile, @"langs/lang[@key='" + key + "']", valueMark);
            }

            //若指定的语言没有值则获取默认语言
            if (String.IsNullOrWhiteSpace(value) &&
                System.IO.File.Exists(defaultLangFile))
            {
                value = XmlHelper.GetValue(defaultLangFile, @"langs/lang[@key='" + key + "']", valueMark);
            }

            if (!String.IsNullOrWhiteSpace(value))
            {
                lock (dictionaryLangs)
                {
                    if (!dictionaryLangs.Contains(key + valueMark))
                    {
                        dictionaryLangs.Add(key + valueMark, value);
                    }
                }
            }

            //如果没有获取到则返回默认值
            if (String.IsNullOrWhiteSpace(value))
            {
                value = defaultvalue;
            }

            return(value);
        }
示例#19
0
 public bool Contains(object key)
 {
     return(m_hybridDictionary.Contains(key));
 }
示例#20
0
 public bool TimerExists(string name)
 {
     return(list.Contains(name));
 }