本文整理汇总了C#中PhpReference类的典型用法代码示例。如果您正苦于以下问题:C# PhpReference类的具体用法?C# PhpReference怎么用?C# PhpReference使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PhpReference类属于命名空间,在下文中一共展示了PhpReference类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Open
private static PhpResource Open(string filename, int mode, PhpReference error, bool persistent)
{
if (persistent) PhpException.FunctionNotSupported(PhpError.Notice);
SQLiteConnectionStringBuilder csb = new SQLiteConnectionStringBuilder();
csb.DataSource = filename;
csb.Version = 3;
try
{
PhpSQLiteDbConnection connection = new PhpSQLiteDbConnection(csb.ConnectionString);
if (error != null)
{
error.Value = null;
}
return connection;
}
catch (Exception ex)
{
if (error != null)
{
error.Value = ex.Message;
}
return null;
}
}
开发者ID:dw4dev,项目名称:Phalanger,代码行数:26,代码来源:SQLite.cs
示例2: Binding
public Binding(PhpReference/*!*/ variable, IDataParameter/*!*/ parameter, ParameterType type)
{
Debug.Assert(variable != null && parameter != null && type != ParameterType.Invalid);
this.Variable = variable;
this.Parameter = parameter;
this.Type = type;
}
开发者ID:dw4dev,项目名称:Phalanger,代码行数:8,代码来源:Statement.cs
示例3: notsetOperation
static PhpReference notsetOperation(DObject self, string name, DTypeDesc caller, PhpReference refrnc)
{
bool getter_exists;
// the CT property has been unset -> try to invoke __get
PhpReference get_ref = self.InvokeGetterRef(name, caller, out getter_exists);
if (getter_exists) return get_ref ?? new PhpReference();
Debug.Assert(refrnc != null);
refrnc.IsAliased = true;
refrnc.IsSet = true;
return refrnc;
}
开发者ID:dw4dev,项目名称:Phalanger,代码行数:14,代码来源:PhpGetMemberBinder.cs
示例4: query
public object query(ScriptContext context, object query, object resultType, PhpReference error)
{
SQLite.QueryResultKeys rt = SQLite.QueryResultKeys.Both;
int vRt = PHP.Core.Convert.ObjectToInteger(resultType);
if (Enum.IsDefined(typeof(SQLite.QueryResultKeys), vRt))
{
rt = (SQLite.QueryResultKeys)vRt;
}
PhpSQLiteDbResult result = (PhpSQLiteDbResult)SQLite.Query(this.m_con, query, rt, error);
if (result != null)
{
return new SQLiteResult(result);
}
else
{
return null;
}
}
开发者ID:dw4dev,项目名称:Phalanger,代码行数:19,代码来源:SQLiteDatabase.cs
示例5: Map
public static PhpArray Map(PHP.Core.Reflection.DTypeDesc caller, PhpCallback map, [PhpRw] params PhpArray[] arrays)
{
if (!PhpArgument.CheckCallback(map, caller, "map", 0, true)) return null;
if (arrays == null || arrays.Length == 0)
{
PhpException.InvalidArgument("arrays", LibResources.GetString("arg:null_or_emtpy"));
return null;
}
// if callback has not been specified uses the default one:
if (map == null)
map = new PhpCallback(new RoutineDelegate(MapIdentity), ScriptContext.CurrentContext);
int count = arrays.Length;
bool preserve_keys = count == 1;
PhpReference[] args = new PhpReference[count];
IEnumerator<KeyValuePair<IntStringKey, object>>[] iterators = new IEnumerator<KeyValuePair<IntStringKey, object>>[count];
PhpArray result;
// initializes iterators and args array, computes length of the longest array:
int max_count = 0;
for (int i = 0; i < arrays.Length; i++)
{
var array = arrays[i];
if (array == null)
{
PhpException.Throw(PhpError.Warning, LibResources.GetString("argument_not_array", i + 2));// +2 (first arg is callback)
return null;
}
args[i] = new PhpReference();
iterators[i] = array.GetEnumerator();
if (array.Count > max_count) max_count = array.Count;
}
// keys are preserved in a case of a single array and re-indexed otherwise:
if (preserve_keys)
result = new PhpArray(arrays[0].IntegerCount, arrays[0].StringCount);
else
result = new PhpArray(max_count, 0);
for (; ; )
{
// fills args[] with items from arrays:
for (int i = 0; i < arrays.Length; i++)
{
if (iterators[i] != null)
{
// an element is available:
if (iterators[i].MoveNext())
{
// note: deep copy is not necessary since a function copies its arguments if needed:
object value = iterators[i].Current.Value;
PhpReference valueref = (value != null) ? value as PhpReference : null;
args[i].Value = (valueref != null) ? valueref.value : value;
//args[i].Value = iterators[i].Current.Value; // TODO: throws if the current Value is PhpReference
}
else
{
// the i-th iterator has stopped:
count--;
iterators[i] = null;
args[i].Value = null;
}
}
}
if (count == 0) break;
// invokes callback:
object return_value = map.Invoke(args);
// return value is not deeply copied:
if (preserve_keys)
result.Add(iterators[0].Current.Key, return_value);
else
result.Add(return_value);
// loads new values (callback may modify some by ref arguments):
for (int i = 0; i < arrays.Length; i++)
{
if (iterators[i] != null)
{
object item = iterators[i].Current.Value;
PhpReference ref_item = item as PhpReference;
if (ref_item != null)
{
ref_item.Value = args[i].Value;
}
else
{
arrays[i][iterators[i].Current.Key] = args[i].Value;
}
}
}
}
return result;
}
开发者ID:dw4dev,项目名称:Phalanger,代码行数:100,代码来源:Arrays.cs
示例6: SetObjectFieldDirectRef
public static void SetObjectFieldDirectRef(PhpReference value, DObject/*!*/ obj, ref PhpReference/*!*/ field,
string/*!*/ name, DTypeDesc caller)
{
Debug.Assert(obj != null && field != null && name != null);
if (field.IsSet)
{
field = value;
}
else
{
SetObjectProperty(obj, name, value, caller);
}
}
开发者ID:kaviarasankk,项目名称:Phalanger,代码行数:14,代码来源:Operators.cs
示例7: GetObjectFieldDirect
public static object GetObjectFieldDirect(DObject/*!*/ obj, PhpReference/*!*/ field,
string/*!*/ name, DTypeDesc caller, bool quiet)
{
Debug.Assert(obj != null && field != null && name != null);
if (field.IsSet)
{
return field.Value;
}
else
{
return GetObjectProperty(obj, name, caller, quiet);
}
}
开发者ID:kaviarasankk,项目名称:Phalanger,代码行数:14,代码来源:Operators.cs
示例8: EnsurePropertyIsObjectInternal
/// <summary>
/// Ensures that a property value is of <see cref="DObject"/> type.
/// </summary>
/// <param name="obj">The object whose property is to be checked.</param>
/// <param name="name">The property name.</param>
/// <param name="caller"><see cref="Type"/> of the object that request the operation.</param>
/// <param name="propValue">The property value (might get updated).</param>
/// <param name="context">The current <see cref="ScriptContext"/>.</param>
/// <returns>The new property value (dereferenced) or <B>null</B> if evaluation of this compound
/// statement should not proceed.</returns>
internal static DObject EnsurePropertyIsObjectInternal(DObject obj, string name, DTypeDesc caller, ref object propValue,
ScriptContext context)
{
DObject result;
PhpReference reference = propValue as PhpReference;
object value;
if (reference != null && !reference.IsSet)
{
// this CT property has been unset
if (obj.TypeDesc.GetMethod(Name.SpecialMethodNames.Set) != null &&
obj.TypeDesc.RealType.Namespace != null &&
obj.TypeDesc.RealType.Namespace.StartsWith(Namespaces.Library))
{
// create a chain of arguments to be passed to the setter
context.BeginSetterChain(obj);
context.ExtendSetterChain(new RuntimeChainProperty(name));
return ScriptContext.SetterChainSingletonObject;
}
// try to invoke __get
bool getter_exists;
reference = obj.InvokeGetterRef(name, caller, out getter_exists);
if (!getter_exists)
{
result = stdClass.CreateDefaultObject(context);
propValue = new PhpReference(result);
return result;
}
else if (reference == null) return null; // error
value = reference.Value;
}
else value = PhpVariable.Dereference(propValue);
// if property value is a DObject, nothing has to be done
result = value as DObject;
if (result != null) return result;
// if the property is "empty"?
if (IsEmptyForEnsure(value))
{
// create a new stdClass and update the reference
result = stdClass.CreateDefaultObject(context);
if (reference != null)
{
reference.Value = result;
reference.IsSet = true;
}
else propValue = result;
return result;
}
// error - the property is a scalar or a PhpArray or a non-empty string
PhpException.VariableMisusedAsObject(value, false);
return null;
}
开发者ID:kaviarasankk,项目名称:Phalanger,代码行数:68,代码来源:Operators.cs
示例9: SetItemRefEpilogue
private static void SetItemRefEpilogue(PhpReference value, object key, ref object var)
{
// object behaving as array:
DObject dobj = var as DObject;
if (dobj != null && dobj.RealObject is Library.SPL.ArrayAccess)
{
PhpStack stack = ScriptContext.CurrentContext.Stack;
stack.AddFrame(key, value);
dobj.InvokeMethod(Library.SPL.PhpArrayObject.offsetSet, null, stack.Context);
return;
}
// errors - non-empty string, DObject, scalar:
PhpException.VariableMisusedAsArray(var, true);
}
开发者ID:kaviarasankk,项目名称:Phalanger,代码行数:15,代码来源:Operators.cs
示例10: GetItemRef
public static PhpReference/*!*/ GetItemRef(string key, ref object var)
{
Debug.Assert(!(var is PhpReference));
Debug.Assert(!(var is PhpArrayString), "ensures and end-of-chain operators only");
// PhpArray:
if (var != null && var.GetType() == typeof(PhpArray)) // fast check for PhpArray, not derived types
return ((PhpArray)var).GetArrayItemRef(key);
// creates a new reference and adds it to an a new array:
if (IsEmptyForEnsure(var))
{
PhpArray array;
var = array = new PhpArray(0, 1);
PhpReference result = new PhpReference();
array.SetArrayItemRef(key, result);
return result;
}
return GetItemRefEpilogue(key, ref var);
}
开发者ID:kaviarasankk,项目名称:Phalanger,代码行数:21,代码来源:Operators.cs
示例11: ParseReference
/// <summary>
/// Parses the <B>R</B> token.
/// </summary>
private void ParseReference()
{
Consume(Tokens.Colon);
int seq_number = (unchecked((int)ReadInteger())) - 1;
Consume(Tokens.Semicolon);
if (seq_number < 0 || seq_number >= sequenceMap.Count) ThrowInvalidReference();
int index = sequenceMap[seq_number];
// make the referenced atom a PhpReference
PhpReference reference = atoms[index] as PhpReference;
if (reference == null)
{
reference = new PhpReference(atoms[index]);
atoms[index] = reference;
}
atoms.Add(new BackReference(index, true));
}
开发者ID:hansdude,项目名称:Phalanger,代码行数:22,代码来源:PhpFormatter.CLR.cs
示例12: ParseStr
public static bool ParseStr(string encoded_string, PhpReference array)
{
try
{
PhpArray result = new PhpArray();
foreach (var x in ParseUrlEncodedGetParameters(encoded_string))
result.Add(x.Key, x.Value);
array.Value = result;
return true;
}
catch
{
return false;
}
}
开发者ID:proff,项目名称:Phalanger,代码行数:18,代码来源:MbString.cs
示例13: ReadLineFormat
public static int ReadLineFormat(PhpResource handle, string format, PhpReference arg, params PhpReference[] arguments)
{
PhpStream stream = PhpStream.GetValid(handle);
if (stream == null) return -1;
string line = stream.ReadLine(-1, null);
return PhpStrings.ScanFormat(line, format, arg, arguments);
}
开发者ID:kripper,项目名称:Phalanger,代码行数:7,代码来源:FileSystem.cs
示例14: EnsurePropertyIsArrayInternal
/// <summary>
/// Ensures that a property value is of <see cref="PhpArray"/> type.
/// </summary>
/// <param name="obj">The object whose property is to be checked.</param>
/// <param name="name">The property name.</param>
/// <param name="caller"><see cref="Type"/> of the object that request the operation.</param>
/// <param name="propValue">The property value (might get updated).</param>
/// <returns>The new property value (dereferenced) or <B>null</B> if evaluation of this compound
/// statement should not proceed.</returns>
internal static PhpArray EnsurePropertyIsArrayInternal(DObject obj, string name, DTypeDesc caller, ref object propValue)
{
PhpArray result;
PhpReference reference = propValue as PhpReference;
object value;
if (reference != null && !reference.IsSet)
{
// this CT property has been unset
if (obj.TypeDesc.GetMethod(DObject.SpecialMethodNames.Set) != null &&
obj.TypeDesc.RealType.Namespace != null &&
obj.TypeDesc.RealType.Namespace.StartsWith(Namespaces.Library))
{
ScriptContext context = ScriptContext.CurrentContext;
// create a chain of arguments to be passed to the setter
context.BeginSetterChain(obj);
context.ExtendSetterChain(new RuntimeChainProperty(name));
return ScriptContext.SetterChainSingletonArray;
}
// try to invoke __get
bool getter_exists;
reference = obj.InvokeGetterRef(name, caller, out getter_exists);
if (!getter_exists)
{
result = new PhpArray();
propValue = new PhpReference(result);
return result;
}
else if (reference == null) return null; // error
value = reference.Value;
}
else value = PhpVariable.Dereference(propValue);
// if the property is PhpArray, nothing has to be done
result = value as PhpArray;
if (result != null) return result;
// checks an object behaving like an array:
DObject dobj = value as DObject;
if (dobj != null && dobj.RealObject is Library.SPL.ArrayAccess)
return new Library.SPL.PhpArrayObject(dobj);
// if the property is "empty"
if (IsEmptyForEnsure(value))
{
// create a new PhpArray and update the reference
result = new PhpArray();
if (reference != null)
{
reference.Value = result;
reference.IsSet = true;
}
else propValue = result;
return result;
}
// non-empty immutable string:
string str_value = value as string;
if (str_value != null)
{
PhpString str = new PhpString(str_value);
if (reference != null) reference.Value = str;
else propValue = str;
return new PhpArrayString(str);
}
// non-empty mutable string:
if (value is PhpString || value is PhpBytes)
return new PhpArrayString(value);
// error - the property is a scalar or a PhpObject:
PhpException.VariableMisusedAsArray(value, false);
return null;
}
开发者ID:jdluzen,项目名称:Phalanger,代码行数:89,代码来源:Operators.cs
示例15: getimagesize
private static PhpArray getimagesize(Stream stream, PhpReference imageinfo)
{
PhpArray exif;
PhpArray result = GetImageSize(stream, imageinfo != null, out exif);
if (imageinfo != null) imageinfo.value = exif ?? new PhpArray();
return result;
}
开发者ID:Ashod,项目名称:Phalanger,代码行数:8,代码来源:PhpImage.cs
示例16: SetVariableRef
public static void SetVariableRef(ScriptContext/*!*/ context, Dictionary<string, object> locals,
string/*!*/ name, PhpReference reference)
{
Debug.Assert(name != null);
if (locals != null)
{
locals[name] = reference;
}
else
{
PhpArray globals = context.AutoGlobals.Globals.Value as PhpArray;
if (globals == null)
context.AutoGlobals.Globals.Value = globals = new PhpArray();
globals[name] = reference;
}
}
开发者ID:kaviarasankk,项目名称:Phalanger,代码行数:19,代码来源:Operators.cs
示例17: WriteReference
/// <summary>
/// Serializes a <see cref="PhpReference"/>.
/// </summary>
/// <param name="value">The reference.</param>
private void WriteReference(PhpReference value)
{
sequenceNumber--;
if (!value.IsAliased)
{
Serialize(value.Value);
return;
}
int seq;
if (serializedRefs.TryGetValue(value, out seq))
{
// this reference has already been serialized -> write out its seq. number
writer.Write(Tokens.Reference);
writer.Write(Tokens.Colon);
writer.Write(seq);
writer.Write(Tokens.Semicolon);
}
else
{
serializedRefs.Add(value, sequenceNumber + 1);
if (value.Value is DObject && serializedRefs.TryGetValue(value.Value, out seq))
{
// this reference's value has already been serialized -> write out its seq. number
// (this is to handle situations such as array($x, &$x), where $x is an object instance)
writer.Write(Tokens.Reference);
writer.Write(Tokens.Colon);
writer.Write(seq);
writer.Write(Tokens.Semicolon);
}
else Serialize(value.Value);
}
}
开发者ID:hansdude,项目名称:Phalanger,代码行数:38,代码来源:PhpFormatter.CLR.cs
示例18: SetItemRef
public static void SetItemRef(PhpReference value, string key, ref object var)
{
Debug.Assert(!(var is PhpReference));
Debug.Assert(!(var is PhpArrayString), "ensures and end-of-chain operators only");
PhpArray array;
// PhpArray:
if ((array = var as PhpArray) != null)
{
// a reference in "value" is directly assigned to the array's item:
array.SetArrayItemRef(key, value);
return;
}
// null, empty string or empty string of bytes
if (IsEmptyForEnsure(var))
{
// a reference in "value" is directly assigned to the array's item:
PhpArray var_array = new PhpArray();
var_array.SetArrayItemRef(key, value);
var = var_array;
return;
}
SetItemRefEpilogue(value, key, ref var);
}
开发者ID:kaviarasankk,项目名称:Phalanger,代码行数:27,代码来源:Operators.cs
示例19: f0
public static void f0(PhpReference arg)
{
PhpVariable.Dump(arg.value);
arg.value = "hello";
}
开发者ID:dw4dev,项目名称:Phalanger,代码行数:5,代码来源:DebugTests.CLR.cs
示例20: EnsurePropertyIsArrayInternal
/// <summary>
/// Ensures that a property value is of <see cref="PhpArray"/> type.
/// </summary>
/// <param name="obj">The object whose property is to be checked.</param>
/// <param name="name">The property name.</param>
/// <param name="caller"><see cref="Type"/> of the object that request the operation.</param>
/// <param name="propValue">The property value (might get updated).</param>
/// <returns>The new property value (dereferenced) or <B>null</B> if evaluation of this compound
/// statement should not proceed.</returns>
internal static PhpArray EnsurePropertyIsArrayInternal(DObject obj, string name, DTypeDesc caller, ref object propValue)
{
PhpArray result;
PhpReference reference = propValue as PhpReference;
object value;
if (reference != null && !reference.IsSet)
{
// this CT property has been unset
if (obj.TypeDesc.GetMethod(Name.SpecialMethodNames.Set) != null &&
obj.TypeDesc.RealType.Namespace != null &&
obj.TypeDesc.RealType.Namespace.StartsWith(Namespaces.Library))
{
ScriptContext context = ScriptContext.CurrentContext;
// create a chain of arguments to be passed to the setter
context.BeginSetterChain(obj);
context.ExtendSetterChain(new RuntimeChainProperty(name));
return ScriptContext.SetterChainSingletonArray;
}
// try to invoke __get
bool getter_exists;
reference = obj.InvokeGetterRef(name, caller, out getter_exists);
if (!getter_exists)
{
result = new PhpArray();
propValue = new PhpReference(result);
return result;
}
else if (reference == null) return null; // error
value = reference.Value;
}
else value = PhpVariable.Dereference(propValue);
// try to wrap into PhpArray:
object new_value;
var wrappedarray = EnsureObjectIsArray(value, out new_value);
if (wrappedarray != null)
{
if (new_value != null)
{
if (reference != null) reference.Value = new_value;
else propValue = new_value;
}
return wrappedarray;
}
// error - the property is a scalar or a PhpObject:
PhpException.VariableMisusedAsArray(value, false);
return null;
}
开发者ID:kaviarasankk,项目名称:Phalanger,代码行数:63,代码来源:Operators.cs
注:本文中的PhpReference类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论