Exemplo n.º 1
0
        public void Parse(AssetsReader reader)
        {
            Version      = reader.ReadCStr();
            Platform     = reader.ReadInt32();
            HasTypeTrees = reader.ReadBoolean();
            int numTypes = reader.ReadInt32();

            for (int i = 0; i < numTypes; i++)
            {
                Types.Add(new AssetsType(reader, HasTypeTrees));
            }
            int numObj = reader.ReadInt32();

            for (int i = 0; i < numObj; i++)
            {
                reader.AlignTo(4);
                var obj = ObjectInfo <AssetsObject> .Parse(ParentFile, reader);

                ObjectInfos.Add(obj);
            }
            int numAdds = reader.ReadInt32();

            for (int i = 0; i < numAdds; i++)
            {
                reader.AlignTo(4);
                Adds.Add(new RawPtr(reader));
            }
            int numExt = reader.ReadInt32();

            for (int i = 0; i < numExt; i++)
            {
                ExternalFiles.Add(new ExternalFile(reader));
            }
            reader.ReadCStr();
        }
Exemplo n.º 2
0
        public OUR_SetWithVC <T> Add(T value, Guid tag, VectorClock vectorClock)
        {
            var existingElement = Adds.FirstOrDefault(a => a.Value.Id == value.Id && a.Tag == tag);

            if (existingElement is not null)
            {
                return(Update(value, tag, vectorClock));
            }

            return(new(Adds.Add(new OUR_SetWithVCElement <T>(value, tag, vectorClock)), Removes));
        }
Exemplo n.º 3
0
        public OUR_Set <T> Add(T value, Guid tag, long timestamp)
        {
            var existingElement = Adds.FirstOrDefault(a => a.Value.Id == value.Id && a.Tag == tag);

            if (existingElement is not null)
            {
                return(Update(value, tag, timestamp));
            }

            return(new(Adds.Add(new OUR_SetElement <T>(value, tag, timestamp)), Removes));
        }
Exemplo n.º 4
0
        public P_Set <T> Add(T value)
        {
            var add    = Adds.FirstOrDefault(e => e.Id == value.Id);
            var remove = Removes.FirstOrDefault(e => e.Id == value.Id);

            if (add is not null || remove is not null)
            {
                return(this);
            }

            return(new(Adds.Add(value), Removes));
        }
Exemplo n.º 5
0
        //用于下一页面实现
        //public bool IsExistChanging { set; get; }
        //public string ShowOnChanging()
        //{
        //    return "分段内容有变动,请修改相应工期设置";
        //}

        #region SectionalData
        /// <summary>
        /// 在选择节点后面插入(默认)
        /// </summary>
        /// <param name="index">所选节点Index,从0开始</param>
        /// <returns></returns>
        void add(int index, EarthworkBlock block)
        {
            //foreach (var IndexBlockId in BlockIdIndexMapper)
            //{
            //    if (IndexBlockId.Value >= index)
            //    {
            //        BlockIdIndexMapper[IndexBlockId.Key]++;
            //    }
            //}
            Blocks.Insert(index, block);
            Adds.Add(block);
        }
Exemplo n.º 6
0
        public void Parse(AssetsReader reader)
        {
            Version      = reader.ReadCStr();
            Platform     = reader.ReadInt32();
            HasTypeTrees = reader.ReadBoolean();
            int numTypes = reader.ReadInt32();

            for (int i = 0; i < numTypes; i++)
            {
                Types.Add(new AssetsType(reader, HasTypeTrees));
            }

            List <ObjectRecord> records = new List <ObjectRecord>();
            int numObj = reader.ReadInt32();

            for (int i = 0; i < numObj; i++)
            {
                reader.AlignTo(4);
                var obj = new ObjectRecord(reader);
                records.Add(obj);
            }

            int numAdds = reader.ReadInt32();

            for (int i = 0; i < numAdds; i++)
            {
                reader.AlignTo(4);
                Adds.Add(new RawPtr(reader));
            }
            int numExt = reader.ReadInt32();

            for (int i = 0; i < numExt; i++)
            {
                ExternalFiles.Add(new ExternalFile(reader));
            }
            reader.ReadCStr();

            //load the object infos in order based on their type
            foreach (var record in records.OrderBy(x => PreloadObjectOrder(x)).ThenBy(x => x.ObjectID))
            {
                var obj = ObjectInfo <AssetsObject> .Parse(ParentFile, record);

                ObjectInfos.Add(obj);
                if (ShouldForceLoadObject(record))
                {
                    var o = obj.Object;
                }
            }
        }
