本文整理汇总了C#中PHP.Core.PhpArray.DeepCopy方法的典型用法代码示例。如果您正苦于以下问题:C# PhpArray.DeepCopy方法的具体用法?C# PhpArray.DeepCopy怎么用?C# PhpArray.DeepCopy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHP.Core.PhpArray
的用法示例。
在下文中一共展示了PhpArray.DeepCopy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ArrayReplaceImpl
/// <summary>
///
/// </summary>
/// <param name="array"></param>
/// <param name="arrays"></param>
/// <param name="recursive"></param>
/// <returns></returns>
/// <remarks>Performs deep copy of array, return array with replacements.</remarks>
internal static PhpArray ArrayReplaceImpl(PhpArray array, PhpArray[] arrays, bool recursive)
{
PhpArray result = (PhpArray)array.DeepCopy();
if (arrays != null)
foreach (PhpArray array1 in arrays)
ArrayReplaceImpl(result, array1, recursive);
//// if called by PHP language then all items in the result should be in place deeply copied:
//result.InplaceCopyOnReturn = true;
return result;
}
示例2: ParseStep
private void ParseStep(XmlReader reader, Stack<ElementRecord> elementStack, ref TextRecord textChunk, PhpArray values, PhpArray indices)
{
string elementName;
bool emptyElement;
ElementRecord currentElementRecord = null;
switch (reader.NodeType)
{
case XmlNodeType.Element:
elementName = reader.Name;
emptyElement = reader.IsEmptyElement;
PhpArray attributeArray = new PhpArray();
if (_processNamespaces && elementName.IndexOf(":") >= 0)
{
string localName = elementName.Substring(elementName.IndexOf(":") + 1);
elementName = reader.NamespaceURI + _namespaceSeparator + localName;
}
if (reader.MoveToFirstAttribute())
{
do
{
if (_processNamespaces && reader.Name.StartsWith("xmlns:"))
{
string namespaceID = reader.Name.Substring(6);
string namespaceUri = reader.Value;
if (_startNamespaceDeclHandler.Callback != null)
_startNamespaceDeclHandler.Invoke(this, namespaceID, namespaceUri);
continue;
}
attributeArray.Add(_enableCaseFolding ? reader.Name.ToUpperInvariant() : reader.Name, reader.Value);
}
while (reader.MoveToNextAttribute());
}
// update current top of stack
if (elementStack.Count != 0)
{
currentElementRecord = elementStack.Peek();
UpdateValueAndIndexArrays(currentElementRecord, ref textChunk, values, indices, true);
if (currentElementRecord.State == ElementState.Beginning)
currentElementRecord.State = ElementState.Interior;
}
// push the element into the stack (needed for parse_into_struct)
elementStack.Push(
new ElementRecord() {
ElementName = elementName,
Level = reader.Depth,
State = ElementState.Beginning,
Attributes = (PhpArray)attributeArray.DeepCopy()
});
if (_startElementHandler.Callback != null)
_startElementHandler.Invoke(this, _enableCaseFolding ? elementName.ToUpperInvariant() : elementName, attributeArray);
else
if (_defaultHandler.Callback != null) _defaultHandler.Invoke(this, "");
if (emptyElement) goto case XmlNodeType.EndElement; // and end the element immediately (<element/>, XmlNodeType.EndElement will not be called)
break;
case XmlNodeType.EndElement:
elementName = reader.Name;
if (_processNamespaces && elementName.IndexOf(":") >= 0)
{
string localName = elementName.Substring(elementName.IndexOf(":") + 1);
elementName = reader.NamespaceURI + _namespaceSeparator + localName;
}
// pop the top element record
currentElementRecord = elementStack.Pop();
UpdateValueAndIndexArrays(currentElementRecord, ref textChunk, values, indices, false);
if (_endElementHandler.Callback != null)
_endElementHandler.Invoke(this, _enableCaseFolding ? elementName.ToUpperInvariant() : elementName);
else
if (_defaultHandler.Callback != null) _defaultHandler.Invoke(this, "");
break;
case XmlNodeType.Whitespace:
case XmlNodeType.Text:
case XmlNodeType.CDATA:
if (textChunk == null)
{
textChunk = new TextRecord() { Text = reader.Value };
}
else
{
textChunk.Text += reader.Value;
//.........这里部分代码省略.........