public virtual void Populate(FieldMap fieldMap, Entity entity)
        {
            var fieldsWithNoValueOnEntity = new List<string>();

            var @class = new Class(GetType());
            @class.EachField(delegate(FieldInfo fieldInfo)
                                 {
                                     var uiItem = fieldInfo.GetValue(this) as UIItem;
                                     if (uiItem == null || !ControlDictionary.Instance.IsEditable(uiItem)) return;

                                     string fieldName = fieldMap.GetFieldNameFor(fieldInfo.Name, fieldInfo.FieldType);
                                     if (string.IsNullOrEmpty(fieldName)) return;

                                     try
                                     {
                                         EntityField entityField = entity.Field(fieldName);
                                         if (entityField == null)
                                             fieldsWithNoValueOnEntity.Add(fieldName);
                                         else
                                             entityField.SetValueOn(uiItem);
                                     }
                                     catch (TargetInvocationException e)
                                     {
                                         throw new AppScreenException(
                                             string.Format("Error assigning {0}.{1} to {2}.{3} ", entity.GetType(), fieldName, GetType(), fieldInfo.Name),
                                             e.InnerException);
                                     }
                                 });

            if (fieldsWithNoValueOnEntity.Count == 0) return;

            string message = string.Join(",", fieldsWithNoValueOnEntity.ToArray());
            WhiteLogger.Instance.WarnFormat("Mapping to screen: {0} with {1}, No value specified for fields {2}", this, entity.GetType(), message);
        }
Beispiel #2
0
        public void AddGroupKeepTypeTest()
        {
            // bug found during issue 56 - Group object was losing type after being added
            FieldMap fm = new FieldMap();
            QuickFix.FIX42.News.LinesOfTextGroup linesGroup = new QuickFix.FIX42.News.LinesOfTextGroup();
            linesGroup.Text = new QuickFix.Fields.Text("foo");
            fm.AddGroup(linesGroup);

            var rvGroup = fm.GetGroup(1, Tags.LinesOfText);
            Assert.IsInstanceOf<QuickFix.FIX42.News.LinesOfTextGroup>(rvGroup);
        }
Beispiel #3
0
        public void AddGetGroupTest()
        {
            Group g1 = new Group(100, 200);
            Group g2 = new Group(100, 201);
            FieldMap fm = new FieldMap();
            fm.AddGroup(g1);
            fm.AddGroup(g2);
            Assert.That(fm.GetGroup(1, 100), Is.EqualTo(g1));
            Assert.That(fm.GetGroup(2, 100), Is.EqualTo(g2));

            Assert.Throws(typeof(FieldNotFoundException),
                delegate { fieldmap.GetGroup(0, 101); });
            Assert.Throws(typeof(FieldNotFoundException),
                delegate { fieldmap.GetGroup(3, 100); });
            Assert.Throws(typeof(FieldNotFoundException),
                delegate { fieldmap.GetGroup(1, 101); });
        }
Beispiel #4
0
        protected override void CreateTable(DbDataReader r)
        {
            string type = "text";

            FieldCount = r.FieldCount;
            Values     = new object[FieldCount];
            //InsterStrBuilder
            StringBuilder ISBer = new StringBuilder($@"INSERT INTO {brackets1}{tableName}{brackets2} (");

            for (int i = 0; i < r.FieldCount; i++)
            {
                ISBer.Append(brackets1);
                ISBer.Append(r.GetName(i));
                ISBer.Append(brackets2);
                ISBer.Append(",");
            }
            ISBer.Remove(ISBer.Length - 1, 1);
            ISBer.Append(") VALUES (");
            for (int i = 0; i < r.FieldCount; i++)
            {
                ISBer.Append("{" + i + "},");
            }
            ISBer.Remove(ISBer.Length - 1, 1);
            ISBer.Append(")");
            InsterStr = ISBer.ToString();

            //FieldMap
            for (int i = 0; i < r.FieldCount; i++)
            {
                FieldMap.Add(r.GetName(i), i);
            }

            var cmd = conn.CreateCommand();

            try
            {
                cmd.CommandText = GetCreateTableString(r, type, brackets1, brackets2);
                cmd.ExecuteNonQuery();
            }
            finally
            {
                cmd.Dispose();
            }
        }
Beispiel #5
0
        private void InstantiateFields()
        {
            var i = 0;

            foreach (var field in _gameBoard.Fields)
            {
                var fieldView = _itemPool.GetField();

                // Find the node at the field's position and set it as a parent of this field
                fieldView.transform.SetParent(NodeMap[field.Position].transform);
                fieldView.Init(field, NodeMap[field.Position], NodeMap[field.ConnectedPosition]);
                fieldView.name = "Field " + i++;

                // Keep track of the field in grid space
                // Since fields are undirected, we should add the opposite direction as well
                FieldMap.Add(field.Position, field.Direction, fieldView);
                FieldMap.Add(field.ConnectedPosition, field.Direction.Opposite(), fieldView);
            }
        }
Beispiel #6
0
        /// <summary>
        /// Reads an object from a JToken
        /// </summary>
        /// <remarks>
        /// The method doesn't change the NDOObjectState.
        /// </remarks>
        /// <param name="pc"></param>
        /// <param name="objectState"></param>
        public static void FromJToken(this IPersistenceCapable pc, JToken objectState)
        {
            Type     myType   = pc.GetType();
            FieldMap fm       = new FieldMap(myType);
            Action   setDirty = () => { };

            if (pc != null && pc.NDOObjectState == NDOObjectState.Persistent)
            {
                if (pc.NDOStateManager == null)                  // Tests ohne Persistenz
                {
                    setDirty = () => { pc.NDOObjectState = NDOObjectState.PersistentDirty; }
                }
                ;
                else
                {
                    setDirty = () => { pc.NDOStateManager.MarkDirty(pc); }
                };
            }

            foreach (var dictEntry in fm.PersistentFields)
            {
                if (!(dictEntry.Value is FieldInfo))
                {
                    continue;                       // This are properties of embedded value types or classes. We should extend the code here, to support embedded members.
                }
                FieldInfo fi     = (FieldInfo)dictEntry.Value;
                object    oldObj = fi.GetValue(pc);

                JToken obj = objectState[fi.Name];

                if (obj != null)
                {
                    fi.SetValue(pc, obj.ToObject(fi.FieldType));
                }
            }

            var ndoStateToken = objectState["NDOObjectState"];

            if (ndoStateToken != null)
            {
                pc.NDOObjectState = ndoStateToken.ToObject <NDOObjectState>();
            }
        }
