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


C# Entity.IsValid方法代码示例

本文整理汇总了C#中System.Entity.IsValid方法的典型用法代码示例。如果您正苦于以下问题:C# Entity.IsValid方法的具体用法?C# Entity.IsValid怎么用?C# Entity.IsValid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Entity的用法示例。


在下文中一共展示了Entity.IsValid方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Stream

      Stream(ArrayList data, Entity entity)
      {
         data.Add(new Snoop.Data.ClassSeparator(typeof(Entity)));
         data.Add(new Snoop.Data.Bool("Is Valid", entity.IsValid()));
         data.Add(new Snoop.Data.Bool("Read Access Granted", entity.ReadAccessGranted()));
         data.Add(new Snoop.Data.Bool("Write Access Granted", entity.WriteAccessGranted()));
         data.Add(new Snoop.Data.Object("Schema", entity.Schema));
         Schema schema = entity.Schema;
         if (schema != null)
         {
            foreach (Field field in schema.ListFields())
            {
               data.Add(new Snoop.Data.Object("Field", new ExtensibleStorageField(entity, field)));
            }
         }

      }
开发者ID:15921050052,项目名称:RevitLookup,代码行数:17,代码来源:CollectorExtMisc.cs

示例2: UpdateEntities

        /// <summary>
        /// Updates the entity in the pipe fitting and accessory pressure drop UI data. 
        /// </summary>
        /// <param name="data">
        /// The pipe fitting and accessory pressure drop UI data.
        /// </param>
        /// <param name="dbServerId">
        /// The corresponding DB server Id of the UI server.
        /// </param>
        /// <param name="schemaField">
        /// The schema field to be updated.
        /// </param>
        /// <param name="newValue">
        /// The new value to be set to the schema field.
        /// </param>
        /// <returns>
        /// True if the entity in the UI data is updated, false otherwise.
        /// </returns>
        public static bool UpdateEntities(PipeFittingAndAccessoryPressureDropUIData data, Guid dbServerId, string schemaField, string newValue)
        {
            bool isUpdated = false;

             ExternalService service = ExternalServiceRegistry.GetService(ExternalServices.BuiltInExternalServices.PipeFittingAndAccessoryPressureDropService);
             if (service == null)
            return isUpdated;

             IPipeFittingAndAccessoryPressureDropServer dbServer = service.GetServer(dbServerId) as IPipeFittingAndAccessoryPressureDropServer;
             if (dbServer == null)
             {
            return isUpdated;
             }

             Schema schema = dbServer.GetDataSchema();
             if (schema == null)
            return isUpdated;

             Field field = schema.GetField(schemaField);
             if (field == null)
            return isUpdated;

             Entity entity = new Entity(schema);
             entity.Set<string>(field, newValue);

             IList<PipeFittingAndAccessoryPressureDropUIDataItem> uiDataItems = data.GetUIDataItems();
             foreach (PipeFittingAndAccessoryPressureDropUIDataItem uiDataItem in uiDataItems)
             {

            Entity oldEntity = uiDataItem.GetEntity();
            if (oldEntity == null && entity == null)
            {
               continue;
            }

            if (oldEntity == null || entity == null)
            {
               uiDataItem.SetEntity(entity);
               isUpdated = true;
               continue;
            }

            if ((!oldEntity.IsValid()) && (!entity.IsValid()))
            {
               continue;
            }

            if ((!oldEntity.IsValid()) || (!entity.IsValid()))
            {
               uiDataItem.SetEntity(entity);
               isUpdated = true;
               continue;
            }

            string oldValue = oldEntity.Get<string>(schemaField);
            if (oldValue != newValue)
            {
               uiDataItem.SetEntity(entity);
               isUpdated = true;
               continue;
            }
             }

             return isUpdated;
        }
开发者ID:jeremytammik,项目名称:UserMepCalculation,代码行数:83,代码来源:FittingAndAccessoryCalculationUIServersHelper.cs

