当前位置: 首页>>代码示例>>C#>>正文


C# Uri.Equals方法代码示例

本文整理汇总了C#中System.Uri.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Uri.Equals方法的具体用法?C# Uri.Equals怎么用?C# Uri.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Uri的用法示例。


在下文中一共展示了Uri.Equals方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IsSupportedMatchingRule

        public static bool IsSupportedMatchingRule(Uri matchBy)
        {
            Fx.Assert(matchBy != null, "The matchBy must be non null.");

            return (matchBy.Equals(FindCriteria.ScopeMatchByPrefix) ||
                matchBy.Equals(FindCriteria.ScopeMatchByUuid) ||
                matchBy.Equals(FindCriteria.ScopeMatchByLdap) ||
                matchBy.Equals(FindCriteria.ScopeMatchByExact) ||
                matchBy.Equals(FindCriteria.ScopeMatchByNone));
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:10,代码来源:ScopeCompiler.cs

示例2: Saml2AuthorizationDecisionStatement

        /// <summary>
        /// Initializes a new instance of the <see cref="Saml2AuthorizationDecisionStatement"/> class from
        /// a resource and decision.
        /// </summary>
        /// <param name="resource">The <see cref="Uri"/> of the resource to be authorized.</param>
        /// <param name="decision">The <see cref="SamlAccessDecision"/> in use.</param>
        /// <param name="actions">Collection of <see cref="Saml2Action"/> specifications.</param>
        public Saml2AuthorizationDecisionStatement(Uri resource, SamlAccessDecision decision, IEnumerable<Saml2Action> actions)
        {
            if (null == resource)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("resource");
            }

            // This check is making sure the resource is either a well-formed absolute uri or
            // an empty relative uri before passing through to the rest of the constructor.
            if (!(resource.IsAbsoluteUri || resource.Equals(EmptyResource)))
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("resource", SR.GetString(SR.ID4121));
            }

            if (decision < SamlAccessDecision.Permit || decision > SamlAccessDecision.Indeterminate)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("decision"));
            }

            this.resource = resource;
            this.decision = decision;

            if (null != actions)
            {
                foreach (Saml2Action action in actions)
                {
                    this.actions.Add(action);
                }
            }
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:37,代码来源:Saml2AuthorizationDecisionStatement.cs

示例3: Contains

    /// <param name="codeBaseUri">Uri pointing to the assembly</param>
    public static bool Contains(Uri codeBaseUri){
      if (codeBaseUri == null) { Debug.Fail("codeBaseUri == null"); return false; }
      lock(GlobalAssemblyCache.Lock){
        if (!GlobalAssemblyCache.FusionLoaded){
          GlobalAssemblyCache.FusionLoaded = true;
          System.Reflection.Assembly systemAssembly = typeof(object).Assembly;
          //^ assume systemAssembly != null && systemAssembly.Location != null;
          string dir = Path.GetDirectoryName(systemAssembly.Location);
          //^ assume dir != null;
          GlobalAssemblyCache.LoadLibrary(Path.Combine(dir, "fusion.dll"));
        }
        IAssemblyEnum assemblyEnum;
        int rc = GlobalAssemblyCache.CreateAssemblyEnum(out assemblyEnum, null, null, ASM_CACHE.GAC, 0);
        if (rc < 0 || assemblyEnum == null) return false;
        IApplicationContext applicationContext;
        IAssemblyName currentName;
        while (assemblyEnum.GetNextAssembly(out applicationContext, out currentName, 0) == 0){
          //^ assume currentName != null;
          AssemblyName assemblyName = new AssemblyName(currentName);
          string scheme = codeBaseUri.Scheme;
          if (scheme != null && assemblyName.CodeBase.StartsWith(scheme)){
            try{
              Uri foundUri = new Uri(assemblyName.CodeBase);
              if (codeBaseUri.Equals(foundUri)) return true;
#if !FxCop
            }catch(Exception){
#else
            }finally{
#endif
            }
          }
        }
        return false;
      }
    } 
开发者ID:tapicer,项目名称:resource-contracts-.net,代码行数:36,代码来源:AssemblyCache.cs