Beispiel #7
0
        private void GetColumnData(TableMap map)
        {
            string       sql  = String.Format(selectColumns, map.TableName);
            SqlStatement stmt = broker.GetStatement(sql);

            stmt.StatementType = StatementType.Select;
            SqlResult sr = stmt.Execute();

            for (int i = 0; i < sr.Rows.Count; i++)
            {
                // returns columns: Field, Type, Null, Key, Default, Extra
                string   columnName = sr.GetString(i, "Field");
                FieldMap fm         = map.GetFieldMapFromColumn(columnName);
                if (fm == null)
                {
                    fm = new FieldMap(map, columnName);
                    map.Fields.Add(fm);
                }
                if (fm != null)
                {
                    string typeinfo = sr.GetString(i, "Type");
                    bool   isUnsigned;
                    fm.SetDbType(ExtractType(typeinfo, out isUnsigned), isUnsigned);
                    if (fm.DbType == (long)MySqlDbType.Enum)
                    {
                        fm.HandleEnumAsString = true;
                    }
                    fm.SetSize(ExtractSize(typeinfo));
                    fm.SetIsNullable(sr.GetString(i, "Null").Equals("YES"));
                    fm.SetIsPrimaryKey(sr.GetString(i, "Key").Equals("PRI"));
                    if (fm.IsPrimaryKey)
                    {
                        fm.SetIsAutoGenerated(sr.GetString(i, "Extra").Equals("auto_increment"));
                    }
                }
                else                 // raise an error if we've detected a database/type mismatch
                {
                    bool hasDefault = sr.GetObject(i, "Default") != null;
                    // TODO disabled due to code restructuring
                    // Check.Verify( isNullable || hasDefault, Error.NoPropertyForNotNullColumn, column, map.Type );
                }
            }
        }
Beispiel #8
0
        public void TestObjectMapTraversal()
        {
            // make sure all types are known (ObjectMap has been created) before we start the test
            ObjectFactory.RegisterAssembly(null, Assembly.GetExecutingAssembly());
            // perform the test
            ObjectMap sourceMap = ObjectFactory.GetMap(null, typeof(MemberPicture));

            Assert.IsNotNull(sourceMap);
            FieldMap sourceField = sourceMap.GetFieldMap("MemberId");

            Assert.IsNotNull(sourceField);
            ObjectMap targetMap = ObjectFactory.GetMap(null, sourceField.ForeignKeyTableName);

            Assert.IsNotNull(targetMap);
            FieldMap targetField = targetMap.GetFieldMapFromColumn(sourceField.ForeignKeyColumnName);

            Assert.IsNotNull(targetField);
            Assert.AreEqual("ListMember.MemberId", targetField.TableColumnName);
        }
Beispiel #9
0
        IDictionary <string, object> MakeDict(IPersistenceCapable pc)
        {
            var      dict    = pc.ToDictionary(pm);
            var      shortId = ((IPersistenceCapable)pc).ShortId();
            var      t       = pc.GetType();
            FieldMap fm      = new FieldMap(t);
            var      mc      = Metaclasses.GetClass(t);

            foreach (var fi in fm.Relations)
            {
                var fiName = fi.Name;
                if (((IPersistenceCapable)pc).NDOGetLoadState(mc.GetRelationOrdinal(fiName)))
                {
                    object relationObj = fi.GetValue(pc);
                    if (relationObj is IList list)
                    {
                        List <object> dictList = new List <object>();
                        foreach (IPersistenceCapable relObject in list)
                        {
                            shortId = ((IPersistenceCapable)relObject).ShortId();
                            dictList.Add(new { _oid = shortId });
                        }
                        dict.Add(fiName, dictList);
                    }
                    else
                    {
                        // Hollow object means, that we don't want to transfer the object to the other side.
                        if (relationObj == null || ((IPersistenceCapable)relationObj).NDOObjectState == NDOObjectState.Hollow)
                        {
                            dict.Add(fiName, null);
                        }
                        else
                        {
                            IPersistenceCapable relIPersistenceCapable = (IPersistenceCapable)relationObj;
                            shortId = ((IPersistenceCapable)relIPersistenceCapable).ShortId();
                            dict.Add(fiName, new { _oid = shortId });
                        }
                    }
                }
            }

            return(dict);
        }
 public DataTableBuilder(Schema schema)
 {
     _schema        = schema;
     _fieldMap      = null;
     _fieldOrder    = 0;
     _rowIndex      = 0;
     _rowCountLimit = int.MaxValue;
     _rowRef        = _schema.rangeStartRef;
     _rows          = new List <string[]>();
     _rows.Add(new string[schema.fieldCount]);
     if (_schema.isRotated)
     {
         tryAppendCell = _TryAppendCellToRight;
     }
     else
     {
         tryAppendCell = _TryAppendCellToDown;
     }
 }
        public void Visit(FieldMap fieldMap)
        {
            if (!fieldMap.IsIdentifier)
            {
                return;
            }

            if (IndentifierField != null)
            {
                throw new ArgumentException("There are multiple identifying fields defined on the model map being visited.");
            }

            IndentifierField = new ModelMapFieldDetails
            {
                FieldName       = fieldMap.FieldNames.First(),
                Property        = fieldMap.Property,
                SchemaFieldType = getSchemaFieldType(fieldMap)
            };
        }
Beispiel #12
0
        public AssignmentGenerator(Class cls)
        {
            this.provider = cls.Provider;
            FieldMap fm = new FieldMap(cls);

            foreach (var e in fm.PersistentFields)
            {
                if (e.Value.CustomAttributes.Any(c => c.AttributeType == typeof(NDOReadOnlyAttribute)))
                {
                    continue;
                }

                var fieldMapping = cls.FindField((string)e.Key);
                if (fieldMapping != null)
                {
                    fields.Add(fieldMapping.Column.Name);
                }
            }

            var relationInfos = new RelationCollector(cls).CollectRelations().ToList();

            foreach (RelationFieldInfo ri in relationInfos)
            {
                Relation r = ri.Rel;
                if (r.Multiplicity == RelationMultiplicity.Element && r.MappingTable == null ||
                    r.Multiplicity == RelationMultiplicity.List && r.MappingTable == null && r.Parent.FullName != cls.FullName)
                {
                    foreach (ForeignKeyColumn fkColumn in r.ForeignKeyColumns)
                    {
                        fields.Add(fkColumn.Name);
                        Type systemType = fkColumn.SystemType;
                    }
                    if (r.ForeignKeyTypeColumnName != null)
                    {
                        fields.Add(r.ForeignKeyTypeColumnName);
                    }
                }
            }
            if (cls.TimeStampColumn != null)
            {
                fields.Add(cls.TimeStampColumn);
            }
        }
Beispiel #13
0
        private void ExportFieldMapData()
        {
            // Reading Palette
            FDPalette palette = new FDPalette(@".\color");

            ShapeDataFile shapeData = new ShapeDataFile(@".\FDSHAP.DAT");

            shapeData.LoadData();

            FieldDataFile fieldData = new FieldDataFile(@".\FDFIELD.DAT");

            fieldData.LoadData();

            for (int m = 0; m < 33; m++)
            {
                FieldMap      map    = fieldData.GetField(m);
                HashSet <int> shapes = new HashSet <int>();
                for (int i = 0; i < map.Width; i++)
                {
                    for (int j = 0; j < map.Height; j++)
                    {
                        var shapeIndex = map.GetShapeIndexAt(i, j);
                        shapes.Add(shapeIndex);
                    }
                }

                var shapePanel = shapeData.GetPanel(m);
                foreach (int shapeIndex in shapes)
                {
                    ShapeInfo shapeInfo = shapePanel.Shapes[shapeIndex];

                    FieldShape shape = new FieldShape();
                    shape.Type             = shapeInfo.Type;
                    shape.BattleGroundId   = shapeInfo.BattleGroundId;
                    map.Shapes[shapeIndex] = shape;
                }

                string mapString = JsonConvert.SerializeObject(map, Formatting.Indented);
                int    mm        = m + 1;
                File.WriteAllText(string.Format(@"D:\Temp\FDII\Chapter_{0}.txt", (mm < 10 ? "0" + mm.ToString() : mm.ToString())), mapString);
            }
        }
