Inheritance: ILogicalThreadAffinative
Example #1
0
        /// <summary>
        /// Gets local configuration associated with a specified script context.
        /// </summary>
        /// <param name="context">Scritp context.</param>
        /// <returns>Local library configuration.</returns>
        public static MySqlLocalConfig GetLocal(ScriptContext/*!*/ context)
        {
            if (context == null)
                throw new ArgumentNullException("context");

            return (MySqlLocalConfig)context.Config.GetLibraryConfig(MySqlLibraryDescriptor.Singleton);
        }
        protected void Setup(ScriptContext c)
        {
            // Set a variable to the My Documents path.
            var section = (ClientSettingsSection)ConfigurationManager
                .GetSection("applicationSettings/wordpress.net.Properties.Settings");
            var settings = section.Settings;

            foreach (SettingElement setting in settings)
            {
                var value = setting.Value.ValueXml.InnerText;
                if (!string.IsNullOrWhiteSpace(value))
                {
                    c.DefineConstant(setting.Name, setting.Value.ValueXml.InnerText);
                }
                else
                {
                    switch (setting.Name)
                    {
                        case "ABSPATH":
                            var path = System.IO.Directory.GetParent(Server.MapPath("~")).Parent.FullName +
                                       "\\components\\WordPress\\";
                            c.DefineConstant("ABSPATH", path.Replace("\\", "/"));
                            break;
                    }
                }
            }

            /** Sets up WordPress vars and included files. */
            c.Include("..\\components\\WordPress\\wp-settings.php", true);
        }
		public object __construct(ScriptContext __context, object name, 		[System.Runtime.InteropServices.OptionalAttribute()]
object value)
		{
			
			string tmp1 = PhpVariable.AsString(name);
			if (tmp1 == null)

				{
					PhpException.InvalidImplicitCast(name, "string", "__construct");
					return null;
				}
			
			string tmp2 = null;
			if (value != Arg.Default)

				{
					tmp2 = PhpVariable.AsString(value);
					if (tmp2 == null)

						{
							PhpException.InvalidImplicitCast(value, "string", "__construct");
							return null;
						}
				}
			__construct(tmp1, tmp2);
			return null;
		}
Example #4
0
 public object fetch(ScriptContext context, object fetch_style/*=null*/, object cursor_orientation/*FETCH_ORI_NEXT*/, object cursor_offset/*0*/)
 {
     PDOFetchType ft;
     if (fetch_style == null || fetch_style == Arg.Default)
         fetch_style = this.m_pdo.getAttribute(context, (int)PDOAttributeType.PDO_ATTR_DEFAULT_FETCH_MODE);
     
     int fetch_style_int = PHP.Core.Convert.ObjectToInteger(fetch_style);
     if (!Enum.IsDefined(typeof(PDOFetchType), fetch_style_int))
     {
         PDOException.Throw(context, "Invalid fetch_style value", null, null, null);
         return null;
     }
     ft = (PDOFetchType)fetch_style_int;
     var dr = this.CurrentReader;
     switch (ft)
     {
         case PDOFetchType.PDO_FETCH_ASSOC:
             return Fetch_Assoc(m_pdo.Driver, dr, false) ?? (object)false;
         case PDOFetchType.PDO_FETCH_NUM:
             return Fetch_Num(m_pdo.Driver, dr) ?? (object)false;
         case PDOFetchType.PDO_FETCH_BOTH:
         case PDOFetchType.PDO_FETCH_USE_DEFAULT:
             return Fetch_Assoc(m_pdo.Driver, dr, true) ?? (object)false;
         default:
             throw new NotImplementedException();
     }
 }
