本文整理汇总了C#中Module.GetValue方法的典型用法代码示例。如果您正苦于以下问题:C# Module.GetValue方法的具体用法?C# Module.GetValue怎么用?C# Module.GetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Module
的用法示例。
在下文中一共展示了Module.GetValue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetValueFromGlobalContext
public void GetValueFromGlobalContext()
{
BindingEnvironment global = new BindingEnvironment();
global.SetValue("one", 1);
Module module = new Module(global);
var result = module.GetValue("one");
Assert.IsNotNull(result);
Assert.AreEqual(1, result);
Assert.IsTrue(module.HasValue("one"));
}
示例2: CreateModule
public void CreateModule()
{
Module module = new Module(null);
Assert.IsNull(module.GlobalContext);
Assert.IsNull(module.GetValue("foo"));
Assert.IsFalse(module.HasValue("foo"));
var names = module.GetNames();
Assert.IsNotNull(names);
Assert.AreEqual(0, names.Count);
}
示例3: fastNoise
/**
* Generates a 1D noise map using reduced sampling and linear interpolation
*
* @param noiseGenerator The noise generator module
* @param xSize The size of the 1D map
* @param samplingRate The sampling rate to use. xSize % samplingRate must
* return 0.
* @param x The x coord
* @param y The y coord
* @param z The z coord
* @throws IllegalArgumentException if the noise generator is null, the
* samplign rate is zero, or xSize % samplingRate doesn't return 0
* @return The noise map
*/
public static double[] fastNoise(Module noiseGenerator, int xSize, int samplingRate, int x, int y, int z)
{
if (noiseGenerator == null) {
throw new ArgumentException("noiseGenerator cannot be null");
}
if (samplingRate == 0) {
throw new ArgumentException("samplingRate cannot be 0");
}
if (xSize % samplingRate != 0) {
throw new ArgumentException("xSize % samplingRate must return 0");
}
double[] noiseArray = new double[xSize + 1];
for (int xx = 0; xx <= xSize; xx += samplingRate) {
noiseArray[xx] = noiseGenerator.GetValue(xx + x, y, z);
}
for (int xx = 0; xx < xSize; xx++) {
if (xx % samplingRate != 0) {
int nx = (xx / samplingRate) * samplingRate;
noiseArray[xx] = MathHelper.lerp(xx, nx, nx + samplingRate,
noiseArray[nx], noiseArray[nx + samplingRate]);
}
}
return noiseArray;
}
示例4: handleCase5
// case 5 : id1 (id2)
// is id2 reference to INT val -> label := id1, no:=INT of id2
List<ObjectIdentifierComponent> handleCase5(int Index, Module mod)
{
if (!mod.isValueDeclared(id2))
throw new SemanticErrorException("Error in line: " + tr2.Line + ", col:" + tr2.CharPositionInLine + ". Unknown identifier: " + id2);
Asn1Value val = mod.GetValue(id2);
if (val.m_TypeID == Asn1Value.TypeID.UNRESOLVED)
return null; // not yet resolved. wait for next round
if (val.m_TypeID == TypeID.INT)
{
int tmp = (int)((IntegerValue)val).Value;
no = tmp;
return null;
}
throw new SemanticErrorException("Error in line: " + tr2.Line + ", col:" + tr2.CharPositionInLine + ". Identifier: " + id2 + "does not resolve to INTEGER or RELATIVE-OID");
}
示例5: handleCase1
// case 1 : id1
// is id1 reserved word --> label:=id1, no = id1.value
// if (INDEX==0) && id1 is value reference to OBJ-ID ->replace component with components of other OBJ-ID
// is id1 reference to INTEGER --> no := INTEGER value
// is id1 reference to REL_OBJ ID --> ?
//default: id1 is unknown or reference wrong type
List<ObjectIdentifierComponent> handleCase1(int Index, Module mod, ObjectIdentifierComponent prev)
{
int tmp;
string prvLbl = null;
if (prev != null)
prvLbl = prev.label;
if (YellowIDs.isYellowId(Index, id1, prvLbl, out tmp))
{
no = tmp;
label = id1;
return null;
}
if (!mod.isValueDeclared(id1))
throw new SemanticErrorException("Error in line: " + tr1.Line + ", col:" + tr1.CharPositionInLine + ". Unknown identifier: " + id1);
Asn1Value val = mod.GetValue(id1);
if (val.m_TypeID == Asn1Value.TypeID.UNRESOLVED)
return null; // not yet resolved. wait for next round
if (val.m_TypeID == TypeID.INT)
{
tmp = (int)((IntegerValue)val).Value;
no = tmp;
return null;
}
if (val.m_TypeID == TypeID.OBJECT_IDENTIFIER)
{
if (Index == 0)
{
ObjectIdentifierValue obj = val as ObjectIdentifierValue;
if (!obj.IsResolved())
return null; //wait until resolved
return obj.m_components;
}
else
throw new SemanticErrorException("Error in line: " + tr1.Line + ", col:" + tr1.CharPositionInLine + ". Identifier: " + id1 + "resolves to OBJECT IDENTIFIER but it is not the first item");
}
if (val.m_TypeID == TypeID.REL_OBJ_ID)
{
throw new Exception("UNIMPLEMENTED FEATURE");
}
throw new SemanticErrorException("Error in line: " + tr1.Line + ", col:" + tr1.CharPositionInLine + ". Identifier: " + id1 + "does not resolve to INTEGER or RELATIVE-OID");
}