Beispiel #1
0
        public object setParameter(string ns, object name, [Optional] string value)
        {
            PhpArray array = name as PhpArray;

            if (array != null)
            {
                // set all name => value pairs contained in the array
                foreach (KeyValuePair <IntStringKey, object> pair in array)
                {
                    if (!pair.Key.IsString)
                    {
                        PhpException.Throw(PhpError.Warning, Resources.InvalidParameterKey);
                        return(false);
                    }

                    if (xsltArgumentList.GetParam(pair.Key.String, ns) != null)
                    {
                        xsltArgumentList.RemoveParam(pair.Key.String, ns);
                    }
                    xsltArgumentList.AddParam(pair.Key.String, ns, XsltConvertor.PhpToDotNet(pair.Value));
                }
            }
            else
            {
                string name_str = PHP.Core.Convert.ObjectToString(name);

                if (xsltArgumentList.GetParam(name_str, ns) != null)
                {
                    xsltArgumentList.RemoveParam(name_str, ns);
                }
                xsltArgumentList.AddParam(name_str, ns, XsltConvertor.PhpToDotNet(value));
            }

            return(true);
        }
Beispiel #2
0
        private object InvokeFunctionCore(string name, params object[] args)
        {
            // check whether this function is allowed to be called
            PhpCallback callback;

            if (allFunctionsRegistered)
            {
                registeredFunctions.TryGetValue(name, out callback);
            }
            else
            {
                if (registeredFunctions.TryGetValue(name, out callback))
                {
                    PhpException.Throw(PhpError.Warning, String.Format(Resources.HandlerNotAllowed, name));
                    return(null);
                }
            }

            // if the callback does not already exists, create it
            if (callback == null)
            {
                // parse name
                int index = name.IndexOf("::");
                switch (index)
                {
                case -1: callback = new PhpCallback(name); break;

                case 0: callback = new PhpCallback(name.Substring(2)); break;

                default: callback = new PhpCallback(name.Substring(0, index), name.Substring(index + 2)); break;
                }

                if (!callback.Bind())
                {
                    return(null);
                }

                registeredFunctions[name] = callback;
            }

            // convert arguments
            for (int i = 0; i < args.Length; i++)
            {
                args[i] = XsltConvertor.DotNetToPhp(args[i]);
            }

            // invoke!
            return(callback.Invoke(args));
        }
Beispiel #3
0
 private string InvokeFunctionString(string name, params object[] args)
 {
     return(XsltConvertor.PhpToString(InvokeFunctionCore(name, args)));
 }
Beispiel #4
0
 private object InvokeFunction(string name, params object[] args)
 {
     return(XsltConvertor.PhpToDotNet(InvokeFunctionCore(name, args)));
 }
Beispiel #5
0
 public object getParameter(string ns, string name)
 {
     return(XsltConvertor.DotNetToPhp(xsltArgumentList.GetParam(name, ns)));
 }