Beispiel #14
0
 /// <summary>
 /// 延迟执行数据库交互,并提交到队列
 /// </summary>
 /// <param name="act">要延迟操作的委托</param>
 /// <param name="map">字段映射</param>
 /// <param name="name">表名称</param>
 /// <param name="isExecute">是否立即执行</param>
 public override void AppendLazy(string name, FieldMap map, Action <Queue> act, bool isExecute)
 {
     try
     {
         CreateQueue(name, map);
         if (isExecute)
         {
             act(Queue); return;
         }
         Queue.LazyAct = act;
         if (Queue != null)
         {
             _groupQueueList.Add(Queue);
         }
     }
     finally
     {
         Clear();
     }
 }
Beispiel #15
0
        public void GroupDelimTest()
        {
            Group g1 = new Group(100, 200);

            Assert.AreEqual(100, g1.Field); //counter
            Assert.AreEqual(200, g1.Delim);

            g1.SetField(new StringField(200, "delim!"));

            FieldMap fm = new FieldMap();

            fm.AddGroup(g1);
            Assert.AreEqual(1, fm.GetInt(100));

            Group g2 = new Group(100, 200);

            g2.SetField(new StringField(200, "again!"));
            fm.AddGroup(g2);
            Assert.AreEqual(2, fm.GetInt(100));
        }
Beispiel #16
0
        /// <summary>Crea o asigna el valor de una posicion en una lista de cadenas</summary>
        private void SetField(string field, string value, List <FieldMap> lstFields)
        {
            FieldMap fdmAdd = new FieldMap();

            fdmAdd.name       = field;
            fdmAdd.value      = value;
            fdmAdd.comp       = Query.dbCom.Equals;
            fdmAdd.isModified = true;
            foreach (FieldMap fldM in lstFieldMap)
            {
                if (fldM.name == field)
                {
                    fldM.value      = value;
                    fdmAdd.comp     = Query.dbCom.Equals;
                    fldM.isModified = true;
                    return;
                }
            }
            lstFieldMap.Add(fdmAdd);
        }
Beispiel #17
0
    public void SaveFieldMap()
    {
        BGSCENE_DEF scene = this.fieldMap.scene;

        Byte[] ebgBin          = scene.ebgBin;
        String mapName         = this.fieldMap.mapName;
        String fieldMapModName = FieldMapEditor.GetFieldMapModName(mapName);
        String mapResourcePath = FieldMap.GetMapResourcePath(mapName);

        using (BinaryWriter binaryWriter = new BinaryWriter(new MemoryStream(ebgBin)))
        {
            for (Int32 i = 0; i < (Int32)scene.overlayCount; i++)
            {
                BGOVERLAY_DEF bgoverlay_DEF = scene.overlayList[i];
                UInt32        oriData       = bgoverlay_DEF.oriData;
                UInt16        num           = (UInt16)bgoverlay_DEF.transform.localPosition.z;
                UInt16        num2          = (UInt16)(oriData >> 8 & 4095u);
                UInt32        num3          = oriData;
                UInt32        num4          = 1048320u;
                num3 &= ~num4;
                num3 |= (UInt32)((Int64)((Int64)num << 8) & (Int64)((UInt64)num4));
                global::Debug.Log(String.Concat(new Object[]
                {
                    i,
                    " : data  :",
                    oriData,
                    ", curZ : ",
                    num,
                    ", oriZ : ",
                    num2,
                    ", res : ",
                    num3
                }));
                binaryWriter.BaseStream.Seek(bgoverlay_DEF.startOffset, SeekOrigin.Begin);
                binaryWriter.Write(num3);
            }
        }
        String path = "Assets/Resources/" + mapResourcePath + fieldMapModName + ".bgs.bytes";

        File.WriteAllBytes(path, ebgBin);
    }
Beispiel #18
0
        private void UpdateTableMapWithColumnInformation(TableMap map)
        {
            SqlResult sr = broker.Execute(String.Format(selectColumns, map.TableName), null, null);

            // process result set using columns: cid, name, type, notnull, dflt_value, pk
            for (int i = 0; i < sr.RowsContained; i++)
            {
                string   columnName = sr.GetString(i, "name");
                FieldMap fm         = map.GetFieldMapFromColumn(columnName);
                if (fm == null)
                {
                    fm = new FieldMap(map, columnName);
                    map.Fields.Add(fm);
                }
                // get basic column information
                fm.SetDbType(sr.GetString(i, "type"), false);
                fm.SetIsNullable(!sr.GetBoolean(i, "notnull"));
                fm.SetIsPrimaryKey(sr.GetBoolean(i, "pk"));
                fm.SetIsAutoGenerated(fm.IsPrimaryKey && (fm.Type == typeof(int) || fm.Type == typeof(long)));
            }
        }
Beispiel #19
0
    public void Awake()
    {
        if (Map.current != null)
        {
            Destroy(this.gameObject);
        }
        else
        {
            Map.current = this; current = this;
        }

        xOffset = Random.Range(0, 999999);
        yOffset = Random.Range(0, 999999);

        graph = new HexGraph(radius);
        Generate();
        SpawnTiles();
        setTopography(true);
        Variagate(Color.cyan, Color.red);
        Camera.main.GetComponent <CameraFollow>().maxSize = (radius + 1) * Mathf.Sqrt(2.0f / 3);
    }
Beispiel #20
0
        public void SetPriorityValueMap(MigrationTestEnvironment env, Configuration config)
        {
            // Map P2 to P1
            Value v1 = env.NewValue("2", "1");

            ValueMap vMap = new ValueMap();

            vMap.name = "PriorityValueMap";
            vMap.Value.Add(v1);

            // Map field
            MappedField mField1 = env.NewMappedField(FIELD_PRIORITY, FIELD_PRIORITY);

            mField1.valueMap = vMap.name;

            // Map the rest of the fields using wild card
            MappedField defaultField = env.NewMappedField("*", "*");

            FieldMap fieldMap = new FieldMap();

            fieldMap.name = "BugToBugFieldMap";
            fieldMap.MappedFields.MappedField.Add(defaultField);
            fieldMap.MappedFields.MappedField.Add(mField1);

            // Map work item type
            WorkItemTypeMappingElement typeMapping = new WorkItemTypeMappingElement();

            typeMapping.LeftWorkItemTypeName  = "Bug";
            typeMapping.RightWorkItemTypeName = "Bug";
            typeMapping.fieldMap = fieldMap.name;

            // Build WIT Session custom setting
            WITSessionCustomSetting customSetting = new WITSessionCustomSetting();

            customSetting.WorkItemTypes.WorkItemType.Add(typeMapping);
            customSetting.FieldMaps.FieldMap.Add(fieldMap);
            customSetting.ValueMaps.ValueMap.Add(vMap);

            SetWitSessionCustomSetting(config, customSetting);
        }