Example #5
0
        public override object Quote(ScriptContext context, object strobj, PDOParamType param_type)
        {
            // From mysql extension
            // in addition, resulting string is quoted as '...'

            if (strobj == null)
                return string.Empty;

            // binary aware:
            if (strobj.GetType() == typeof(PhpBytes))
            {
                var strbytes = (PhpBytes)strobj;
                if (strbytes.Length == 0) return strobj;

                var bytes = strbytes.ReadonlyData;
                List<byte>/*!*/result = new List<byte>(bytes.Length + 2);
                result.Add((byte)'\'');
                for (int i = 0; i < bytes.Length; i++)
                {
                    switch (bytes[i])
                    {
                        case (byte)'\0': result.Add((byte)'\\'); goto default;
                        case (byte)'\\': result.Add((byte)'\\'); goto default;
                        case (byte)'\n': result.Add((byte)'\\'); result.Add((byte)'n'); break;
                        case (byte)'\r': result.Add((byte)'\\'); result.Add((byte)'r'); break;
                        case (byte)'\u001a': result.Add((byte)'\\'); result.Add((byte)'Z'); break;
                        case (byte)'\'': result.Add((byte)'\\'); goto default;
                        case (byte)'"': result.Add((byte)'\\'); goto default;
                        default: result.Add(bytes[i]); break;
                    }
                }
                result.Add((byte)'\'');

                return new PhpBytes(result.ToArray());
            }

            // else
            string str = Core.Convert.ObjectToString(strobj);

            StringBuilder sb = new StringBuilder();
            sb.Append('\'');
            for (int i = 0; i < str.Length; i++)
            {
                char c = str[i];
                switch (c)
                {
                    case '\0': sb.Append(@"\0"); break;
                    case '\\': sb.Append(@"\\"); break;
                    case '\n': sb.Append(@"\n"); break;
                    case '\r': sb.Append(@"\r"); break;
                    case '\u001a': sb.Append(@"\Z"); break;
                    case '\'': sb.Append(@"''"); break;
                    case '"': sb.Append("\"\""); break;
                    default: sb.Append(c); break;
                }
            }
            sb.Append('\'');

            return sb.ToString();
        }
Example #6
0
		/// <summary>
		/// Initializes the script context for a web request.
		/// </summary>
		/// <param name="appContext">Application context.</param>
		/// <param name="context">HTTP context of the request.</param>
		/// <returns>A instance of <see cref="ScriptContext"/> to be used by the request.</returns>
		/// <exception cref="System.Configuration.ConfigurationErrorsException">
		/// Web configuration is invalid. The context is not initialized then.
		/// </exception>
		internal static ScriptContext/*!*/ InitWebRequest(ApplicationContext/*!*/ appContext, HttpContext/*!*/ context)
		{
			Debug.Assert(appContext != null && context != null);

			// reloads configuration of the current thread from ASP.NET caches or web.config files;
			// cached configuration is reused;
			Configuration.Reload(appContext, false);

			// takes a writable copy of a global configuration (may throw ConfigurationErrorsException):
			LocalConfiguration config = (LocalConfiguration)Configuration.DefaultLocal.DeepCopy();

            // following initialization statements shouldn't throw an exception:    // can throw on Integrated Pipeline, events must be attached within HttpApplication.Init()

			ScriptContext result = new ScriptContext(appContext, config, context.Response.Output, context.Response.OutputStream);

			result.IsOutputBuffered = config.OutputControl.OutputBuffering;
			result.ThrowExceptionOnError = true;
			result.WorkingDirectory = Path.GetDirectoryName(context.Request.PhysicalPath);
            if (config.OutputControl.ContentType != null) context.Response.ContentType = config.OutputControl.ContentType;
            if (config.OutputControl.CharSet != null) context.Response.Charset = config.OutputControl.CharSet;

			result.AutoGlobals.Initialize(config, context);

			ScriptContext.CurrentContext = result;

			Externals.BeginRequest();

			return result;
		}
Example #7
0
        public override void Load(string code = "")
        {
            try
            {
                context = ScriptContext.CurrentContext;
                context.Include(rpath  + "\\" + Name + ".php", true);
                Class = (PhpObject) context.NewObject(Name);
                PHPGlobals = context.GlobalVariables;
                context.GlobalVariables.Add("Commands", chatCommands);
                context.GlobalVariables.Add("DataStore", DataStore.GetInstance());
                context.GlobalVariables.Add("Find", Find.GetInstance());
                context.GlobalVariables.Add("GlobalData", GlobalData);
                context.GlobalVariables.Add("Plugin", this);
                context.GlobalVariables.Add("Server", Pluton.Server.GetInstance());
                context.GlobalVariables.Add("ServerConsoleCommands", consoleCommands);
                context.GlobalVariables.Add("Util", Util.GetInstance());
                context.GlobalVariables.Add("Web", Web.GetInstance());
                context.GlobalVariables.Add("World", World.GetInstance());
                foreach (var x in PHPGlobals)
                {
                    Globals.Add(x.Key.ToString());
                }

                State = PluginState.Loaded;
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                State = PluginState.FailedToLoad;
            }

            PluginLoader.GetInstance().OnPluginLoaded(this);
        }
