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


C# Module.GetValue方法代码示例

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

示例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);
        }
开发者ID:Refandler,项目名称:PythonSharp,代码行数:13,代码来源:ModuleTests.cs

示例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;
 }
开发者ID:RenaudWasTaken,项目名称:SkyLands,代码行数:38,代码来源:WorldGeneratorUtils.cs

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

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


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