Esempio n. 1
0
        private PropertyInfo GetPropertyInfoByName(StateType stateType, string entityName)
        {
            var allStateEntities = stateType.GetType().GetProperties();
            var entity           = allStateEntities.FirstOrDefault(property => property.Name.Equals(entityName));

            Assert.IsNotNull(entity, string.Format("'{0}' entity was not found.", entityName));
            return(entity);
        }
Esempio n. 2
0
        /// <summary>
        /// This method travels all the fields of ItemType comparing with the fields of another itemType.
        /// </summary>
        /// <param name="typeOfItemType">Type of the type of item.</param>
        /// <param name="typeOfStateType">Type of the type of other item.</param>
        /// <returns></returns>
        public bool IsEquals()
        {
            var  stateEntityNameResolver = new StateEntityNameResolver();
            Type typeOfItemType          = itemType.GetType();
            Type typeOfStateType         = stateType.GetType();

            var fiedsOfStateType = typeOfStateType.GetProperties();


            foreach (var field in fiedsOfStateType)
            {
                var valueOfState    = field.GetValue(this.stateType, null);
                var stateEntityName = stateEntityNameResolver.Resolve(field);

                if (valueOfState is EntitySimpleBaseType)
                {
                    if ((EntitySimpleBaseType)valueOfState != null)
                    {
                        var allItemEntities = typeOfItemType.GetProperties();
                        var fieldOfItemType =
                            allItemEntities
                            .FirstOrDefault(x => x.Name.Equals(stateEntityName, StringComparison.InvariantCultureIgnoreCase));
                        if (fieldOfItemType == null)
                        {
                            return(false);
                        }

                        if (!this.ProcessComparations(field, fieldOfItemType))
                        {
                            return(false);
                        }
                    }
                }
                else if (valueOfState is EntityComplexBaseType)
                {
                    if ((EntityComplexBaseType)valueOfState != null)
                    {
                        var fieldOfItemType =
                            typeOfItemType.GetProperties()
                            .FirstOrDefault(x => x.Name.Equals(field.Name, StringComparison.InvariantCultureIgnoreCase));

                        if (fieldOfItemType == null)
                        {
                            return(false);
                        }
                        else
                        {
                            return(ProcessComparisionForComplexEntityType(
                                       (EntityItemRecordType[])fieldOfItemType.GetValue(this.itemType, null),
                                       (EntityStateRecordType)valueOfState));
                        }
                    }
                }
            }
            return(true);
        }
Esempio n. 3
0
        private IEnumerable <string> GetAllStateEntities(StateType state)
        {
            var referencedVariables = new List <string>();

            foreach (var field in state.GetType().GetProperties())
            {
                var stateField = field.GetValue(state, null);

                if (stateField is EntityStateSimpleBaseType)
                {
                    referencedVariables.Add(((EntityStateSimpleBaseType)stateField).var_ref);
                }
                else if (stateField is EntityStateRecordType)
                {
                    var recordFields = ((EntityStateRecordType)stateField).field;
                    referencedVariables.AddRange(recordFields.Select(f => f.var_ref));
                }
            }

            return(referencedVariables.ToArray());
        }