PutElement() public static method

Adds a new key-and-value pair into the hash table
public static PutElement ( System collection, System key, System newValue ) : Object
collection System The collection to work with
key System Key used to obtain the value
newValue System Value asociated with the key
return System.Object
        public bool AddVM(string vmName, string macroBody, string[] argArray, string ns)
        {
            VelocimacroManager.MacroEntry macroEntry = new VelocimacroManager.MacroEntry(this, this, vmName, macroBody, argArray, ns);
            macroEntry.FromLibrary = this.registerFromLib;
            bool flag = true;

            if (this.registerFromLib)
            {
                SupportClass.PutElement(this.libraryMap, ns, ns);
            }
            else
            {
                flag = this.libraryMap.ContainsKey(ns);
            }
            bool result;

            if (!flag && this.UsingNamespaces(ns))
            {
                Hashtable @namespace = this.GetNamespace(ns, true);
                SupportClass.PutElement(@namespace, vmName, macroEntry);
                result = true;
            }
            else
            {
                VelocimacroManager.MacroEntry macroEntry2 = (VelocimacroManager.MacroEntry) this.GetNamespace(VelocimacroManager.GLOBAL_NAMESPACE)[vmName];
                if (macroEntry2 != null)
                {
                    macroEntry.FromLibrary = macroEntry2.FromLibrary;
                }
                SupportClass.PutElement(this.GetNamespace(VelocimacroManager.GLOBAL_NAMESPACE), vmName, macroEntry);
                result = true;
            }
            return(result);
        }
示例#2
0
        /// <summary>  instantiates and loads the directive with some basic checks
        ///
        /// </summary>
        /// <param name="directiveClass">classname of directive to load
        ///
        /// </param>
        private void  loadDirective(System.String directiveClass, System.String caption)
        {
            try {
                Type directiveType = System.Type.GetType(directiveClass);

                if (directiveType == null)
                {
                    error("Exception Loading " + caption + " Directive: " + directiveClass + " - you might need to specify the assembly");
                    return;
                }

                System.Object o = System.Activator.CreateInstance(directiveType);

                if (o is Directive.Directive)
                {
                    Directive.Directive directive = (Directive.Directive)o;
                    SupportClass.PutElement(runtimeDirectives, directive.Name, directive);

                    info("Loaded " + caption + " Directive: " + directiveClass);
                }
                else
                {
                    error(caption + " Directive " + directiveClass + " is not NVelocity.Runtime.Directive.Directive." + " Ignoring. ");
                }
            } catch (System.Exception e) {
                error("Exception Loading " + caption + " Directive: " + directiveClass + " : " + e);
            }
        }
示例#3
0
        /// <summary>
        /// Get an InputStream so that the Runtime can build a
        /// template with it.
        /// </summary>
        /// <param name="name">name of template to get</param>
        /// <returns>InputStream containing the template
        /// @throws ResourceNotFoundException if template not found
        /// in the file template path.
        /// </returns>
        public override Stream getResourceStream(String templateName)
        {
            lock (this) {
                String template = null;
                int    size     = paths.Count;

                for (int i = 0; i < size; i++)
                {
                    String path = (String)
                                  paths[i];

                    // Make sure we have a valid templateName.
                    if (templateName == null || templateName.Length == 0)
                    {
                        // If we don't get a properly formed templateName
                        // then there's not much we can do. So
                        // we'll forget about trying to search
                        // any more paths for the template.
                        throw new ResourceNotFoundException("Need to specify a file name or file path!");
                    }

                    template = StringUtils.normalizePath(templateName)
                    ;
                    if (template == null || template.Length == 0)
                    {
                        String msg = "File resource error : argument " + template + " contains .. and may be trying to access " + "content outside of template root.  Rejected.";

                        rsvc.error("FileResourceLoader : " + msg)
                        ;

                        throw new ResourceNotFoundException(msg);
                    }

                    // if a / leads off, then just nip that :)
                    if (template.StartsWith("/"))
                    {
                        template = template.Substring(1)
                        ;
                    }

                    Stream inputStream = findTemplate(path, template)
                    ;

                    if (inputStream != null)
                    {
                        // Store the path that this template came
                        // from so that we can check its modification
                        // time.
                        SupportClass.PutElement(templatePaths, templateName, path);
                        return(inputStream);
                    }
                }

                // We have now searched all the paths for
                // templates and we didn't find anything so
                // throw an exception.
                String msg2 = "FileResourceLoader Error: cannot find resource " + template;
                throw new ResourceNotFoundException(msg2);
            }
        }
