本文整理汇总了C#中AList.Add方法的典型用法代码示例。如果您正苦于以下问题:C# AList.Add方法的具体用法?C# AList.Add怎么用?C# AList.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AList
的用法示例。
在下文中一共展示了AList.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestJoinIterable
public virtual void TestJoinIterable()
{
IList<string> strings = new AList<string>();
strings.Add("A");
strings.Add("B");
strings.Add("C");
Sharpen.Tests.AreEqual("A;B;C", StringUtil.Join(strings.ToCharSequence(), ";"));
Sharpen.Tests.AreEqual(string.Empty, StringUtil.Join(new AList<string>().ToCharSequence(), ";"));
}
示例2: GetCertificateBySubjectName
public virtual IList<CertificateAndContext> GetCertificateBySubjectName(X509Name
subjectName)
{
IList<CertificateAndContext> list = new AList<CertificateAndContext>();
try
{
string url = GetAccessLocation(certificate, X509ObjectIdentifiers.IdADCAIssuers);
if (url != null)
{
X509CertificateParser parser = new X509CertificateParser();
X509Certificate cert = parser.ReadCertificate(httpDataLoader.Get(url));
if (cert.SubjectDN.Equals(subjectName))
{
list.Add(new CertificateAndContext());
}
}
}
catch (CannotFetchDataException)
{
return new List<CertificateAndContext>();
}
catch (CertificateException)
{
return new List<CertificateAndContext>();
}
return list;
}
示例3: SetUp
public virtual void SetUp()
{
Com.Drew.Metadata.Metadata metadata = new Com.Drew.Metadata.Metadata();
IList<sbyte[]> jpegSegments = new AList<sbyte[]>();
jpegSegments.Add(FileUtil.ReadBytes("Tests/Data/withXmpAndIptc.jpg.app1.1"));
new XmpReader().ReadJpegSegments(jpegSegments.AsIterable(), metadata, JpegSegmentType.App1);
ICollection<XmpDirectory> xmpDirectories = metadata.GetDirectoriesOfType<XmpDirectory>();
NUnit.Framework.Assert.IsNotNull(xmpDirectories);
Sharpen.Tests.AreEqual(1, xmpDirectories.Count);
_directory = xmpDirectories.Iterator().Next();
Sharpen.Tests.IsFalse(_directory.HasErrors());
}
示例4: TypeRefFromCCIType
//.........这里部分代码省略.........
var mttp = type as CCI.MethodTypeParameter;
if (mttp != null)
// Bound by method. May implement zero or more interfaces.
return new ParameterTypeRef(ParameterFlavor.Method, mttp.ParameterListIndex);
var ctp = type as CCI.ClassParameter;
if (ctp != null)
// Boound by class/struct/interface. Known to derive from a class or struct,
// and possibly implements additional interfaces
return new ParameterTypeRef(ParameterFlavor.Type, ctp.ParameterListIndex);
var ttp = type as CCI.TypeParameter;
if (ttp != null)
// Bound by class/struct/interface. May implement zero or more interfaces.
return new ParameterTypeRef(ParameterFlavor.Type, ttp.ParameterListIndex);
var arrType = type as CCI.ArrayType;
if (arrType != null)
// Built-in array type
return new BuiltinTypeRef(global.ArrayTypeConstructorDef, TypeRefFromCCIType(arrType.ElementType));
var refType = type as CCI.Reference;
if (refType != null)
// Built-in managed pointer type
return new BuiltinTypeRef
(global.ManagedPointerTypeConstructorDef, TypeRefFromCCIType(refType.ElementType));
var ptrType = type as CCI.Pointer;
if (ptrType != null)
// Built-in unmanaged pointer type
return new BuiltinTypeRef
(global.UnmanagedPointerTypeConstructorDef, TypeRefFromCCIType(ptrType.ElementType));
var funptrType = type as CCI.FunctionPointer;
if (funptrType != null)
// Built-in function and action types
return CodePointerFromParameters(funptrType.ParameterTypes, funptrType.ReturnType);
var arguments = default(AList<TypeRef>);
// In the following we'll follow two chains:
// - type will follow the Template chain back to the definition of the higher-kinded type
// - appType will follow the Template/DeclaringType chain to accumulate types from
// the phantom type applications invented by CCI
var appType = type;
do
{
if (appType.TemplateArguments != null && appType.TemplateArguments.Count > 0)
{
if (arguments == null)
arguments = new AList<TypeRef>();
// Grab type arguments
var n = appType.TemplateArguments.Count;
for (var i = 0; i < n; i++)
// Prepend type arguments (since we may already have gathered arguments from nested types)
arguments.Insert(i, TypeRefFromCCIType(appType.TemplateArguments[i]));
if (appType.Template == null)
throw new InvalidOperationException("invalid type");
if (type.Template == null)
throw new InvalidOperationException("invalid type");
// Step into higher-kinded type
appType = appType.Template;
type = type.Template;
if (appType.TemplateArguments != null && appType.TemplateArguments.Count > 0)
throw new InvalidOperationException("invalid type");
if (appType.TemplateParameters == null || appType.TemplateParameters.Count != n)
throw new InvalidOperationException("invalid type");
}
// Also look for type arguments in any outer types
appType = appType.DeclaringType;
}
while (appType != null);
if (type.Template != null || type is CCI.ArrayType || type is CCI.Reference || type is CCI.FunctionPointer ||
type is CCI.Pointer)
throw new InvalidOperationException("invalid type");
if (type.DeclaringModule == null || type.DeclaringModule.ContainingAssembly == null || type.Name == null)
throw new InvalidOperationException("type definition not found");
// If the type we found takes type parameters but we didn't collect any type arguments,
// create a self-reference to the higher-kinded type
var arity = 0;
var absType = type;
do
{
if (absType.TemplateParameters != null)
arity += absType.TemplateParameters.Count;
absType = absType.DeclaringType;
}
while (absType != null);
if (arity > 0 && arguments == null)
{
arguments = new AList<TypeRef>();
for (var i = 0; i < arity; i++)
arguments.Add(new ParameterTypeRef(ParameterFlavor.Type, i));
}
return new NamedTypeRef(QualifiedTypeNameFromCCIType(type), arguments);
}
示例5: TestHistory
public void TestHistory()
{
var properties = new Dictionary<String, Object>();
properties["testName"] = "test06_History";
properties["tag"] = 1L;
var db = StartDatabase();
var doc = CreateDocumentWithProperties(db, properties);
var rev1ID = doc.CurrentRevisionId;
Log.I(Tag, "1st revision: " + rev1ID);
Assert.IsTrue (rev1ID.StartsWith ("1-", StringComparison.Ordinal), "1st revision looks wrong: " + rev1ID);
Assert.AreEqual(doc.UserProperties, properties);
properties = new Dictionary<String, Object>(doc.Properties);
properties["tag"] = 2;
Assert.IsNotNull(!properties.Equals(doc.Properties));
Assert.IsNotNull(doc.PutProperties(properties));
var rev2ID = doc.CurrentRevisionId;
Log.I(Tag, "rev2ID" + rev2ID);
Assert.IsTrue(rev2ID.StartsWith("2-", StringComparison.Ordinal), "2nd revision looks wrong:" + rev2ID);
var revisions = doc.RevisionHistory.ToList();
Log.I(Tag, "Revisions = " + revisions);
Assert.AreEqual(revisions.Count, 2);
var rev1 = revisions[0];
Assert.AreEqual(rev1.Id, rev1ID);
var gotProperties = rev1.Properties;
Assert.AreEqual(1, gotProperties["tag"]);
var rev2 = revisions[1];
Assert.AreEqual(rev2.Id, rev2ID);
Assert.AreEqual(rev2, doc.CurrentRevision);
gotProperties = rev2.Properties;
Assert.AreEqual(2, gotProperties["tag"]);
var tmp = new AList<SavedRevision>();
tmp.Add(rev2);
Assert.AreEqual(doc.ConflictingRevisions, tmp);
Assert.AreEqual(doc.LeafRevisions, tmp);
}
示例6: JpegSegmentType
static JpegSegmentType()
{
// /** Start-of-Frame (4) segment identifier. */
// SOF4((byte)0xC4, true),
// /** Start-of-Frame (12) segment identifier. */
// SOF12((byte)0xCC, true),
IList<Com.Drew.Imaging.Jpeg.JpegSegmentType> segmentTypes = new AList<Com.Drew.Imaging.Jpeg.JpegSegmentType>();
foreach (Com.Drew.Imaging.Jpeg.JpegSegmentType segmentType in typeof(Com.Drew.Imaging.Jpeg.JpegSegmentType).GetEnumConstants<JpegSegmentType>())
{
if (segmentType.canContainMetadata)
{
segmentTypes.Add(segmentType);
}
}
canContainMetadataTypes = segmentTypes;
}
示例7: SlotsOfCCIMethod
// Return all the methods that the given method definition may be called via, including any
// overridden method in base type, all implicit interface method implementations (via name and signature) and
// all explicit interface method implementations (via definition itself) interface methods. Note
// that there are polymorphic method references: the refs may be to polymorphic methods and are never
// to instances of polymorphic methods.
private AList<PolymorphicMethodRef> SlotsOfCCIMethod(CCI.Method method)
{
var set = new HashSet<CCI.Method>(); // default comparer ok
if (method.OverriddenMethod != null)
set.Add(method.OverriddenMethod);
var interfaceMethods = method.ImplicitlyImplementedInterfaceMethods;
if (interfaceMethods != null)
{
foreach (var m in interfaceMethods)
AddImplementedInterfaceMethod(set, method, m);
}
interfaceMethods = method.ImplementedInterfaceMethods;
if (interfaceMethods != null)
{
foreach (var m in interfaceMethods)
AddImplementedInterfaceMethod(set, method, m);
}
var res = new AList<PolymorphicMethodRef>();
foreach (var m in set)
res.Add(PolymorphicMethodRefFromCCIMethod(m));
return res;
}
示例8: TestCreateRevisions
public void TestCreateRevisions()
{
var properties = new Dictionary<String, Object>();
properties["testName"] = "testCreateRevisions";
properties["tag"] = 1337;
var db = StartDatabase();
var doc = CreateDocumentWithProperties(db, properties);
var rev1 = doc.CurrentRevision;
Assert.IsTrue(rev1.Id.StartsWith("1-"));
Assert.AreEqual(1, rev1.Sequence);
Assert.AreEqual(0, rev1.Attachments.Count());
// Test -createRevisionWithProperties:
var properties2 = new Dictionary<String, Object>(properties);
properties2["tag"] = 4567;
var rev2 = rev1.CreateRevision(properties2);
Assert.IsNotNull(rev2, "Put failed");
Assert.IsTrue(doc.CurrentRevisionId.StartsWith("2-"), "Document revision ID is still " + doc.CurrentRevisionId);
Assert.AreEqual(rev2.Id, doc.CurrentRevisionId);
Assert.IsNotNull(rev2.PropertiesAvailable);
Assert.AreEqual(rev2.UserProperties, properties2);
Assert.AreEqual(rev2.Document, doc);
Assert.AreEqual(rev2.GetProperty("_id"), doc.Id);
Assert.AreEqual(rev2.GetProperty("_rev"), rev2.Id);
// Test -createRevision:
var newRev = rev2.CreateRevision();
Assert.IsNull(newRev.Id);
Assert.AreEqual(newRev.Parent, rev2);
Assert.AreEqual(newRev.ParentId, rev2.Id);
var listRevs = new AList<SavedRevision>();
listRevs.Add(rev1);
listRevs.Add(rev2);
Assert.AreEqual(newRev.RevisionHistory, listRevs);
Assert.AreEqual(newRev.Properties, rev2.Properties);
Assert.AreEqual(newRev.UserProperties, rev2.UserProperties);
var userProperties = new Dictionary<String, Object>();
userProperties["because"] = "NoSQL";
newRev.SetUserProperties(userProperties);
Assert.AreEqual(newRev.UserProperties, userProperties);
var expectProperties = new Dictionary<String, Object>();
expectProperties["because"] = "NoSQL";
expectProperties["_id"] = doc.Id;
expectProperties["_rev"] = rev2.Id;
Assert.AreEqual(newRev.Properties, expectProperties);
var rev3 = newRev.Save();
Assert.IsNotNull(rev3);
Assert.AreEqual(rev3.UserProperties, newRev.UserProperties);
}
示例9: Extract
/// <exception cref="Com.Drew.Imaging.Png.PngProcessingException"/>
/// <exception cref="System.IO.IOException"/>
public virtual Iterable<PngChunk> Extract(SequentialReader reader, ICollection<PngChunkType> desiredChunkTypes)
{
//
// PNG DATA STREAM
//
// Starts with a PNG SIGNATURE, followed by a sequence of CHUNKS.
//
// PNG SIGNATURE
//
// Always composed of these bytes: 89 50 4E 47 0D 0A 1A 0A
//
// CHUNK
//
// 4 - length of the data field (unsigned, but always within 31 bytes), may be zero
// 4 - chunk type, restricted to [65,90] and [97,122] (A-Za-z)
// * - data field
// 4 - CRC calculated from chunk type and chunk data, but not length
//
// CHUNK TYPES
//
// Critical Chunk Types:
//
// IHDR - image header, always the first chunk in the data stream
// PLTE - palette table, associated with indexed PNG images
// IDAT - image data chunk, of which there may be many
// IEND - image trailer, always the last chunk in the data stream
//
// Ancillary Chunk Types:
//
// Transparency information: tRNS
// Colour space information: cHRM, gAMA, iCCP, sBIT, sRGB
// Textual information: iTXt, tEXt, zTXt
// Miscellaneous information: bKGD, hIST, pHYs, sPLT
// Time information: tIME
//
reader.SetMotorolaByteOrder(true);
// network byte order
if (!Arrays.Equals(PngSignatureBytes, reader.GetBytes(PngSignatureBytes.Length)))
{
throw new PngProcessingException("PNG signature mismatch");
}
bool seenImageHeader = false;
bool seenImageTrailer = false;
IList<PngChunk> chunks = new AList<PngChunk>();
ICollection<PngChunkType> seenChunkTypes = new HashSet<PngChunkType>();
while (!seenImageTrailer)
{
// Process the next chunk.
int chunkDataLength = reader.GetInt32();
PngChunkType chunkType = new PngChunkType(reader.GetBytes(4));
sbyte[] chunkData = reader.GetBytes(chunkDataLength);
// Skip the CRC bytes at the end of the chunk
// TODO consider verifying the CRC value to determine if we're processing bad data
reader.Skip(4);
if (seenChunkTypes.Contains(chunkType) && !chunkType.AreMultipleAllowed())
{
throw new PngProcessingException(Sharpen.Extensions.StringFormat("Observed multiple instances of PNG chunk '%s', for which multiples are not allowed", chunkType));
}
if (chunkType.Equals(PngChunkType.Ihdr))
{
seenImageHeader = true;
}
else
{
if (!seenImageHeader)
{
throw new PngProcessingException(Sharpen.Extensions.StringFormat("First chunk should be '%s', but '%s' was observed", PngChunkType.Ihdr, chunkType));
}
}
if (chunkType.Equals(PngChunkType.Iend))
{
seenImageTrailer = true;
}
if (desiredChunkTypes == null || desiredChunkTypes.Contains(chunkType))
{
chunks.Add(new PngChunk(chunkType, chunkData));
}
seenChunkTypes.Add(chunkType);
}
return chunks.AsIterable();
}
示例10: PostChangeNotifications
internal void PostChangeNotifications()
{
// This is a 'while' instead of an 'if' because when we finish posting notifications, there
// might be new ones that have arrived as a result of notification handlers making document
// changes of their own (the replicator manager will do this.) So we need to check again.
while (_transactionLevel == 0 && _isOpen && !_isPostingChangeNotifications && _changesToNotify.Count > 0)
{
try
{
_isPostingChangeNotifications = true;
IList<DocumentChange> outgoingChanges = new AList<DocumentChange>();
foreach (var change in _changesToNotify)
{
outgoingChanges.Add(change);
}
_changesToNotify.Clear();
// TODO: change this to match iOS and call cachedDocumentWithID
var isExternal = false;
foreach (var change in outgoingChanges)
{
var document = GetDocument(change.DocumentId);
document.RevisionAdded(change);
if (change.SourceUrl != null)
{
isExternal = true;
}
}
var args = new DatabaseChangeEventArgs {
Changes = outgoingChanges,
IsExternal = isExternal,
Source = this
} ;
var changeEvent = Changed;
if (changeEvent != null)
changeEvent(this, args);
}
catch (Exception e)
{
Log.E(Tag, " got exception posting change notifications", e);
}
finally
{
_isPostingChangeNotifications = false;
}
}
}
示例11: TypeNameFromCCIType
private TypeName TypeNameFromCCIType(CCI.TypeNode type)
{
while (type.Template != null)
type = type.Template;
var types = new AList<string>();
types.Add(type.Name.Name);
while (type.DeclaringType != null)
{
type = type.DeclaringType;
types.Insert(0, type.Name.Name);
}
var ns = default(IImAList<string>);
if (type.Namespace != null && !string.IsNullOrEmpty(type.Namespace.Name))
{
if (!namespaceCache.TryGetValue(type.Namespace.Name, out ns))
{
ns = new AList<string>(type.Namespace.Name.Split('.'));
namespaceCache.Add(type.Namespace.Name, ns);
}
}
return new TypeName(ns, types);
}
示例12: dump
internal IList<IDictionary<string, object>> dump()
{
if (Id < 0)
{
return null;
}
var selectArgs = new[] { Id.ToString() };
Cursor cursor = null;
var result = new AList<IDictionary<string, object>>();
try
{
cursor = Database.StorageEngine.
RawQuery("SELECT sequence, key, value FROM map WHERE view_id=? ORDER BY key", selectArgs);
while(cursor.MoveToNext())
{
var row = new Dictionary<string, object>();
row["seq"] = cursor.GetInt(0);
row["key"] = cursor.GetString(1);
row["value"] = cursor.GetString(2);
result.Add(row);
}
}
catch (Exception e)
{
Log.E(Tag, "Error dumping view", e);
result = null;
}
finally
{
if (cursor != null)
{
cursor.Close();
}
}
return result;
}
示例13: AssemblyDefFromCCIAssembly
private AssemblyDef AssemblyDefFromCCIAssembly(CCI.AssemblyNode assembly)
{
var references = default(AList<StrongAssemblyName>);
if (assembly.AssemblyReferences != null && assembly.AssemblyReferences.Count > 0)
{
references = new AList<StrongAssemblyName>();
for (var i = 0; i < assembly.AssemblyReferences.Count; i++)
{
var reference = assembly.AssemblyReferences[i];
if (reference.Assembly == null ||
!reference.Assembly.StrongName.Equals
(reference.StrongName, StringComparison.OrdinalIgnoreCase) ||
reference.Assembly.Location.Equals("unknown:location", StringComparison.OrdinalIgnoreCase))
throw new InvalidOperationException("invalid assembly reference");
references.Add(StrongAssemblyNameFromCCIAssembly(reference.Assembly));
}
references.Sort((l, r) => l.CompareTo(r));
}
var nameToTypeDef = new Dictionary<TypeName, TypeDef>();
if (assembly.Types != null)
{
for (var i = 0; i < assembly.Types.Count; i++)
AddCCITypes(nameToTypeDef, assembly, assembly.Types[i]);
}
var sn = StrongAssemblyNameFromCCIAssembly(assembly);
// Extract names and sort them
var names = new List<TypeName>();
foreach (var kv in nameToTypeDef)
names.Add(kv.Key);
names.Sort((l, r) => l.CompareTo(r));
// Place definitions in canonical order
var typeDefs = default(AList<TypeDef>);
if (names.Count > 0)
{
typeDefs = new AList<TypeDef>();
foreach (var nm in names)
typeDefs.Add(nameToTypeDef[nm]);
}
var entryPoint = default(MethodRef);
if (assembly.EntryPoint != null)
entryPoint = MethodRefFromCCIMethod(assembly.EntryPoint);
var customAttributes = default(AList<CustomAttribute>);
if (assembly.Attributes != null && assembly.Attributes.Count > 0)
{
customAttributes = new AList<CustomAttribute>();
for (var i = 0; i < assembly.Attributes.Count; i++)
customAttributes.Add(CustomAttributeFromCCIAttribute(assembly.Attributes[i]));
}
return new AssemblyDef(global, null, customAttributes, sn, references, typeDefs, entryPoint);
}
示例14: TypeDefFromCCIType
private TypeDef TypeDefFromCCIType(CCI.AssemblyNode assembly, CCI.TypeNode type)
{
if (!IsCCITypeDefinition(type))
throw new InvalidOperationException("type is not a definition");
if (type.DeclaringModule == null || type.DeclaringModule.ContainingAssembly == null ||
type.DeclaringModule.ContainingAssembly != assembly || type.Name == null)
throw new InvalidOperationException("type definition not found in assembly");
if (type is CCI.ArrayType || type is CCI.Reference || type is CCI.Pointer || type is CCI.FunctionPointer)
throw new InvalidOperationException("type is not a definition");
if (type is CCI.ClassParameter || type is CCI.TypeParameter)
throw new InvalidOperationException("unexpected type parameter");
var parameters = default(AList<ParameterTypeDef>);
var declType = type;
do
{
if (declType.TemplateArguments != null && declType.TemplateArguments.Count > 0)
throw new InvalidOperationException("type is not a definition");
if (declType.TemplateParameters != null && declType.TemplateParameters.Count > 0)
{
if (parameters == null)
parameters = new AList<ParameterTypeDef>();
for (var i = 0; i < declType.TemplateParameters.Count; i++)
{
var p = declType.TemplateParameters[i];
if (p.Template != null)
throw new InvalidOperationException("invalid class type parameter");
if (p is CCI.MethodClassParameter || p is CCI.MethodTypeParameter)
throw new InvalidOperationException("invalid class type parameter");
var cp = p as CCI.ClassParameter;
var tp = p as CCI.TypeParameter;
if (cp != null || tp != null)
{
var variance = default(ParameterVariance);
var constraint = default(ParameterConstraint);
ParameterConstraintFromCCITypeParameterFlags
(cp == null ? tp.TypeParameterFlags : cp.TypeParameterFlags,
out variance,
out constraint);
var pextends = default(TypeRef);
var pimplements = default(AList<TypeRef>);
TypeDerivationFromCCIType(p, out pextends, out pimplements);
parameters.Insert
(i,
(new ParameterTypeDef
(null,
CustomAttributesFromCCIMember(p),
pextends,
pimplements,
ParameterFlavor.Type,
i,
variance,
constraint)));
}
else
throw new InvalidOperationException("invalid class type parameter");
}
}
declType = declType.DeclaringType;
}
while (declType != null);
var members = default(AList<MemberDef>);
for (var i = 0; i < type.Members.Count; i++)
{
var member = type.Members[i];
var method = member as CCI.Method;
if (method != null)
{
if (members == null)
members = new AList<MemberDef>();
members.Add(MethodDefFromCCIMethod(method));
}
else
{
var field = member as CCI.Field;
if (field != null)
{
if (members == null)
members = new AList<MemberDef>();
members.Add(FieldDefFromCCIField(field));
}
else
{
var prop = member as CCI.Property;
if (prop != null)
{
if (members == null)
members = new AList<MemberDef>();
members.Add(PropertyDefFromCCIProperty(prop));
}
else
{
var evnt = member as CCI.Event;
if (evnt != null)
{
if (members == null)
//.........这里部分代码省略.........
示例15: FieldDefFromCCIField
private FieldDef FieldDefFromCCIField(CCI.Field field)
{
if (!IsCCIFieldDefinition(field))
throw new InvalidOperationException("field is not a definition");
var annotations = new AList<Annotation>();
annotations.Add(new FieldAccessAnnotation(field.IsInitOnly));
var init = default(FieldInit);
if (field.DefaultValue != null)
{
if (field.InitialData != null)
throw new InvalidOperationException("invalid field definition");
init = new ConstFieldInit(field.DefaultValue.Value);
}
else if (field.InitialData != null)
init = new RawFieldInit(field.InitialData);
else
init = null;
var customAttributes = CustomAttributesFromCCIMember(field);
return new FieldDef
(annotations, customAttributes, field.Name.Name, field.IsStatic, TypeRefFromCCIType(field.Type), init);
}