Beispiel #21
0
        /// <summary>
        /// Recupera os dados de todas as chaves estrangeiras.
        /// </summary>
        private void GetForeignKeyData()
        {
            DataTable dt = GetForeignKeys(null);

            foreach (DataRow row in dt.Rows)
            {
                string   fkTableName  = (string)row["FK_TABLE_NAME"];
                string   fkColumnName = (string)row["FK_COLUMN_NAME"];
                string   pkTableName  = (string)row["PK_TABLE_NAME"];
                string   pkColumnName = (string)row["PK_COLUMN_NAME"];
                TableMap map          = GetTableMap(fkTableName);
                if (map != null)
                {
                    FieldMap fm = map.GetFieldMapFromColumn(fkColumnName);
                    if (fm != null)
                    {
                        fm.ForeignKeyTableName  = pkTableName;
                        fm.ForeignKeyColumnName = pkColumnName;
                    }
                }
            }
        }
Beispiel #22
0
        void RecursivelyAddAdditionalObjects(IPersistenceCapable e, List <IPersistenceCapable> rootObjects, List <IPersistenceCapable> additionalObjects)
        {
            var      t  = e.GetType();
            FieldMap fm = new FieldMap(t);
            var      mc = Metaclasses.GetClass(t);

            foreach (var fi in fm.Relations)
            {
                if (((IPersistenceCapable)e).NDOGetLoadState(mc.GetRelationOrdinal(fi.Name)))
                {
                    object relationObj = fi.GetValue(e);
                    if (relationObj is IList list)
                    {
                        List <object> dictList = new List <object>();
                        foreach (IPersistenceCapable relIPersistenceCapable in list)
                        {
                            if (!rootObjects.Contains(relIPersistenceCapable) && !additionalObjects.Contains(relIPersistenceCapable))
                            {
                                additionalObjects.Add(relIPersistenceCapable);
                                RecursivelyAddAdditionalObjects(relIPersistenceCapable, rootObjects, additionalObjects);
                            }
                        }
                    }
                    else
                    {
                        // Hollow object means, that we don't want to transfer the object to the other side.
                        if (relationObj != null && ((IPersistenceCapable)relationObj).NDOObjectState != NDOObjectState.Hollow)
                        {
                            IPersistenceCapable relIPersistenceCapable = (IPersistenceCapable)relationObj;
                            if (!rootObjects.Contains(relIPersistenceCapable) && !additionalObjects.Contains(relIPersistenceCapable))
                            {
                                additionalObjects.Add(relIPersistenceCapable);
                                RecursivelyAddAdditionalObjects(relIPersistenceCapable, rootObjects, additionalObjects);
                            }
                        }
                    }
                }
            }
        }
        public void Visit(BeginProperty instruction)
        {
            var key = instruction.Key.Resolve(_services).ToString();

            _propertyDef = new PropertyDefinition
            {
                Key = instruction.Key.Resolve(_services).ToString()
            };

            if (instruction.Field == null)
            {
                return;
            }

            _currentFieldMap = new FieldMap
            {
                Key          = key,
                FieldNames   = new [] { instruction.Field.Resolve(_services).ToString() },
                IsIdentifier = instruction.IsIdentifier,
                PropertyType = PropertyTypes.Parse(instruction.DataType.Resolve(_services).ToString())
            };
        }
Beispiel #24
0
        public static IDictionary <string, object> ToDictionary(this IPersistenceCapable pc, IPersistenceManager pm)
        {
            if (pc == null)
            {
                return(new Dictionary <string, object>());
            }

            if (pm == null)
            {
                var sm = pc.NDOStateManager;
                if (sm == null)
                {
                    throw new Exception("ToDictionary: pm == null und kann nicht aus dem Objekt ermittelt werden.");
                }
                pm = sm.PersistenceManager;
            }

            Type     myType = pc.GetType();
            FieldMap fm     = new FieldMap(myType);
            Dictionary <string, object> result = new Dictionary <string, object>();

            foreach (var dictEntry in fm.PersistentFields)
            {
                MemberInfo mi = (MemberInfo)dictEntry.Value;
                if (!(mi is FieldInfo))
                {
                    continue;                      // This are properties of embedded value types or classes. We should extend the code here, to support embedded members.
                }
                FieldInfo fi = (FieldInfo)dictEntry.Value;

                object obj = fi.GetValue(pc);
                result.Add(dictEntry.Key, obj);
            }

            result.Add("_oid", pc.ShortId());
            result.Add("NDOObjectState", pc.NDOObjectState);
            return(result);
        }
Beispiel #25
0
        private void TestEnvironment_FieldMapToEmpty(Configuration config)
        {
            // Map field
            MappedField mField1 = new MappedField();

            mField1.LeftName    = FIELD_PRIORITY;
            mField1.RightName   = string.Empty;
            mField1.MapFromSide = SourceSideTypeEnum.Left;
            mField1.valueMap    = string.Empty; // set value map name to be empty string

            // Map the rest of the fields using wild card
            MappedField defaultField = new MappedField();

            defaultField.LeftName    = "*";
            defaultField.RightName   = "*";
            defaultField.MapFromSide = SourceSideTypeEnum.Left;

            FieldMap fieldMap = new FieldMap();

            fieldMap.name = "BugToBugFieldMap";
            fieldMap.MappedFields.MappedField.Add(defaultField);
            fieldMap.MappedFields.MappedField.Add(mField1);

            // Map work item type
            WorkItemTypeMappingElement typeMapping = new WorkItemTypeMappingElement();

            typeMapping.LeftWorkItemTypeName  = "Bug";
            typeMapping.RightWorkItemTypeName = "Bug";
            typeMapping.fieldMap = fieldMap.name;

            // Build WIT Session custom setting
            WITSessionCustomSetting customSetting = new WITSessionCustomSetting();

            customSetting.WorkItemTypes.WorkItemType.Add(typeMapping);
            customSetting.FieldMaps.FieldMap.Add(fieldMap);

            SetWitSessionCustomSetting(config, customSetting);
        }
        public async Task ProcessNestedAggregationsWithAliasesAsync()
        {
            var client = GetClient();
            var index  = CreateRandomIndex <MyType>(client, d => d.Dynamic().Properties(p => p
                                                                                        .GeoPoint(g => g.Name(f => f.Field3))
                                                                                        .Object <Dictionary <string, object> >(o1 => o1.Name(f1 => f1.Data).Properties(p1 => p1
                                                                                                                                                                       .Object <object>(o2 => o2.Name("@user").Properties(p2 => p2
                                                                                                                                                                                                                          .Text(f3 => f3.Name("identity")
                                                                                                                                                                                                                                .Fields(f => f.Keyword(k => k.Name("keyword").IgnoreAbove(256))))))))));

            client.IndexMany(new[] { new MyType {
                                         Field1 = "value1"
                                     } }, index);
            await client.Indices.RefreshAsync(index);

            var aliasMap = new FieldMap {
                { "user", "*****@*****.**" }, { "alias1", "field1" }
            };
            var processor    = new ElasticQueryParser(c => c.SetLoggerFactory(Log).UseMappings(client, index).UseFieldMap(aliasMap));
            var aggregations = await processor.BuildAggregationsAsync("terms:(alias1 cardinality:user)");

            var    actualResponse = client.Search <MyType>(d => d.Index(index).Aggregations(aggregations));
            string actualRequest  = actualResponse.GetRequest();

            _logger.LogInformation("Actual: {Request}", actualRequest);

            var expectedResponse = client.Search <MyType>(d => d.Index(index).Aggregations(a => a
                                                                                           .Terms("terms_alias1", t => t.Field("field1.keyword").Meta(m => m.Add("@field_type", "keyword"))
                                                                                                  .Aggregations(a1 => a1.Cardinality("cardinality_user", c => c.Field("*****@*****.**"))))));
            string expectedRequest = expectedResponse.GetRequest();

            _logger.LogInformation("Expected: {Request}", expectedRequest);

            Assert.Equal(expectedRequest, actualRequest);
            Assert.True(actualResponse.IsValid);
            Assert.True(expectedResponse.IsValid);
            Assert.Equal(expectedResponse.Total, actualResponse.Total);
        }
