本文整理汇总了C#中Collection.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Collection.GetType方法的具体用法?C# Collection.GetType怎么用?C# Collection.GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Collection
的用法示例。
在下文中一共展示了Collection.GetType方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Deploy
public static void Deploy(SPSolution solution, Collection<SPWebApplication> applications, int minCompat, int maxCompat, ILog log)
{
#if SP2013
SPSolutionLanguagePack languagePack = solution.GetLanguagePack(0);
SPCompatibilityRange compatibilityRange = new SPCompatibilityRange(minCompat, maxCompat);
Type deployType = languagePack.GetType();
Type[] argumentTypes = new Type[] { typeof(DateTime), applications.GetType(), typeof(SPSolutionDeploymentJobType), typeof(bool), typeof(bool), typeof(bool), compatibilityRange.GetType() };
ParameterModifier[] modifiers = new ParameterModifier[] { new ParameterModifier(7) };
MethodInfo deployMethod = deployType.GetMethod("CreateSolutionDeployTimerJob", BindingFlags.Instance | BindingFlags.NonPublic, null, argumentTypes, modifiers);
DateTime jobTime = GetImmediateJobTime();
object[] args = new object[] { jobTime, applications, SPSolutionDeploymentJobType.Deploy, true, true, false, compatibilityRange };
deployMethod.Invoke(languagePack, args);
#endif
}
示例2: FromXml
public static Collection<PackageItem> FromXml(string data)
{
Collection<PackageItem> result = new Collection<PackageItem>();
try
{
StringReader tr = new StringReader(data);
XmlSerializer xs = new XmlSerializer(result.GetType());
result = (Collection<PackageItem>)xs.Deserialize(tr);
if (result == null) result = new Collection<PackageItem>();
}
catch
{
result = new Collection<PackageItem>();
}
return result;
}
示例3: ValidateTryGetType
public void ValidateTryGetType()
{
Type returnType;
int num = 0;
Assert.IsTrue(TypeFactory.TryGetType("int", num.GetType(), out returnType));
Assert.IsTrue(TypeFactory.TryGetType("int32", num.GetType(), out returnType));
long longVar = 0;
Assert.IsTrue(TypeFactory.TryGetType("long", longVar.GetType(), out returnType));
Assert.IsTrue(TypeFactory.TryGetType("int64", longVar.GetType(), out returnType));
string strVar = string.Empty;
Assert.IsTrue(TypeFactory.TryGetType("string", strVar.GetType(), out returnType));
double doubleVar = 1.234;
Assert.IsTrue(TypeFactory.TryGetType("double", doubleVar.GetType(), out returnType));
Collection<int> intColl = new Collection<int>();
intColl.Add(1);
Assert.IsTrue(TypeFactory.TryGetType("System.Collections.ObjectModel.Collection`1[System.Int32]", intColl.GetType(), out returnType));
}
示例4: InvalidateTryGetType
public void InvalidateTryGetType()
{
try
{
Type returnType;
int num = 0;
bool check = TypeFactory.TryGetType(null, num.GetType(), out returnType);
Assert.Fail();
}
catch (ArgumentNullException anex)
{
ApplicationLog.WriteLine("Successfully caught ArgumentNullException : " + anex.Message);
}
try
{
Type returnType;
bool check = TypeFactory.TryGetType("int", null, out returnType);
Assert.Fail();
}
catch (ArgumentNullException anex)
{
ApplicationLog.WriteLine("Successfully caught ArgumentNullException : " + anex.Message);
}
try
{
Type returnType;
Collection<int> intcoll = new Collection<int>();
intcoll.Add(1);
bool check = TypeFactory.TryGetType("<>", intcoll.GetType(), out returnType);
Assert.Fail();
}
catch (ArgumentNullException ex)
{
ApplicationLog.WriteLine("Successfully caught Exception : " + ex.Message);
}
}
示例5: Save
/// <summary>
/// Save images list
/// </summary>
/// <param name="list"></param>
public static void Save(Collection<ImageItem> list)
{
try
{
using (var writer = new StreamWriter(GetPath(PictureSlidesLabImagesList)))
{
var serializer = new XmlSerializer(list.GetType());
serializer.Serialize(writer, list);
writer.Flush();
}
}
catch (Exception e)
{
PowerPointLabsGlobals.Log("Failed to save Picture Slides Lab settings: " + e.StackTrace, "Error");
}
}
示例6: TypeTestForCollection
public void TypeTestForCollection()
{
Collection<object> cx = new Collection<object>();
StringAssert.Contains("System.Collections.ObjectModel.Collection`1[System.Object]", cx.GetType().ToString());
}
示例7: Save
/// <summary>
/// Save images list
/// </summary>
/// <param name="list"></param>
public static void Save(Collection<ImageItem> list)
{
try
{
using (var writer = new StreamWriter(GetPath(PictureSlidesLabImagesList)))
{
var serializer = new XmlSerializer(list.GetType());
serializer.Serialize(writer, list);
writer.Flush();
}
}
catch (Exception e)
{
Logger.LogException(e, "Failed to save Picture Slides Lab images list");
}
}