示例#1
0
 internal StructFieldVisitor(
     VisitorFactory <TData> visitorFactory,
     PropertyInfo property,
     ProcessField <TData, TObj, V> process,
     MustVisitStatus mustVisit) : base(visitorFactory, property, process, mustVisit)
 {
 }
        void IMeasurements.UpdateMeasurements()
        {
            if (isUpdated)
            {
                return;
            }
            isUpdated = true;
            ReferenceFrame frame = position.GetParentFrame();

            foreach (IPhysicalField field in fields)
            {
                IPositionObject po = field as IPositionObject;
                IPosition       p  = po.Position;
                ReferenceFrame  ff = po.Position.GetParentFrame();
                ReferenceFrame.GetRelativeFrame(ff, frame, relative);
                double[] r = relative.Position;
                double[,] m = relative.Matrix;
                object[] o = null;
                try
                {
                    o = field[r];
                    fieldValue[field] = o;
                }
                catch (Exception ex)
                {
                    ex.ShowError(10);
                    o = GetFieldValue(field);
                }

                /* if (updatedFields[field])
                 * {
                 *   o = fieldValue[field];
                 * }
                 * else
                 * {
                 *   o = field[r];
                 *   updatedFields[field] = true;
                 *   fieldValue[field] = o;
                 * }*/
                IList <object>       res = results[field];
                IList <ProcessField> pr  = proc[field];
                for (int i = 0; i < o.Length; i++)
                {
                    object       result  = res[i];
                    ProcessField process = pr[i];
                    process(o[i], m, result);
                }
            }
            isUpdated = true;

            /*foreach (IPhysicalField field in fields)
             * {
             *  updatedFields[field] = false;
             * }*/
        }
示例#3
0
 protected void ProcessFields(object obj, ProcessField func, Type[] attrType = null, object user = null)
 {
     // for all non static fields of the object
     foreach (var field in obj.GetType().GetFields(Public | NonPublic | Instance))
     {
         // check if a valid attribute is defined for the field
         if (attrType?.Any(x => field.IsDefined(x)) ?? true)
         {
             // process field
             func(obj, field, user);
         }
     }
 }
        private void CreateMesurements(IPhysicalField field)
        {
            string name = this.GetRelativeName(field as IAssociatedObject) + "_";

            name = name.Replace(".", "_");
            name = name.Replace("/", "_");
            int n = field.Count;
            IList <IMeasurement> lm = new List <IMeasurement>();
            IList <ProcessField> pr = new List <ProcessField>();
            IList <object>       lo = new List <object>();

            dic[field]     = lm;
            proc[field]    = pr;
            results[field] = lo;
            IMeasurement mea = null;

            measures.Clear();
            for (int i = 0; i < n; i++)
            {
                object       result = null;
                ProcessField pf     = null;
                string       na     = name + (i + 1);
                object       type   = field.GetType(i);
                object       tt     = field.GetTransformationType(i);
                if (type is ArrayReturnType)
                {
                    if (tt.Equals(Field3D_Types.CovariantVector))
                    {
                        pf = ProcessCovariantVector;
                    }
                    else
                    {
                        pf = ProcessInvariantVector;
                    }
                    ArrayReturnType art = type as ArrayReturnType;
                    int             dim = art.Dimension[0];
                    result = new double[dim];
                    mea    = new FieldMeasurement(na, type, result);
                }
                else
                {
                    pf     = ProcessSimpleType;
                    result = new object[1];
                    mea    = new FieldMeasurementElement(na, type, result as object[]);
                }
                lm.Add(mea);
                pr.Add(pf);
                lo.Add(result);
                measures.Add(mea);
            }
        }