Beispiel #27
0
        void TestEnvironment_InsertTwoFieldMapToSameTargetInMappedField(Configuration config)
        {
            // Map field
            MappedField mField1 = new MappedField();

            mField1.LeftName    = FIELD_PRIORITY;
            mField1.RightName   = FIELD_PRIORITY;
            mField1.MapFromSide = SourceSideTypeEnum.Left;
            mField1.valueMap    = string.Empty; // set value map name to be empty string

            // Map to SAME field again
            MappedField defaultField = new MappedField();

            defaultField.LeftName    = FIELD_AREA_PATH;
            defaultField.RightName   = FIELD_PRIORITY;
            defaultField.MapFromSide = SourceSideTypeEnum.Left;

            FieldMap fieldMap = new FieldMap();

            fieldMap.name = "BugToBugFieldMap";
            fieldMap.MappedFields.MappedField.Add(defaultField);
            fieldMap.MappedFields.MappedField.Add(mField1);

            // Map work item type
            WorkItemTypeMappingElement typeMapping = new WorkItemTypeMappingElement();

            typeMapping.LeftWorkItemTypeName  = "Bug";
            typeMapping.RightWorkItemTypeName = "Bug";
            typeMapping.fieldMap = fieldMap.name;

            // Build WIT Session custom setting
            WITSessionCustomSetting customSetting = new WITSessionCustomSetting();

            customSetting.WorkItemTypes.WorkItemType.Add(typeMapping);
            customSetting.FieldMaps.FieldMap.Add(fieldMap);

            SetWitSessionCustomSetting(config, customSetting);
        }
Beispiel #28
0
        /// <summary>
        /// 取得仅更新的SQL语句
        /// </summary>
        protected virtual string GetSqlCode(TData data)
        {
            StringBuilder sql   = new StringBuilder();
            bool          first = true;

            foreach (var pro in data.__Struct.Properties.Where(p => p.Value.Featrue.HasFlag(PropertyFeatrue.Property)))
            {
                if (!FieldMap.ContainsKey(pro.Value.Name))
                {
                    continue;
                }
                if (first)
                {
                    first = false;
                }
                else
                {
                    sql.Append(',');
                }
                sql.AppendLine($"       `{pro.Value.ColumnName}` = ?{pro.Value.Name}");
            }
            return(first ? null : sql.ToString());
        }
Beispiel #29
0
        /// <summary>
        /// Get calles when Map is displayed.
        /// </summary>
        /// <param name="e">Event Arguments.</param>
        protected override void OnElementChanged(ElementChangedEventArgs <View> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement == null)
            {
                this.mapView = Control as MKMapView;
                this.mapView.ShowsUserLocation      = true;
                this.mapView.DidUpdateUserLocation += this.SetUserPostionOnce;
                this.mapView.AddGestureRecognizer(this.tapGesture);

                /* Readd LFHeatMap project first
                 * Found at https://github.com/TreeWatch/LFHeatMaps
                 * Code:
                 * mapView.RegionChanged += ChangeRegion;
                 */

                this.myMap = e.NewElement as FieldMap;
                this.mapView.OverlayRenderer = this.GetOverlayRender;

                this.AddFields();
            }
        }
Beispiel #30
0
        /// <summary>
        /// Este método preenche os dados das colunas da table.
        /// </summary>
        private void GetColumnData(TableMap map)
        {
            DataTable dt = GetColumns(map.TableName);

            foreach (DataRow row in dt.Rows)
            {
                string   columnName = (string)row["COLUMN_NAME"];
                FieldMap fm         = map.GetFieldMapFromColumn(columnName);
                if (fm == null)
                {
                    fm = new FieldMap(map, columnName);
                    map.Fields.Add(fm);
                }
                fm.IsNullable = Convert.ToBoolean(row["IS_NULLABLE"]);
                OleDbType dbType = (OleDbType)row["DATA_TYPE"];
                fm.SetDbType((long)dbType);
                fm.DbTypeName = dbType.ToString();
                if (dbType == OleDbType.Decimal || dbType == OleDbType.Numeric || dbType == OleDbType.VarNumeric)
                {
                    fm.Size = Convert.ToInt32(row["NUMERIC_PRECISION"]);
                }
                else if (dbType == OleDbType.LongVarBinary || dbType == OleDbType.LongVarChar || dbType == OleDbType.LongVarWChar || dbType == OleDbType.VarBinary || dbType == OleDbType.VarChar || dbType == OleDbType.VarWChar || dbType == OleDbType.WChar || dbType == OleDbType.Char || dbType == OleDbType.BSTR || dbType == OleDbType.Binary)
                {
                    fm.Size = Convert.ToInt32(row["CHARACTER_MAXIMUM_LENGTH"]);
                }
                int  columnFlags    = Convert.ToInt32(row["COLUMN_FLAGS"]);
                int  flags          = (int)DBCOLUMNFLAGS.ISNULLABLE + (int)DBCOLUMNFLAGS.MAYBENULL;
                bool isNullableFlag = (columnFlags & flags) != 0;
                flags = (int)DBCOLUMNFLAGS.WRITE + (int)DBCOLUMNFLAGS.WRITEUNKNOWN;
                bool isReadOnly = (columnFlags & flags) == 0;
                fm.IsReadOnly = isReadOnly;
                if (row["DESCRIPTION"] != DBNull.Value && row["DESCRIPTION"] is string)
                {
                    fm.Comment = row["DESCRIPTION"].ToString();
                }
            }
        }
