YAMP.ParseContext.AddConstant C# (CSharp) Method

AddConstant() public method

Adds a constant to the context.
public AddConstant ( String name, IConstants constant ) : ParseContext
name String /// The name of the constant. ///
constant IConstants /// The class instance of the constant. ///
return ParseContext
        public ParseContext AddConstant(String name, IConstants constant)
        {
            _constants[name] = constant;
            return this;
        }

Usage Example

コード例 #1
0
        /// <summary>
        /// Installs the plugin.
        /// </summary>
        public void Install()
        {
            var types    = _assembly.GetTypes();
            var elements = _context.Elements;

            foreach (var type in types)
            {
                if (!type.IsAbstract)
                {
                    if (type.Name.EndsWith("Value", StringComparison.Ordinal))
                    {
                        var value = Instantiate <IRegisterElement>(elements, type);
                        value.RegisterElement(elements);
                        _valueTypes.Add(type.Name.RemoveValueConvention());
                    }
                    else
                    {
                        var interfaces = type.GetInterfaces();
                        var element    = Instantiate <IRegisterElement>(elements, type, interfaces);

                        if (element != null)
                        {
                            element.RegisterElement(elements);
                        }

                        var function = Instantiate <IFunction>(elements, type, interfaces);

                        if (function != null)
                        {
                            bool isNested;
                            var  name = FunctionName(type, out isNested);
                            _functions.Add(name);
                            _context.AddFunction(name, function);
                        }

                        var constant = Instantiate <IConstants>(elements, type, interfaces);

                        if (constant != null)
                        {
                            var name = constant.Name;
                            _constants.Add(name);
                            _context.AddConstant(name, constant);
                        }

                        var loader = Instantiate <IFunctionLoader>(elements, type, interfaces);

                        if (loader != null)
                        {
                            _loaders.Add(loader);
                        }
                    }
                }
            }
        }
All Usage Examples Of YAMP.ParseContext::AddConstant