示例#4
0
 public virtual void  preStart()
 {
     props = new System.Collections.Hashtable();
     SupportClass.PutElement(props, "THRC.Identifier", "inhaus.Lamp");
     SupportClass.PutElement(props, "THRC.Interface", "de.inhaus.inHausLamp.Lamp");
     //  props.put("THRC.Credential", "1000");
 }
示例#5
0
文件: LoadFunction.cs 项目: ikvm/test
 public static void addDSFunction(string funName, string className, string dllPath)
 {
     try
     {
         Type type;
         funName = funName.ToLower();
         if (dllPath != null)
         {
             type = Assembly.LoadFrom(dllPath).GetType(className);
         }
         else
         {
             type = Type.GetType(className);
         }
         if (hashtable_1.ContainsKey(funName))
         {
             throw new SystemException(new StringBuilder("系统中有两个叫").Append(funName).Append("的数据集函数!").ToString().ToString());
         }
         SupportClass.PutElement(hashtable_1, funName, type);
         SupportClass.PutElement(hashtable_3, type, funName);
     }
     catch (Exception exception)
     {
         throw new SystemException(exception.Message);
     }
 }
示例#6
0
        /// <summary>   adds a namespace to the namespaces
        /// *
        /// </summary>
        /// <param name="namespace">name of namespace to add
        /// </param>
        /// <returns>Hash added to namespaces, ready for use
        ///
        /// </returns>
        private System.Collections.Hashtable addNamespace(System.String namespace_Renamed)
        {
            System.Collections.Hashtable h = new System.Collections.Hashtable();
            System.Object oh;

            if ((oh = SupportClass.PutElement(namespaceHash, namespace_Renamed, h)) != null)
            {
                /*
                 * There was already an entry on the table, restore it!
                 * This condition should never occur, given the code
                 * and the fact that this method is private.
                 * But just in case, this way of testing for it is much
                 * more efficient than testing before hand using get().
                 */
                SupportClass.PutElement(namespaceHash, namespace_Renamed, oh);

                /*
                 * Should't we be returning the old entry (oh)?
                 * The previous code was just returning null in this case.
                 */
                return(null);
            }

            return(h);
        }
示例#7
0
        private void prepareEnv(string args, Env env, ReportDefine rd)
        {
            var collection = new Hashtable();

            if (!string.IsNullOrEmpty(args))
            {
                string[] arrayItem = args.Split(new[] { '&' });
                for (int i = 0, length = arrayItem.Length; i < length; i++)
                {
                    string item = arrayItem[i];
                    if ((item != null) && (item.Trim().Length > 0))
                    {
                        string[] arrayVar = arrayItem[i].Split(new[] { '=' });
                        if (arrayVar.Length == 2)
                        {
                            string key = arrayVar[0];
                            string src = arrayVar[1];
                            if ((src != null) && (src.Trim().Length != 0))
                            {
                                SupportClass.PutElement(collection, key, Escape.unescape(src));
                            }
                        }
                    }
                }
            }
            preapareArgs(rd, collection, env);
            prepareDataSource(rd.DataSetConfigs.getDataSourceNames(), env);
        }
