本文整理汇总了C#中PrivateType.GetStaticField方法的典型用法代码示例。如果您正苦于以下问题:C# PrivateType.GetStaticField方法的具体用法?C# PrivateType.GetStaticField怎么用?C# PrivateType.GetStaticField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PrivateType
的用法示例。
在下文中一共展示了PrivateType.GetStaticField方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Init
public void Init()
{
PrivateType p = new PrivateType(typeof(Dev2DataLanguageParser));
var cache = p.GetStaticField("_expressionCache") as ConcurrentDictionary<string, IList<IIntellisenseResult>>;
Assert.IsNotNull(cache);
cache.Clear();
var cache2 = p.GetStaticField("_payloadCache") as ConcurrentDictionary<Tuple<string, string>, IList<IIntellisenseResult>>;
Assert.IsNotNull(cache2);
cache2.Clear();
Monitor.Enter(DataListSingletonTest.DataListSingletonTestGuard);
var testEnvironmentModel = ResourceModelTest.CreateMockEnvironment();
_resourceModel = new ResourceModel(testEnvironmentModel.Object)
{
ResourceName = "test",
ResourceType = ResourceType.Service,
DataList = @"
<DataList>
<Scalar/>
<Country/>
<State />
<City>
<Name/>
<GeoLocation />
</City>
</DataList>
"
};
IDataListViewModel setupDatalist = new DataListViewModel();
DataListSingleton.SetDataList(setupDatalist);
DataListSingleton.ActiveDataList.InitializeDataListViewModel(_resourceModel);
}
示例2: CalculateCosineCoefficients_Test
public void CalculateCosineCoefficients_Test()
{
PrivateType pt = new PrivateType(typeof(JpegImage));
JpegImage ji = new JpegImage(new Bitmap(200, 100), 100, 4); //Constructor calls calcCosineCoef
float[,] CosCoef = (float[,])pt.GetStaticField("CosinesCoefficients");
float[,] ExpectedCosCoef = new float[8, 8]
{
{1f, 0.980785251f, 0.9238795f, 0.8314696f, 0.707106769f, 0.555570245f, 0.382683426f, 0.195090324f},
{1f, 0.8314696f, 0.382683426f, -0.195090324f, -0.707106769f, -0.980785251f, -0.9238795f, -0.555570245f},
{1f, 0.555570245f, -0.382683426f, -0.980785251f, -0.707106769f, 0.195090324f, 0.923879504f, 0.831469595f},
{1f, 0.195090324f, -0.923879504f, -0.555570245f, 0.707106769f, 0.831469595f, -0.382683426f, -0.980785251f},
{1f, -0.195090324f, -0.923879504f, 0.555570245f, 0.707106769f, -0.831469595f, -0.382683426f, 0.980785251f},
{1f, -0.555570245f, -0.382683426f, 0.980785251f, -0.707106769f, -0.195090324f, 0.923879504f, -0.831469595f},
{1f, -0.831469595f, 0.382683426f, 0.195090324f, -0.707106769f, 0.980785251f, -0.923879504f, 0.555570245f},
{1f, -0.980785251f, 0.923879504f, -0.831469595f, 0.707106769f, -0.555570245f, 0.382683426f, -0.195090324f},
};
Assert.AreEqual(ExpectedCosCoef, CosCoef);
}
示例3: Dev2LanuageParser_Parse_IValid_ExpectNoCache
public void Dev2LanuageParser_Parse_IValid_ExpectNoCache()
{
//------------Setup for test--------------------------
const string dl = "<ADL><rec><val/></rec></ADL>";
const string payload = "[[rec().val]]";
PrivateType p = new PrivateType(typeof(Dev2DataLanguageParser));
var cache = p.GetStaticField("_expressionCache") as ConcurrentDictionary<string, IList<IIntellisenseResult>>;
Assert.IsNotNull(cache);
cache.Clear();
Assert.AreEqual(cache.Count, 0);
ParseDataLanguageForIntellisense(payload, dl, true, false);
Assert.IsNotNull(cache);
Assert.AreEqual(cache.Count, 0);
//------------Execute Test---------------------------
//------------Assert Results-------------------------
}
示例4: Dev2LanuageParser_Parse_Valid_ExpectCache
public void Dev2LanuageParser_Parse_Valid_ExpectCache()
{
//------------Setup for test--------------------------
PrivateType p = new PrivateType(typeof(Dev2DataLanguageParser));
var cache = p.GetStaticField("_payloadCache") as ConcurrentDictionary<Tuple<string, string>, IList<IIntellisenseResult>>;
if(cache != null)
{
cache.Clear();
}
const string dl = "<ADL><rec><val/></rec></ADL>";
const string payload = "[[rec().val]]";
var dev2LanuageParser = new Dev2DataLanguageParser();
IList<IIntellisenseResult> results = ParseDataLanguageForIntellisense(payload, dl, true, false);
Assert.IsNotNull(cache);
Assert.AreEqual(cache.Count,1);
//------------Execute Test---------------------------
//------------Assert Results-------------------------
}
示例5: Dev2LanuageParser_ParseExpressionIntoParts_WhenInValid_ExpectNoCache
public void Dev2LanuageParser_ParseExpressionIntoParts_WhenInValid_ExpectNoCache()
{
//------------Setup for test--------------------------
var dev2LanuageParser = new Dev2DataLanguageParser();
PrivateType p = new PrivateType(typeof(Dev2DataLanguageParser));
var cache = p.GetStaticField("_payloadCache") as ConcurrentDictionary<Tuple<string, string>, IList<IIntellisenseResult>>;
Assert.IsNotNull(cache);
cache.Clear();
Assert.AreEqual(cache.Count, 0);
const string data = @"[[rec(*123).a]]";
const string dl = "<DataList><rec><a/></rec></DataList>";
var compiler = DataListFactory.CreateDataListCompiler();
ErrorResultTO errors;
var dlID = compiler.ConvertTo(DataListFormat.CreateFormat(GlobalConstants._XML_Without_SystemTags), string.Empty.ToStringBuilder(), dl.ToStringBuilder(), out errors);
var bdl = compiler.FetchBinaryDataList(dlID, out errors);
var intillisenseParts = bdl.FetchIntellisenseParts();
//------------Execute Test---------------------------
dev2LanuageParser.ParseExpressionIntoParts(data, intillisenseParts);
//------------Assert Results-------------------------
Assert.IsNotNull(cache);
Assert.AreEqual(cache.Count, 0);
}