Beispiel #31
0
        private void SetInvalidFieldValueMap(MigrationTestEnvironment env, Configuration config)
        {
            ValueMap vMap = new ValueMap();

            vMap.name = "PriorityValues";
            var value = env.NewValue("*", "10000");

            vMap.Value.Add(value);

            MappedField mField1 = env.NewMappedField(FIELD_PRIORITY, FIELD_PRIORITY);

            mField1.valueMap = "PriorityValues";

            // Map the rest of the fields using wild card
            MappedField defaultField = env.NewMappedField("*", "*");

            FieldMap fieldMap = new FieldMap();

            fieldMap.name = "BugToBugFieldMap";
            fieldMap.MappedFields.MappedField.Add(defaultField);
            fieldMap.MappedFields.MappedField.Add(mField1);

            WorkItemTypeMappingElement typeMapping = new WorkItemTypeMappingElement();

            typeMapping.LeftWorkItemTypeName  = "Bug";
            typeMapping.RightWorkItemTypeName = "Bug";
            typeMapping.fieldMap = fieldMap.name;

            WITSessionCustomSetting customSetting = new WITSessionCustomSetting();

            customSetting.WorkItemTypes.WorkItemType.Add(typeMapping);
            customSetting.FieldMaps.FieldMap.Add(fieldMap);
            customSetting.ValueMaps.ValueMap.Add(vMap);

            SetWitSessionCustomSetting(config, customSetting);
        }
        private void GetColumnData(TableMap map)
        {
            string    sql = String.Format(selectColumns, map.TableId);
            SqlResult sr  = broker.Execute(sql);

            for (int i = 0; i < sr.Rows.Count; i++)
            {
                string   column = sr.GetString(i, "column_name");
                FieldMap fm     = map.GetFieldMapFromColumn(column);
                if (fm == null)
                {
                    fm = new FieldMap(map, column);
                    map.Fields.Add(fm);
                }

                bool isNullable      = sr.GetString(i, "nulls").Equals("Y");
                bool isAutoGenerated = sr.GetString(i, "default").ToLower() == "autoincrement";
                fm.ColumnId = sr.GetInt(i, "column_id");
                fm.SetDbType(sr.GetString(i, "domain_name"), false);
                fm.SetIsNullable(isNullable);
                fm.SetIsAutoGenerated(isAutoGenerated);
                fm.SetSize(sr.GetInt(i, "width"));
            }
        }
        private static object GetGenericFieldValue(FieldMap fieldMap, ClarifyDataRow record)
        {
            if (fieldMap.FieldNames.Length == 1)
            {
                var fieldName           = fieldMap.FieldNames[0];
                var fieldValueForRecord = record[fieldName];

                if (DBNull.Value.Equals(fieldValueForRecord))
                {
                    fieldValueForRecord = null;
                }

                return(fieldValueForRecord);
            }

            if (fieldMap.FieldNames.Length > 1)
            {
                var recordValues = Array.ConvertAll(fieldMap.FieldNames, x => record[x].ToString());

                return(String.Join(" ", recordValues));
            }

            return(new Exception("No fields were specified for this assignment"));
        }
Beispiel #34
0
 protected int SetGroup(StringField grpNoFld, string msgstr, int pos, FieldMap fieldMap, DataDictionary.IGroupSpec dd,
     DataDictionary.DataDictionary sessionDataDictionary, DataDictionary.DataDictionary appDD)
 {
     return SetGroup(grpNoFld, msgstr, pos, fieldMap, dd, sessionDataDictionary, appDD, null);
 }
Beispiel #35
0
        public static string GetFieldOrDefault(FieldMap fields, int tag, string defaultValue)
        {
            if (!fields.IsSetField(tag))
                return defaultValue;

            try
            {
                return fields.GetField(tag);
            }
            catch (FieldNotFoundException)
            {
                return defaultValue;
            }
        }
Beispiel #36
0
        public string toXMLFields(FieldMap fields, int space)
        {
            StringBuilder s = new StringBuilder();
            string name = string.Empty;

            // fields
            foreach (var f in fields)
            {
                
               s.Append("<field ");
               if ((dataDictionary_ != null) && ( dataDictionary_.FieldsByTag.ContainsKey(f.Key)))
               {
                   s.Append("name=\"" + dataDictionary_.FieldsByTag[f.Key].Name + "\" ");
               }
               s.Append("number=\"" + f.Key.ToString() + "\">");
               s.Append("<![CDATA[" + f.Value.ToString() + "]]>");
               s.Append("</field>");

            }
            // now groups
            List<int> groupTags = fields.GetGroupTags();
            foreach (int groupTag in groupTags)
            {
                for (int counter = 1; counter <= fields.GroupCount(groupTag); counter++)
                {
                    s.Append("<group>");
                    s.Append( toXMLFields( fields.GetGroup(counter, groupTag), space+1));
                    s.Append("</group>");
                }
            }
            
            return s.ToString();
        }
Beispiel #37
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ValidationScope"/> class.
        /// </summary>
        /// <param name="root">The root element of the scope where the initial <see cref="ICollection{IError}"/> has been attached.</param>
        public ValidationScope(FrameworkElement root)
        {
            if (root == null)
            {
                throw new ArgumentNullException("root");
            }

            this.fieldList = new FieldMap();
            this.errorWatcher = new CollectionWatcher<IError, ValidationError>(this.OnAdded, this.OnRemoved, this.OnCleared);
            this.reattachErrorCommand = new RunAfterDispatchCommand(this.ReattachConversionErrors);

            Validation.AddErrorHandler(root, this.HandleDataConversionError);
        }
Beispiel #38
0
 public FieldMapTests()
 {
     this.fieldmap = new FieldMap();
 }
Beispiel #39
0
 public void ClearAndIsEmptyTest()
 {
     FieldMap fieldmap = new FieldMap();
     BooleanField field = new BooleanField(200, true);
     Assert.That(fieldmap.IsEmpty(), Is.EqualTo(true));
     fieldmap.SetField(field);
     Assert.That(fieldmap.IsEmpty(), Is.EqualTo(false));
     fieldmap.Clear();
     Assert.That(fieldmap.IsEmpty(), Is.EqualTo(true));
     Group g = new Group(100, 101);
     fieldmap.AddGroup(g);
     Assert.That(fieldmap.IsEmpty(), Is.EqualTo(false));
     fieldmap.Clear();
     Assert.That(fieldmap.IsEmpty(), Is.EqualTo(true));
 }
 public static void CheckHasNoRepeatedTags(FieldMap map)
 {
     if (map.RepeatedTags.Count > 0)
         throw new RepeatedTag(map.RepeatedTags[0].Tag);
 }
Beispiel #41
0
 public void IsFieldSetTest()
 {
     FieldMap fieldmap = new FieldMap();
     BooleanField field = new BooleanField(200, true);
     Assert.That(fieldmap.IsSetField(field), Is.EqualTo(false));
     Assert.That(fieldmap.IsSetField(field.Tag), Is.EqualTo(false));
     fieldmap.SetField(field);
     Assert.That(fieldmap.IsSetField(field), Is.EqualTo(true));
     Assert.That(fieldmap.IsSetField(field.Tag), Is.EqualTo(true));
 }
Beispiel #42
0
 public void SimpleFieldOrderTest()
 {
     int[] fieldord = { 10, 11, 12, 13, 200 };
     FieldMap fm = new FieldMap(fieldord);
     Assert.That(fm.FieldOrder, Is.EqualTo(fieldord));
 }