示例#8
0
文件: lexer.cs 项目: rmorgan0076/CUP
        /*-----------------------------------------------------------*/
        /*--- Static Methods ----------------------------------------*/
        /*-----------------------------------------------------------*/

        /// <summary>Initialize the scanner.  This sets up the keywords and char_symbols
        /// tables and reads the first two characters of lookahead.
        /// </summary>
        public static void  init()
        {
            /* set up the keyword table */
            SupportClass.PutElement(keywords, "package", sym.PACKAGE);
            SupportClass.PutElement(keywords, "import", sym.IMPORT);
            SupportClass.PutElement(keywords, "code", sym.CODE);
            SupportClass.PutElement(keywords, "action", sym.ACTION);
            SupportClass.PutElement(keywords, "parser", sym.PARSER);
            SupportClass.PutElement(keywords, "terminal", sym.TERMINAL);
            SupportClass.PutElement(keywords, "non", sym.NON);
            SupportClass.PutElement(keywords, "nonterminal", sym.NONTERMINAL);             // [CSA]
            SupportClass.PutElement(keywords, "init", sym.INIT);
            SupportClass.PutElement(keywords, "scan", sym.SCAN);
            SupportClass.PutElement(keywords, "with", sym.WITH);
            SupportClass.PutElement(keywords, "start", sym.START);
            SupportClass.PutElement(keywords, "precedence", sym.PRECEDENCE);
            SupportClass.PutElement(keywords, "left", sym.LEFT);
            SupportClass.PutElement(keywords, "right", sym.RIGHT);
            SupportClass.PutElement(keywords, "nonassoc", sym.NONASSOC);

            /* set up the table of single character symbols */
            SupportClass.PutElement(char_symbols, ';', sym.SEMI);
            SupportClass.PutElement(char_symbols, ',', sym.COMMA);
            SupportClass.PutElement(char_symbols, '*', sym.STAR);
            SupportClass.PutElement(char_symbols, '.', sym.DOT);
            SupportClass.PutElement(char_symbols, '|', sym.BAR);
            SupportClass.PutElement(char_symbols, '[', sym.LBRACK);
            SupportClass.PutElement(char_symbols, ']', sym.RBRACK);

            /* read two characters of lookahead */
            next_char = _inStream.ReadByte();
            if (next_char == EOF_CHAR)
            {
                next_char2 = EOF_CHAR;
                next_char3 = EOF_CHAR;
                next_char4 = EOF_CHAR;
            }
            else
            {
                next_char2 = _inStream.ReadByte();
                if (next_char2 == EOF_CHAR)
                {
                    next_char3 = EOF_CHAR;
                    next_char4 = EOF_CHAR;
                }
                else
                {
                    next_char3 = _inStream.ReadByte();
                    if (next_char3 == EOF_CHAR)
                    {
                        next_char4 = EOF_CHAR;
                    }
                    else
                    {
                        next_char4 = _inStream.ReadByte();
                    }
                }
            }
        }
示例#9
0
        protected void SetUp()
        {
            provider = new TestProvider();
            al       = provider.Customers;
            h        = new System.Collections.Hashtable();

            SupportClass.PutElement(h, "Bar", "this is from a hashtable!");
            SupportClass.PutElement(h, "Foo", "this is from a hashtable too!");

            /*
             *  lets set up a vector of objects to test late introspection. See ASTMethod.java
             */

            vec = new System.Collections.ArrayList();

            vec.Add(new System.String("string1".ToCharArray()));
            vec.Add(new System.String("string2".ToCharArray()));

            /*
             *  set up 3 chained contexts, and add our data
             *  throught the 3 of them.
             */

            context2 = new VelocityContext();
            context1 = new VelocityContext(context2);
            context  = new VelocityContext(context1);

            context.Put("provider", provider);
            context1.Put("name", "jason");
            context2.Put("providers", provider.Customers2);
            context.Put("list", al);
            context1.Put("hashtable", h);
            context2.Put("hashmap", new Hashtable());
            context2.Put("search", provider.Search);
            context.Put("relatedSearches", provider.RelSearches);
            context1.Put("searchResults", provider.RelSearches);
            context2.Put("stringarray", provider.Array);
            context.Put("vector", vec);
            context.Put("mystring", new System.String("".ToCharArray()));
            context.Put("runtime", new FieldMethodizer("NVelocity.Runtime.RuntimeSingleton"));
            context.Put("fmprov", new FieldMethodizer(provider));
            context.Put("Floog", "floogie woogie");
            context.Put("boolobj", new BoolObj());

            /*
             *  we want to make sure we test all types of iterative objects
             *  in #foreach()
             */

            System.Object[] oarr   = new System.Object[] { "a", "b", "c", "d" };
            int[]           intarr = new int[] { 10, 20, 30, 40, 50 };

            context.Put("collection", vec);
            context2.Put("iterator", vec.GetEnumerator());
            context1.Put("map", h);
            context.Put("obarr", oarr);
            context.Put("enumerator", vec.GetEnumerator());
            context.Put("intarr", intarr);
        }
