Here are the examples of the csharp api System.Collections.IEnumerable.GetEnumerator() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
845 Examples
19
Source : PlaymodeTestsController.cs
with Creative Commons Zero v1.0 Universal
from Colanderp
with Creative Commons Zero v1.0 Universal
from Colanderp
public IEnumerator Run()
{
CoroutineTestWorkItem.monoBehaviourCoroutineRunner = this;
gameObject.hideFlags |= HideFlags.DontSave;
if (settings.sceneBased)
{
SceneManager.LoadScene(1, LoadSceneMode.Additive);
yield return null;
}
var testListUtil = new PlayerTestreplacedemblyProvider(new replacedemblyLoadProxy(), m_replacedembliesWithTests);
m_Runner = new UnityTestreplacedemblyRunner(new UnityTestreplacedemblyBuilder(), new PlaymodeWorkItemFactory());
var loadedTests = m_Runner.Load(testListUtil.GetUserreplacedemblies().Select(a => a.replacedembly).ToArray(), UnityTestreplacedemblyBuilder.GetNUnitTestBuilderSettings(TestPlatform.PlayMode));
loadedTests.ParseForNameDuplicates();
runStartedEvent.Invoke(m_Runner.LoadedTest);
var testListenerWrapper = new TestListenerWrapper(testStartedEvent, testFinishedEvent);
m_TestSteps = m_Runner.Run(testListenerWrapper, settings.filter.BuildNUnitFilter()).GetEnumerator();
yield return TestRunnerCorotine();
}
19
Source : CoroutineTestWorkItem.cs
with Creative Commons Zero v1.0 Universal
from Colanderp
with Creative Commons Zero v1.0 Universal
from Colanderp
protected override IEnumerable PerformWork()
{
if (m_Command is SkipCommand)
{
m_Command.Execute(Context);
Result = Context.CurrentResult;
WorkItemComplete();
yield break;
}
if (m_Command is ApplyChangesToContextCommand)
{
var applyChangesToContextCommand = (ApplyChangesToContextCommand)m_Command;
applyChangesToContextCommand.ApplyChanges(Context);
m_Command = applyChangesToContextCommand.GetInnerCommand();
}
var enumerableTestMethodCommand = (IEnumerableTestMethodCommand)m_Command;
try
{
var executeEnumerable = enumerableTestMethodCommand.ExecuteEnumerable(Context).GetEnumerator();
var coroutineRunner = new CoroutineRunner(monoBehaviourCoroutineRunner, Context);
yield return coroutineRunner.HandleEnumerableTest(executeEnumerable);
if (coroutineRunner.HasFailedWithTimeout())
{
Context.CurrentResult.SetResult(ResultState.Failure, string.Format("Test exceeded Timeout value of {0}ms", Context.TestCaseTimeout));
}
while (executeEnumerable.MoveNext()) {}
Result = Context.CurrentResult;
}
finally
{
WorkItemComplete();
}
}
19
Source : UnParserExtensions.cs
with MIT License
from commandlineparser
with MIT License
from commandlineparser
private static string FormatValue(Specification spec, object value)
{
var builder = new StringBuilder();
switch (spec.TargetType)
{
case TargetType.Scalar:
builder.Append(FormatWithQuotesIfString(value));
break;
case TargetType.Sequence:
var sep = spec.SeperatorOrSpace();
Func<object, object> format = v
=> sep == ' ' ? FormatWithQuotesIfString(v) : v;
var e = ((IEnumerable)value).GetEnumerator();
while (e.MoveNext())
builder.Append(format(e.Current)).Append(sep);
builder.TrimEndIfMatch(sep);
break;
}
return builder.ToString();
}
19
Source : UnParserExtensions.cs
with MIT License
from commandlineparser
with MIT License
from commandlineparser
private static bool IsEmpty(this object value, Specification specification, bool skipDefault)
{
if (value == null) return true;
if (skipDefault && value.Equals(specification.DefaultValue.FromJust())) return true;
if (Nullable.GetUnderlyingType(specification.ConversionType) != null) return false; //nullable
#if !SKIP_FSHARP
if (ReflectionHelper.IsFSharpOptionType(value.GetType()) && !FSharpOptionHelper.IsSome(value)) return true;
#endif
if (value is ValueType && value.Equals(value.GetType().GetDefaultValue())) return true;
if (value is string && ((string)value).Length == 0) return true;
if (value is IEnumerable && !((IEnumerable)value).GetEnumerator().MoveNext()) return true;
return false;
}
19
Source : ListIsNullOrEmptyConverter.shared.cs
with MIT License
from CommunityToolkit
with MIT License
from CommunityToolkit
internal static bool ConvertInternal(object? value)
{
if (value == null)
return true;
if (value is IEnumerable list)
return !list.GetEnumerator().MoveNext();
throw new ArgumentException("Value is not a valid IEnumerable or null", nameof(value));
}
19
Source : NewsPage.cs
with MIT License
from CommunityToolkit
with MIT License
from CommunityToolkit
protected override void OnAppearing()
{
base.OnAppearing();
if (Content is RefreshView refreshView
&& refreshView.Content is CollectionView collectionView
&& IsNullOrEmpty(collectionView.ItemsSource))
{
refreshView.IsRefreshing = true;
}
static bool IsNullOrEmpty(in IEnumerable? enumerable) => !enumerable?.GetEnumerator().MoveNext() ?? true;
}
19
Source : QueryableSingle.cs
with MIT License
from connellw
with MIT License
from connellw
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable) _underlyingQuery).GetEnumerator();
}
19
Source : LazyDictionary.cs
with MIT License
from connellw
with MIT License
from connellw
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable) _dictionary).GetEnumerator();
}
19
Source : SynchronizedCollection.cs
with MIT License
from CoreWCF
with MIT License
from CoreWCF
IEnumerator IEnumerable.GetEnumerator()
{
return ((IList)Items).GetEnumerator();
}
19
Source : ArgumentUtility.cs
with Apache License 2.0
from coronabytes
with Apache License 2.0
from coronabytes
[replacedertionMethod]
public static T CheckNotEmpty<T>([InvokerParameterName] string argumentName, T enumerable)
where T : IEnumerable
{
// ReSharper disable CompareNonConstrainedGenericWithNull
if (enumerable != null)
// ReSharper restore CompareNonConstrainedGenericWithNull
{
var collection = enumerable as ICollection;
if (collection != null)
{
if (collection.Count == 0)
throw CreateArgumentEmptyException(argumentName);
return enumerable;
}
var enumerator = enumerable.GetEnumerator();
var disposableEnumerator = enumerator as IDisposable;
using (disposableEnumerator) // using (null) is allowed in C#
{
if (!enumerator.MoveNext())
throw CreateArgumentEmptyException(argumentName);
}
}
return enumerable;
}
19
Source : QueryableBase.cs
with Apache License 2.0
from coronabytes
with Apache License 2.0
from coronabytes
IEnumerator IEnumerable.GetEnumerator()
{
return Provider.Execute<IEnumerable>(Expression).GetEnumerator();
}
19
Source : CollectionWrapper.cs
with MIT License
from CragonGame
with MIT License
from CragonGame
IEnumerator IEnumerable.GetEnumerator()
{
#if (UNITY_IOS || UNITY_IPHONE)
IEnumerator result;
result = _genericCollection != null ? ((IEnumerable)_genericCollection).GetEnumerator() : ((IEnumerable)_list).GetEnumerator();
return result;
#else
if (_genericCollection != null)
return _genericCollection.GetEnumerator();
else
return _list.GetEnumerator();
#endif
}
19
Source : EnumerableCompareHint.cs
with Mozilla Public License 2.0
from CreateAndFake
with Mozilla Public License 2.0
from CreateAndFake
private static IEnumerable<Difference> LazyCompare(
IEnumerable expected, IEnumerable actual, ValuerChainer valuer)
{
IEnumerator expectedEnumerator = expected.GetEnumerator();
IEnumerator actualEnumerator = actual.GetEnumerator();
int index = 0;
while (expectedEnumerator.MoveNext())
{
if (actualEnumerator.MoveNext())
{
foreach (Difference diff in valuer.Compare(expectedEnumerator.Current, actualEnumerator.Current))
{
yield return new Difference(index, diff);
}
}
else
{
yield return new Difference(index, new Difference(expectedEnumerator.Current, "'outofbounds'"));
}
index++;
}
while (actualEnumerator.MoveNext())
{
yield return new Difference(index++, new Difference("'outofbounds'", actualEnumerator.Current));
}
}
19
Source : ValueComparer.cs
with Mozilla Public License 2.0
from CreateAndFake
with Mozilla Public License 2.0
from CreateAndFake
public bool Equals(IEnumerable x, IEnumerable y)
{
if (ReferenceEquals(x, y))
{
return true;
}
else if (x is null || y is null)
{
return false;
}
else if (x is string)
{
return x.Equals(y);
}
else if (x is IDictionary asDict)
{
return Equals(asDict, y as IDictionary);
}
else
{
IEnumerator xGen = x.GetEnumerator();
IEnumerator yGen = y.GetEnumerator();
while (xGen.MoveNext())
{
if (!yGen.MoveNext() || !Equals(xGen.Current, yGen.Current))
{
return false;
}
}
return !yGen.MoveNext();
}
}
19
Source : CollectionCopyHint.cs
with Mozilla Public License 2.0
from CreateAndFake
with Mozilla Public License 2.0
from CreateAndFake
private static object[] CopyContentsHelper(IEnumerable source, DuplicatorChainer duplicator, bool reverse)
{
List<object> copy = new();
IEnumerator enumerator = source.GetEnumerator();
while (enumerator.MoveNext())
{
copy.Add(duplicator.Copy(enumerator.Current));
}
if (reverse)
{
copy.Reverse();
}
return copy.ToArray();
}
19
Source : CreateHintTestBase.cs
with Mozilla Public License 2.0
from CreateAndFake
with Mozilla Public License 2.0
from CreateAndFake
[Fact]
public void TryCreate_SupportsValidTypes()
{
foreach (Type type in _validTypes)
{
(bool, object) result = TestInstance.TryCreate(type, CreateChainer());
try
{
Tools.replacederter.Is(true, result.Item1,
"Hint '" + typeof(T).Name + "' did not support type '" + type.Name + "'.");
Tools.replacederter.IsNot(null, result.Item2,
"Hint '" + typeof(T).Name + "' did not create valid '" + type.Name + "'.");
if (result.Item2 is IEnumerable collection)
{
Tools.replacederter.Is(true, collection.GetEnumerator().MoveNext(),
"Hint '" + typeof(T).Name + "' failed to create populated '" + type + "'.");
}
}
finally
{
Disposer.Cleanup(result.Item2);
}
}
}
19
Source : AssertGroupBase.cs
with Mozilla Public License 2.0
from CreateAndFake
with Mozilla Public License 2.0
from CreateAndFake
public virtual replacedertChainer<T> IsNotEmpty(string details = null)
{
if (Collection == null)
{
throw new replacedertException(
$"Expected collection with elements, but was 'null'.", details, Gen.InitialSeed);
}
else if (!Collection.GetEnumerator().MoveNext())
{
throw new replacedertException(
"Expected collection with elements, but was empty.", details, Gen.InitialSeed);
}
else
{
return ToChainer();
}
}
19
Source : AssertGroupBase.cs
with Mozilla Public License 2.0
from CreateAndFake
with Mozilla Public License 2.0
from CreateAndFake
public virtual replacedertChainer<T> HasCount(int count, string details = null)
{
if (Collection == null)
{
throw new replacedertException(
$"Expected collection of '{count}' elements, but was 'null'.", details, Gen.InitialSeed);
}
StringBuilder contents = new();
int i = 0;
for (IEnumerator data = Collection.GetEnumerator(); data.MoveNext(); i++)
{
_ = contents.Append('[').Append(i).Append("]:").Append(data.Current).AppendLine();
}
if (i != count)
{
throw new replacedertException(
$"Expected collection of '{count}' elements, but was '{i}'.",
details, Gen.InitialSeed, contents.ToString());
}
return ToChainer();
}
19
Source : LinkedHashSet.cs
with MIT License
from cschladetsch
with MIT License
from cschladetsch
IEnumerator IEnumerable.GetEnumerator()
{
return (list as IEnumerable).GetEnumerator();
}
19
Source : ObservableList.cs
with MIT License
from cschladetsch
with MIT License
from cschladetsch
IEnumerator IEnumerable.GetEnumerator()
{
return (Items as IEnumerable).GetEnumerator();
}
19
Source : TamlArray.cs
with MIT License
from csharpfritz
with MIT License
from csharpfritz
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable)_Values).GetEnumerator();
}
19
Source : CollectionHelpers.cs
with MIT License
from cuteant
with MIT License
from cuteant
IEnumerator IEnumerable.GetEnumerator()
{
return _collection.GetEnumerator();
}
19
Source : DequeTests.cs
with MIT License
from cuteant
with MIT License
from cuteant
[Fact]
public void NonGenericEnumerator_EnumeratesItems()
{
var deque = new Deque<int>(new[] { 1, 2 });
var results = new List<int>();
var objEnum = ((System.Collections.IEnumerable)deque).GetEnumerator();
while (objEnum.MoveNext())
{
results.Add((int)objEnum.Current);
}
replacedert.Equal(results, deque);
}
19
Source : StrongListWrapper.cs
with MIT License
from dahall
with MIT License
from dahall
public IEnumerator<T> GetEnumerator() => new StrongListWrapperEnumerator<T>(list.GetEnumerator());
19
Source : CborObject.cs
with MIT License
from dahomey-technologies
with MIT License
from dahomey-technologies
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable)_pairs).GetEnumerator();
}
19
Source : BaseCollection.cs
with MIT License
from DanielEverland
with MIT License
from DanielEverland
IEnumerator IEnumerable.GetEnumerator()
{
return List.GetEnumerator();
}
19
Source : DictionaryPropertyDrawer.cs
with MIT License
from daniellochner
with MIT License
from daniellochner
private object GetValue_Imp(object source, string name, int index)
{
var enumerable = GetValue_Imp(source, name) as System.Collections.IEnumerable;
if (enumerable == null) return null;
var enm = enumerable.GetEnumerator();
//while (index-- >= 0)
// enm.MoveNext();
//return enm.Current;
for (int i = 0; i <= index; i++)
{
if (!enm.MoveNext()) return null;
}
return enm.Current;
}
19
Source : AseParameterCollection.cs
with Apache License 2.0
from DataAction
with Apache License 2.0
from DataAction
public override IEnumerator GetEnumerator()
{
return ((IList)_parameters).GetEnumerator();
}
19
Source : ReadOnlyDictionary{TKey, TValue}.cs
with MIT License
from DataObjects-NET
with MIT License
from DataObjects-NET
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable)innerDictionary).GetEnumerator();
}
19
Source : MSSQLExtractorTests.cs
with MIT License
from DataObjects-NET
with MIT License
from DataObjects-NET
public static void replacedertCollectionsAreEqual(IEnumerable col1, IEnumerable col2)
{
if (col1==col2)
return;
if (col2==null || col1==null)
throw new replacedertionException("One of arrays is null.");
IEnumerator enumerator1 = col1.GetEnumerator();
IEnumerator enumerator2 = col2.GetEnumerator();
enumerator1.Reset();
enumerator2.Reset();
while (enumerator1.MoveNext()) {
if (!enumerator2.MoveNext())
throw new replacedertionException("Different count.");
replacedert.AreEqual(enumerator1.Current, enumerator2.Current);
}
if (enumerator2.MoveNext())
throw new replacedertionException("Different count.");
}
19
Source : PropertyUtility.cs
with MIT License
from dbrizov
with MIT License
from dbrizov
private static object GetValue_Imp(object source, string name, int index)
{
IEnumerable enumerable = GetValue_Imp(source, name) as IEnumerable;
if (enumerable == null)
{
return null;
}
IEnumerator enumerator = enumerable.GetEnumerator();
for (int i = 0; i <= index; i++)
{
if (!enumerator.MoveNext())
{
return null;
}
}
return enumerator.Current;
}
19
Source : Asn1Set.cs
with MIT License
from dcomms
with MIT License
from dcomms
public virtual IEnumerator GetEnumerator()
{
return _set.GetEnumerator();
}
19
Source : BerOctetString.cs
with MIT License
from dcomms
with MIT License
from dcomms
public IEnumerator GetEnumerator()
{
if (octs == null)
{
return GenerateOcts().GetEnumerator();
}
return octs.GetEnumerator();
}
19
Source : TBSCertList.cs
with MIT License
from dcomms
with MIT License
from dcomms
public IEnumerator GetEnumerator()
{
return new RevokedCertificatesEnumerator(en.GetEnumerator());
}
19
Source : X509Extensions.cs
with MIT License
from dcomms
with MIT License
from dcomms
[Obsolete("Use ExtensionOids IEnumerable property")]
public IEnumerator Oids()
{
return ExtensionOids.GetEnumerator();
}
19
Source : Asn1Sequence.cs
with MIT License
from dcomms
with MIT License
from dcomms
public virtual IEnumerator GetEnumerator()
{
return seq.GetEnumerator();
}
19
Source : JsonapiCamelCasePropertyNamesContractResolver.cs
with MIT License
from dcomartin
with MIT License
from dcomartin
protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization) {
var property = base.CreateProperty(member, memberSerialization);
if(property.PropertyType.GetTypeInfo().GetInterface(typeof(IEnumerable).Name) != null && property.PropertyType != typeof(string)) {
property.ShouldSerialize = instance => {
var enumerable = property.DeclaringType.GetProperty(property.PropertyName, BindingFlags).GetValue(instance) as IEnumerable;
return enumerable?.GetEnumerator().MoveNext() ?? false;
};
}
return property;
}
19
Source : SkeinEngine.cs
with MIT License
from dcomms
with MIT License
from dcomms
private void InitParams(IDictionary parameters)
{
IEnumerator keys = parameters.Keys.GetEnumerator();
IList pre = Platform.CreateArrayList();
IList post = Platform.CreateArrayList();
while (keys.MoveNext())
{
int type = (int)keys.Current;
byte[] value = (byte[])parameters[type];
if (type == PARAM_TYPE_KEY)
{
this.key = value;
}
else if (type < PARAM_TYPE_MESSAGE)
{
pre.Add(new Parameter(type, value));
}
else
{
post.Add(new Parameter(type, value));
}
}
preMessageParameters = new Parameter[pre.Count];
pre.CopyTo(preMessageParameters, 0);
Array.Sort(preMessageParameters);
postMessageParameters = new Parameter[post.Count];
post.CopyTo(postMessageParameters, 0);
Array.Sort(postMessageParameters);
}
19
Source : PgpKeyRingGenerator.cs
with MIT License
from dcomms
with MIT License
from dcomms
public PgpPublicKeyRing GeneratePublicKeyRing()
{
IList pubKeys = Platform.CreateArrayList();
IEnumerator enumerator = keys.GetEnumerator();
enumerator.MoveNext();
PgpSecretKey pgpSecretKey = (PgpSecretKey) enumerator.Current;
pubKeys.Add(pgpSecretKey.PublicKey);
while (enumerator.MoveNext())
{
pgpSecretKey = (PgpSecretKey) enumerator.Current;
PgpPublicKey k = new PgpPublicKey(pgpSecretKey.PublicKey);
k.publicPk = new PublicSubkeyPacket(
k.Algorithm, k.CreationTime, k.publicPk.Key);
pubKeys.Add(k);
}
return new PgpPublicKeyRing(pubKeys);
}
19
Source : PkixCertPathValidatorUtilities.cs
with MIT License
from dcomms
with MIT License
from dcomms
internal static void PrepareNextCertB1(
int i,
IList[] policyNodes,
string id_p,
IDictionary m_idp,
X509Certificate cert)
{
bool idp_found = false;
IEnumerator nodes_i = policyNodes[i].GetEnumerator();
while (nodes_i.MoveNext())
{
PkixPolicyNode node = (PkixPolicyNode)nodes_i.Current;
if (node.ValidPolicy.Equals(id_p))
{
idp_found = true;
node.ExpectedPolicies = (ISet)m_idp[id_p];
break;
}
}
if (!idp_found)
{
nodes_i = policyNodes[i].GetEnumerator();
while (nodes_i.MoveNext())
{
PkixPolicyNode node = (PkixPolicyNode)nodes_i.Current;
if (ANY_POLICY.Equals(node.ValidPolicy))
{
ISet pq = null;
Asn1Sequence policies = null;
try
{
policies = DerSequence.GetInstance(GetExtensionValue(cert, X509Extensions.CertificatePolicies));
}
catch (Exception e)
{
throw new Exception("Certificate policies cannot be decoded.", e);
}
IEnumerator enm = policies.GetEnumerator();
while (enm.MoveNext())
{
PolicyInformation pinfo = null;
try
{
pinfo = PolicyInformation.GetInstance(enm.Current);
}
catch (Exception ex)
{
throw new Exception("Policy information cannot be decoded.", ex);
}
if (ANY_POLICY.Equals(pinfo.PolicyIdentifier.Id))
{
try
{
pq = GetQualifierSet(pinfo.PolicyQualifiers);
}
catch (PkixCertPathValidatorException ex)
{
throw new PkixCertPathValidatorException(
"Policy qualifier info set could not be built.", ex);
}
break;
}
}
bool ci = false;
ISet critExtOids = cert.GetCriticalExtensionOids();
if (critExtOids != null)
{
ci = critExtOids.Contains(X509Extensions.CertificatePolicies.Id);
}
PkixPolicyNode p_node = (PkixPolicyNode)node.Parent;
if (ANY_POLICY.Equals(p_node.ValidPolicy))
{
PkixPolicyNode c_node = new PkixPolicyNode(
Platform.CreateArrayList(), i,
(ISet)m_idp[id_p],
p_node, pq, id_p, ci);
p_node.AddChild(c_node);
policyNodes[i].Add(c_node);
}
break;
}
}
}
}
19
Source : PkixCertPath.cs
with MIT License
from dcomms
with MIT License
from dcomms
public override bool Equals(
object obj)
{
if (this == obj)
return true;
PkixCertPath other = obj as PkixCertPath;
if (other == null)
return false;
// if (!this.Type.Equals(other.Type))
// return false;
//return this.Certificates.Equals(other.Certificates);
// TODO Extract this to a utility clreplaced
IList thisCerts = this.Certificates;
IList otherCerts = other.Certificates;
if (thisCerts.Count != otherCerts.Count)
return false;
IEnumerator e1 = thisCerts.GetEnumerator();
IEnumerator e2 = thisCerts.GetEnumerator();
while (e1.MoveNext())
{
e2.MoveNext();
if (!Platform.Equals(e1.Current, e2.Current))
return false;
}
return true;
}
19
Source : PkixCertPathValidatorUtilities.cs
with MIT License
from dcomms
with MIT License
from dcomms
internal static void GetCrlIssuersFromDistributionPoint(
DistributionPoint dp,
ICollection issuerPrincipals,
X509CrlStoreSelector selector,
PkixParameters pkixParams)
{
IList issuers = Platform.CreateArrayList();
// indirect CRL
if (dp.CrlIssuer != null)
{
GeneralName[] genNames = dp.CrlIssuer.GetNames();
// look for a DN
for (int j = 0; j < genNames.Length; j++)
{
if (genNames[j].TagNo == GeneralName.DirectoryName)
{
try
{
issuers.Add(X509Name.GetInstance(genNames[j].Name.ToAsn1Object()));
}
catch (IOException e)
{
throw new Exception(
"CRL issuer information from distribution point cannot be decoded.",
e);
}
}
}
}
else
{
/*
* certificate issuer is CRL issuer, distributionPoint field MUST be
* present.
*/
if (dp.DistributionPointName == null)
{
throw new Exception(
"CRL issuer is omitted from distribution point but no distributionPoint field present.");
}
// add and check issuer principals
for (IEnumerator it = issuerPrincipals.GetEnumerator(); it.MoveNext(); )
{
issuers.Add((X509Name)it.Current);
}
}
// TODO: is not found although this should correctly add the rel name. selector of Sun is buggy here or PKI test case is invalid
// distributionPoint
// if (dp.getDistributionPoint() != null)
// {
// // look for nameRelativeToCRLIssuer
// if (dp.getDistributionPoint().getType() == DistributionPointName.NAME_RELATIVE_TO_CRL_ISSUER)
// {
// // append fragment to issuer, only one
// // issuer can be there, if this is given
// if (issuers.size() != 1)
// {
// throw new AnnotatedException(
// "nameRelativeToCRLIssuer field is given but more than one CRL issuer is given.");
// }
// DEREncodable relName = dp.getDistributionPoint().getName();
// Iterator it = issuers.iterator();
// List issuersTemp = new ArrayList(issuers.size());
// while (it.hasNext())
// {
// Enumeration e = null;
// try
// {
// e = ASN1Sequence.getInstance(
// new ASN1InputStream(((X500Principal) it.next())
// .getEncoded()).readObject()).getObjects();
// }
// catch (IOException ex)
// {
// throw new AnnotatedException(
// "Cannot decode CRL issuer information.", ex);
// }
// ASN1EncodableVector v = new ASN1EncodableVector();
// while (e.hasMoreElements())
// {
// v.add((DEREncodable) e.nextElement());
// }
// v.add(relName);
// issuersTemp.add(new X500Principal(new DERSequence(v)
// .getDEREncoded()));
// }
// issuers.clear();
// issuers.addAll(issuersTemp);
// }
// }
selector.Issuers = issuers;
}
19
Source : EnumerableProxy.cs
with MIT License
from dcomms
with MIT License
from dcomms
public IEnumerator GetEnumerator()
{
return inner.GetEnumerator();
}
19
Source : HashSet.cs
with MIT License
from dcomms
with MIT License
from dcomms
public virtual IEnumerator GetEnumerator()
{
return impl.Keys.GetEnumerator();
}
19
Source : Pkcs12Entry.cs
with MIT License
from dcomms
with MIT License
from dcomms
[Obsolete("Use 'BagAttributeKeys' property")]
public IEnumerator GetBagAttributeKeys()
{
return this.attributes.Keys.GetEnumerator();
}
19
Source : PkixCertPathValidator.cs
with MIT License
from dcomms
with MIT License
from dcomms
public virtual PkixCertPathValidatorResult Validate(
PkixCertPath certPath,
PkixParameters paramsPkix)
{
if (paramsPkix.GetTrustAnchors() == null)
{
throw new ArgumentException(
"trustAnchors is null, this is not allowed for certification path validation.",
"parameters");
}
//
// 6.1.1 - inputs
//
//
// (a)
//
IList certs = certPath.Certificates;
int n = certs.Count;
if (certs.Count == 0)
throw new PkixCertPathValidatorException("Certification path is empty.", null, certPath, 0);
//
// (b)
//
// DateTime validDate = PkixCertPathValidatorUtilities.GetValidDate(paramsPkix);
//
// (c)
//
ISet userInitialPolicySet = paramsPkix.GetInitialPolicies();
//
// (d)
//
TrustAnchor trust;
try
{
trust = PkixCertPathValidatorUtilities.FindTrustAnchor(
(X509Certificate)certs[certs.Count - 1],
paramsPkix.GetTrustAnchors());
if (trust == null)
throw new PkixCertPathValidatorException("Trust anchor for certification path not found.", null, certPath, -1);
CheckCertificate(trust.TrustedCert);
}
catch (Exception e)
{
throw new PkixCertPathValidatorException(e.Message, e.InnerException, certPath, certs.Count - 1);
}
//
// (e), (f), (g) are part of the paramsPkix object.
//
IEnumerator cerreplaceder;
int index = 0;
int i;
// Certificate for each interation of the validation loop
// Signature information for each iteration of the validation loop
//
// 6.1.2 - setup
//
//
// (a)
//
IList[] policyNodes = new IList[n + 1];
for (int j = 0; j < policyNodes.Length; j++)
{
policyNodes[j] = Platform.CreateArrayList();
}
ISet policySet = new HashSet();
policySet.Add(Rfc3280CertPathUtilities.ANY_POLICY);
PkixPolicyNode validPolicyTree = new PkixPolicyNode(Platform.CreateArrayList(), 0, policySet, null, new HashSet(),
Rfc3280CertPathUtilities.ANY_POLICY, false);
policyNodes[0].Add(validPolicyTree);
//
// (b) and (c)
//
PkixNameConstraintValidator nameConstraintValidator = new PkixNameConstraintValidator();
// (d)
//
int explicitPolicy;
ISet acceptablePolicies = new HashSet();
if (paramsPkix.IsExplicitPolicyRequired)
{
explicitPolicy = 0;
}
else
{
explicitPolicy = n + 1;
}
//
// (e)
//
int inhibitAnyPolicy;
if (paramsPkix.IsAnyPolicyInhibited)
{
inhibitAnyPolicy = 0;
}
else
{
inhibitAnyPolicy = n + 1;
}
//
// (f)
//
int policyMapping;
if (paramsPkix.IsPolicyMappingInhibited)
{
policyMapping = 0;
}
else
{
policyMapping = n + 1;
}
//
// (g), (h), (i), (j)
//
AsymmetricKeyParameter workingPublicKey;
X509Name workingIssuerName;
X509Certificate sign = trust.TrustedCert;
try
{
if (sign != null)
{
workingIssuerName = sign.SubjectDN;
workingPublicKey = sign.GetPublicKey();
}
else
{
workingIssuerName = new X509Name(trust.CAName);
workingPublicKey = trust.CAPublicKey;
}
}
catch (ArgumentException ex)
{
throw new PkixCertPathValidatorException("Subject of trust anchor could not be (re)encoded.", ex, certPath,
-1);
}
AlgorithmIdentifier workingAlgId = null;
try
{
workingAlgId = PkixCertPathValidatorUtilities.GetAlgorithmIdentifier(workingPublicKey);
}
catch (PkixCertPathValidatorException e)
{
throw new PkixCertPathValidatorException(
"Algorithm identifier of public key of trust anchor could not be read.", e, certPath, -1);
}
// DerObjectIdentifier workingPublicKeyAlgorithm = workingAlgId.Algorithm;
// Asn1Encodable workingPublicKeyParameters = workingAlgId.Parameters;
//
// (k)
//
int maxPathLength = n;
//
// 6.1.3
//
X509CertStoreSelector certConstraints = paramsPkix.GetTargetCertConstraints();
if (certConstraints != null && !certConstraints.Match((X509Certificate)certs[0]))
{
throw new PkixCertPathValidatorException(
"Target certificate in certification path does not match targetConstraints.", null, certPath, 0);
}
//
// initialize CertPathChecker's
//
IList pathCheckers = paramsPkix.GetCertPathCheckers();
cerreplaceder = pathCheckers.GetEnumerator();
while (cerreplaceder.MoveNext())
{
((PkixCertPathChecker)cerreplaceder.Current).Init(false);
}
X509Certificate cert = null;
for (index = certs.Count - 1; index >= 0; index--)
{
// try
// {
//
// i as defined in the algorithm description
//
i = n - index;
//
// set certificate to be checked in this round
// sign and workingPublicKey and workingIssuerName are set
// at the end of the for loop and initialized the
// first time from the TrustAnchor
//
cert = (X509Certificate)certs[index];
try
{
CheckCertificate(cert);
}
catch (Exception e)
{
throw new PkixCertPathValidatorException(e.Message, e.InnerException, certPath, index);
}
//
// 6.1.3
//
Rfc3280CertPathUtilities.ProcessCertA(certPath, paramsPkix, index, workingPublicKey,
workingIssuerName, sign);
Rfc3280CertPathUtilities.ProcessCertBC(certPath, index, nameConstraintValidator);
validPolicyTree = Rfc3280CertPathUtilities.ProcessCertD(certPath, index,
acceptablePolicies, validPolicyTree, policyNodes, inhibitAnyPolicy);
validPolicyTree = Rfc3280CertPathUtilities.ProcessCertE(certPath, index, validPolicyTree);
Rfc3280CertPathUtilities.ProcessCertF(certPath, index, validPolicyTree, explicitPolicy);
//
// 6.1.4
//
if (i != n)
{
if (cert != null && cert.Version == 1)
{
// we've found the trust anchor at the top of the path, ignore and keep going
if ((i == 1) && cert.Equals(trust.TrustedCert))
continue;
throw new PkixCertPathValidatorException(
"Version 1 certificates can't be used as CA ones.", null, certPath, index);
}
Rfc3280CertPathUtilities.PrepareNextCertA(certPath, index);
validPolicyTree = Rfc3280CertPathUtilities.PrepareCertB(certPath, index, policyNodes,
validPolicyTree, policyMapping);
Rfc3280CertPathUtilities.PrepareNextCertG(certPath, index, nameConstraintValidator);
// (h)
explicitPolicy = Rfc3280CertPathUtilities.PrepareNextCertH1(certPath, index, explicitPolicy);
policyMapping = Rfc3280CertPathUtilities.PrepareNextCertH2(certPath, index, policyMapping);
inhibitAnyPolicy = Rfc3280CertPathUtilities.PrepareNextCertH3(certPath, index, inhibitAnyPolicy);
//
// (i)
//
explicitPolicy = Rfc3280CertPathUtilities.PrepareNextCertI1(certPath, index, explicitPolicy);
policyMapping = Rfc3280CertPathUtilities.PrepareNextCertI2(certPath, index, policyMapping);
// (j)
inhibitAnyPolicy = Rfc3280CertPathUtilities.PrepareNextCertJ(certPath, index, inhibitAnyPolicy);
// (k)
Rfc3280CertPathUtilities.PrepareNextCertK(certPath, index);
// (l)
maxPathLength = Rfc3280CertPathUtilities.PrepareNextCertL(certPath, index, maxPathLength);
// (m)
maxPathLength = Rfc3280CertPathUtilities.PrepareNextCertM(certPath, index, maxPathLength);
// (n)
Rfc3280CertPathUtilities.PrepareNextCertN(certPath, index);
ISet criticalExtensions1 = cert.GetCriticalExtensionOids();
if (criticalExtensions1 != null)
{
criticalExtensions1 = new HashSet(criticalExtensions1);
// these extensions are handled by the algorithm
criticalExtensions1.Remove(X509Extensions.KeyUsage.Id);
criticalExtensions1.Remove(X509Extensions.CertificatePolicies.Id);
criticalExtensions1.Remove(X509Extensions.PolicyMappings.Id);
criticalExtensions1.Remove(X509Extensions.InhibitAnyPolicy.Id);
criticalExtensions1.Remove(X509Extensions.IssuingDistributionPoint.Id);
criticalExtensions1.Remove(X509Extensions.DeltaCrlIndicator.Id);
criticalExtensions1.Remove(X509Extensions.PolicyConstraints.Id);
criticalExtensions1.Remove(X509Extensions.BasicConstraints.Id);
criticalExtensions1.Remove(X509Extensions.SubjectAlternativeName.Id);
criticalExtensions1.Remove(X509Extensions.NameConstraints.Id);
}
else
{
criticalExtensions1 = new HashSet();
}
// (o)
Rfc3280CertPathUtilities.PrepareNextCertO(certPath, index, criticalExtensions1, pathCheckers);
// set signing certificate for next round
sign = cert;
// (c)
workingIssuerName = sign.SubjectDN;
// (d)
try
{
workingPublicKey = PkixCertPathValidatorUtilities.GetNextWorkingKey(certPath.Certificates, index);
}
catch (PkixCertPathValidatorException e)
{
throw new PkixCertPathValidatorException("Next working key could not be retrieved.", e, certPath, index);
}
workingAlgId = PkixCertPathValidatorUtilities.GetAlgorithmIdentifier(workingPublicKey);
// (f)
// workingPublicKeyAlgorithm = workingAlgId.Algorithm;
// (e)
// workingPublicKeyParameters = workingAlgId.Parameters;
}
}
//
// 6.1.5 Wrap-up procedure
//
explicitPolicy = Rfc3280CertPathUtilities.WrapupCertA(explicitPolicy, cert);
explicitPolicy = Rfc3280CertPathUtilities.WrapupCertB(certPath, index + 1, explicitPolicy);
//
// (c) (d) and (e) are already done
//
//
// (f)
//
ISet criticalExtensions = cert.GetCriticalExtensionOids();
if (criticalExtensions != null)
{
criticalExtensions = new HashSet(criticalExtensions);
// Requires .Id
// these extensions are handled by the algorithm
criticalExtensions.Remove(X509Extensions.KeyUsage.Id);
criticalExtensions.Remove(X509Extensions.CertificatePolicies.Id);
criticalExtensions.Remove(X509Extensions.PolicyMappings.Id);
criticalExtensions.Remove(X509Extensions.InhibitAnyPolicy.Id);
criticalExtensions.Remove(X509Extensions.IssuingDistributionPoint.Id);
criticalExtensions.Remove(X509Extensions.DeltaCrlIndicator.Id);
criticalExtensions.Remove(X509Extensions.PolicyConstraints.Id);
criticalExtensions.Remove(X509Extensions.BasicConstraints.Id);
criticalExtensions.Remove(X509Extensions.SubjectAlternativeName.Id);
criticalExtensions.Remove(X509Extensions.NameConstraints.Id);
criticalExtensions.Remove(X509Extensions.CrlDistributionPoints.Id);
}
else
{
criticalExtensions = new HashSet();
}
Rfc3280CertPathUtilities.WrapupCertF(certPath, index + 1, pathCheckers, criticalExtensions);
PkixPolicyNode intersection = Rfc3280CertPathUtilities.WrapupCertG(certPath, paramsPkix, userInitialPolicySet,
index + 1, policyNodes, validPolicyTree, acceptablePolicies);
if ((explicitPolicy > 0) || (intersection != null))
{
return new PkixCertPathValidatorResult(trust, intersection, cert.GetPublicKey());
}
throw new PkixCertPathValidatorException("Path processing failed on policy.", null, certPath, index);
}
19
Source : CollectionUtilities.cs
with MIT License
from dcomms
with MIT License
from dcomms
public static string ToString(IEnumerable c)
{
StringBuilder sb = new StringBuilder("[");
IEnumerator e = c.GetEnumerator();
if (e.MoveNext())
{
sb.Append(e.Current.ToString());
while (e.MoveNext())
{
sb.Append(", ");
sb.Append(e.Current.ToString());
}
}
sb.Append(']');
return sb.ToString();
}
19
Source : UnmodifiableListProxy.cs
with MIT License
from dcomms
with MIT License
from dcomms
public override IEnumerator GetEnumerator()
{
return l.GetEnumerator();
}
19
Source : ComputeContextPropertyList.cs
with MIT License
from deepakkumar1984
with MIT License
from deepakkumar1984
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable)_properties).GetEnumerator();
}
19
Source : ComputeEventList.cs
with MIT License
from deepakkumar1984
with MIT License
from deepakkumar1984
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable)_events).GetEnumerator();
}
See More Examples