Example #8
0
		private PhpCallback/*!*/ GetOrCreateFilterCallback(ScriptContext/*!*/ context)
		{
			if (filterCallback == null)
				filterCallback = new PhpCallback(new RoutineDelegate(Filter), context);

			return filterCallback;
		}
 /// <summary>
 /// Creates a connection resource.
 /// </summary>
 /// <param name="connectionString">Connection string.</param>
 /// <param name="context">Script context associated with the connection.</param>
 public PhpMyDbConnection(string/*!*/ connectionString, ScriptContext/*!*/ context)
     : base(connectionString, new MySqlConnection(), "mysql connection")
 {
     if (context == null)
         throw new ArgumentNullException("context");
     _context = context;
     _sharedConnection = false;
 }
Example #10
0
		/// <param name="context">A script context to get declarators from.</param>
		/// <param name="caller">A current type context.</param>
		public TypesProvider(ScriptContext/*!*/ context, DTypeDesc/*!*/ caller)
		{
			Debug.Assert(context != null && caller != null);

			this.context = context;
			this.caller = caller;
			Debug.WriteLine("PROVIDER", "created");
		}
Example #11
0
 public override object GetLastInsertId(ScriptContext context, PDO pdo, string name)
 {
     var cmd = pdo.PDOConnection.LastCommand;
     if (cmd is MySqlCommand)
         return ((MySqlCommand)cmd).LastInsertedId;
     else
         return false;
 }
Example #12
0
        public object __construct(ScriptContext/*!*/context,
            object faultcode, object faultstring, [Optional]object faultactor,
            [Optional]object detail, [Optional]object faultname,
            [Optional]object headerfault)
        {
            base.__construct(context, faultstring, faultcode);

            return null;
        }
Example #13
0
		/// <summary>
		/// Creates a new connection resource.
		/// </summary>
		/// <param name="connectionString">Connection string.</param>
		/// <param name="context">Script context associated with the connection.</param>
		public PhpSqlDbConnection(string/*!*/ connectionString, ScriptContext/*!*/ context)
			: base(connectionString, new SqlConnection(), "mssql connection")
		{
			if (context == null)
				throw new ArgumentNullException("context");

			this.context = context;
			// TODO: Connection.InfoMessage += new SqlInfoMessageEventHandler(InfoMessage);
		}
Example #14
0
        /// <summary>
        /// Constructor of PHP closure.
        /// </summary>
        /// <param name="context">Current <see cref="ScriptContext"/></param>
        /// <param name="lambda">Delegate to lambda function itself.</param>
        /// <param name="parameter"><see cref="PhpArray"/> of closure <c>parameter</c> field. Can be <c>null</c> if there are no parameters.</param>
        /// <param name="static"><see cref="PhpArray"/> of closure <c>parameter</c> field. Can be <c>null</c> if there is no <c>use</c> of scope variables.</param>
        public Closure(ScriptContext/*!*/context, RoutineDelegate/*!*/lambda, PhpArray parameter, PhpArray @static)
            :this(context, true)
        {
            Debug.Assert(context != null);
            Debug.Assert(lambda != null);

            this.lambda = lambda;
            this.parameter = parameter;
            this.@static = @static;
        }
Example #15
0
		// variables may be null when the code is global

		protected LinqContext(DObject outerType, Dictionary<string, object> variables, ScriptContext/*!*/ context, DTypeDesc typeHandle)
		{
			if (context == null)
				throw new ArgumentNullException("context");
			
			this.variables = variables;
			this.outerType = outerType;
			this.context = context;
			this.typeHandle = typeHandle;
		}
Example #16
0
		/// <summary>
		/// Creates a new instance of <see cref="PhpStack"/>.
		/// </summary>
		/// <param name="context">The script context.</param>
		internal PhpStack(ScriptContext/*!*/ context)
		{
			Debug.Assert(context != null);

			this.Items = new object[25];
			this.Types = new DTypeDesc[10];
			this.Top = 0;
			this.TypesTop = 0;
			this.Context = context;
		}
		public object item(ScriptContext __context, object index)
		{
			if (!(index is int))

				{
					PhpException.InvalidImplicitCast(index, "int", "item");
					return null;
				}
			return item((int)index);
		}
		public object getNamedItem(ScriptContext __context, object name)
		{
			
			string tmp1 = PhpVariable.AsString(name);
			if (tmp1 == null)

				{
					PhpException.InvalidImplicitCast(name, "string", "getNamedItem");
					return null;
				}
			return getNamedItem(tmp1);
		}