Beispiel #43
0
        /// <summary>
        /// Constructs a group and stores it in this Message object
        /// </summary>
        /// <param name="grpNoFld"></param>
        /// <param name="msgstr"></param>
        /// <param name="pos"></param>
        /// <param name="fieldMap"></param>
        /// <param name="dd"></param>
        /// <param name="sessionDataDictionary"></param>
        /// <param name="appDD"></param>
        /// <param name="msgFactory">if this is null, then this method will use the generic Group class constructor</param>
        /// <returns></returns>
        protected int SetGroup(StringField grpNoFld, string msgstr, int pos, FieldMap fieldMap, DataDictionary.IGroupSpec dd, DataDictionary.DataDictionary sessionDataDictionary, DataDictionary.DataDictionary appDD, IMessageFactory msgFactory)
        {
            int delim = dd.Delim;
            int grpPos = pos;
            Group grp = null;

            while (pos < msgstr.Length)
            {
                grpPos = pos;
                StringField f = ExtractField(msgstr, ref pos, sessionDataDictionary, appDD);
                if (f.Tag == delim)
                {
                    if (grp != null)
                    {
                        fieldMap.AddGroup(grp, false);
                    }

                    if (msgFactory != null)
                        grp = msgFactory.Create(Message.ExtractBeginString(msgstr), Message.GetMsgType(msgstr), grpNoFld.Tag);

                    //If above failed, just use a generic Group.
                    if (grp == null)
                        grp = new Group(grpNoFld.Tag, delim);
                }
                else if (!dd.IsField(f.Tag))
                {
                    if (grp != null)
                    {
                        fieldMap.AddGroup(grp, false);
                    }
                    return grpPos;
                }

                grp.SetField(f);

                if (dd.IsGroup(f.Tag))
                {

                    if (FixMessageDescriptorEnabled)
                    {
                        var oldCurrField = _currentGroupField;

                        _currentGroupField = new GroupFixFieldInfo();

                        _currentGroupField.Tag = f.Tag;

                        DataDictionary.DDField field = null;

                        if (appDD != null && appDD.FieldsByTag.TryGetValue(f.Tag, out field))
                        {
                            _currentGroupField.Name = field.Name;
                        }
                        else if (sessionDataDictionary != null && sessionDataDictionary.FieldsByTag.TryGetValue(f.Tag, out field))
                        {
                            _currentGroupField.Name = field.Name;
                        }
                        _currentGroupField.Value = f.getValue();

                        _currentGroupField.EnumValue = GetEnumValueFromField(f, field);

                        oldCurrField.Fields.Add(_currentGroupField);
                    }

                    pos = SetGroup(f, msgstr, pos, grp, dd.GetGroupSpec(f.Tag), sessionDataDictionary, appDD, msgFactory);

                }
                else
                {
                    if (FixMessageDescriptorEnabled)
                    {
                        FixFieldInfo fi = new FixFieldInfo();

                        fi.Tag = f.Tag;

                        DataDictionary.DDField field = null;

                        if (appDD != null && appDD.FieldsByTag.TryGetValue(f.Tag, out field))
                        {
                            _currentGroupField.Name = field.Name;
                        }
                        else if (sessionDataDictionary != null && sessionDataDictionary.FieldsByTag.TryGetValue(f.Tag, out field))
                        {
                            _currentGroupField.Name = field.Name;
                        }

                        fi.Value = f.getValue();

                        fi.EnumValue = GetEnumValueFromField(f, field);

                        _currentGroupField.Fields.Add(fi);

                    }

                }
            }

            return grpPos;
        }
Beispiel #44
0
 protected void InsertOrigSendingTime(FieldMap header, System.DateTime sendingTime)
 {
     if (this.SessionID.BeginString.CompareTo(FixValues.BeginString.FIX42) >= 0)
         header.SetField(new OrigSendingTime(sendingTime));
     else
         header.SetField(new OrigSendingTime(sendingTime, false));
 }
        public void Iterate(FieldMap map, string msgType)
        {
            DataDictionary.CheckHasNoRepeatedTags(map);

            // check non-group fields
            int lastField = 0;
            foreach (KeyValuePair<int, Fields.IField> kvp in map)
            {
                Fields.IField field = kvp.Value;
                if (lastField != 0 && field.Tag == lastField)
                    throw new RepeatedTag(lastField);
                CheckHasValue(field);

                if (null != this.Version && this.Version.Length > 0)
                {
                    CheckValidFormat(field);

                    if (ShouldCheckTag(field))
                    {
                        CheckValidTagNumber(field.Tag);
                        CheckValue(field);
                        if (!Message.IsHeaderField(field.Tag, this) && !Message.IsTrailerField(field.Tag, this))
                        {
                            CheckIsInMessage(field, msgType);
                            CheckGroupCount(field, map, msgType);
                        }
                    }
                }
                lastField = field.Tag;
            }

            // check contents of each group
            foreach (int groupTag in map.GetGroupTags())
            {
                for (int i = 1; i <= map.GroupCount(groupTag); i++)
                {
                    Group g = map.GetGroup(i, groupTag);
                    DDGrp ddg = this.Messages[msgType].GetGroup(groupTag);
                    IterateGroup(g, ddg, msgType);
                }
            }
        }
Beispiel #46
0
        /// <summary>
        /// Constructs a group and stores it in this Message object
        /// </summary>
        /// <param name="grpNoFld">the group's counter field</param>
        /// <param name="msgstr">full message string</param>
        /// <param name="pos">starting character position of group</param>
        /// <param name="fieldMap">full message as FieldMap</param>
        /// <param name="dd">group definition structure from dd</param>
        /// <param name="sessionDataDictionary"></param>
        /// <param name="appDD"></param>
        /// <param name="msgFactory">if null, then this method will use the generic Group class constructor</param>
        /// <returns></returns>
        protected int SetGroup(
            StringField grpNoFld, string msgstr, int pos, FieldMap fieldMap, DataDictionary.IGroupSpec dd,
            DataDictionary.DataDictionary sessionDataDictionary, DataDictionary.DataDictionary appDD, IMessageFactory msgFactory)
        {
            int grpEntryDelimiterTag = dd.Delim;
            int grpPos = pos;
            Group grp = null; // the group entry being constructed

            while (pos < msgstr.Length)
            {
                grpPos = pos;
                StringField f = ExtractField(msgstr, ref pos, sessionDataDictionary, appDD);
                if (f.Tag == grpEntryDelimiterTag)
                {
                    // This is the start of a group entry.

                    if (grp != null)
                    {
                        // We were already building an entry, so the delimiter means it's done.
                        fieldMap.AddGroup(grp, false);
                        grp = null; // prepare for new Group
                    }

                    // Create a new group!
                    if (msgFactory != null)
                        grp = msgFactory.Create(Message.ExtractBeginString(msgstr), Message.GetMsgType(msgstr), grpNoFld.Tag);

                    //If above failed (shouldn't ever happen), just use a generic Group.
                    if (grp == null)
                        grp = new Group(grpNoFld.Tag, grpEntryDelimiterTag);
                }
                else if (!dd.IsField(f.Tag))
                {
                    // This field is not in the group, thus the repeating group is done.

                    if (grp != null)
                    {
                        fieldMap.AddGroup(grp, false);
                    }
                    return grpPos;
                }

                if (grp == null)
                {
                    // This means we got into the group's fields without finding a delimiter tag.
                    throw new GroupDelimiterTagException(grpNoFld.Tag, grpEntryDelimiterTag);
                }

                // f is just a field in our group entry.  Add it and iterate again.
                grp.SetField(f);
                if(dd.IsGroup(f.Tag))
                {
                    // f is a counter for a nested group.  Recurse!
                    pos = SetGroup(f, msgstr, pos, grp, dd.GetGroupSpec(f.Tag), sessionDataDictionary, appDD, msgFactory);
                }
            }

            return grpPos;
        }