Exemplo n.º 7
0
        public LWW_SetWithVC <T> Add(T value, VectorClock vectorClock)
        {
            var existingElement = Adds.FirstOrDefault(a => a.Value.Id == value.Id);

            if (existingElement is not null && existingElement.VectorClock < vectorClock)
            {
                var elements = Adds.Remove(existingElement);

                return(new(elements.Add(new LWW_SetWithVCElement <T>(value, vectorClock)), Removes));
            }

            if (existingElement is null)
            {
                return(new(Adds.Add(new LWW_SetWithVCElement <T>(value, vectorClock)), Removes));
            }

            return(this);
        }
Exemplo n.º 8
0
        public LWW_Set <T> Assign(T value, long timestamp)
        {
            var existingElement = Adds.FirstOrDefault(a => a.Value.Id == value.Id);

            if (existingElement is not null && existingElement.Timestamp < timestamp)
            {
                var elements = Adds.Remove(existingElement);

                return(new(elements.Add(new LWW_SetElement <T>(value, timestamp)), Removes));
            }

            if (existingElement is null)
            {
                return(new(Adds.Add(new LWW_SetElement <T>(value, timestamp)), Removes));
            }

            return(this);
        }
Exemplo n.º 9
0
        public override void Add(EarthworkBlocking blocking, ElementId elementId)
        {
            var block = blocking.Blocks.FirstOrDefault(c => c.ElementIds.Exists(p => p.IntegerValue == elementId.IntegerValue));

            if (block != null)
            {
                if (block.Id == Id)
                {
                    return;
                }

                block.Delete(blocking, new List <ElementId>()
                {
                    elementId
                });
            }
            ElementIds.Add(elementId);
            ElementIdValues.Add(elementId.IntegerValue);
            Adds.Add(elementId);
            CPSettings.ApplySetting(blocking, new List <ElementId>()
            {
                elementId
            });
        }
Exemplo n.º 10
0
        private void CompareNodes(XmlNode node, XmlNamespaceManager nsmgr)
        {
            foreach (XmlNode n in node.ChildNodes)
            {
                if (n.NodeType != XmlNodeType.Element)
                {
                    continue;
                }
                if (n.Attributes.Count > 0)
                {
                    foreach (var a in n.Attributes.Cast <XmlAttribute>().Where(a => IsNamespace(a)))
                    {
                        nsmgr.AddNamespace(a.LocalName, a.Value);  //We need to declare the namespaces BEFORE we unwind the call stack.
                    }
                }
                CompareNodes(n, nsmgr);
            }
            if (node.NodeType != XmlNodeType.Element)
            {
                return;                                       //the very first node is not type Element
            }
            string xp;
            List <XmlAttribute> matchedAttr = new List <XmlAttribute>();
            if (node.Attributes != null && node.Attributes.Count > 0)
            {
                foreach (XmlAttribute a in node.Attributes)
                {
                    XmlAttribute xa;
                    if (IsNamespace(a))//SelectSingleNode does not work on namespace attributes!
                    {
                        xp = GetXPath(a.OwnerElement);
                        XmlNode n = xOriRoot.SelectSingleNode(xp, nsmgr);
                        if (n == null)
                        {
                            continue;
                        }
                        xa = n.Attributes.Cast <XmlAttribute>().FirstOrDefault(m => m.Name == a.Name);
                        xp = GetXPath(a);
                    }
                    else
                    {
                        xp = GetXPath(a);
                        xa = xOriRoot.SelectSingleNode(xp, nsmgr) as XmlAttribute;
                    }
                    if (xa == null)
                    {
                        if (string.IsNullOrWhiteSpace(a.Value))
                        {
                            continue;
                        }
                        if (!Identifiers.Contains(a.Name))
                        {
                            Adds.Add(new Diff(xp, a.Value));
                        }
                        //else Adds.Add(new Diff(GetXPath(a.OwnerElement), null)); //don't need to create an empty element.
                        continue;
                    }
                    if (!EqualsI(xa.Value, a.Value) && !Identifiers.Contains(a.Name))
                    {
                        Changes.Add(new Diff(xp, a.Value, xa.Value));
                    }
                    MatchedNodes.Add(xa);
                }
            }

            xp = GetXPath(node);
            XmlElement xn    = (XmlElement)xOriRoot.SelectSingleNode(xp, nsmgr);
            string nodeValue = node.GetValue();

            if (xn == null)
            {
                if (!string.IsNullOrWhiteSpace(nodeValue))
                {
                    Adds.Add(new Diff(xp, nodeValue));
                }
                return;
            }
            string xnValue = xn.GetValue();
            if (!EqualsI(xnValue, nodeValue))
            {
                Changes.Add(new Diff(xp, nodeValue, xnValue));
            }
            MatchedNodes.Add(xn);
        }
Exemplo n.º 11
0
 void add(int index, TEarthworkBlock block)
 {
     this.EarthworkBlocks.Insert(index, block);
     Adds.Add(block);
 }
 public override int Add(T element)
 {
     Collection.Insert(0, element);
     Adds.Add(0);
     return(0);
 }