本文整理汇总了C#中PHP.Core.PhpArray.SetArrayItemRef方法的典型用法代码示例。如果您正苦于以下问题:C# PhpArray.SetArrayItemRef方法的具体用法?C# PhpArray.SetArrayItemRef怎么用?C# PhpArray.SetArrayItemRef使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHP.Core.PhpArray
的用法示例。
在下文中一共展示了PhpArray.SetArrayItemRef方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: 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);
}