示例#10
0
 /// <summary> Sets a property of the constraints object.
 ///
 /// No property names have been defined at this time, but the
 /// mechanism is in place in order to support revisional as well as
 /// dynamic and proprietary extensions to operation modifiers.
 ///
 /// </summary>
 /// <param name="name">   Name of the property to set.
 ///
 /// </param>
 /// <param name="value">  Value to assign to the property.
 /// property is not supported.
 ///
 /// @throws NullPointerException if name or value are null
 ///
 /// </param>
 /// <seealso cref="LdapConnection.getProperty">
 /// </seealso>
 public virtual void setProperty(string name, object value_Renamed)
 {
     if (properties == null)
     {
         properties = new System.Collections.Hashtable();
     }
     SupportClass.PutElement(properties, name, value_Renamed);
 }
示例#11
0
        internal static void create(Interp interp, Interp slaveInterp, Interp masterInterp, TclObject name, TclObject targetName, int objIx, TclObject[] objv)
        {
            string inString = name.ToString();

            InterpAliasCmd alias = new InterpAliasCmd();

            alias.name = name;
            name.Preserve();

            alias.slaveInterp  = slaveInterp;
            alias.targetInterp = masterInterp;

            alias.prefix = TclList.NewInstance();
            alias.prefix.Preserve();
            TclList.Append(interp, alias.prefix, targetName);
            TclList.insert(interp, alias.prefix, 1, objv, objIx, objv.Length - 1);

            slaveInterp.CreateCommand(inString, alias);
            alias.slaveCmd = NamespaceCmd.findCommand(slaveInterp, inString, null, 0);

            try
            {
                interp.preventAliasLoop(slaveInterp, alias.slaveCmd);
            }
            catch (TclException e)
            {
                // Found an alias loop!  The last call to Tcl_CreateObjCommand made
                // the alias point to itself.  Delete the command and its alias
                // record.  Be careful to wipe out its client data first, so the
                // command doesn't try to delete itself.

                slaveInterp.DeleteCommandFromToken(alias.slaveCmd);
                throw;
            }

            // Make an entry in the alias table. If it already exists delete
            // the alias command. Then retry.

            if (slaveInterp._aliasTable.ContainsKey(inString))
            {
                InterpAliasCmd oldAlias = (InterpAliasCmd)slaveInterp._aliasTable[inString];
                slaveInterp.DeleteCommandFromToken(oldAlias.slaveCmd);
            }

            alias.aliasEntry = inString;
            SupportClass.PutElement(slaveInterp._aliasTable, inString, alias);

            // Create the new command. We must do it after deleting any old command,
            // because the alias may be pointing at a renamed alias, as in:
            //
            // interp alias {} foo {} bar		# Create an alias "foo"
            // rename foo zop				# Now rename the alias
            // interp alias {} foo {} zop		# Now recreate "foo"...

            SupportClass.PutElement(masterInterp._targetTable, alias.slaveCmd, slaveInterp);

            interp.SetResult(name);
        }
示例#12
0
 /// <summary> Adds the schema definition to the idList and nameList HashMaps.
 /// This method is used by the methods fetchSchema and add.
 ///
 /// Note that the nameTable has all keys cast to Upper-case.  This is so we
 /// can have a case-insensitive HashMap.  The getXXX (string key) methods
 /// will also cast to uppercase.
 ///
 /// </summary>
 /// <param name="schemaType">   Type of schema definition, use one of the final
 /// integers defined at the top of this class:
 /// ATTRIBUTE, OBJECT_CLASS, SYNTAX, NAME_FORM,
 /// DITCONTENT, DITSTRUCTURE, MATCHING, MATCHING_USE
 ///
 /// </param>
 /// <param name="element">      Schema element definition.
 /// </param>
 private void addElement(int schemaType, LdapSchemaElement element)
 {
     SupportClass.PutElement(idTable[schemaType], element.ID, element);
     string[] names = element.Names;
     for (int i = 0; i < names.Length; i++)
     {
         SupportClass.PutElement(nameTable[schemaType], names[i].ToUpper(), element);
     }
 }
示例#13
0
 internal static void  registerChannel(Interp interp, Channel chan)
 {
     if (interp != null)
     {
         Hashtable chanTable = getInterpChanTable(interp);
         SupportClass.PutElement(chanTable, chan.ChanName, chan);
         chan.refCount++;
     }
 }