示例3: GetSerObjectiveFromEntity

        public static SerializableObjective GetSerObjectiveFromEntity(Entity ent, Vector3 pos)
        {
            {
                var threshold = 1.5f;
                foreach (SerializablePickupObjective objective in CurrentMission.Objectives.OfType<SerializablePickupObjective>())
                {
                    if (objective.GetObject() == null || !objective.GetObject().IsValid()) continue;
                    if ((objective.GetObject().Position - pos).Length() > threshold) continue;
                    return objective;
                }

                foreach (var mark in CurrentMission.Objectives.OfType<SerializableMarker>())
                {
                    if ((mark.Position - pos).Length() > threshold) continue;
                    return mark;
                }
            }

            if (ent == null || !ent.IsValid()) return null;

            var type = GetEntityType(ent);
            
            switch (type)
            {
                case EntityType.ObjectiveActor:
                    return CurrentMission.Objectives.First(o =>
                    {
                        var act = o as SerializableActorObjective;
                        return act?.GetPed()?.Handle.Value == ent.Handle.Value;
                    });
                case EntityType.ObjectiveVehicle:
                    return CurrentMission.Objectives.First(o =>
                    {
                        var act = o as SerializableVehicleObjective;
                        return act?.GetVehicle()?.Handle.Value == ent.Handle.Value;
                    });
                case EntityType.ObjectivePickup:
                    return CurrentMission.Objectives.First(o =>
                    {
                        var d = o as SerializablePickupObjective;
                        return d?.GetObject()?.Handle.Value == ent.Handle.Value;
                    });
            }


            return null;
        }
开发者ID:LordRevan2,项目名称:MissionCreator,代码行数:47,代码来源:Editor.cs

示例4: CheckForIntersection

        private void CheckForIntersection(Entity ent)
        {
            if (MarkerData.RepresentedBy != null && MarkerData.RepresentedBy.IsValid() && ent != null && ent.IsValid())
            {
                var type = GetEntityType(ent);
                if (MarkerData.RepresentedBy is Vehicle && type == EntityType.NormalVehicle && !IsPlacingObjective)
                {
                    MarkerData.RepresentedBy.Opacity = 0f;
                    MarkerData.HeadingOffset = 45f;
                    RingData.Color = Color.Red;
                    _hoveringEntity = ent;
                }

                if (MarkerData.RepresentedBy is Vehicle && IsPlacingObjective && type == EntityType.ObjectiveVehicle)
                {
                    MarkerData.RepresentedBy.Opacity = 0f;
                    MarkerData.HeadingOffset = 45f;
                    RingData.Color = Color.Red;
                    _hoveringEntity = ent;
                }

                else if (MarkerData.RepresentedBy is Ped && ent.IsPed() && !PlayerSpawnOpen && !IsPlacingObjective && type == EntityType.NormalActor)
                {
                    MarkerData.RepresentedBy.Opacity = 0f;
                    MarkerData.HeadingOffset = 45f;
                    RingData.Color = Color.Red;
                    _hoveringEntity = ent;
                }

                else if (MarkerData.RepresentedBy is Ped && ent.IsPed() && PlayerSpawnOpen && type == EntityType.Spawnpoint)
                {
                    MarkerData.RepresentedBy.Opacity = 0f;
                    MarkerData.HeadingOffset = 45f;
                    RingData.Color = Color.Red;
                    _hoveringEntity = ent;
                }

                else if (MarkerData.RepresentedBy is Ped && ent.IsPed() && IsPlacingObjective && type == EntityType.ObjectiveActor)
                {
                    MarkerData.RepresentedBy.Opacity = 0f;
                    MarkerData.HeadingOffset = 45f;
                    RingData.Color = Color.Red;
                    _hoveringEntity = ent;
                }

                else if (MarkerData.RepresentedBy is Ped && ent.IsVehicle() &&
                    type == EntityType.NormalVehicle &&
                    ((Vehicle)ent).GetFreeSeatIndex().HasValue)
                {
                    RingData.Color = Color.GreenYellow;
                    _hoveringEntity = ent;
                }

                else if (MarkerData.RepresentedBy is Object && ent.IsObject() &&
                    type == EntityType.NormalObject && PlacedWeaponHash == 0)
                {
                    MarkerData.RepresentedBy.Opacity = 0f;
                    MarkerData.HeadingOffset = 45f;
                    RingData.Color = Color.Red;
                    _hoveringEntity = ent;
                }
            }
            else if (_hoveringEntity != null && _hoveringEntity.IsValid() && MarkerData.RepresentedBy != null && MarkerData.RepresentedBy.IsValid() && PlacedWeaponHash == 0)
            {
                MarkerData.RepresentedBy.Opacity = 1f;
                MarkerData.HeadingOffset = 0f;
                RingData.Color = Color.MediumPurple;
                _hoveringEntity = null;
            }
        }