Beispiel #47
0
        public void GroupDelimTest()
        {
            Group g1 = new Group(100, 200);
            Assert.AreEqual(100, g1.Field); //counter
            Assert.AreEqual(200, g1.Delim);

            g1.SetField(new StringField(200, "delim!"));

            FieldMap fm = new FieldMap();
            fm.AddGroup(g1);
            Assert.AreEqual(1, fm.GetInt(100));

            Group g2 = new Group(100, 200);
            g2.SetField(new StringField(200, "again!"));
            fm.AddGroup(g2);
            Assert.AreEqual(2, fm.GetInt(100));
        }
Beispiel #48
0
        protected void InsertSendingTime(FieldMap header)
        {
            bool showMilliseconds = false;
            if (this.SessionID.BeginString == FixValues.BeginString.FIXT11)
                showMilliseconds = true;
            else
                showMilliseconds = this.SessionID.BeginString.CompareTo(FixValues.BeginString.FIX42) >= 0;

            header.SetField(new Fields.SendingTime(System.DateTime.UtcNow, showMilliseconds && MillisecondsInTimeStamp));
        }
Beispiel #49
0
        protected int SetGroup(StringField grpNoFld, string msgstr, int pos, FieldMap fieldMap, DataDictionary.IGroupSpec dd, DataDictionary.DataDictionary sessionDataDictionary, DataDictionary.DataDictionary appDD)
        {
            int delim = dd.Delim;
            int grpPos = pos;
            Group grp = null;

            while (pos < msgstr.Length)
            {
                grpPos = pos;
                StringField f = ExtractField(msgstr, ref pos, sessionDataDictionary, appDD);
                if (f.Tag == delim)
                {
                    if (grp != null)
                    {
                        fieldMap.AddGroup(grp, false);
                    }
                    grp = new Group(grpNoFld.Tag, delim);
                }
                else if (!dd.IsField(f.Tag))
                {
                    if (grp != null)
                    {
                        fieldMap.AddGroup(grp, false);
                    }
                    return grpPos;
                }
                grp.SetField(f);
                if(dd.IsGroup(f.Tag))
                {
                    pos = SetGroup(f, msgstr, pos, grp, dd.GetGroupSpec(f.Tag), sessionDataDictionary, appDD);
                }
            }

            return grpPos;
        }
 /// <summary>
 /// If <paramref name="field"/> is a group-counter for <paramref name="msgType"/>, check that it is accurate, else do nothing.
 /// </summary>
 /// <param name="field">a group's counter field</param>
 /// <param name="map">the FieldMap that contains the group being checked</param>
 /// <param name="msgType">msg type of message that is/contains <paramref name="map"/></param>
 public void CheckGroupCount(Fields.IField field, FieldMap map, string msgType)
 {
     if(IsGroup(msgType, field.Tag))
     {
         if (map.GetInt(field.Tag) != map.GroupCount(field.Tag))
         {
             throw new RepeatingGroupCountMismatch(field.Tag);
         }
     }
 }
Beispiel #51
0
        /// <summary>
        /// Constructs a group and stores it in this Message object
        /// </summary>
        /// <param name="grpNoFld"></param>
        /// <param name="msgstr"></param>
        /// <param name="pos"></param>
        /// <param name="fieldMap"></param>
        /// <param name="dd"></param>
        /// <param name="sessionDataDictionary"></param>
        /// <param name="appDD"></param>
        /// <param name="msgFactory">if this is null, then this method will use the generic Group class constructor</param>
        /// <returns></returns>
        protected int SetGroup(StringField grpNoFld, string msgstr, int pos, FieldMap fieldMap, DataDictionary.IGroupSpec dd, DataDictionary.DataDictionary sessionDataDictionary, DataDictionary.DataDictionary appDD, IMessageFactory msgFactory)
        {
            int delim = dd.Delim;
            int grpPos = pos;
            Group grp = null;

            while (pos < msgstr.Length)
            {
                grpPos = pos;
                StringField f = ExtractField(msgstr, ref pos, sessionDataDictionary, appDD);
                if (f.Tag == delim)
                {
                    if (grp != null)
                    {
                        fieldMap.AddGroup(grp, false);
                    }

                    if (msgFactory != null)
                        grp = msgFactory.Create(Message.ExtractBeginString(msgstr), Message.GetMsgType(msgstr), grpNoFld.Tag);

                    //If above failed, just use a generic Group.
                    if (grp == null)
                        grp = new Group(grpNoFld.Tag, delim);
                }
                else if (!dd.IsField(f.Tag))
                {
                    if (grp != null)
                    {
                        fieldMap.AddGroup(grp, false);
                    }
                    return grpPos;
                }
                grp.SetField(f);
                if(dd.IsGroup(f.Tag))
                {
                    pos = SetGroup(f, msgstr, pos, grp, dd.GetGroupSpec(f.Tag), sessionDataDictionary, appDD, msgFactory);
                }
            }

            return grpPos;
        }
        public void Iterate(FieldMap map, string msgType)
        {
            DataDictionary.CheckHasNoRepeatedTags(map);

            int lastField = 0;
            foreach (KeyValuePair<int, Fields.IField> kvp in map)
            {
                Fields.IField field = kvp.Value;
                if (lastField != 0 && field.Tag == lastField)
                    throw new RepeatedTag(lastField);
                CheckHasValue(field);

                if (null != this.Version && this.Version.Length > 0)
                {
                    CheckValidFormat(field);

                    if (ShouldCheckTag(field))
                    {
                        CheckValidTagNumber(field.Tag);
                        CheckValue(field);
                        if (!Message.IsHeaderField(field.Tag, this) && !Message.IsTrailerField(field.Tag, this))
                        {
                            CheckIsInMessage(field, msgType);
                            CheckGroupCount(field, map, msgType);
                        }
                    }
                }

                lastField = field.Tag;
            }
        }
Beispiel #53
0
 protected void InsertSendingTime(FieldMap header)
 {
     if (this.SessionID.BeginString.CompareTo(FixValues.BeginString.FIX42) >= 0)
         header.SetField(new Fields.SendingTime(System.DateTime.UtcNow));
     else
         header.SetField(new Fields.SendingTime(System.DateTime.UtcNow, false));
 }