示例#14
0
文件: LoadFunction.cs 项目: ikvm/test
 public static void addFunction(string funName, Type funClass)
 {
     funName = funName.ToLower();
     if (funNameHash.ContainsKey(funName))
     {
         throw new SystemException(new StringBuilder("系统中有两个叫").Append(funName).Append("的函数!").ToString().ToString());
     }
     SupportClass.PutElement(funNameHash, funName, funClass);
     SupportClass.PutElement(funTypeHash, funClass, funName);
 }
示例#15
0
        /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/

        /// <summary>Add a production to our set of productions.
        /// </summary>
        public virtual void  add_production(production prod)
        {
            /* catch improper productions */
            if (prod == null || prod.lhs() == null || prod.lhs().the_symbol() != this)
            {
                throw new internal_error("Attempt to add invalid production to non terminal production table");
            }

            /* add it to the table, keyed with itself */
            SupportClass.PutElement(_productions, prod, prod);
        }
示例#16
0
        /// <summary> Sets the values of a specified optional or non-standard qualifier of
        /// the element.
        ///
        /// The setQualifier method is used to set the values of vendor-
        /// specific qualifiers (which begin with "X-").
        ///
        /// </summary>
        /// <param name="name">          The name of the qualifier, case-sensitive.
        ///
        /// </param>
        /// <param name="values">        The values to set for the qualifier.
        /// </param>
        public virtual void setQualifier(string name, string[] values)
        {
            AttributeQualifier attrQualifier = new AttributeQualifier(name, values);

            SupportClass.PutElement(hashQualifier, name, attrQualifier);

            /*
             * This is the only method that modifies the schema element.
             * We need to reset the attribute value since it has changed.
             */
            Value = formatString();
        }
示例#17
0
        /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/

        /// <summary>Add a single symbol to the set.
        /// </summary>
        /// <param name="sym">the symbol we are adding.
        /// </param>
        /// <returns>true if this changes the set.
        ///
        /// </returns>
        public virtual bool add(symbol sym)
        {
            System.Object previous;

            not_null(sym);

            /* put the object in */
            previous = SupportClass.PutElement(_all, sym.name_Renamed_Method(), sym);

            /* if we had a previous, this is no change */
            return(previous == null);
        }
示例#18
0
        /// <summary> Adds the specified attribute to this set if it is not already present.
        /// If an attribute with the same name already exists in the set then the
        /// specified attribute will not be added.
        ///
        /// </summary>
        /// <param name="attr">  Object of type <code>LdapAttribute</code>
        ///
        /// </param>
        /// <returns> true if the attribute was added.
        ///
        /// @throws ClassCastException occurs the specified Object
        /// is not of type <code>LdapAttribute</code>.
        /// </returns>
        public override bool Add(object attr)
        {
            //We must enforce that attr is an LdapAttribute
            LdapAttribute attribute = (LdapAttribute)attr;
            string        name      = attribute.Name.ToUpper();

            if (map.ContainsKey(name))
            {
                return(false);
            }
            SupportClass.PutElement(map, name, attribute);
            return(true);
        }
示例#19
0
        /// <summary>
        /// Adds a factory to the list channel factories.
        /// </summary>
        /// <param name="factory"></param>
        public void AddChannelFactory(ChannelFactory factory)
        {
            String[] types = factory.SupportedChannelTypes;
            for (int i = 0; i < types.Length; i++)
            {
                if (channelfactories.ContainsKey(types[i]))
                {
                    throw new SSHException(types[i] + " channel is already registered!", SSHException.BAD_API_USAGE);
                }

                SupportClass.PutElement(channelfactories, types[i], factory);
            }
        }
示例#20
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="thread">The thread that owns this Notifier.</param>
 /// <returns></returns>
 public static Notifier GetNotifierForThread(Thread thread)
 {
     lock (typeof(Notifier))
     {
         Notifier notifier = (Notifier)_notifierTable[thread];
         if (notifier == null)
         {
             notifier = new Notifier(thread);
             SupportClass.PutElement(_notifierTable, thread, notifier);
         }
         return(notifier);
     }
 }