开发者ID:LordRevan2,项目名称:MissionCreator,代码行数:70,代码来源:Editor.cs

示例5: GetSerObjectFromEntity

        public static SerializableObject GetSerObjectFromEntity(Entity ent, Vector3 pos)
        {
            {
                var threshold = 1.5f;
                foreach (SerializablePickup pickup in CurrentMission.Pickups)
                {
                    if (pickup.GetEntity() == null || !pickup.GetEntity().IsValid()) continue;
                    if ((pickup.GetEntity().Position - pos).Length() > threshold) continue;
                    return pickup;
                }
            }

            if (ent == null || !ent.IsValid()) return null;

            var type = GetEntityType(ent);
            switch (type)
            {
                case EntityType.NormalActor:
                    return CurrentMission.Actors.First(o => o?.GetEntity()?.Handle.Value == ent.Handle.Value);
                case EntityType.Spawnpoint:
                    return CurrentMission.Spawnpoints.First(o => o?.GetEntity()?.Handle.Value == ent.Handle.Value);
                case EntityType.NormalVehicle:
                    return CurrentMission.Vehicles.First(o => o?.GetEntity()?.Handle.Value == ent.Handle.Value);
                case EntityType.NormalObject:
                    return CurrentMission.Objects.First(o => o?.GetEntity()?.Handle.Value == ent.Handle.Value);
                case EntityType.NormalPickup:
                    return CurrentMission.Pickups.First(o => o?.GetEntity()?.Handle.Value == ent.Handle.Value);
            }
            return null;
        }
开发者ID:LordRevan2,项目名称:MissionCreator,代码行数:30,代码来源:Editor.cs

示例6: GetEntityType

        public static EntityType GetEntityType(Entity ent)
        {
            if (ent == null || !ent.IsValid()) return EntityType.None;

            if (ent.IsPed())
            {
                if(CurrentMission.Actors.Any(o => o?.GetEntity()?.Handle.Value == ent.Handle.Value))
                    return EntityType.NormalActor;
                if(CurrentMission.Spawnpoints.Any(o => o?.GetEntity()?.Handle.Value == ent.Handle.Value))
                    return EntityType.Spawnpoint;
                if (CurrentMission.Objectives.Any(o =>
                {
                    var act = o as SerializableActorObjective;
                    return act?.GetPed()?.Handle.Value == ent.Handle.Value;
                })) 
                    return EntityType.ObjectiveActor;
            }
            else if (ent.IsVehicle())
            {
                if(CurrentMission.Vehicles.Any(o => o?.GetEntity()?.Handle.Value == ent.Handle.Value))
                    return EntityType.NormalVehicle;
                if (CurrentMission.Objectives.Any(o =>
                {
                    var act = o as SerializableVehicleObjective;
                    return act?.GetVehicle()?.Handle.Value == ent.Handle.Value;
                }))
                    return EntityType.ObjectiveVehicle;
            }
            else if (ent.IsObject())
            {
                if(CurrentMission.Objects.Any(o => o?.GetEntity()?.Handle.Value == ent.Handle.Value))
                    return EntityType.NormalObject;
                if(CurrentMission.Pickups.Any(o => o?.GetEntity()?.Handle.Value == ent.Handle.Value))
                    return EntityType.NormalPickup;
                if(CurrentMission.Objectives.Any(o =>
                {
                    var d = o as SerializablePickupObjective;
                    return d?.GetObject()?.Handle.Value == ent.Handle.Value;
                }))
                    return EntityType.ObjectivePickup;
            }
            return EntityType.None;
        }
开发者ID:LordRevan2,项目名称:MissionCreator,代码行数:43,代码来源:Editor.cs

