当前位置: 首页>>代码示例>>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;未经允许,请勿转载。