示例#21
0
文件: UnitSet.cs 项目: ikvm/test
 private void method_2(string string_0)
 {
     if (string_0 != null)
     {
         ArgToken token = new ArgToken(string_0, this.char_0);
         while (token.hasNext())
         {
             string str3  = token.next();
             int    index = str3.IndexOf('=');
             string str   = str3.Substring(0, (index < 0) ? str3.Length : index);
             string str2  = (index >= 0) ? str3.Substring(index + 1) : null;
             SupportClass.PutElement(this.hashtable_0, this.method_0(str), this.method_1(str2));
         }
     }
 }
示例#22
0
        public virtual IDictionary calcDataSets(Env env, CellExt1 ecs)
        {
            string[]  dataSetNames = this.DataSetNames;
            Hashtable collection   = new Hashtable(dataSetNames.Length);

            for (int i = 0; i < dataSetNames.Length; i++)
            {
                DataSet newValue = this.calcDataSet(env, dataSetNames[i], ecs);
                if (newValue != null)
                {
                    SupportClass.PutElement(collection, dataSetNames[i], newValue);
                }
            }
            return(collection);
        }
示例#23
0
        public static Notifier getNotifierForThread(System.Threading.Thread thread)
        // The thread that owns this Notifier.
        {
            lock (typeof(tcl.lang.Notifier))
            {
                Notifier notifier = (Notifier)notifierTable[thread];
                if (notifier == null)
                {
                    notifier = new Notifier(thread);
                    SupportClass.PutElement(notifierTable, thread, notifier);
                }

                return(notifier);
            }
        }
示例#24
0
        /// <summary> Parse an input and write the output to an output file.  If the
        /// output file parameter is null or an empty string the result is
        /// returned as a string object.  Otherwise an empty string is returned.
        /// You can add objects to the context with the objs Hashtable.
        /// *
        /// </summary>
        /// <param name="String">input template
        /// </param>
        /// <param name="String">inputEncoding template encoding
        /// </param>
        /// <param name="String">output file
        /// </param>
        /// <param name="String">outputEncoding encoding of output file
        /// </param>
        /// <param name="String">id for object to be placed in the control context
        /// </param>
        /// <param name="String">object to be placed in the context
        /// </param>
        /// <returns>String generated output from velocity
        ///
        /// </returns>
        public virtual System.String parse(System.String inputTemplate, System.String intputEncoding, System.String outputFile, System.String outputEncoding, System.String objectID, System.Object object_Renamed)
        {
            if (objectID != null && object_Renamed != null)
            {
                controlContext.Put(objectID, object_Renamed);
            }

            Template template = getTemplate(inputTemplate, inputEncoding != null?inputEncoding:this.inputEncoding)
            ;

            if (outputFile == null || outputFile.Equals(""))
            {
                System.IO.StringWriter sw = new System.IO.StringWriter();
                template.Merge(controlContext, sw);
                return(sw.ToString());
            }
            else
            {
                System.IO.StreamWriter writer = null;

                if (writers[outputFile] == null)
                {
                    /*
                     * We have never seen this file before so create
                     * a new file writer for it.
                     */
                    writer = getWriter(OutputPath + System.IO.Path.DirectorySeparatorChar.ToString() + outputFile, outputEncoding != null?outputEncoding:this.outputEncoding);

                    /*
                     * Place the file writer in our collection
                     * of file writers.
                     */
                    SupportClass.PutElement(writers, outputFile, writer);
                }
                else
                {
                    writer = (System.IO.StreamWriter)writers[outputFile];
                }

                VelocityContext vc = new VelocityContext(controlContext);
                template.Merge(vc, writer);

                // commented because it is closed in shutdown();
                //fw.close();

                return("");
            }
        }
示例#25
0
        /*-----------------------------------------------------------*/
        /*--- Constructor(s) ----------------------------------------*/
        /*-----------------------------------------------------------*/

        /// <summary>Full constructor.
        /// </summary>
        /// <param name="nm"> the name of the non terminal.
        /// </param>
        /// <param name="tp"> the type string for the non terminal.
        ///
        /// </param>
        public non_terminal(string nm, string tp) : base(nm, tp)
        {
            InitBlock();

            /* add to set of all non terminals and check for duplicates */
            System.Object conflict = SupportClass.PutElement(_all, nm, this);
            if (conflict != null)
            {
                (new internal_error("Duplicate non-terminal (" + nm + ") created")).crash();
            }

            /* assign a unique index */
            _index = next_index++;

            /* add to by_index set */
            SupportClass.PutElement(_all_by_index, _index, this);
        }