示例7: CheckForProperty

 private void CheckForProperty(Entity ent)
 {
     if (ent != null && ent.IsValid())
     {
         var type = GetEntityType(ent);
         if (type != EntityType.None)
         {
             RingData.Color = Color.Yellow;
             _hoveringEntity = ent;
         }
     }
     else if (_hoveringEntity != null && _hoveringEntity.IsValid())
     {
         var type = GetEntityType(_hoveringEntity);
         if (type == EntityType.NormalPickup || type == EntityType.ObjectivePickup || type == EntityType.ObjectiveMarker) return;
         RingData.Color = Color.Gray;
         _hoveringEntity = null;
     }
 }
开发者ID:LordRevan2,项目名称:MissionCreator,代码行数:19,代码来源:Editor.cs

示例8: Process

        public void Process(Vector3 markerPos, Entity crossent)
        {
            CreateWaypointMenu.ProcessControl();
            CreateWaypointMenu.Draw();

            _waypointPropertiesMenu.ProcessControl();
            _waypointPropertiesMenu.Draw();

            if (_children != null)
                foreach (var menu in _children)
                {
                    menu.ProcessControl();
                    menu.Draw();
                }

            if (!IsInEditor) return;
            RepresentCurrentWaypoints();
            DrawInstructionalButtonsScaleform();
            if (CreateWaypointMenu.Visible && Util.IsDisabledControlJustPressed(GameControl.CellphoneCancel))
            {
                
                return;
            }

            if (crossent != null && crossent.IsValid() && crossent.IsVehicle())
            {
                var item = CreateWaypointMenu.MenuItems.FirstOrDefault(i => i.Text.EndsWith("EnterVehicle"));
                if (item != null)
                    item.Enabled = true;
            }
            else
            {
                var item = CreateWaypointMenu.MenuItems.FirstOrDefault(i => i.Text.EndsWith("EnterVehicle"));
                if (item != null)
                    item.Enabled = false;
            }

            var wpy = CheckForIntersection(markerPos);
            if (wpy != null && CreateWaypointMenu.Visible)
            {
                if (Util.IsDisabledControlJustPressed(GameControl.Attack))
                {
                    RebuildWaypointPropertiesMenu(wpy);
                    CreateWaypointMenu.Visible = false;
                    _waypointPropertiesMenu.Visible = true;
                    return;
                }

                if (Util.IsDisabledControlJustPressed(GameControl.CreatorDelete))
                {
                    if (_mainPed != null)
                        _mainPed.Waypoints.Remove(wpy);
                    else _mainActorObjective.Waypoints.Remove(wpy);
                    return;
                }
            }

            if (CreateWaypointMenu.Visible)
            {
                DrawCrosshair(markerPos);
                //if (Game.IsControlJustPressed(0, GameControl.Attack))
                if (Util.IsDisabledControlJustPressed(GameControl.Attack))
                {
                    CreateWaypoint(_placingWaypointType, markerPos + new Vector3(0,0,1), crossent);
                    return;
                }
            }
        }
开发者ID:LordRevan2,项目名称:MissionCreator,代码行数:68,代码来源:WaypointEditor.cs

示例9: CreateWaypoint

        public SerializableWaypoint CreateWaypoint(WaypointTypes type, Vector3 pos, Entity ent)
        {
            var wpy = new SerializableWaypoint();
            wpy.Type = type;
            wpy.Position = pos;
            wpy.Duration = 0;
            wpy.VehicleSpeed = 20f;
            wpy.DrivingStyle = 0xC00AB;

            switch (type)
            {
                case WaypointTypes.EnterVehicle:
                    if (ent != null && ent.IsValid() && ent.IsVehicle())
                    {
                        wpy.VehicleTargetModel = ent.Model.Hash;
                    }
                    break;
            }


            if(_mainPed != null)
                _mainPed.Waypoints.Add(wpy);
            else
                _mainActorObjective.Waypoints.Add(wpy);

            return wpy;
        }
开发者ID:LordRevan2,项目名称:MissionCreator,代码行数:27,代码来源:WaypointEditor.cs


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