예제 #1
0
파일: TestType.cs 프로젝트: ywcsz/modSIC
        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();
        }
예제 #2
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;
 }