當前位置: 首頁>>代碼示例>>C#>>正文


C# Entity.Clone方法代碼示例

本文整理匯總了C#中System.Entity.Clone方法的典型用法代碼示例。如果您正苦於以下問題:C# Entity.Clone方法的具體用法?C# Entity.Clone怎麽用?C# Entity.Clone使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Entity的用法示例。


在下文中一共展示了Entity.Clone方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: PipeSet

        public PipeSet(Entity referencePipeEntity, float scrollSpeed, float startScrollPos, float screenWidth)
        {
            this.scrollSpeed = scrollSpeed;
            this.startScrollPos = startScrollPos;
            halfScrollWidth = screenWidth / 2f;

            // Store Entity and create another one for two rendering:
            // top and bottom sprite of pipe.
            var spriteComp = referencePipeEntity.Get<SpriteComponent>();
             bottomPipe = referencePipeEntity.Clone();
            topPipe = referencePipeEntity.Clone();
            Entity.AddChild(bottomPipe);
            Entity.AddChild(topPipe);

            var sprite = spriteComp.CurrentSprite;
            pipeWidth = sprite.SizeInPixels.X;
            pipeHeight = sprite.SizeInPixels.Y;
            halfPipeWidth = pipeWidth/2f;

            // Setup pipeCollider
            pipeCollider = new RectangleF(0, 0, pipeWidth, pipeHeight);

            // Place the top/bottom pipes relatively to the root.
            topPipe.Transform.Position.Y = -(VerticalDistanceBetweenPipe + pipeHeight) * 0.5f;
            bottomPipe.Transform.Position.Y = (VerticalDistanceBetweenPipe + pipeHeight) * 0.5f;
            bottomPipe.Transform.Rotation = Quaternion.RotationZ(MathUtil.Pi);

            ResetPipe();
        }
開發者ID:cg123,項目名稱:xenko,代碼行數:29,代碼來源:PipeSet.cs

示例2: CreateCube

        private void CreateCube(string name, Vector3 position, float scaleFactor, float angleStep, float speed)
        {
            var cube = new Entity(name)
                           .AddComponent(new Transform3D() { Position = position, Scale = new Vector3(scaleFactor) })
                           .AddComponent(Model.CreateCube())
                            .AddComponent(new MaterialsMap(new BasicMaterial(GenerateRandomColors())))
                       .AddComponent(new ModelRenderer())
                       .AddComponent(new CubeBehavior(name, angleStep, speed));

            EntityManager.Add(cube);

            var clone = cube.Clone(name + "_1");
            clone.FindComponent<Transform3D>().Position = new Vector3(position.X + 5, position.Y + 5, position.Z + 5);
            EntityManager.Add(clone);

            clone = cube.Clone(name + "_2");
            clone.FindComponent<Transform3D>().Position = new Vector3(position.X - 5, position.Y - 5, position.Z - 5);
            EntityManager.Add(clone);
        }
開發者ID:123asd123A,項目名稱:Samples,代碼行數:19,代碼來源:MyScene.cs

示例3: AddEntity

        /// <summary>
        /// 
        /// </summary>
        /// <param name="ent"></param>
        /// <param name="position"></param>
        /// <param name="rotation"></param>
        /// <param name="scale"></param>
        /// <param name="color"></param>
        public override void AddEntity(Entity entity, Vector3 position, Quaternion rotation, Vector3 scale, ColorEx color)
        {
            SceneNode node = mRootNode.CreateChildSceneNode();
            node.Position = position;
            mNodeList.Add(node);

            Entity ent = entity.Clone(GetUniqueID());
            ent.CastShadows = false;
            ent.RenderQueueGroup = entity.RenderQueueGroup;
            node.AttachObject(ent);
        }
開發者ID:andyhebear,項目名稱:mogrelibrarys,代碼行數:19,代碼來源:GrassPage.cs

