/// <summary> /// Formats a property name for serialization according to its visibility and declaing type. /// </summary> /// <param name="property">The property desc.</param> /// <param name="propertyName">The property name.</param> /// <returns>The property name formatted according to the <paramref name="property"/> as used by PHP serialization. /// </returns> public static string /*!*/ FormatPropertyName(DPropertyDesc /*!*/ property, string /*!*/ propertyName) { switch (property.MemberAttributes & PhpMemberAttributes.VisibilityMask) { case PhpMemberAttributes.Public: return(propertyName); case PhpMemberAttributes.Protected: return("\0*\0" + propertyName); case PhpMemberAttributes.Private: return("\0" + property.DeclaringType.MakeFullName() + "\0" + propertyName); default: Debug.Fail(); return(null); } }
public virtual object __construct(ScriptContext context, object @class, object propertyname) { string propertynameStr = PhpVariable.AsString(propertyname); if (@class == null || string.IsNullOrEmpty(propertynameStr)) { return(false); } this.dtype = null; this.property = null; DObject dobj; string str; if ((dobj = (@class as DObject)) != null) { this.dtype = dobj.TypeDesc; } else if ((str = PhpVariable.AsString(@class)) != null) { this.dtype = context.ResolveType(str, null, null, null, ResolveTypeFlags.UseAutoload); } if (this.dtype == null) { return(false); } if (this.dtype.GetProperty(new VariableName(propertynameStr), dtype, out this.property) == GetMemberResult.NotFound) { object runtimeValue; if (dobj != null && dobj.RuntimeFields != null && dobj.RuntimeFields.TryGetValue(propertynameStr, out runtimeValue)) { // create desc of runtime field: this.property = new RuntimePhpProperty(dtype, (instance) => ((DObject)instance).GetRuntimeField(this.name, null), (instance, value) => ((DObject)instance).SetRuntimeField(this.name, value, null, null, null)); this.property.Member = new KnownRuntimeProperty(this.property, propertynameStr); } else { return(false); } } return(null); }
public KnownRuntimeProperty(DPropertyDesc desc, string name) : base(desc, new VariableName(name)) { }