示例4: Contains

 /// <include file='doc\AssemblyCache.uex' path='docs/doc[@for="GlobalAssemblyCache.Contains"]/*' />
 /// <param name="codeBaseUri">Uri pointing to the assembly</param>
 public static bool Contains(Uri codeBaseUri)
 {
     lock (GlobalAssemblyCache.Lock)
     {
         if (!GlobalAssemblyCache.FusionLoaded)
         {
             GlobalAssemblyCache.FusionLoaded = true;
             GlobalAssemblyCache.LoadLibrary(Path.Combine(Path.GetDirectoryName(typeof(object).Module.Assembly.Location), "fusion.dll"));
         }
         IAssemblyEnum assemblyEnum;
         int rc = GlobalAssemblyCache.CreateAssemblyEnum(out assemblyEnum, null, null, ASM_CACHE.GAC, 0);
         if (rc < 0 || assemblyEnum == null) return false;
         IApplicationContext applicationContext;
         IAssemblyName currentName;
         while (assemblyEnum.GetNextAssembly(out applicationContext, out currentName, 0) == 0)
         {
             AssemblyName assemblyName = new AssemblyName(currentName);
             if (assemblyName.CodeBase.StartsWith(codeBaseUri.Scheme))
             {
                 try
                 {
                     Uri foundUri = new Uri(assemblyName.CodeBase);
                     if (codeBaseUri.Equals(foundUri)) return true;
                 }
                 catch (Exception) { }
             }
         }
         return false;
     }
 }
开发者ID:hesam,项目名称:SketchSharp,代码行数:32,代码来源:AssemblyCache.cs

示例5: Deserialize

        public object Deserialize(string value, JsonConverter converter)
        {
            //Integration.Implementation.LogAudit("TinCanActor Deserialize called", null);
            IDictionary objMap = converter.DeserializeJSONToMap(value);
            string typeField = null;
            if (objMap.Contains("type"))
            {
                typeField = (string)objMap["type"];
            }

            //Avoid infinite loop here, if type is this base class
            Type targetType = typeof(ActivityDefinition_JsonTarget);

            if (typeField != null)
            {
                Uri activityType = new Uri((string)objMap["type"]);

                if (activityType.Equals("http://adlnet.gov/expapi/activities/cmi.interaction"))
                {
                    targetType = typeof(InteractionDefinition);
                }
            }

            return converter.DeserializeJSON(value, targetType);
        }
开发者ID:jonesd52,项目名称:connxtiontesting-part2,代码行数:25,代码来源:ActivityDefinitionConverter.cs

示例6: MergeLinkMetadata

 internal static AtomLinkMetadata MergeLinkMetadata(AtomLinkMetadata metadata, string relation, Uri href, string title, string mediaType)
 {
     AtomLinkMetadata metadata2 = new AtomLinkMetadata(metadata);
     string strB = metadata2.Relation;
     if (strB != null)
     {
         if (string.CompareOrdinal(relation, strB) != 0)
         {
             throw new ODataException(Strings.ODataAtomWriterMetadataUtils_LinkRelationsMustMatch(relation, strB));
         }
     }
     else
     {
         metadata2.Relation = relation;
     }
     if (href != null)
     {
         Uri uri = metadata2.Href;
         if (uri != null)
         {
             if (!href.Equals(uri))
             {
                 throw new ODataException(Strings.ODataAtomWriterMetadataUtils_LinkHrefsMustMatch(href, uri));
             }
         }
         else
         {
             metadata2.Href = href;
         }
     }
     if (title != null)
     {
         string str2 = metadata2.Title;
         if (str2 != null)
         {
             if (string.CompareOrdinal(title, str2) != 0)
             {
                 throw new ODataException(Strings.ODataAtomWriterMetadataUtils_LinkTitlesMustMatch(title, str2));
             }
         }
         else
         {
             metadata2.Title = title;
         }
     }
     if (mediaType != null)
     {
         string str3 = metadata2.MediaType;
         if (str3 == null)
         {
             metadata2.MediaType = mediaType;
             return metadata2;
         }
         if (!HttpUtils.CompareMediaTypeNames(mediaType, str3))
         {
             throw new ODataException(Strings.ODataAtomWriterMetadataUtils_LinkMediaTypesMustMatch(mediaType, str3));
         }
     }
     return metadata2;
 }
