Ejemplo n.º 1
0
        internal static DxfXData FromBuffer(DxfCodePairBufferReader buffer, string applicationName)
        {
            DxfXDataItem last  = null;
            var          items = new List <DxfXDataItem>();

            while (buffer.ItemsRemain)
            {
                var pair = buffer.Peek();
                if (pair.Code == (int)DxfXDataType.ApplicationName || pair.Code < 1000)
                {
                    // new xdata or non-xdata
                    break;
                }

                var item = DxfXDataItem.FromBuffer(buffer);
                if (item != null)
                {
                    if (last is DxfXDataString xdataString && item is DxfXDataItemList list)
                    {
                        // re-build last and current item as named group
                        items.RemoveAt(items.Count - 1);
                        item = new DxfXDataNamedList(xdataString.Value, list.Items);
                    }

                    items.Add(item);
                    last = item;
                }
            }

            return(new DxfXData(applicationName, items));
        }
Ejemplo n.º 2
0
        internal static DxfXDataItemList ListFromBuffer(DxfCodePairBufferReader buffer)
        {
            Debug.Assert(buffer.ItemsRemain);
            DxfCodePair pair;
            var         items = new List <DxfXDataItem>();

            while (buffer.ItemsRemain)
            {
                pair = buffer.Peek();
                Debug.Assert(pair.Code >= 1000, "Unexpected non-XDATA code pair");
                if (pair.Code == (int)DxfXDataType.ControlString && pair.StringValue == "}")
                {
                    buffer.Advance();
                    break;
                }

                var item = DxfXDataItem.FromBuffer(buffer);
                if (item != null)
                {
                    items.Add(item);
                }
            }

            return(new DxfXDataItemList(items));
        }
Ejemplo n.º 3
0
        internal static void PopulateFromBuffer(DxfCodePairBufferReader buffer, IDictionary <string, DxfXDataApplicationItemCollection> xdata, string applicationName)
        {
            xdata[applicationName] = new DxfXDataApplicationItemCollection();
            while (buffer.ItemsRemain)
            {
                var pair = buffer.Peek();
                if (pair.Code == (int)DxfXDataType.ApplicationName || pair.Code < 1000)
                {
                    return;
                }

                var item = DxfXDataItem.FromBuffer(buffer);
                if (item != null)
                {
                    xdata[applicationName].Add(item);
                }
            }
        }
Ejemplo n.º 4
0
        internal static DxfXData FromBuffer(DxfCodePairBufferReader buffer, string applicationName)
        {
            var items = new List <DxfXDataItem>();

            while (buffer.ItemsRemain)
            {
                var pair = buffer.Peek();
                if (pair.Code == (int)DxfXDataType.ApplicationName || pair.Code < 1000)
                {
                    // new xdata or non-xdata
                    break;
                }

                items.Add(DxfXDataItem.FromBuffer(buffer));
            }

            return(new DxfXData(applicationName, items));
        }