/// <summary> /// Emit a field. /// </summary> protected virtual void emit(FField f) { if ((f.m_flags & FConst.Storage) != 0) { emitter.emitField("m_" + f.m_name, nname(f.m_type), fieldFlags(f.m_flags)); } }
/// <summary> /// Only emit static fields (stored on body, not interface) /// </summary> protected override void emit(FField f) { if ((f.m_flags & FConst.Static) != 0) { base.emit(f); } }
/// <summary> /// Map fcode field to a sys::Field. /// </summary> private Field map(FPod fpod, FField f) { string name = String.Intern(f.m_name); Type fieldType = m_pod.findType(f.m_type); Facets facets = Facets.mapFacets(m_pod, f.m_attrs.m_facets); return(new Field(this, name, f.m_flags, facets, f.m_attrs.m_lineNum, fieldType)); }
public void ComplexTest() { var form = creator.form; var context = creator.context; var field = creator.fields[0]; Func <Form, bool> allow = (f => true); Func <Form, bool> disallow = (f => false); // create FField input = new FField { SectionId = form.Sections.First().Id, Column = "bb", ParentId = field.Id, FieldType = FieldType.BuiltIn, InputStyle = InputStyle.Input, Position = 0, DefaultValue = "", }; var newFieldId = FieldsServices <Form, Field> .Create(context, form.Id, input, allow); var newField = context.FormCoreFields.Find(newFieldId); creator.UpdateNewID(newField); Assert.AreEqual(field.Label, newField.Label); // update TestBase.CalcVirtualAttributes(context); try { input = new FField { Position = 1, ParentId = newField.Id }; FieldsServices <Form, Field> .Update(context, form.Id, newField.Id, input, allow); Assert.Fail(); }catch (Exception e) { Assert.IsTrue(e is AccessDenied); } input = new FField { Position = 1, ParentId = creator.fields[1].Id }; FieldsServices <Form, Field> .Update(context, form.Id, newField.Id, input, allow); newField = context.FormCoreFields.Find(newField.Id); Assert.AreEqual(1, newField.Position); }
/*public FFieldInfo[] GetFields(object value) { * FObjects<FFieldInfo> infos = new FObjects<FFieldInfo>(); * if (value != null) { * Type type = value.GetType(); * FieldInfo[] fields = type.GetFields(); * foreach (FieldInfo field in fields) { * FFieldInfo fieldInfo = new FFieldInfo(); * fieldInfo.Name = field.Name; * fieldInfo.Value = field.GetValue(value); * collection.Push(fieldInfo); * } * } * return collection; * }*/ public static FField[] GetFields(object value) { FObjects <FField> infos = new FObjects <FField>(); if (value != null) { Type type = value.GetType(); FieldInfo[] fields = type.GetFields(); foreach (FieldInfo field in fields) { FField fieldInfo = new FField(); fieldInfo.Name = field.Name; fieldInfo.Value = field.GetValue(value); infos.Push(fieldInfo); } } return(infos.ToArray()); }