Esempio n. 1
0
        /// <summary>
        /// 比较两个站点主机头实体是否相等,不比较站点ID(SiteID),仅比较IP/Port/HostHeader3项。
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public override bool Equals(object obj)
        {
            IISWebSiteHostHeader header = obj as IISWebSiteHostHeader;

            if (header != null)
            {
                if (header.IP == this.IP && header.Port == this.Port && header.HostHeader == this.HostHeader)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }

            return(base.Equals(obj));
        }
Esempio n. 2
0
        /// <summary>
        /// 在指定IIS服务器中检测指定主机头实例是否存在,存在返回true,否则返回false
        /// </summary>
        /// <param name="serverName">IIS服务器</param>
        /// <param name="newHostHeader">待检测的主机头实例</param>
        /// <returns></returns>
        public static bool IsHostHeaderExists(string serverName, IISWebSiteHostHeader newHostHeader)
        {
            bool isFind = false;

            List <IISWebSite> siteList = LoadIISWebSiteData(serverName);

            foreach (IISWebSite site in siteList)
            {
                List <IISWebSiteHostHeader> headerList = LoadHostHeaderList(serverName, site.SiteID);
                foreach (IISWebSiteHostHeader header in headerList)
                {
                    if (newHostHeader.Equals(header))
                    {
                        isFind = true;
                        break;
                    }
                }
            }
            return(isFind);
        }