当前位置: 首页>>代码示例>>C#>>正文


C# PrivateType.SetStaticField方法代码示例

本文整理汇总了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);
        }
开发者ID:joy1192,项目名称:WPF,代码行数:7,代码来源:UnitTest1.cs

示例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);
 }
开发者ID:oo00spy00oo,项目名称:SharedTerminals,代码行数:12,代码来源:InjectionDateTime.cs

示例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)
            { }
        }
开发者ID:joy1192,项目名称:WPF,代码行数:14,代码来源:UnitTest1.cs

示例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");
            }
        }
开发者ID:sadeghsm,项目名称:ChronoZoom,代码行数:21,代码来源:DefaultHttpHandlerTest.cs

示例5: SetPrivateStaticField

 public static void SetPrivateStaticField(Type type, string fieldName, object value)
 {
     PrivateType t = new PrivateType(type);
     t.SetStaticField(fieldName, value);
 }
开发者ID:Microsoft,项目名称:ApplicationInsights-dotnet-server,代码行数:5,代码来源:QuickPulseTestHelper.cs

示例6: SetBufferedNodeEnumeratorBufferSize

 void SetBufferedNodeEnumeratorBufferSize(int size)
 {
     var nodeResolverAcc = new PrivateType(typeof(BufferedNodeEnumerator<Node>));
     nodeResolverAcc.SetStaticField("BufferSize", size);
 }
开发者ID:maxpavlov,项目名称:FlexNet,代码行数:5,代码来源:QueryResultTests.cs

示例7: SetBackwardCompatibilityXmlNamespaces

 private void SetBackwardCompatibilityXmlNamespaces(bool newValue)
 {
     var pt = new PrivateType(typeof(RepositoryConfiguration));
     pt.SetStaticField("_backwardCompatibilityXmlNamespaces", newValue);
 }
开发者ID:maxpavlov,项目名称:FlexNet,代码行数:5,代码来源:ContentListTest.cs

示例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");
        }
开发者ID:maxpavlov,项目名称:FlexNet,代码行数:17,代码来源:PermissionEvaluatorTest.cs


注:本文中的PrivateType.SetStaticField方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。