本文整理汇总了C#中System.Collections.ArrayList.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# ArrayList.GetType方法的具体用法?C# ArrayList.GetType怎么用?C# ArrayList.GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.ArrayList
的用法示例。
在下文中一共展示了ArrayList.GetType方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanWrite_ReturnsFalse_IfValueIsAList
public void CanWrite_ReturnsFalse_IfValueIsAList()
{
object value = new ArrayList();
Assert.IsFalse(writer.CanWrite(value, value.GetType()));
value = new List<int>();
Assert.IsFalse(writer.CanWrite(value, value.GetType()));
}
示例2: ArrayListHoldsObjects
public void ArrayListHoldsObjects()
{
ArrayList list = new ArrayList();
// list type = ArrayList, gets the method .Add()
System.Reflection.MethodInfo method = list.GetType().GetMethod("Add");
// Gets method's first param (.Add()) and asks type of that param.
Assert.Equal(typeof(object), method.GetParameters()[0].ParameterType);
}
示例3: AnySerialize
public bool AnySerialize(ArrayList Items)
{
if (Items.Count == 0) {
File.Delete(FileName);
return true;
}
try
{
SObj = new XmlSerializer(Items.GetType(), new Type[] { type.GetType() });
writer = new StreamWriter(@FileName);
SObj.Serialize(writer, Items);
writer.Close();
return true;
}
catch (Exception e)
{
writer.Close();
return false;
}
}
示例4: ArrayListEnumeratorSimple
internal ArrayListEnumeratorSimple(ArrayList list)
{
_list = list;
_index = -1;
_version = list._version;
_isArrayList = (list.GetType() == typeof(ArrayList));
_currentElement = s_dummyObject;
}
示例5: ArrayListEnumeratorSimple
internal ArrayListEnumeratorSimple(ArrayList list) {
this.list = list;
this.index = -1;
version = list._version;
isArrayList = (list.GetType() == typeof(ArrayList));
currentElement = dummyObject;
}
示例6: Run
/// <summary>
/// Main running method for the application.
/// </summary>
/// <param name="args">Commandline arguments to the application.</param>
/// <returns>Returns the application error code.</returns>
private int Run(string[] args)
{
int beginTickCount = Environment.TickCount;
try
{
this.tempFileCollection = new TempFileCollection();
Environment.SetEnvironmentVariable("WixUnitTempDir", this.tempFileCollection.BasePath, EnvironmentVariableTarget.Process);
this.ParseCommandline(args);
// get the assemblies
Assembly wixUnitAssembly = this.GetType().Assembly;
FileVersionInfo fv = FileVersionInfo.GetVersionInfo(wixUnitAssembly.Location);
if (this.showHelp)
{
Console.WriteLine("WixUnit version {0}", fv.FileVersion);
Console.WriteLine("Copyright (C) .NET Foundation and contributors. All rights reserved.");
Console.WriteLine();
Console.WriteLine(" usage: WixUnit [-?] tests.xml");
Console.WriteLine();
Console.WriteLine(" -env:<var>=<value> Sets an environment variable to the value for the current process");
Console.WriteLine(" -notidy Do not delete temporary files (for checking results)");
Console.WriteLine(" -rf Re-run the failed test from the last run");
Console.WriteLine(" -st Run the tests on a single thread");
Console.WriteLine(" -test:<Test_name> Run only the specified test (may use wildcards)");
Console.WriteLine(" -update Prompt user to auto-update a test if expected and actual output files do not match");
Console.WriteLine(" -v Verbose output");
Console.WriteLine(" -val Run MSI validation for light unit tests");
return 0;
}
// set the environment variables for the process only
foreach (KeyValuePair<string, string> environmentVariable in this.environmentVariables)
{
Environment.SetEnvironmentVariable(environmentVariable.Key, environmentVariable.Value, EnvironmentVariableTarget.Process);
}
// load the schema
XmlReader schemaReader = null;
XmlSchemaCollection schemas = null;
try
{
schemas = new XmlSchemaCollection();
schemaReader = new XmlTextReader(wixUnitAssembly.GetManifestResourceStream("Microsoft.Tools.WindowsInstallerXml.Unit.unitTests.xsd"));
XmlSchema schema = XmlSchema.Read(schemaReader, null);
schemas.Add(schema);
}
finally
{
if (schemaReader != null)
{
schemaReader.Close();
}
}
// load the unit tests
XmlTextReader reader = null;
XmlDocument doc = new XmlDocument();
try
{
reader = new XmlTextReader(this.unitTestsFile);
XmlValidatingReader validatingReader = new XmlValidatingReader(reader);
validatingReader.Schemas.Add(schemas);
// load the xml into a DOM
doc.Load(validatingReader);
}
catch (XmlException e)
{
SourceLineNumber sourceLineNumber = new SourceLineNumber(this.unitTestsFile, e.LineNumber);
SourceLineNumberCollection sourceLineNumbers = new SourceLineNumberCollection(new SourceLineNumber[] { sourceLineNumber });
throw new WixException(WixErrors.InvalidXml(sourceLineNumbers, "unitTests", e.Message));
}
catch (XmlSchemaException e)
{
SourceLineNumber sourceLineNumber = new SourceLineNumber(this.unitTestsFile, e.LineNumber);
SourceLineNumberCollection sourceLineNumbers = new SourceLineNumberCollection(new SourceLineNumber[] { sourceLineNumber });
throw new WixException(WixErrors.SchemaValidationFailed(sourceLineNumbers, e.Message, e.LineNumber, e.LinePosition));
}
finally
{
if (reader != null)
{
reader.Close();
}
}
// check the document element
if ("UnitTests" != doc.DocumentElement.LocalName || XmlNamespace != doc.DocumentElement.NamespaceURI)
//.........这里部分代码省略.........
示例7: Execute
////xiao.[email protected] adds for capture return value for regression assertion
//public override string ToCSharpCode(ReadOnlyCollection<string> arguments, string newValueName, string return_val)
//{
// return ToCSharpCode(arguments, newValueName);
//}
public override bool Execute(out ResultTuple ret, ResultTuple[] parameters,
Plan.ParameterChooser[] parameterMap, TextWriter executionLog, TextWriter debugLog, out Exception exceptionThrown, out bool contractViolated, bool forbidNull)
{
contractViolated = false;
ArrayList a = new ArrayList();
for (int i = 0; i < length; i++)
{
Plan.ParameterChooser pair = parameterMap[i];
if (forbidNull)
Util.Assert(parameters[pair.planIndex].tuple[pair.resultIndex] != null);
a.Add(parameters[pair.planIndex].tuple[pair.resultIndex]);
}
exceptionThrown = null;
ret = new ResultTuple(this, a);
executionLog.WriteLine("execute arraylistconstructor type " + a.GetType().ToString());//[email protected] adds
return true;
}
示例8: BaseOptions
protected BaseOptions(SerializationInfo info, StreamingContext context)
: base(info, context)
{
if(info == null)
throw new ArgumentNullException("info");
LoadFileName();
ArrayList tmp = new ArrayList();
heapNames = (ArrayList)info.GetValue("HeapNames", tmp.GetType());
heapValues = (ArrayList)info.GetValue("HeapValues", tmp.GetType());
}
示例9: TestCases2
public static IEnumerable<TestCaseData> TestCases2()
{
var r = new Random();
yield return new TestCaseData(r.Next(),typeof(int));
yield return new TestCaseData(Math.Round(r.NextDouble(), 15), typeof(double));
yield return new TestCaseData("test string",typeof(string));
yield return new TestCaseData(DateTime.UtcNow,typeof(DateTime));
var len = r.Next(5, 30);
var array = Enumerable.Repeat(0, len).Select(a => r.Next()).ToArray();
yield return new TestCaseData(array,typeof(int[]));
var list = new List<int>(array);
yield return new TestCaseData(list,list.GetType());
var list2 = new ArrayList(array);
yield return new TestCaseData(list2,list2.GetType());
var hashset = new HashSet<double>();
hashset.UnionWith(Enumerable.Repeat(0,r.Next(5,50)).Select(a => Math.Round(r.NextDouble(), 15)));
yield return new TestCaseData(hashset,typeof(HashSet<double>));
var hashset2 = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase);
hashset2.UnionWith(Enumerable.Repeat(0,r.Next(5,30)).Select(i => RandomString(r.Next(5,10))));
yield return new TestCaseData(hashset2,typeof(HashSet<string>));
var dic = new Dictionary<string,int>();
var entries = r.Next(3, 10);
for (int i = 0; i < entries; i++)
{
string key;
do
{
key = RandomString(6);
} while (dic.ContainsKey(key));
dic.Add(key,r.Next());
}
yield return new TestCaseData(dic,typeof(Dictionary<string, int>));
var dic2 = new Dictionary<string,int>(StringComparer.InvariantCultureIgnoreCase);
var entries2 = r.Next(3, 10);
for (int i = 0; i < entries2; i++)
{
string key;
do
{
key = RandomString(6);
} while (dic2.ContainsKey(key));
dic2.Add(key, r.Next());
}
yield return new TestCaseData(dic2, typeof(Dictionary<string, int>));
}