开发者ID:nickchal,项目名称:pash,代码行数:60,代码来源:ODataAtomWriterMetadataUtils.cs

示例7: ProcessRequest

        public void ProcessRequest(HttpContext context, Uri serviceBaseUri)
        {
            var sparqlGenerator = new SparqlGenerator(_config.Map, _config.DefaultLanguageCode, _config.MaxPageSize);

            var messageWriterSettings = new ODataMessageWriterSettings(_config.BaseODataWriterSettings)
                {
                    BaseUri = serviceBaseUri
                };
            if (context.Request.AcceptTypes != null)
            {
                messageWriterSettings.SetContentType(String.Join(",", context.Request.AcceptTypes),
                                                     context.Request.Headers["Accept-Charset"]);
            }

            var requestMessage = new HttpDataRequestMessage(context.Request);
            ODataVersion effectiveVersion = GetEffectiveODataVersion(requestMessage);
            messageWriterSettings.Version = effectiveVersion;

            var metadataUri = new Uri(serviceBaseUri, "./$metadata");
            if (serviceBaseUri.Equals(context.Request.Url))
            {
                // We need to respond with the service document
                var responseMessage = new HttpDataResponseMessage(context.Response);
                context.Response.ContentType = "application/xml";
                context.Response.ContentEncoding = System.Text.Encoding.UTF8;
                var feedGenerator = new ODataFeedGenerator(requestMessage, responseMessage,
                                                           _config.Map, serviceBaseUri.ToString(),
                                                           messageWriterSettings);
                feedGenerator.WriteServiceDocument();
            }
            else if (serviceBaseUri.ToString().TrimEnd('/').Equals(context.Request.Url.ToString().TrimEnd('/')))
            {
                // Trimming of trailing slash to normalize - the serviceBaseUri should always have a trailing slash, 
                // but we will redirect requests that do not to the proper service document url
                context.Response.RedirectPermanent(serviceBaseUri.ToString(), true);
            }
            else if (metadataUri.Equals(context.Request.Url))
            {
                context.Response.ContentType = "application/xml";
                context.Response.WriteFile(_config.MetadataPath);
            }
            else
            {
                var parsedQuery = QueryDescriptorQueryNode.ParseUri(
                    context.Request.Url,
                    serviceBaseUri,
                    _config.Model);
                sparqlGenerator.ProcessQuery(parsedQuery);
                var responseMessage = new HttpDataResponseMessage(context.Response);
                var feedGenerator = new ODataFeedGenerator(
                    requestMessage,
                    responseMessage,
                    _config.Map,
                    serviceBaseUri.ToString(),
                    messageWriterSettings);
                sparqlGenerator.SparqlQueryModel.Execute(_config.SparqlEndpoint, feedGenerator);
                context.Response.ContentType = "application/atom+xml";
            }
        }
开发者ID:smasonuk,项目名称:odata-sparql,代码行数:59,代码来源:ODataSparqlRequestHandler.cs

示例8: Remove

 // Remove the 'CredentialInfo' object from the list that matches to the given 'Uri' and 'AuthenticationType'
 public void Remove(Uri uriObj, String authenticationType)
 {
     for (int index = 0; index < arrayListObj.Count; index++)
     {
         CredentialInfo credentialInfo = (CredentialInfo)arrayListObj[index];
         if (uriObj.Equals(credentialInfo.uriObj) && authenticationType.Equals(credentialInfo.authenticationType))
             arrayListObj.RemoveAt(index);
     }
 }
开发者ID:maesse,项目名称:NZBHags,代码行数:10,代码来源:CredentialList.cs