示例#5
0
        /// <summary> Fill form data to name value collection </summary>
        /// <param name="formData">form data to process</param>
        /// <param name="formFields">form fields</param>
        /// <param name="ps">fields processor method</param>
        protected internal static void FillFormData(NameValueCollection formData, AdaptedResultList formFields, ProcessField ps)
        {
            foreach (AdaptedControlResult field in formFields)
              {
            string fieldName = GetFieldName(field);

            if (!string.IsNullOrEmpty(fieldName))
            {
              if (ps != null)
              {
            formData.Add(ps(fieldName, field.Value));
              }
              else
              {
            formData.Add(fieldName, field.Value);
              }
            }
              }
        }
示例#6
0
        private void HandleProcessFields(EncogFileSection section)
        {
            IList <ProcessField> fields = _script.Process.Fields;
            bool first = true;

            fields.Clear();

            foreach (string line in section.Lines)
            {
                if (!first)
                {
                    IList <string> cols    = EncogFileSection.SplitColumns(line);
                    String         name    = cols[0];
                    String         command = cols[1];
                    var            pf      = new ProcessField(name, command);
                    fields.Add(pf);
                }
                else
                {
                    first = false;
                }
            }
        }
示例#7
0
        /// <summary> Fill form data to name value collection </summary>
        /// <param name="formData">form data to process</param>
        /// <param name="formFields">form fields</param>
        /// <param name="ps">fields processor method</param>
        protected internal static void FillFormData(NameValueCollection formData, AdaptedResultList formFields, ProcessField ps)
        {
            foreach (AdaptedControlResult field in formFields)
            {
                string fieldName = GetFieldName(field);

                if (!string.IsNullOrEmpty(fieldName))
                {
                    if (ps != null)
                    {
                        formData.Add(ps(fieldName, field.Value));
                    }
                    else
                    {
                        formData.Add(fieldName, field.Value);
                    }
                }
            }
        }
示例#8
0
        public async Task <Model.Process.Process> GetByTypeAsync(int processTypeId, string userId)
        {
            Model.Process.Process process = new Model.Process.Process();

            var user = await this.UserManager.FindByIdAsync(userId);

            Model.ProcessType.ProcessType type = this.ProcessTypeService.GetById(processTypeId);
            process.Type = type;

            List <ProcessField> fields = new List <ProcessField>();

            foreach (ProcessTypeField ptField in type.Fields)
            {
                object       value    = null;
                PropertyInfo property = user.GetType().GetProperty(ptField.Type.ToString());
                if (property != null)
                {
                    value = property.GetValue(user);

                    switch (ptField.Type)
                    {
                    case FieldType.Date:
                    case FieldType.BirthDate:
                        value = ((DateTime)value).ToString(@"dd\/MM\/yyyy");
                        break;

                    case FieldType.Gender:
                        value = EnumHelper <Gender> .GetDisplayValue((Gender)Enum.Parse(typeof(Gender), value.ToString()));

                        break;

                    case FieldType.MaritalStatus:
                        value = EnumHelper <MaritalStatus> .GetDisplayValue((MaritalStatus)Enum.Parse(typeof(MaritalStatus), value.ToString()));

                        break;

                    case FieldType.Country:
                        value = user.CountryId.HasValue ? this.CountryService.GetById(user.CountryId.Value).Name : null;
                        break;

                    default:
                        break;
                    }
                }

                ProcessField field = new ProcessField
                {
                    Name       = ptField.Name,
                    IsRequired = ptField.IsRequired,
                    Type       = ptField.Type,
                    Value      = (value == null ? string.Empty : value.ToString())
                };

                fields.Add(field);
            }

            process.Fields = fields;

            List <ProcessDocument> documents = new List <ProcessDocument>();

            foreach (ProcessTypeDocument ptDocument in type.Documents)
            {
                ProcessDocument document = new ProcessDocument
                {
                    Name        = ptDocument.Name,
                    IsRequired  = ptDocument.IsRequired,
                    IsAvailable = false
                };

                documents.Add(document);
            }

            process.Documents = documents;

            return(process);
        }
示例#9
0
 protected virtual void OnFieldCreated(ProcessFieldEventArgs <TParserContext> e)
 {
     ProcessField?.Invoke(this, e);
 }