Ejemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Core.Models.Definitions.UnitDefinition"/> class.
 /// </summary>
 /// <param name="unitType">Unit type.</param>
 /// <param name="actions">Actions which are possible.</param>
 /// <param name="attack">Attack damage.</param>
 /// <param name="defense">Defense of the entity.</param>
 /// <param name="health">Health of the entity.</param>
 /// <param name="moves">Move range.</param>
 /// <param name="attackRange">Attack range.</param>
 /// <param name="population">Population cost.</param>
 /// <param name="scrapcost">Scrap cost.</param>
 /// <param name="energycost">Energy cost.</param>
 /// <param name="plutoniumcost">Plutonium cost.</param>
 /// <param name="techcost">Tech cost.</param>
 public UnitDefinition(
     EntityType unitType,
     string[] actions,
     int attack,
     int defense,
     int health,
     int moves,
     int attackRange,
     int population,
     int scrapcost,
     int energycost,
     int plutoniumcost,
     int techcost)
     : base((int)unitType)
 {
     Actions = actions;
     Attack = attack;
     Defense = defense;
     Health = health;
     Moves = moves;
     AttackRange = attackRange;
     Population = population;
     Scrapecost = scrapcost;
     Energycost = energycost;
     Plutoniumcost = plutoniumcost;
     Techcost = techcost;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the DefaultThumbnailViewModel class.
 /// </summary>
 /// <param name="thumbnailID">Thumbnail Guid</param>
 /// <param name="entity">Type of the entity</param>
 /// <param name="altText">Alt text for IMG tag</param>
 /// <param name="contentType">Content Type of the content. In case of community, it will be generic which will not be used.</param>
 public DefaultThumbnailViewModel(Guid? thumbnailID, EntityType entity, string altText, ContentTypes contentType)
 {
     this.ThumbnailID = thumbnailID;
     this.Entity = entity;
     this.AltText = HttpContext.Current.Server.HtmlEncode(altText);
     this.ContentType = contentType;
 }
        private static ModelElement CreateModelElementForEFObjectType(EFObject obj, Partition partition)
        {
            ModelElement modelElement = null;
            var t = obj.GetType();
            if (t == typeof(ConceptualEntityModel))
            {
                modelElement = new EntityDesignerViewModel(partition);
            }
            else if (t == typeof(ConceptualEntityType))
            {
                modelElement = new EntityType(partition);
            }
            else if (t == typeof(ConceptualProperty))
            {
                modelElement = new ScalarProperty(partition);
            }
            else if (t == typeof(ComplexConceptualProperty))
            {
                modelElement = new ComplexProperty(partition);
            }
            else if (t == typeof(Association))
            {
                modelElement = new ViewModel.Association(partition);
            }
            else if (t == typeof(EntityTypeBaseType))
            {
                modelElement = new Inheritance(partition);
            }
            else if (t == typeof(NavigationProperty))
            {
                modelElement = new ViewModel.NavigationProperty(partition);
            }

            return modelElement;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            _manageTagPopup.Options.IsPopup = true;

            entityType = StringToEntityType(Request["view"]);

            _switcherEntityType.SortItemsHeader = CRMCommonResource.Show + ":";

            _forContacts.SortLabel = CRMSettingResource.BothPersonAndCompany;
            _forContacts.SortUrl = "settings.aspx?type=tag";
            _forContacts.IsSelected = entityType == EntityType.Contact;


            _forDeals.SortLabel = CRMCommonResource.DealModuleName;
            _forDeals.SortUrl = String.Format("settings.aspx?type=tag&view={0}", EntityType.Opportunity.ToString().ToLower());
            _forDeals.IsSelected = entityType == EntityType.Opportunity;


            _forCases.SortLabel = CRMCommonResource.CasesModuleName;
            _forCases.SortUrl = String.Format("settings.aspx?type=tag&view={0}", EntityType.Case.ToString().ToLower());
            _forCases.IsSelected = entityType == EntityType.Case;

            RegisterClientScriptHelper.DataTagSettingsView(Page, entityType);
            RegisterScript();
        }
        public void Get_generation_property_returns_generation_property_from_foreign_key_tree()
        {
            var model = new Model();

            var leftType = new EntityType("Left", model);
            var leftId = leftType.AddProperty("Id", typeof(int), true);
            var leftKey = leftType.AddKey(leftId);

            var rightType = new EntityType("Right", model);
            var rightId1 = rightType.AddProperty("Id1", typeof(int), true);
            var rightId2 = rightType.AddProperty("Id2", typeof(int), true);
            var rightKey = rightType.AddKey(new[] { rightId1, rightId2 });

            var middleType = new EntityType("Middle", model);
            var middleProperty1 = middleType.AddProperty("FK1", typeof(int), true);
            var middleProperty2 = middleType.AddProperty("FK2", typeof(int), true);
            var middleKey1 = middleType.AddKey(middleProperty1);
            var middleFK1 = middleType.AddForeignKey(middleProperty1, leftKey, leftType);
            var middleFK2 = middleType.AddForeignKey(new[] { middleProperty2, middleProperty1 }, rightKey, rightType);

            var endType = new EntityType("End", model);
            var endProperty = endType.AddProperty("FK", typeof(int), true);

            var endFK = endType.AddForeignKey(endProperty, middleKey1, middleType);

            rightId2.RequiresValueGenerator = true;

            Assert.Equal(rightId2, endProperty.GetGenerationProperty());
        }
Ejemplo n.º 6
0
        private string buildNoticeLink(NotificationType noticeType, int entityId, EntityType entityType)
        {
            string result = "";

            switch (entityType)
            {
                case EntityType.Project:
                    switch (noticeType)
                    {
                        case NotificationType.BidSubmitted:
                            result = string.Format("/Project/{0}/Bid/Received", entityId);
                            break;
                        case NotificationType.InvitationRequest:
                            result = string.Format("/Project/{0}/Invitation/Requests", entityId);
                            break;
                        case NotificationType.InvitationResponse:
                        case NotificationType.InvitationToBid:
                        case NotificationType.ProjectChange:
                            result = string.Format("/Project/Details/{0}", entityId);
                            break;
                    }
                    break;
                case EntityType.Company:
                    switch (noticeType)
                    {
                        case NotificationType.ConnectionAccepted:
                        case NotificationType.RequestToConnect:
                            result = string.Format("/Company/Profile/{0}", entityId);
                            break;
                    }
                    break;
            }

            return result;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Adds a new row to the EntitySet with the specified entity type.
        /// </summary>
        /// <param name="entityType">Entity type for the new row.</param>
        /// <returns>Instance of <see cref="EntitySetDataRow"/> for the newly added row.</returns>
        public EntitySetDataRow AddNewRowOfType(EntityType entityType)
        {
            ExceptionUtilities.CheckArgumentNotNull(entityType, "entityType");
            this.CheckEntityTypeBelongsToEntitySet(entityType);

            return this.AddNewRowOfTypeInternal(entityType);
        }
Ejemplo n.º 8
0
 public AnimatedSprite(Texture2D texture, EntityType entityType, IList<AnimationSequence> animations, AnimationActions initialAnimationAction,
     Rectangle worldPosition, Vector2 speed = new Vector2(), Vector2 direction = new Vector2(), bool isCollidable = false, int collisionOffset = 0)
     : base(texture, entityType, worldPosition, speed: speed, direction: direction, isCollidable: isCollidable, collisionOffset: collisionOffset)
 {
     Animations = animations;
     CurrentAnimation = Animations.First(a => a.AnimationAction == initialAnimationAction);
 }
Ejemplo n.º 9
0
        protected List<int> SearchByTags(EntityType entityType, int[] exceptIDs, IEnumerable<String> tags)
        {
            if (tags == null || !tags.Any())
                throw new ArgumentException();

            var tagIDs = new List<int>();

            foreach (var tag in tags)
                tagIDs.Add(DbManager.ExecuteScalar<int>(Query("crm_tag")
                      .Select("id")
                      .Where(Exp.Eq("entity_type", (int)entityType ) & Exp.Eq("title", tag))));
            
            var sqlQuery = new SqlQuery("crm_entity_tag")
                .Select("entity_id")
                .Select("count(*) as count")
              
                .GroupBy("entity_id")
                .Having(Exp.Eq("count", tags.Count()));
               
            if (exceptIDs != null && exceptIDs.Length > 0)
                sqlQuery.Where(Exp.In("entity_id", exceptIDs) & Exp.Eq("entity_type", (int)entityType));
            else
                sqlQuery.Where(Exp.Eq("entity_type", (int)entityType));

            sqlQuery.Where(Exp.In("tag_id", tagIDs));

            return DbManager.ExecuteList(sqlQuery).ConvertAll(row => Convert.ToInt32(row[0]));
        }
Ejemplo n.º 10
0
 /// <summary>Creates a new, empty Entity object of the type specified</summary>
 /// <param name="entityTypeToCreate">The entity type to create.</param>
 /// <returns>A new, empty Entity object.</returns>
 public static IEntity2 Create(EntityType entityTypeToCreate)
 {
     IEntityFactory2 factoryToUse = null;
     switch(entityTypeToCreate)
     {
         case DirectSports.BL.EntityType.ProductEntity:
             factoryToUse = new ProductEntityFactory();
             break;
         case DirectSports.BL.EntityType.ProductSectionEntity:
             factoryToUse = new ProductSectionEntityFactory();
             break;
         case DirectSports.BL.EntityType.ProductVariationEntity:
             factoryToUse = new ProductVariationEntityFactory();
             break;
         case DirectSports.BL.EntityType.RoleEntity:
             factoryToUse = new RoleEntityFactory();
             break;
         case DirectSports.BL.EntityType.SpecialOfferEntity:
             factoryToUse = new SpecialOfferEntityFactory();
             break;
         case DirectSports.BL.EntityType.UserEntity:
             factoryToUse = new UserEntityFactory();
             break;
         case DirectSports.BL.EntityType.UserRoleLinkEntity:
             factoryToUse = new UserRoleLinkEntityFactory();
             break;
     }
     return factoryToUse.Create();
 }
Ejemplo n.º 11
0
 public static EntityType EntityType()
 {
     var entityType = new EntityType(typeof(NullablePoco));
     entityType.AddProperty("NullInt", typeof(int?));
     entityType.AddProperty("NullDouble", typeof(double?));
     return entityType;
 }
Ejemplo n.º 12
0
 public UserControlledSprite(Texture2D texture, EntityType entityType, IList<AnimationSequence> animations, AnimationActions initialAnimationAction,
     Rectangle worldPosition, int moveSpeed, bool isCollidable = false, int collisionOffset = 0)
     : base(texture, entityType, animations, initialAnimationAction, worldPosition, isCollidable: isCollidable,
     collisionOffset: collisionOffset)
 {
     MaxMoveSpeed = moveSpeed;
 }
Ejemplo n.º 13
0
 public Book(string inputTitle, string inputAuthors, int inputYear, 
     string inputPublisher, string inputPublisherAddr, EntityType inputEntityType, DateTime inputEntryDate)
     : base(inputTitle, inputAuthors, inputYear, inputEntityType, inputEntryDate)
 {
     Publisher = inputPublisher;
     PublisherAddr = inputPublisherAddr;
 }
Ejemplo n.º 14
0
        /*
         *	Builds the dynamic Insert query for all the entities
         */
        public int GetEntity(int scanID, EntityType entity, ref ArrayList entData)
        {
            try
            {
                using (SqlCeCommand command = Connection.CreateCommand())
                {
                    command.CommandText = SelectConditionalQueryString(entity, "where ScanID = ?");

                    command.Parameters.Add(new SqlCeParameter("ScanID",
                        SqlDbType.Int, 4)).Value = scanID;

                    using (SqlCeDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            entData.Add(DataReaderToObject(reader, entity));
                        }
                    }
                }
            }
            catch (Exception)
            {

            }
            return 1;
        }
Ejemplo n.º 15
0
        public Dictionary<int, List<String>> GetEntitiesTags(EntityType entityType)
        {

            var result = new Dictionary<int, List<String>>();

            var sqlQuery =
                 new SqlQuery("crm_entity_tag")
                .Select("entity_id", "title")
                .LeftOuterJoin("crm_tag", Exp.EqColumns("id", "tag_id"))
                .Where(Exp.Eq("crm_tag.entity_type", (int)entityType) & Exp.Eq("crm_tag.tenant_id", TenantID))
                .OrderBy("entity_id", true)
                .OrderBy("title", true);

            using (var db = GetDb())
            {
                db.ExecuteList(sqlQuery).ForEach(row =>
                                                           {
                                                               var entityID = Convert.ToInt32(row[0]);
                                                               var tagTitle = Convert.ToString(row[1]);

                                                               if (!result.ContainsKey(entityID))
                                                                   result.Add(entityID, new List<String>
                                                                                         {
                                                                                            tagTitle
                                                                                         });
                                                               else
                                                                   result[entityID].Add(tagTitle);

                                                           });
            }
            return result;
        }
    public bool Create(EntityType entityType)
    {
        if (IsServer() == false)
        {
            Debug.LogError("Client cannot spawn enemies, please use ServerCreateRequest if it is from server request");
            return false;
        }

        Vector3 position = EntitySpawnPoint.transform.position;
        Quaternion rotation = EntitySpawnPoint.transform.rotation;
        GameObject instantiateObject = null;

        float randX = Random.Range(-3, 3);
        float randZ = Random.Range(-3, 3);

        Vector3 newPosition = new Vector3(position.x + randX, position.y, position.z + randZ);

        instantiateObject = InstantiateEntityType(entityType, newPosition, rotation);

        if (instantiateObject != null)
        {
            instantiateObject.transform.parent = transform;
            instantiateObject.name = instantiateObject.name + "Ins" + iInstantiateCounter;
            iInstantiateCounter++;

            SendRPC("InstantiateEntity", RPCMode.Others, (int) entityType, instantiateObject.name, newPosition, rotation);
            return true;
        }

        return false;
    }
    private GameObject InstantiateEntityType(EntityType entityType, Vector3 position, Quaternion rotation)
    {
        GameObject instantiateObject = null;
        switch (entityType)
        {
            case EntityType.Worker:
                instantiateObject = (GameObject)Instantiate(WorkerPrefab, position, rotation);
                break;

            case EntityType.WarriorGreen:
                instantiateObject = (GameObject)Instantiate(WarriorGreenPrefab, position, rotation);
                break;

            case EntityType.Tower:
                towerSelector.StartCreating();
                instantiateObject = null;
                break;

            case EntityType.WarriorYellow:
                instantiateObject = (GameObject)Instantiate(WarriorYellowPrefab, position, rotation);
                break;

            case EntityType.WarriorRed:
                instantiateObject = (GameObject)Instantiate(WarriorRedPrefab, position, rotation);
                break;
            default:
                break;
        }

        return instantiateObject;
    }
Ejemplo n.º 18
0
 /// <summary>General factory entrance method which will return an EntityFields object with the format generated by the factory specified</summary>
 /// <param name="relatedEntityType">The type of entity the fields are for</param>
 /// <returns>The IEntityFields2 instance requested</returns>
 public static IEntityFields2 CreateEntityFieldsObject(EntityType relatedEntityType)
 {
     IEntityFields2 fieldsToReturn=null;
     switch(relatedEntityType)
     {
         case DirectSports.BL.EntityType.ProductEntity:
             fieldsToReturn = CreateProductEntityFields();
             break;
         case DirectSports.BL.EntityType.ProductSectionEntity:
             fieldsToReturn = CreateProductSectionEntityFields();
             break;
         case DirectSports.BL.EntityType.RoleEntity:
             fieldsToReturn = CreateRoleEntityFields();
             break;
         case DirectSports.BL.EntityType.SpecialOfferEntity:
             fieldsToReturn = CreateSpecialOfferEntityFields();
             break;
         case DirectSports.BL.EntityType.UserEntity:
             fieldsToReturn = CreateUserEntityFields();
             break;
         case DirectSports.BL.EntityType.UserRoleLinkEntity:
             fieldsToReturn = CreateUserRoleLinkEntityFields();
             break;
     }
     return fieldsToReturn;
 }
Ejemplo n.º 19
0
        /// <summary>
        /// Handles the SaveClick event of the mdEdit control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void mdEdit_SaveClick( object sender, EventArgs e )
        {
            var rockContext = new RockContext();
            EntityTypeService entityTypeService = new EntityTypeService( rockContext );
            EntityType entityType = entityTypeService.Get( int.Parse( hfEntityTypeId.Value ) );

            if ( entityType == null )
            {
                entityType = new EntityType();
                entityType.IsEntity = true;
                entityType.IsSecured = true;
                entityTypeService.Add( entityType );
            }

            entityType.Name = tbName.Text;
            entityType.FriendlyName = tbFriendlyName.Text;
            entityType.IsCommon = cbCommon.Checked;

            rockContext.SaveChanges();

            EntityTypeCache.Flush( entityType.Id );

            hfEntityTypeId.Value = string.Empty;

            HideDialog();

            BindGrid();
        }
Ejemplo n.º 20
0
 public Article(string inputTitle, string inputAuthors, int inputYear, 
     string inputJournal, int inputVolume, EntityType inputEntityType, DateTime inputEntryDate)
     : base(inputTitle, inputAuthors, inputYear, inputEntityType, inputEntryDate)
 {
     Journal = inputJournal;
     Volume = inputVolume;
 }
Ejemplo n.º 21
0
 public Thesis(string inputTitle, string inputAuthor, int inputYear, 
     ThesisType inputThesisEntityType, string inputSchool, EntityType inputEntityType, DateTime inputEntryDate)
     : base(inputTitle, inputAuthor, inputYear, inputEntityType, inputEntryDate)
 {
     School = inputSchool;
     ThesisEntityType = inputThesisEntityType;
 }
Ejemplo n.º 22
0
 public AAnimate(EntityType type, string texture_path, int width, int height, float posx, float posy, float speed)
     : base(type, texture_path, posx, posy, speed)
 {
     Width = width;
     Height = height;
     sprite = new SpriteSheet(Defaults.MOUVEMENT_PHASE_MIDDLE, Defaults.MOUVEMENT_DIRECTION_DOWN, Width, Height);
 }
Ejemplo n.º 23
0
 public AAnimate(SpriteSheet sp, EntityType type, string texture_path, float posx, float posy, float speed)
     : base(type, texture_path, posx, posy, speed)
 {
     sprite = sp;
     Width = sp.getWidth();
     Height = sp.getHeight();
 }
Ejemplo n.º 24
0
        private static void AppendDescriptionUsingContext(DbContext context, StringBuilder builder, EntityType type, ActionType aType, object entity)
        {
            string additionalInfo = string.Empty;
            string identity = string.Empty;
            var enrty = context.Entry(entity);

            var prop =
                enrty.Entity.GetType()
                    .GetProperties()
                    .FirstOrDefault(c => c.GetCustomAttributes(typeof(KeyAttribute), true).FirstOrDefault() != null);
            var name = enrty.Entity.GetType().GetProperties().FirstOrDefault(c => c.Name.Contains("Name"));

            identity = CreateIdentityString(entity, prop, identity, name);

            if (aType == ActionType.Updating)
            {
                additionalInfo = string.Format("Были изменены следующие поля: {0}",
                    string.Join(",", enrty.CurrentValues.PropertyNames));
            }

            if (aType != ActionType.Import || aType != ActionType.Export)
            {
                builder.Append(string.Format("Сущность \"{0}\" {1} была {2}.{3}", type.GetEntityTypeName(), identity,
                    aType.GetActionTypeName(), additionalInfo));
            }
        }
        /// <summary>
        /// Gets the specified <see cref="Rock.Model.EntityType"/> by the object type. If a match is not found, it can optionally create a new <see cref="Rock.Model.EntityType"/> for the object.
        /// </summary>
        /// <param name="type">The <see cref="System.Type"/> to search for.</param>
        /// <param name="createIfNotFound">A <see cref="System.Boolean"/> value that indicates if a new <see cref="Rock.Model.EntityType"/> should be created if a match is not found. This value
        /// will be <c>true</c> if a new <see cref="Rock.Model.EntityType"/> should be created if there is not a match; otherwise <c>false</c>/</param>
        /// <param name="personAlias">A <see cref="Rock.Model.PersonAlias"/> representing the alias of the <see cref="Rock.Model.Person"/> who is searching for and possibly creating a new EntityType.  This value can be
        /// null if the logged in person is not known (i.e. an anonymous user).</param>
        /// <returns>A <see cref="Rock.Model.EntityType"/> matching the provided type. If a match is not found and createIfNotFound is false this value will be null.</returns>
        public EntityType Get( Type type, bool createIfNotFound, PersonAlias personAlias )
        {
            var entityType = Get( type.FullName );
            if ( entityType != null )
            {
                return entityType;
            }

            if ( createIfNotFound )
            {
                // Create a new context so type can be saved independing of current context
                using ( var rockContext = new RockContext() )
                {
                    var EntityTypeService = new EntityTypeService( rockContext );
                    entityType = new EntityType();
                    entityType.Name = type.FullName;
                    entityType.FriendlyName = type.Name.SplitCase();
                    entityType.AssemblyName = type.AssemblyQualifiedName;
                    EntityTypeService.Add( entityType );
                    rockContext.SaveChanges();
                }

                // Read type using current context
                return this.Get( entityType.Id );
            }

            return null;
        }
Ejemplo n.º 26
0
 public static EntityType EntityType()
 {
     var entityType = new EntityType(typeof(IntKeysPoco));
     entityType.AddProperty("PartitionID", typeof(int)).SetColumnName("PartitionKey");
     entityType.AddProperty("RowID", typeof(int)).SetColumnName("RowKey");
     return entityType;
 }
Ejemplo n.º 27
0
        public void StartImport(EntityType entityType, String CSVFileURI, String importSettingsJSON)
        {
            ImportFromCSV.Start(entityType, CSVFileURI, importSettingsJSON);

            var action = GetMessageAction(entityType);
            MessageService.Send(HttpContext.Current.Request, action);
        }
        private EntityType RemoveEntityType(EntityType entityType)
        {
            var referencingForeignKey = entityType.GetDeclaredReferencingForeignKeys().FirstOrDefault();
            if (referencingForeignKey != null)
            {
                throw new InvalidOperationException(
                    CoreStrings.EntityTypeInUseByForeignKey(
                        entityType.DisplayName(),
                        "{" + string.Join(", ", referencingForeignKey.Properties.Select(p => "'" + p.Name + "'")) + "}",
                        referencingForeignKey.DeclaringEntityType.DisplayName()));
            }

            var derivedEntityType = entityType.GetDirectlyDerivedTypes().FirstOrDefault();
            if (derivedEntityType != null)
            {
                throw new InvalidOperationException(
                    CoreStrings.EntityTypeInUseByDerived(
                        entityType.DisplayName(),
                        derivedEntityType.DisplayName()));
            }

            var removed = _entityTypes.Remove(entityType.Name);
            entityType.Builder = null;

            return entityType;
        }
Ejemplo n.º 29
0
		public override bool Resolve(ICollection<IEntity> resultingSet, string name, EntityType typesToConsider)
		{
			bool found = false;
			foreach (InternalModule m in InternalModules())
			{
				if (string.IsNullOrEmpty(m.Namespace))
				{
					if (m.Resolve(resultingSet, name, typesToConsider))
						found = true;
					continue;
				}

				if (!HasNamespacePrefix(m, name))
					continue;

				if (m.Namespace.Length == name.Length)
				{
					resultingSet.Add(m.ModuleMembersNamespace);
					found = true;
					continue;
				}

				if (m.Namespace[name.Length] == '.')
				{
					resultingSet.Add(new PartialModuleNamespace(name, m));
					found = true;
					continue;
				}
			}
			return found;
		}
        /// <summary>
        ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
        ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
        ///     any release. You should only use it directly in your code with extreme caution and knowing that
        ///     doing so can result in application failures when updating to a new Entity Framework Core release.
        /// </summary>
        public virtual Expression BindNavigation(INavigation navigation, bool clientEval)
        {
            if (!EntityType.IsAssignableFrom(navigation.DeclaringEntityType) &&
                !navigation.DeclaringEntityType.IsAssignableFrom(EntityType))
            {
                throw new InvalidOperationException(
                          $"Called EntityProjectionExpression.GetNavigation() with incorrect INavigation. EntityType:{EntityType.DisplayName()}, Navigation:{navigation.Name}");
            }

            if (!_navigationExpressionsCache.TryGetValue(navigation, out var expression))
            {
                if (navigation.IsCollection())
                {
                    expression = new ObjectArrayProjectionExpression(navigation, AccessExpression);
                }
                else
                {
                    expression = new EntityProjectionExpression(
                        navigation.GetTargetType(),
                        new ObjectAccessExpression(navigation, AccessExpression));
                }

                _navigationExpressionsCache[navigation] = expression;
            }

            if (!clientEval &&
                expression.Name.Length == 0)
            {
                // Non-persisted navigation can't be translated
                return(null);
            }

            return((Expression)expression);
        }
        /// <summary>
        ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
        ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
        ///     any release. You should only use it directly in your code with extreme caution and knowing that
        ///     doing so can result in application failures when updating to a new Entity Framework Core release.
        /// </summary>
        public virtual Expression BindProperty(IProperty property, bool clientEval)
        {
            if (!EntityType.IsAssignableFrom(property.DeclaringEntityType) &&
                !property.DeclaringEntityType.IsAssignableFrom(EntityType))
            {
                throw new InvalidOperationException(
                          $"Called EntityProjectionExpression.GetProperty() with incorrect IProperty. EntityType:{EntityType.DisplayName()}, Property:{property.Name}");
            }

            if (!_propertyExpressionsCache.TryGetValue(property, out var expression))
            {
                expression = new KeyAccessExpression(property, AccessExpression);
                _propertyExpressionsCache[property] = expression;
            }

            if (!clientEval &&
                expression.Name.Length == 0)
            {
                // Non-persisted property can't be translated
                return(null);
            }

            return((Expression)expression);
        }
Ejemplo n.º 32
0
        /// <summary>
        /// Gets the .NET type from the AQD.Model.EntityType specified.
        /// </summary>
        /// <param name="typeOfEntity">The type of entity.</param>
        /// <returns>.NET type fo the entity or null if not found</returns>
        public static Type GetTypeFromEntityTypeEnum(EntityType typeOfEntity)
        {
            var ef = EntityFactoryFactory.GetFactory(typeOfEntity);

            return(ef != null?ef.Create().GetType() : null);
        }
Ejemplo n.º 33
0
 public AttackData(EntityType victim, EntityType attacker, bool entityKilled)
 {
     this.victim       = victim;
     this.attacker     = attacker;
     this.entityKilled = entityKilled;
 }
Ejemplo n.º 34
0
 public bool Resolve(ICollection <IEntity> resultingSet, string name, EntityType typesToConsider)
 {
     return(BaseType.Resolve(resultingSet, name, typesToConsider));
 }
Ejemplo n.º 35
0
 public static RelationalEntityTypeAnnotations MySQL(this EntityType entityType)
 {
     return((RelationalEntityTypeAnnotations)MySQL((IEntityType)entityType));
 }
Ejemplo n.º 36
0
 public override bool Resolve(ICollection <IEntity> resultingSet, string name, EntityType flags)
 {
     return(false);
 }
        private static Expression <Func <T, IEnumerable <TChild> > > GetRootEntityToChildCollectionSelector <T, TChild>(EntityType cSpaceType)
            where T : class
            where TChild : class
        {
            var parameter        = Expression.Parameter(typeof(T), "t");
            var memberExpression = Expression.Property(parameter, cSpaceType.NavigationProperties.First(p => p.ToEndMember.GetEntityType().Name == typeof(TChild).Name).Name);
            var lambdaExpression = Expression.Lambda <Func <T, IEnumerable <TChild> > >(memberExpression, parameter);

            return(lambdaExpression);
        }
Ejemplo n.º 38
0
        override public bool Resolve(ICollection <IEntity> resultingSet, string name, EntityType typesToConsider)
        {
            bool found = base.Resolve(resultingSet, name, typesToConsider);

            foreach (TypeReference baseType in _node.BaseTypes)
            {
                if (TypeSystemServices.GetType(baseType).Resolve(resultingSet, name, typesToConsider))
                {
                    found = true;
                }
            }

            if (!found)
            {
                // also look in System.Object
                if (BaseType.Resolve(resultingSet, name, typesToConsider))
                {
                    found = true;
                }
            }
            return(found);
        }
Ejemplo n.º 39
0
 public override bool Resolve(System.Collections.Generic.ICollection <IEntity> resultingSet, string name, EntityType typesToConsider)
 {
     return(Namespaces.ResolveCoalescingNamespaces(this, Delegates, name, typesToConsider, resultingSet));
 }
Ejemplo n.º 40
0
        public void RegularUserMakesAChangeIsLogged()
        {
            var toDelete = new List <long>();

            try
            {
                var userAccount = Entity.Create <UserAccount>();
                userAccount.Name = "Test user " + Guid.NewGuid().ToString();
                userAccount.Save();
                toDelete.Add(userAccount.Id);

                new AccessRuleFactory()
                .AddAllowByQuery(
                    userAccount.As <Subject>(),
                    UserResource.UserResource_Type.As <SecurableEntity>(),
                    new EntityRef[] { new EntityRef("core:create") },
                    TestQueries.EntitiesWithName("Creatable").ToReport());

                new AccessRuleFactory()
                .AddAllowByQuery(
                    userAccount.As <Subject>(),
                    UserResource.UserResource_Type.As <SecurableEntity>(),
                    new EntityRef[] { new EntityRef("core:modify") },
                    TestQueries.EntitiesWithName("bob").ToReport());

                var entityType = new EntityType {
                    Name = "Creatable"
                };
                entityType.Inherits.Add(UserResource.UserResource_Type);
                entityType.Save();
                toDelete.Add(entityType.Id);

                var policy = new RecordChangeAuditPolicy()
                {
                    Name = "TEST ResourceAuditEventHandlerTests RegularUserMakesAChangeIsLogged", TriggeredOnType = entityType, TriggerEnabled = true
                };
                policy.UpdatedFieldsToTriggerOn.Add(Resource.Description_Field.Cast <Field>());
                policy.Save();
                toDelete.Add(policy.Id);

                var log = RunAndLog(() =>
                {
                    using (new SetUser(userAccount))
                    {
                        var entity = Entity.Create(entityType);
                        entity.SetField(Resource.Name_Field.As <Field>(), "bob");
                        entity.SetField(Resource.Description_Field.As <Field>(), "first");
                        entity.Save();
                        toDelete.Add(entity.Id);

                        entity = entity.AsWritable();
                        entity.SetField(Resource.Description_Field.As <Field>(), "second");
                        entity.Save();
                    }
                });


                Assert.That(log.Count, Is.EqualTo(2));
                Assert.That(log[0].Description, Is.EqualTo("[Description] set to 'first'"));
                Assert.That(log[1].Description, Is.EqualTo("[Description] changed from 'first' -> 'second'"));
            }
            finally
            {
                Entity.Delete(toDelete);
            }
        }
Ejemplo n.º 41
0
        public static Entity Create(this EntityType entityType, World world)
        {
            Entity entity = null;

            switch (entityType)
            {
            case EntityType.None:
                return(null);

            case EntityType.Chicken:
                entity = new Chicken(world);
                break;

            case EntityType.Cow:
                entity = new Cow(world);
                break;

            case EntityType.Pig:
                entity = new Pig(world);
                break;

            case EntityType.Sheep:
                entity = new Sheep(world);
                break;

            case EntityType.Wolf:
                entity = new Wolf(world);
                break;

            case EntityType.Villager:
                entity = new Villager(world);
                break;

            case EntityType.MushroomCow:
                entity = new Mooshroom(world);
                break;

            case EntityType.Squid:
                entity = new Squid(world);
                break;

            case EntityType.Rabbit:
                entity = new Rabbit(world);
                break;

            case EntityType.Bat:
                entity = new Bat(world);
                break;

            case EntityType.IronGolem:
                entity = new VillagerGolem(world);
                break;

            case EntityType.SnowGolem:
                entity = new Snowman(world);
                break;

            case EntityType.Ocelot:
                entity = new Ocelot(world);
                break;

            case EntityType.Zombie:
                entity = new Zombie(world);
                break;

            case EntityType.Creeper:
                entity = new Creeper(world);
                break;

            case EntityType.Skeleton:
                entity = new Skeleton(world);
                break;

            case EntityType.Spider:
                entity = new Spider(world);
                break;

            case EntityType.ZombiePigman:
                entity = new ZombiePigman(world);
                break;

            case EntityType.Slime:
                entity = new Slime(world);
                break;

            case EntityType.Endermite:
                entity = new Endermite(world);
                break;

            case EntityType.Enderman:
                entity = new Enderman(world);
                break;

            case EntityType.Silverfish:
                entity = new Silverfish(world);
                break;

            case EntityType.CaveSpider:
                entity = new CaveSpider(world);
                break;

            case EntityType.Ghast:
                entity = new Ghast(world);
                break;

            case EntityType.MagmaCube:
                entity = new MagmaCube(world);
                break;

            case EntityType.Blaze:
                entity = new Blaze(world);
                break;

            case EntityType.ZombieVillager:
                entity = new ZombieVillager(world);
                break;

            case EntityType.Witch:
                entity = new Witch(world);
                break;

            case EntityType.Stray:
                entity = new Stray(world);
                break;

            case EntityType.Husk:
                entity = new Husk(world);
                break;

            case EntityType.WitherSkeleton:
                entity = new WitherSkeleton(world);
                break;

            case EntityType.Guardian:
                entity = new Guardian(world);
                break;

            case EntityType.ElderGuardian:
                entity = new ElderGuardian(world);
                break;

            case EntityType.Horse:
                entity = new Horse(world);
                break;

            case EntityType.ZombieHorse:
                entity = new ZombieHorse(world);
                break;

            case EntityType.PolarBear:
                entity = new PolarBear(world);
                break;

            case EntityType.Shulker:
                entity = new Shulker(world);
                break;

            case EntityType.EnderDragon:
                entity = new EnderDragon(world);
                break;

            case EntityType.SkeletonHorse:
                entity = new SkeletonHorse(world);
                break;

            case EntityType.Wither:
                entity = new Wither(world);
                break;

            case EntityType.Evoker:
                entity = new EvocationIllager(world);
                break;

            case EntityType.Vindicator:
                entity = new VindicationIllager(world);
                break;

            case EntityType.Vex:
                entity = new Vex(world);
                break;

            case EntityType.FallingBlock:
                entity = new EntityFallingBlock(world);
                break;

            case EntityType.ArmorStand:
                entity = new EntityArmorStand(world, null);
                break;

            case EntityType.Arrow:
                entity = new ArrowEntity(world, null);
                break;

            case EntityType.Item:
                entity = new ItemEntity(world);
                break;

            case EntityType.Mooshroom:
                entity = new Mooshroom(world);
                break;

            case EntityType.Snowball:
                entity = new SnowballEntity(world, null);
                break;

            case EntityType.ThrownEgg:
                entity = new EggEntity(world, null);

                break;

            case EntityType.Donkey:
                entity = new Donkey(world);
                break;

            case EntityType.Llama:
                entity = new Llama(world);
                break;

            case EntityType.Mule:
                entity = new Mule(world);
                break;

            case EntityType.Fox:
                entity = new Fox(world);
                break;

            case EntityType.Parrot:
                entity = new Parrot(world);
                break;

            case EntityType.Phantom:
                entity = new Phantom(world);
                break;

            case EntityType.Bee:
                entity = new Bee(world);
                break;

            case EntityType.LlamaSpit:
                entity = new LlamaSpit(world);
                break;

            case EntityType.Cat:
                entity = new Cat(world);
                break;

            case EntityType.SmallFireball:
                entity = new SmallFireball(world);
                break;

            case EntityType.Fireball:
                entity = new Fireball(world);
                break;

            case EntityType.Dolphin:
                entity = new Dolphin(world);
                break;

            case EntityType.Cod:
                entity = new Cod(world);
                break;

            case EntityType.PufferFish:
                entity = new PufferFish(world);
                break;

            case EntityType.Salmon:
                entity = new Salmon(world);
                break;

            case EntityType.TropicalFish:
                entity = new TropicalFish(world);
                break;

            case EntityType.FireworkRocket:
                entity = new FireworkRocket(world, null);
                break;

            //case EntityType.Human:
            //entity = new PlayerMob("test", world, );
            //	break;
            default:
                return(null);
            }

            return(entity);
        }
Ejemplo n.º 42
0
 /// <summary>
 ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
 ///     directly from your code. This API may change or be removed in future releases.
 /// </summary>
 public virtual bool Apply(InternalEntityTypeBuilder entityTypeBuilder, EntityType oldBaseType)
 => Apply(entityTypeBuilder) != null;
Ejemplo n.º 43
0
        /// <summary>
        /// Adds a message to the AuditLog
        /// </summary>
        /// <param name="merchelloContext">
        /// The merchello context.
        /// </param>
        /// <param name="key">
        /// The key.
        /// </param>
        /// <param name="entityType">
        /// The <see cref="EntityType"/>
        /// </param>
        /// <param name="message">
        /// The message.
        /// </param>
        private static void UpdateAuditLog(IMerchelloContext merchelloContext, Guid key, EntityType entityType, string message)
        {
            if (string.IsNullOrEmpty(message) || key == Guid.Empty)
            {
                return;
            }

            if (!MerchelloConfiguration.Current.Section.EnableLogging)
            {
                return;
            }

            try
            {
                merchelloContext.Services.AuditLogService.CreateAuditLogWithKey(key, entityType, message);
            }
            catch (Exception ex)
            {
                LogHelper.Error(typeof(SalesHistoryAuditingExtensions), string.Format("Failed to log {0} for entityType {1} with key {2}", message, entityType, key), ex);
            }
        }
 public void SetEntityType(EntityType type)
 {
     _entityType = type;
 }
Ejemplo n.º 45
0
        private IReadOnlyList <Property> GetCompatiblePrimaryKeyProperties(EntityType dependentEntityType, EntityType principalEntityType, IReadOnlyList <Property> propertiesToReference)
        {
            var dependentPkProperties = dependentEntityType.FindPrimaryKey()?.Properties;

            if (dependentPkProperties != null &&
                ForeignKey.AreCompatible(
                    propertiesToReference,
                    dependentPkProperties,
                    principalEntityType,
                    dependentEntityType,
                    shouldThrow: false))
            {
                return(dependentPkProperties);
            }

            return(null);
        }
Ejemplo n.º 46
0
 /// <summary>
 /// The log.
 /// </summary>
 /// <param name="key">
 /// The key.
 /// </param>
 /// <param name="entityType">
 /// The entity type.
 /// </param>
 /// <param name="message">
 /// The message.
 /// </param>
 internal static void UpdateAuditLog(Guid key, EntityType entityType, string message)
 {
     UpdateAuditLog(MerchelloContext.Current, key, entityType, message);
 }
Ejemplo n.º 47
0
 /// <summary>
 ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
 ///     directly from your code. This API may change or be removed in future releases.
 /// </summary>
 public override object this[string propertyName]
 {
     get { return(GetValueInternal(EntityType.GetProperty(propertyName))); }
     set { SetValueInternal(EntityType.GetProperty(propertyName), value); }
 }
Ejemplo n.º 48
0
 /// <summary>
 ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
 ///     directly from your code. This API may change or be removed in future releases.
 /// </summary>
 public override object this[IProperty property]
 {
     get { return(GetValueInternal(EntityType.CheckPropertyBelongsToType(property))); }
     set { SetValueInternal(EntityType.CheckPropertyBelongsToType(property), value); }
 }
Ejemplo n.º 49
0
 public void AddEntity(DbObjectKey key, EntityType type)
 {
     _entityLookup.Add(key, type);
     _reverseEntityLookup.Add(type, key);
 }
Ejemplo n.º 50
0
 /// <summary>
 /// Gets the member of the specified type with the specified name, assuming there is only one.
 /// </summary>
 private IEntity GetMember(IType type, string name, EntityType entityType)
 {
     return(NameResolutionService.ResolveMember(type, name, entityType));
 }
Ejemplo n.º 51
0
 /// <summary>
 /// Gets the CLR instance type for the specified entity type.
 /// </summary>
 /// <param name="entity">The entity type to get the instance type for.</param>
 /// <param name="canReflectOnInstanceType">true if reflection over the instance type is allowed; otherwise false.</param>
 /// <returns>The CLR instance type to use.</returns>
 protected override Type GetEntityInstanceType(EntityType entity, out bool canReflectOnInstanceType)
 {
     canReflectOnInstanceType = false;
     return(typeof(DSPResource));
 }
Ejemplo n.º 52
0
            public EntitySet GetEntitySet(RelationshipEndMember end)
            {
                EntityType type = RelationshipEndTypeLookup[end];

                return(EntityTypeToSet[type]);
            }
Ejemplo n.º 53
0
 /// <summary>
 /// Add the stored Number to the entities' memory
 /// </summary>
 public MemoryTask(EntityType type)
 {
     _type = type;
 }
Ejemplo n.º 54
0
 public DamageNumberTask(EntityType type, bool spellDmg = false)
 {
     Type     = type;
     SpellDmg = spellDmg;
 }
Ejemplo n.º 55
0
 /// <summary>
 /// Process the given action with the memory of entities
 /// </summary>
 public MemoryTask(EntityType type, Action <IPlayable, IList <int> > action)
 {
     _type   = type;
     _action = action;
 }
Ejemplo n.º 56
0
 /// <summary>
 /// Copies the memory of the given entity to the stack.
 /// </summary>
 /// <param name="type"></param>
 public MemoryToNumbersTask(EntityType type)
 {
     _type = type;
 }
Ejemplo n.º 57
0
        public void RelNameChangeDoesNotBreakExistingPolicy()
        {
            var toDelete = new List <long>();

            try
            {
                var parentType = new EntityType {
                    Name = "dummy parent type"
                };
                parentType.Save();
                toDelete.Add(parentType.Id);

                var childType = new EntityType {
                    Name = "dummy child type"
                };
                childType.Save();
                toDelete.Add(childType.Id);

                var rel = new Relationship {
                    Name = "test rel", FromType = parentType, ToType = childType, Cardinality_Enum = CardinalityEnum_Enumeration.OneToOne
                };
                rel.Save();
                toDelete.Add(rel.Id);

                var policy = new RecordChangeAuditPolicy()
                {
                    Name = "TEST ResourceAuditEventHandlerTests CascadeDeleteOfRelated", TriggeredOnType = parentType, TriggerEnabled = true
                };
                policy.UpdatedRelationshipsToTriggerOn.Add(rel);
                policy.Save();
                toDelete.Add(policy.Id);

                rel      = rel.AsWritable <Relationship>();
                rel.Name = "renamed rel";
                rel.Save();

                var child = Entity.Create(childType);
                child.SetField(Resource.Name_Field, "child");
                child.Save();
                toDelete.Add(child.Id);

                var parent = Entity.Create(parentType);
                parent.Save();
                toDelete.Add(parent.Id);

                var log = RunAndLog(() =>
                {
                    parent = parent.AsWritable();
                    parent.GetRelationships(rel).Add(child);
                    parent.Save();
                });

                Assert.That(log.Count, Is.EqualTo(1));

                var logEntry = log[0].As <RecordChangeLogEntry>();
                Assert.That(logEntry.Description, Is.EqualTo("[renamed rel] set to 'child'"));
            }
            finally
            {
                Entity.Delete(toDelete);
            }
        }
Ejemplo n.º 58
0
 public virtual bool Resolve(ICollection <IEntity> resultingSet, string name, EntityType typesToConsider)
 {
     return(My <NameResolutionService> .Instance.Resolve(name, GetMembers(), typesToConsider, resultingSet));
 }
Ejemplo n.º 59
0
        void TestRelationship(Func <EntityType, EntityType, Relationship> createRelFn, Action <RecordChangeAuditPolicy, EntityType, EntityType> setPolicyAction, Action <Resource, Resource, Relationship> updateAction, string expected)
        {
            var toDelete = new List <long>();

            try
            {
                var rType1 = new EntityType()
                {
                    Name = "rType1"
                };
                rType1.Inherits.Add(Resource.Resource_Type);
                rType1.Save();
                toDelete.Add(rType1.Id);

                var rType2 = new EntityType()
                {
                    Name = "rType2"
                };
                rType2.Inherits.Add(Resource.Resource_Type);
                rType2.Save();
                toDelete.Add(rType2.Id);

                var rel = createRelFn(rType1, rType2);

                rel.Save();
                toDelete.Add(rel.Id);

                var policy = new RecordChangeAuditPolicy()
                {
                    Name = "TEST ResourceAuditEventHandlerTests ForwardLookup", TriggerEnabled = true
                };
                policy.UpdatedRelationshipsToTriggerOn.Add(rel);
                setPolicyAction(policy, rType1, rType2);
                policy.Save();
                toDelete.Add(policy.Id);

                var r1 = Entity.Create(rType1).As <Resource>();
                r1.Name = "r1";
                r1.Save();

                var r2 = Entity.Create(rType2).As <Resource>();
                r2.Name = "r2";
                r2.Save();

                var log = RunAndLog(() =>
                {
                    updateAction(r1, r2, rel);
                });

                Assert.That(log.Count, Is.EqualTo(1));

                var logEntry = log[0].As <RecordChangeLogEntry>();

                Assert.That(logEntry, Is.Not.Null);

                Assert.That(logEntry.Description, Is.StringContaining(expected));
            }
            finally
            {
                Entity.Delete(toDelete);
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="SimpleConcreteGestureInputPlayable"/> class.
 /// </summary>
 /// <param name="mst">The MST.</param>
 /// <param name="mask">The mask.</param>
 /// <param name="et">The et.</param>
 public SimpleConcreteGestureInputPlayable(GestureType gestureType, Action<GestureSample> mst = null, InputMask mask = InputMask.GSYSTEM, EntityType et = Input.EntityType.TOOLS)
 {
     this.GestureType = gestureType;
     this.GestureFired += mst;
     this.EntityType = et;
     this.mask = mask;
 }