Example #19
0
 public object __construct(ScriptContext context, object argFileName, object argMode, object error)
 {
     string filename = PHP.Core.Convert.ObjectToString(argFileName);
     int mode = PHP.Core.Convert.ObjectToInteger(argMode);
     if (mode == 0)
     {
         mode = SQLite.DEFAULT_FILE_MODE;
     }
     this.m_filename = filename;
     this.m_con = SQLite.Open(this.m_filename, mode, error as PhpReference);
     return null;
 }
Example #20
0
    static HatenaSharp()
    {
        _context = ScriptContext.CurrentContext;

        DeclareType(typeof(HatenaSyntax));
        DeclareType(typeof(HatenaSyntax_Renderer));
        DeclareType(typeof(HatenaSyntax_Tree));
        DeclareType(typeof(HatenaSyntax_Util));

        DeclareType(typeof(PEG));
        DeclareType(typeof(PEG_Util));
    }
Example #21
0
        /// <summary>
        /// Load required zlib functions into the <paramref name="context"/>.
        /// </summary>
        public static void Load(ScriptContext/*!*/context)
        {
            Debug.Assert(context != null);
            Debug.Assert(!context.ApplicationContext.GetLoadedExtensions().Contains("zlib"));

            // - zlib.output_compression (ignore, always "")
            if (PHP.Library.IniOptions.GetOption("zlib.output_compression") == null)
            {
                lock (typeof(Zlib)) try
                    {
                        PHP.Library.IniOptions.Register("zlib.output_compression", PHP.Library.IniFlags.Supported, (config, option, value, action) => string.Empty, "zlib");
                    }
                    catch { }
            }

            // - gzopen, gzclose, gzread, gzinflate
            DeclareFunction(context, "gzopen", NotSupportedFunction);
            DeclareFunction(context, "gzclose", NotSupportedFunction);
            DeclareFunction(context, "gzread", NotSupportedFunction);
            DeclareFunction(context, "gzinflate", (_, stack) =>
            {
                if (stack.ArgCount != 1) return null;
                if (!(stack.PeekValue(1) is PhpBytes)) return false;

                var bytes = ((PhpBytes)stack.PeekValue(1)).ReadonlyData;

                try
                {
                    List<byte>/*!*/inflate = new List<byte>(bytes.Length);

                    using (var stream = new DeflateStream(new System.IO.MemoryStream(bytes), CompressionMode.Decompress))
                    {
                        byte[] buffer = new byte[1024];
                        int n;
                        while ((n = stream.Read(buffer, 0, buffer.Length)) > 0)
                            inflate.AddRange(buffer.Take(n));
                    }

                    return new PhpBytes(inflate.ToArray());
                }
                catch (Exception ex)
                {
                    PhpException.Throw(PhpError.Warning, "Error while decompressing gz stream: " + ex.Message);
                    return false;
                }
            });

            // - NS: gzdeflate, gzputs, gzwrite
            DeclareFunction(context, "gzdeflate", NotSupportedFunction);
            DeclareFunction(context, "gzputs", NotSupportedFunction);
            DeclareFunction(context, "gzwrite", NotSupportedFunction);
        }
Example #22
0
		/// <summary>
		/// Invoked when the instance is created (not called when unserialized).
		/// </summary>
		protected override void InstanceCreated(ScriptContext context)
		{
			base.InstanceCreated(context);

			PhpStackTrace trace = new PhpStackTrace(context, 1);
			PhpStackFrame frame = trace.GetFrame(0);
			Debug.Assert(frame != null);

			this.file.Value = frame.File;
			this.line.Value = frame.Line;
			this.column.Value = frame.Column;
			this.trace.Value = trace.GetUserTrace();
		}
Example #23
0
		public object __construct(ScriptContext __context, object document)
		{
			
			DOMDocument tmp1 = document as DOMDocument;
			if (tmp1 == null)

				{
					PhpException.InvalidImplicitCast(document, "DOMDocument", "__construct");
					return null;
				}
			__construct(tmp1);
			return null;
		}
