Exemplo n.º 1
0
        protected T fieldInstance <T>(ApplicationField genericField, string externalId = null, int?fieldId = null)
            where T : ApplicationField, new()
        {
            T specificField = new T();

            if (genericField != null)
            {
                foreach (var property in genericField.GetType().GetProperties())
                {
                    var jsonAttribute =
                        ((JsonPropertyAttribute[])property.GetCustomAttributes(typeof(JsonPropertyAttribute), false));
                    if (jsonAttribute.Length > 0)
                    {
                        specificField.GetType()
                        .GetProperty(property.Name)
                        .SetValue(specificField, property.GetValue(genericField, null), null);
                    }
                }
            }
            return(specificField);
        }
Exemplo n.º 2
0
 private void SetFieldType(ApplicationField field)
 {
     if (field.GetType() == typeof(TextApplicationField))
     {
         field.Type = "text";
     }
     if (field.GetType() == typeof(NumericApplicationField))
     {
         field.Type = "number";
     }
     if (field.GetType() == typeof(StateApplicationField))
     {
         field.Type = "state";
     }
     if (field.GetType() == typeof(ImageApplicationField))
     {
         field.Type = "image";
     }
     if (field.GetType() == typeof(DateApplicationField))
     {
         field.Type = "date";
     }
     if (field.GetType() == typeof(AppReferenceApplicationField))
     {
         field.Type = "app";
     }
     if (field.GetType() == typeof(MoneyApplicationField))
     {
         field.Type = "money";
     }
     if (field.GetType() == typeof(ProgressApplicationField))
     {
         field.Type = "progress";
     }
     if (field.GetType() == typeof(LocationApplicationField))
     {
         field.Type = "location";
     }
     if (field.GetType() == typeof(DurationApplicationField))
     {
         field.Type = "duration";
     }
     if (field.GetType() == typeof(ContactApplicationField))
     {
         field.Type = "contact";
     }
     if (field.GetType() == typeof(CalculationApplicationField))
     {
         field.Type = "calculation";
     }
     if (field.GetType() == typeof(EmbedApplicationField))
     {
         field.Type = "embed";
     }
     if (field.GetType() == typeof(QuestionApplicationField))
     {
         field.Type = "question";
     }
     if (field.GetType() == typeof(CategoryApplicationField))
     {
         field.Type = "category";
     }
     if (field.GetType() == typeof(FileApplicationField))
     {
         field.Type = "file";
     }
     if (field.GetType() == typeof(EmailApplicationField))
     {
         field.Type = "email";
     }
     if (field.GetType() == typeof(PhoneApplicationField))
     {
         field.Type = "tel";
     }
 }