示例#1
0
        public static Extensions Parse(Mobile from, ref string[] args)
        {
            Extensions parsed = new Extensions();

            int size = args.Length;

            Type baseType = null;

            for (int i = args.Length - 1; i >= 0; --i)
            {
                if (!ExtensionInfo.Table.TryGetValue(args[i], out ExtensionInfo extInfo))
                {
                    continue;
                }

                if (extInfo.IsFixedSize && i != size - extInfo.Size - 1)
                {
                    throw new Exception("Invalid extended argument count.");
                }

                BaseExtension ext = extInfo.Constructor();

                ext.Parse(from, args, i + 1, size - i - 1);

                if (ext is WhereExtension extension)
                {
                    baseType = extension.Conditional.Type;
                }

                parsed.Add(ext);

                size = i;
            }

            parsed.Sort((a, b) => a.Order - b.Order);

            AssemblyEmitter emitter = null;

            foreach (BaseExtension update in parsed)
            {
                update.Optimize(from, baseType, ref emitter);
            }

            if (size != args.Length)
            {
                string[] old = args;
                args = new string[size];

                for (int i = 0; i < args.Length; ++i)
                {
                    args[i] = old[i];
                }
            }

            return(parsed);
        }
示例#2
0
        public static Extensions Parse(Mobile from, ref string[] args)
        {
            Extensions parsed = new Extensions();

            int size = args.Length;

            Type baseType = null;

            for (int i = args.Length - 1; i >= 0; --i)
            {
                ExtensionInfo extInfo = null;

                if (!ExtensionInfo.Table.TryGetValue(args[i], out extInfo))
                {
                    continue;
                }

                if (extInfo.IsFixedSize && i != (size - extInfo.Size - 1))
                {
                    throw new Exception("Invalid extended argument count.");
                }

                BaseExtension ext = extInfo.Constructor();

                ext.Parse(from, args, i + 1, size - i - 1);

                if (ext is WhereExtension)
                {
                    baseType = (ext as WhereExtension).Conditional.Type;
                }

                parsed.Add(ext);

                size = i;
            }

            #region genova: support to mono
#if MONO
            parsed.Sort(SortFunc);
#else
            parsed.Sort(delegate(BaseExtension a, BaseExtension b)
            {
                return(a.Order - b.Order);
            });
#endif
            #endregion

            AssemblyEmitter emitter = null;

            foreach (BaseExtension update in parsed)
            {
                update.Optimize(from, baseType, ref emitter);
            }

            if (size != args.Length)
            {
                string[] old = args;
                args = new string[size];

                for (int i = 0; i < args.Length; ++i)
                {
                    args[i] = old[i];
                }
            }

            return(parsed);
        }