Example #24
0
        public static void CleanDashboard(ScriptContext context)
        {
            dynamic wp = context.Globals;

            wp.add_action( "wp_dashboard_setup", new Action(() => {

                wp.remove_meta_box( "dashboard_primary", "dashboard", "side" );
                wp.remove_meta_box( "dashboard_secondary", "dashboard", "side" );
                wp.remove_meta_box( "dashboard_plugins", "dashboard", "normal" );
                wp.remove_meta_box( "dashboard_incoming_links", "dashboard", "normal" );

            }));
        }
Example #25
0
        internal static void Throw(ScriptContext/*!*/context,
            string faultcode, string faultstring, bool throwSoapFault=true)
        {
            if (throwSoapFault)
            {
                var e = new SoapFault(context, true);
                e.__construct(context, faultcode, faultstring);

                throw new PhpUserException(e);
            }
            else
            {
                PhpException.Throw(PhpError.Error, faultstring);
            }
        }
Example #26
0
        /// <summary>
        /// Load required Mbstring stuff into the <paramref name="context"/>.
        /// </summary>
        public static void Load(ScriptContext/*!*/context)
        {
            Debug.Assert(context != null);
            Debug.Assert(!context.ApplicationContext.GetLoadedExtensions().Contains("mbstring"));

            // mbstring.func_overload just return 0, so Phalanger won't throw warning(unlike PHP)
            if (PHP.Library.IniOptions.GetOption("mbstring.func_overload") == null)
            {
                lock (typeof(Mbstring)) try
                    {
                        PHP.Library.IniOptions.Register("mbstring.func_overload", PHP.Library.IniFlags.Supported, (config, option, value, action) => 0, "mbstring");
                    }
                    catch { }
            }
        }
Example #27
0
        public override PDOConnection OpenConnection(ScriptContext context, string dsn_data, string username, string password, object argdriver_options)
        {
            //Determine file path
            string filename = dsn_data.Replace('/', Path.DirectorySeparatorChar);
            string filePath = Path.GetFullPath(Path.Combine(context.WorkingDirectory, filename));

            SQLiteConnectionStringBuilder csb = new SQLiteConnectionStringBuilder();
            csb.DataSource = filePath;
            csb.Version = 3;

            var con = new PDOConnection(csb.ConnectionString, new SQLiteConnection(), "PDO sqllite connection");
            con.Connect();

            return con;
        }
Example #28
0
		public static bool CreateClrThread(ScriptContext/*!*/context, PhpCallback/*!*/ callback, params object[] args)
		{
			if (callback == null)
				PhpException.ArgumentNull("callback");

			if (!callback.Bind())
				return false;

			object[] copies = (args != null) ? new object[args.Length] : ArrayUtils.EmptyObjects;

			for (int i = 0; i < copies.Length; i++)
				copies[i] = PhpVariable.DeepCopy(args[i]);

            return ThreadPool.QueueUserWorkItem(new Worker(context, copies).Run, callback);
		}
Example #29
0
        public object __construct(ScriptContext/*!*/context, object filename)
        {
            // check arguments
            string filenamestr = PhpVariable.AsString(filename);
            if (filenamestr == null)
            {
                PhpException.InvalidArgumentType("filename", PhpVariable.TypeNameString);
            }
            else
            {
                // TODO                
            }

            return null;
        }
Example #30
0
 public object addAll(ScriptContext/*!*/context, object storage)
 {
     var data = asObjectStorage(storage);
     if (data != null)
     {
         foreach (var x in data.storage)
         {
             this.attach(context, x.Key, x.Value);
         }
     }
     else
     {
         // ...
     }
     return null;
 }
Example #31
0
 /// <summary>
 /// Walks the object graph rooted in this node.
 /// </summary>
 /// <param name="callback">The callback method.</param>
 /// <param name="context">Current <see cref="ScriptContext"/>.</param>
 public void Walk(PhpWalkCallback callback, ScriptContext context)
 {
     // PhpResources have no child objects, however as they constitute an interesting PHP type,
     // IPhpObjectGraphNode is implemented
 }