示例#26
0
        private Hashtable AddNamespace(string ns)
        {
            Hashtable hashtable = new Hashtable();
            object    newValue;
            Hashtable result;

            if ((newValue = SupportClass.PutElement(this.namespaceHash, ns, hashtable)) != null)
            {
                SupportClass.PutElement(this.namespaceHash, ns, newValue);
                result = null;
            }
            else
            {
                result = hashtable;
            }
            return(result);
        }
示例#27
0
        /*-----------------------------------------------------------*/
        /*--- Constructor(s) ----------------------------------------*/
        /*-----------------------------------------------------------*/

        /// <summary>Full constructor.
        /// </summary>
        /// <param name="nm">the name of the terminal.
        /// </param>
        /// <param name="tp">the type of the terminal.
        ///
        /// </param>
        public terminal(string nm, string tp, int precedence_side, int precedence_num) : base(nm, tp)
        {
            /* add to set of all terminals and check for duplicates */
            System.Object conflict = SupportClass.PutElement(_all, nm, this);
            if (conflict != null)
            {
                (new internal_error("Duplicate terminal (" + nm + ") created")).crash();
            }

            /* assign a unique index */
            _index = next_index++;

            /* set the precedence */
            _precedence_num  = precedence_num;
            _precedence_side = precedence_side;

            /* add to by_index set */
            SupportClass.PutElement(_all_by_index, _index, this);
        }
示例#28
0
文件: LoadFunction.cs 项目: ikvm/test
        public static void addFunction(string funName, string className, string dllPath)
        {
            if (!string.IsNullOrEmpty(funName))
            {
                var  name = funName.ToLower();
                Type type = dllPath != null?Assembly.LoadFrom(dllPath).GetType(className) : Type.GetType(className);

                if (null != type)
                {
                    if (!funNameHash.ContainsKey(name))
                    {
                        //throw new SystemException(
                        //    new StringBuilder("系统中有两个叫").Append(name).Append("的函数!").ToString().ToString());
                        SupportClass.PutElement(funNameHash, name, type);
                        SupportClass.PutElement(funTypeHash, type, name);
                    }
                }
            }
        }
示例#29
0
        /// <summary>
        /// Adds a handler to the list of global request handlers.
        /// </summary>
        /// <param name="handler"></param>
        public void AddRequestHandler(GlobalRequestHandler handler)
        {
#if DEBUG
            System.Diagnostics.Trace.WriteLine("Adding global request handler");
#endif
            System.String[] types = handler.SupportedRequests;
            for (int i = 0; i < types.Length; i++)
            {
                if (requesthandlers.ContainsKey(types[i]))
                {
                    throw new SSHException(types[i] + " request is already registered!",
                                           SSHException.BAD_API_USAGE);
                }

#if DEBUG
                System.Diagnostics.Trace.WriteLine("Registering request " + types[i]);
#endif
                SupportClass.PutElement(requesthandlers, types[i], handler);
            }
        }
示例#30
0
        public override Stream GetResourceStream(string templateName)
        {
            Stream result;

            lock (this)
            {
                int count = this.paths.Count;
                if (templateName == null || templateName.Length == 0)
                {
                    throw new ResourceNotFoundException("Need to specify a file name or file path!");
                }
                string text = StringUtils.NormalizePath(templateName);
                if (text == null || text.Length == 0)
                {
                    string exceptionMessage = "File resource error : argument " + text + " contains .. and may be trying to access content outside of template root.  Rejected.";
                    throw new ResourceNotFoundException(exceptionMessage);
                }
                if (text.StartsWith("/") || text.StartsWith("\\"))
                {
                    text = text.Substring(1);
                }
                for (int i = 0; i < count; i++)
                {
                    string text2 = (string)this.paths[i];
                    if (text2.IndexOf(Path.AltDirectorySeparatorChar) >= 0)
                    {
                        text2 = text2.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
                    }
                    Stream stream = this.FindTemplate(text2, text);
                    if (stream != null)
                    {
                        SupportClass.PutElement(this.templatePaths, templateName, text2);
                        result = stream;
                        return(result);
                    }
                }
                string exceptionMessage2 = "FileResourceLoader Error: cannot find resource " + text;
                throw new ResourceNotFoundException(exceptionMessage2);
            }
            return(result);
        }