Exemple #1
0
        //------------------------------------------------------
        //
        // IMEMBERSHIPCONDITION IMPLEMENTATION
        //
        //------------------------------------------------------

        /// <include file='doc\StrongNameMembershipCondition.uex' path='docs/doc[@for="StrongNameMembershipCondition.Check"]/*' />
        public bool Check(Evidence evidence)
        {
            if (evidence == null)
            {
                return(false);
            }

            IEnumerator enumerator = evidence.GetHostEnumerator();

            while (enumerator.MoveNext())
            {
                if (enumerator.Current is StrongName)
                {
                    StrongName name = (StrongName)enumerator.Current;

                    if ((this.PublicKey != null && this.PublicKey.Equals(name.PublicKey)) &&
                        (this.Name == null || (name.Name != null && StrongName.CompareNames(name.Name, this.Name))) &&
                        ((Object)this.Version == null || ((Object)name.Version != null && name.Version.CompareTo(this.Version) == 0)))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
        bool IReportMatchMembershipCondition.Check(Evidence evidence, out object usedEvidence)
        {
            usedEvidence = null;

            if (evidence == null)
            {
                return(false);
            }

            StrongName name = evidence.GetDelayEvaluatedHostEvidence <StrongName>();

            if (name != null)
            {
                bool publicKeyMatch = PublicKey != null && PublicKey.Equals(name.PublicKey);
                bool nameMatch      = Name == null || (name.Name != null && StrongName.CompareNames(name.Name, Name));
                bool versionMatch   = (object)Version == null || ((object)name.Version != null && name.Version.CompareTo(Version) == 0);

                if (publicKeyMatch && nameMatch && versionMatch)
                {
                    // Note that we explicitly do not want to mark the strong name evidence as used at
                    // this point, since we could be a child code group where our parent provides more
                    // trust than we do.  For instance, if we're in a setup like this:
                    //
                    //   AllCode -> FullTrust
                    //     StrongName -> FullTrust
                    //
                    // the StrongName code group didn't add anything to the final grant set and therefore
                    // does not need to be evaluated.
                    usedEvidence = name;
                    return(true);
                }
            }

            return(false);
        }
 bool IReportMatchMembershipCondition.Check(Evidence evidence, out object usedEvidence)
 {
     usedEvidence = null;
     if (evidence != null)
     {
         StrongName delayEvaluatedHostEvidence = evidence.GetDelayEvaluatedHostEvidence <StrongName>();
         if (delayEvaluatedHostEvidence != null)
         {
             bool flag  = (this.PublicKey != null) && this.PublicKey.Equals(delayEvaluatedHostEvidence.PublicKey);
             bool flag2 = (this.Name == null) || ((delayEvaluatedHostEvidence.Name != null) && StrongName.CompareNames(delayEvaluatedHostEvidence.Name, this.Name));
             bool flag3 = (this.Version == null) || ((delayEvaluatedHostEvidence.Version != null) && (delayEvaluatedHostEvidence.Version.CompareTo(this.Version) == 0));
             if ((flag && flag2) && flag3)
             {
                 usedEvidence = delayEvaluatedHostEvidence;
                 return(true);
             }
         }
     }
     return(false);
 }
        bool IReportMatchMembershipCondition.Check(Evidence evidence, out object usedEvidence)
        {
            usedEvidence = (object)null;
            if (evidence == null)
            {
                return(false);
            }
            StrongName evaluatedHostEvidence = evidence.GetDelayEvaluatedHostEvidence <StrongName>();

            if (evaluatedHostEvidence != null)
            {
                int  num1  = this.PublicKey == null ? 0 : (this.PublicKey.Equals(evaluatedHostEvidence.PublicKey) ? 1 : 0);
                bool flag1 = this.Name == null || evaluatedHostEvidence.Name != null && StrongName.CompareNames(evaluatedHostEvidence.Name, this.Name);
                bool flag2 = this.Version == null || evaluatedHostEvidence.Version != null && evaluatedHostEvidence.Version.CompareTo(this.Version) == 0;
                int  num2  = flag1 ? 1 : 0;
                if ((num1 & num2 & (flag2 ? 1 : 0)) != 0)
                {
                    usedEvidence = (object)evaluatedHostEvidence;
                    return(true);
                }
            }
            return(false);
        }