Example #32
0
        /// <summary>
        /// Sets a property of a <see cref="DObject"/> instance according to deserialized name and value.
        /// </summary>
        /// <param name="instance">The instance being deserialized.</param>
        /// <param name="name">The property name formatted for serialization (see <see cref="FormatPropertyName"/>).</param>
        /// <param name="value">The property value.</param>
        /// <param name="context">Current <see cref="ScriptContext"/>.</param>
        public static void SetProperty(DObject /*!*/ instance, string /*!*/ name, object value, ScriptContext /*!*/ context)
        {
            // the property name might encode its visibility and "classification" -> use these
            // information for suitable property desc lookups
            PhpMemberAttributes visibility;
            string type_name;

            string property_name = ParsePropertyName(name, out type_name, out visibility);

            DTypeDesc declarer;

            if (type_name == null)
            {
                declarer = instance.TypeDesc;
            }
            else
            {
                declarer = context.ResolveType(type_name);
                if (declarer == null)
                {
                    declarer = instance.TypeDesc;
                }
            }

            // try to find a suitable field handle
            DPropertyDesc property;

            if (instance.TypeDesc.GetProperty(new VariableName(property_name), declarer, out property) ==
                PHP.Core.Reflection.GetMemberResult.OK)
            {
                if ((property.IsPrivate &&
                     declarer != property.DeclaringType))
                {
                    // if certain conditions are met, don't use the handle even if it was found
                    // (this is to precisely mimic the PHP behavior)
                    property = null;
                }
            }
            else
            {
                property = null;
            }

            if (property != null)
            {
                property.Set(instance, value);
            }
            else
            {
                // suitable CT field not found -> add it to RT fields
                // (note: care must be taken so that the serialize(unserialize($x)) round
                // trip returns $x even if user classes specified in $x are not declared)
                if (instance.RuntimeFields == null)
                {
                    instance.RuntimeFields = new PhpArray();
                }
                instance.RuntimeFields[name] = value;
            }
        }
Example #33
0
        /// <summary>
        /// Returns names and values of properties whose names have been returned by <c>__sleep</c>.
        /// </summary>
        /// <param name="instance">The instance being serialized.</param>
        /// <param name="sleepResult">The array returned by <c>__sleep</c>.</param>
        /// <param name="context">Current <see cref="ScriptContext"/>.</param>
        /// <returns>Name-value pairs. Names are properly formatted for serialization.</returns>
        /// <exception cref="PhpException">Property of the name returned from <c>__sleep</c> does not exist.</exception>
        /// <remarks>
        /// This method returns exactly <paramref name="sleepResult"/>'s <see cref="PhpHashtable.Count"/> items.
        /// </remarks>
        public static IEnumerable <KeyValuePair <string, object> > EnumerateSerializableProperties(
            DObject /*!*/ instance,
            PhpArray /*!*/ sleepResult,
            ScriptContext /*!*/ context)
        {
            foreach (object item in sleepResult.Values)
            {
                PhpMemberAttributes visibility;
                string name = PHP.Core.Convert.ObjectToString(item);
                string declaring_type_name;
                string property_name = ParsePropertyName(name, out declaring_type_name, out visibility);

                DTypeDesc declarer;
                if (declaring_type_name == null)
                {
                    declarer = instance.TypeDesc;
                }
                else
                {
                    declarer = context.ResolveType(declaring_type_name);
                    if (declarer == null)
                    {
                        // property name refers to an unknown class -> value will be null
                        yield return(new KeyValuePair <string, object>(name, null));

                        continue;
                    }
                }

                // obtain the property desc and decorate the prop name according to its visibility and declaring class
                DPropertyDesc property;
                if (instance.TypeDesc.GetProperty(new VariableName(property_name), declarer, out property) ==
                    GetMemberResult.OK && !property.IsStatic)
                {
                    if ((Enums.VisibilityEquals(visibility, property.MemberAttributes) &&
                         visibility != PhpMemberAttributes.Public)
                        ||
                        (visibility == PhpMemberAttributes.Private &&
                         declarer != property.DeclaringType))
                    {
                        // if certain conditions are met, serialize the property as null
                        // (this is to precisely mimic the PHP behavior)
                        yield return(new KeyValuePair <string, object>(name, null));

                        continue;
                    }
                    name = FormatPropertyName(property, property_name);
                }
                else
                {
                    property = null;
                }

                // obtain the property value
                object val = null;

                if (property != null)
                {
                    val = property.Get(instance);
                }
                else if (instance.RuntimeFields == null || !instance.RuntimeFields.TryGetValue(name, out val))
                {
                    // this is new in PHP 5.1
                    PhpException.Throw(PhpError.Notice, CoreResources.GetString("sleep_returned_bad_field", name));
                }

                yield return(new KeyValuePair <string, object>(name, val));
            }
        }