本文整理汇总了C#中PrivateType.SetStaticField方法的典型用法代码示例。如果您正苦于以下问题:C# PrivateType.SetStaticField方法的具体用法?C# PrivateType.SetStaticField怎么用?C# PrivateType.SetStaticField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PrivateType
的用法示例。
在下文中一共展示了PrivateType.SetStaticField方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
public void Initialize()
{
PrivateType pt = new PrivateType(typeof(SQLiteRepositoryClient));
pt.SetStaticField("dataSource", filename);
wait = new AutoResetEvent(false);
}
示例2: SetTestDateTime
/// <summary>
/// Injects current UTC time as fixed constant as replacement of DateTime.UtcNow for testing purposes
/// </summary>
internal static void SetTestDateTime()
{
var moment = new PrivateType(typeof(Moment));
var current = DateTime.UtcNow;
// reduce precision to seconds, because Ticks may be extracted by SQL server
DateTime precise = new DateTime(current.Year, current.Month, current.Day, current.Hour, current.Minute, current.Second);
var customMoment = new InjectionDateTime { UtcNow = precise };
moment.SetStaticField("service", customMoment);
}
示例3: Cleanup
public void Cleanup()
{
try
{
PrivateType pt = new PrivateType(typeof(Taskboard.Apps.TaskboardApp));
pt.SetStaticField("_applcation", null);
wait.Dispose();
File.Delete(filename);
}
catch(Exception)
{ }
}
示例4: TestUI_DefaultHttpHandler_GeneratesDefaultPage
public void TestUI_DefaultHttpHandler_GeneratesDefaultPage()
{
PageInformation pageInformation = new PageInformation();
PrivateType privateDefaultHttpHandler = new PrivateType(typeof(DefaultHttpHandler));
privateDefaultHttpHandler.SetStaticField("_hostPath", new Lazy<string>(() =>
{
return "";
}));
try
{
string page = DefaultHttpHandler.GenerateDefaultPage(pageInformation);
Assert.IsNotNull(page, "Page is expected to generate correctly");
Assert.IsTrue(page.Length > 0, "Page is expected to contain content");
}
catch (Exception)
{
Assert.Fail("GenerateDefaultPage should not throw exceptions");
}
}
示例5: SetPrivateStaticField
public static void SetPrivateStaticField(Type type, string fieldName, object value)
{
PrivateType t = new PrivateType(type);
t.SetStaticField(fieldName, value);
}
示例6: SetBufferedNodeEnumeratorBufferSize
void SetBufferedNodeEnumeratorBufferSize(int size)
{
var nodeResolverAcc = new PrivateType(typeof(BufferedNodeEnumerator<Node>));
nodeResolverAcc.SetStaticField("BufferSize", size);
}
示例7: SetBackwardCompatibilityXmlNamespaces
private void SetBackwardCompatibilityXmlNamespaces(bool newValue)
{
var pt = new PrivateType(typeof(RepositoryConfiguration));
pt.SetStaticField("_backwardCompatibilityXmlNamespaces", newValue);
}
示例8: Security_MembershipExtender
public void Security_MembershipExtender()
{
var extAcc = new PrivateType(typeof(MembershipExtenderBase));
var extender = new TestMembershipExtender();
extAcc.SetStaticField("_instance", extender);
var user = User.Visitor;
var ext0 = user.MembershipExtension;
MembershipExtenderBase.Extend(user);
var ext1 = user.MembershipExtension;
Assert.IsTrue(ext0 == null, "#1");
Assert.IsTrue(ext1.ExtensionIds.Count() == 1, "#2");
Assert.IsTrue(ext1.ExtensionIds.ElementAt(0) == 111, "#3");
}