当前位置: 首页>>代码示例>>C#>>正文


C# PhpArray.DeepCopy方法代码示例

本文整理汇总了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;
        }
开发者ID:dw4dev,项目名称:Phalanger,代码行数:20,代码来源:Arrays.cs

示例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;
//.........这里部分代码省略.........
开发者ID:toburger,项目名称:Phalanger,代码行数:101,代码来源:XmlParserResource.cs


注:本文中的PHP.Core.PhpArray.DeepCopy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。