示例9: ApplyTo

        /// <summary>
        /// Applys the rule instance to the public or system identifier in an
        /// attempt to locate the URI of a resource with can provide the required
        /// information.
        /// </summary>
        /// <param name="publicId">The public identifier of the external entity
        /// being referenced, or null if none was supplied.</param>
        /// <param name="systemId">The system identifier of the external entity
        /// being referenced.</param>
        /// <param name="catalogs">The stack of catalogs being processed.</param>
        /// <returns>A new URI if the rule was successfully applied, otherwise
        /// <b>null</b>.</returns>
        public String ApplyTo(String publicId, String systemId, Stack<GroupEntry> catalogs)
        {
            Uri				targetUri = new Uri (systemId);
            Uri				systemUri = new Uri (BaseAsUri (), this.systemId);

            if (targetUri.Equals (systemUri))
                return (new Uri (BaseAsUri (), new Uri (uri)).ToString ());

            return (null);
        }
开发者ID:formicary,项目名称:fpml-toolkit-csharp,代码行数:22,代码来源:SystemEntry.cs

示例10: GetCredential

 public NetworkCredential GetCredential(Uri uriObj, String authenticationType)
 {
     for (int index = 0; index < arrayListObj.Count; index++)
     {
         CredentialInfo credentialInfoObj = (CredentialInfo)arrayListObj[index];
         if (uriObj.Equals(credentialInfoObj.uriObj) && authenticationType.Equals(credentialInfoObj.authenticationType))
             return credentialInfoObj.networkCredentialObj;
     }
     return null;
 }
开发者ID:maesse,项目名称:NZBHags,代码行数:10,代码来源:CredentialList.cs

示例11: GetBytesFromWeb

 private static byte[] GetBytesFromWeb(Uri imageURL)
 {
     if (imageURL.Equals(Resources.MissingPictureUrl)) return ConvertImageToBytes(Resources.missingPicture);
     try
     {
         var webClient = new WebClient();
         return webClient.DownloadData(imageURL);
     }
     catch
     {
         return ConvertImageToBytes(Resources.missingPicture);
     }
 }
开发者ID:taoxiease,项目名称:asegrp,代码行数:13,代码来源:ImageHelper.cs

示例12: fEquals

        public static void fEquals()
        {
            Uri uri1 = new Uri("http://www.yahoo.com/tw");
            Uri uri2 = new Uri("http://www.yahoo.com");

            if (uri1.Equals(uri2))
            {
                MessageBox.Show("相同");
            }
            else {
                MessageBox.Show("不相同");
            }
        }
开发者ID:HatsuneMiku0309,项目名称:vs2015-winform,代码行数:13,代码来源:URLOrURIProcess.cs

示例13: StorageUriWithTwoUris

        public void StorageUriWithTwoUris()
        {
            Uri primaryClientUri = new Uri("http://" + AccountName + BlobService + EndpointSuffix);
            Uri primaryContainerUri = new Uri(primaryClientUri, "container");
            Uri secondaryClientUri = new Uri("http://" + AccountName + SecondarySuffix + BlobService + EndpointSuffix);
            Uri dummyClientUri = new Uri("http://" + AccountName + "-dummy" + BlobService + EndpointSuffix);

            StorageUri singleUri = new StorageUri(primaryClientUri);
            Assert.IsTrue(primaryClientUri.Equals(singleUri.PrimaryUri));
            Assert.IsNull(singleUri.SecondaryUri);

            StorageUri singleUri2 = new StorageUri(primaryClientUri);
            Assert.IsTrue(singleUri.Equals(singleUri2));

            StorageUri singleUri3 = new StorageUri(secondaryClientUri);
            Assert.IsFalse(singleUri.Equals(singleUri3));

            StorageUri multiUri = new StorageUri(primaryClientUri, secondaryClientUri);
            Assert.IsTrue(primaryClientUri.Equals(multiUri.PrimaryUri));
            Assert.IsTrue(secondaryClientUri.Equals(multiUri.SecondaryUri));
            Assert.IsFalse(multiUri.Equals(singleUri));

            StorageUri multiUri2 = new StorageUri(primaryClientUri, secondaryClientUri);
            Assert.IsTrue(multiUri.Equals(multiUri2));

            TestHelper.ExpectedException<ArgumentException>(
                () => new StorageUri(primaryClientUri, primaryContainerUri),
                "StorageUri constructor should fail if both URIs do not point to the same resource");

            StorageUri multiUri3 = new StorageUri(primaryClientUri, dummyClientUri);
            Assert.IsFalse(multiUri.Equals(multiUri3));

            StorageUri multiUri4 = new StorageUri(dummyClientUri, secondaryClientUri);
            Assert.IsFalse(multiUri.Equals(multiUri4));

            StorageUri multiUri5 = new StorageUri(secondaryClientUri, primaryClientUri);
            Assert.IsFalse(multiUri.Equals(multiUri5));
        }