示例4: MemoryClone

            /// <summary>
            /// 從指定的對象中拷貝所有數據到另一對象中。
            /// 
            /// 默認實體隻拷貝所有數據屬性。
            /// 子類可重寫此方法來拷貝更多一般字段。
            /// </summary>
            /// <param name="src">數據源對象。</param>
            /// <param name="dst">目標對象。</param>
            protected virtual void MemoryClone(Entity src, Entity dst)
            {
                //同時由於以下代碼隻是對托管屬性進行了拷貝,會導致一些一般字段無法複製。(參見 Rafy.RBAC.ModuleAC 實體類型。)

                //返回的子對象的屬性隻是簡單的完全Copy參數data的數據。
                dst.Clone(src, CloneOptions.ReadDbRow());
            }
開發者ID:569550384,項目名稱:Rafy,代碼行數:15,代碼來源:MemoryEntityRepository.cs

示例5: JoinAttributes

        /// <summary>
        /// Extension method to join the attributes of entity e and otherEntity
        /// </summary>
        /// <param name="e"></param>
        /// <param name="otherEntity"></param>
        /// <param name="attributes"></param>
        /// <returns></returns>
        public static Entity JoinAttributes(this Entity e, Entity otherEntity, ColumnSet columnSet, string alias, XrmFakedContext context)
        {
            if (otherEntity == null) return e; //Left Join where otherEntity was not matched

            otherEntity = otherEntity.Clone(); //To avoid joining entities from/to the same entities, which would cause collection modified exceptions

            if (columnSet.AllColumns)
            {
                foreach (var attKey in otherEntity.Attributes.Keys)
                {
                    e[alias + "." + attKey] = new AliasedValue(alias, attKey, otherEntity[attKey]);
                }
            }
            else
            {
                //Return selected list of attributes
                foreach (var attKey in columnSet.Columns)
                {
                    if (!context.AttributeExistsInMetadata(otherEntity.LogicalName, attKey))
                    {
                        OrganizationServiceFaultQueryBuilderNoAttributeException.Throw(attKey);
                    }

                    if (otherEntity.Attributes.ContainsKey(attKey))
                    {
                        e[alias + "." + attKey] = new AliasedValue(alias, attKey, otherEntity[attKey]);
                    }
                    else
                    {
                        e[alias + "." + attKey] = new AliasedValue(alias, attKey, null);
                    }
                    
                }
            }
            return e;
        }
開發者ID:ccellar,項目名稱:fake-xrm-easy,代碼行數:43,代碼來源:EntityExtensions.cs

示例6: Add

        /// <summary>
        /// Add a single entity
        /// </summary>
        /// <param name="e">the entity</param>
        /// <param name="label">optional label, null if none</param>
        /// <returns>the 2 entity clones actually used in the view</returns>
        public Entity[] Add(Entity e, devDept.Eyeshot.Labels.Label[] labels)
        {
            Entity[] ents = new Entity[2];
            m_viewleft.Entities.Add(ents[0] = (Entity)e.Clone());
            m_viewright.Entities.Add(ents[1] = (Entity)e.Clone());
            ents[0].EntityData = ents[1].EntityData = e.EntityData;
            ents[0].GroupIndex = ents[1].GroupIndex = e.GroupIndex;

            if (e is Mesh)
            {
                e.ColorMethod = colorMethodType.byEntity;
                Color baseColor = e.Color;
                if (e.LayerIndex > 0 && e.LayerIndex < this[0].Layers.Count)
                    baseColor = this[0].Layers[e.LayerIndex].Color;
                e.Color = Color.FromArgb(50, baseColor);
            }
            if (labels != null)
            {
                foreach (devDept.Eyeshot.Labels.Label label in labels)
                {
                    label.Visible = false;
                    m_viewleft.Labels.Add(label);
                    m_viewright.Labels.Add(label);
                }
            }

            return ents;
        }
開發者ID:GabeTesta,項目名稱:Warps,代碼行數:34,代碼來源:DualView.cs


注:本文中的System.Entity.Clone方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。