开发者ID:DaC24,项目名称:azure-storage-net,代码行数:38,代码来源:StorageUriTests.cs

示例14: DynamicVirtualDiscoSearcher

 internal DynamicVirtualDiscoSearcher(string startDir, string[] excludedUrls, string rootUrl) : base(excludedUrls)
 {
     this.webApps = new Hashtable();
     this.Adsi = new Hashtable();
     base.origUrl = rootUrl;
     this.entryPathPrefix = this.GetWebServerForUrl(rootUrl) + "/ROOT";
     this.startDir = startDir;
     string localPath = new Uri(rootUrl).LocalPath;
     if (localPath.Equals("/"))
     {
         localPath = "";
     }
     this.rootPathAsdi = this.entryPathPrefix + localPath;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:14,代码来源:DynamicVirtualDiscoSearcher.cs

示例15: Contains

    /// <summary>
    /// Determines whether the GAC contains the specified code base URI.
    /// </summary>
    /// <param name="codeBaseUri">The code base URI.</param>
    public static bool Contains(Uri codeBaseUri) {
      Contract.Requires(codeBaseUri != null);
      
      lock (GlobalLock.LockingObject) {
#if COMPACTFX
        var gacKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"\Software\Microsoft\.NETCompactFramework\Installer\Assemblies\Global");
        if (gacKey == null) return false;
        var codeBase = codeBaseUri.AbsoluteUri;
        foreach (var gacName in gacKey.GetValueNames()) {
          var values = gacKey.GetValue(gacName) as string[];
          if (values == null || values.Length == 0) continue;
          if (string.Equals(values[0], codeBase, StringComparison.OrdinalIgnoreCase)) return true;
          if (values.Length > 1 && string.Equals(values[1], codeBase, StringComparison.OrdinalIgnoreCase)) return true;
        }
        return false;
#else
#if __MonoCS__
        IAssemblyEnum assemblyEnum = new MonoAssemblyEnum();
#else
        if (!GlobalAssemblyCache.FusionLoaded) {
          GlobalAssemblyCache.FusionLoaded = true;
          var systemAssembly = typeof(object).Assembly;
          var systemAssemblyLocation = systemAssembly.Location;
          string dir = Path.GetDirectoryName(systemAssemblyLocation)??"";
          GlobalAssemblyCache.LoadLibrary(Path.Combine(dir, "fusion.dll"));
        }
        IAssemblyEnum assemblyEnum;
        int rc = GlobalAssemblyCache.CreateAssemblyEnum(out assemblyEnum, null, null, ASM_CACHE.GAC, 0);
        if (rc < 0 || assemblyEnum == null) return false;
#endif
        IApplicationContext applicationContext;
        IAssemblyName currentName;
        while (assemblyEnum.GetNextAssembly(out applicationContext, out currentName, 0) == 0) {
          //^ assume currentName != null;
          AssemblyName assemblyName = new AssemblyName(currentName);
          string/*?*/ scheme = codeBaseUri.Scheme;
          if (scheme != null && assemblyName.CodeBase.StartsWith(scheme, StringComparison.OrdinalIgnoreCase)) {
            try {
              Uri foundUri = new Uri(assemblyName.CodeBase);
              if (codeBaseUri.Equals(foundUri)) return true;
            } catch (System.ArgumentNullException) {
            } catch (System.UriFormatException) {
            }
          }
        }
        return false;
#endif
      }
    }
开发者ID:modulexcite,项目名称:Microsoft.Cci.Metadata,代码行数:53,代码来源:GlobalAssemblyCache.cs


注:本文中的System.Uri.Equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。