当前位置: 首页>>代码示例>>C#>>正文


C# FieldMap类代码示例

本文整理汇总了C#中FieldMap的典型用法代码示例。如果您正苦于以下问题:C# FieldMap类的具体用法?C# FieldMap怎么用?C# FieldMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FieldMap类属于命名空间,在下文中一共展示了FieldMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Populate

        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);
        }
开发者ID:hsteinhilber,项目名称:white-project,代码行数:34,代码来源:AppScreen.cs

示例2: AddGroupKeepTypeTest

        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);
        }
开发者ID:BobRoss79,项目名称:quickfixn,代码行数:11,代码来源:FieldMapTests.cs

示例3: AddGetGroupTest

        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); });
        }
开发者ID:BobRoss79,项目名称:quickfixn,代码行数:17,代码来源:FieldMapTests.cs

示例4: SetGroup

        /// <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;
        }
开发者ID:BuddyWork,项目名称:quickfixn,代码行数:71,代码来源:Message.cs

示例5: GetFieldOrDefault

        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;
            }
        }
开发者ID:BuddyWork,项目名称:quickfixn,代码行数:14,代码来源:Message.cs

示例6: SetGroup

        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;
        }
开发者ID:shanetrotter,项目名称:quickfixn,代码行数:35,代码来源:Message.cs

示例7: toXMLFields

        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();
        }
开发者ID:baffled,项目名称:quickfixn,代码行数:33,代码来源:Message.cs

示例8: ClearAndIsEmptyTest

 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));
 }
开发者ID:BobRoss79,项目名称:quickfixn,代码行数:15,代码来源:FieldMapTests.cs

示例9: SetGroup

        /// <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);
//.........这里部分代码省略.........
开发者ID:unclepaul84,项目名称:quickfixn,代码行数:101,代码来源:Message.cs

示例10: CheckGroupCount

 /// <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);
         }
     }
 }
开发者ID:KITSOlgaLosynska,项目名称:quickfixn,代码行数:16,代码来源:DataDictionary.cs

示例11: SetGroup

        /// <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;
        }
开发者ID:TheJeremyGray,项目名称:quickfixn,代码行数:53,代码来源:Message.cs

示例12: IsFieldSetTest

 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));
 }
开发者ID:BobRoss79,项目名称:quickfixn,代码行数:10,代码来源:FieldMapTests.cs

示例13: InsertSendingTime

        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));
        }
开发者ID:thomasfleming,项目名称:quickfixn,代码行数:10,代码来源:Session.cs

示例14: GroupDelimTest

        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));
        }
开发者ID:BobRoss79,项目名称:quickfixn,代码行数:17,代码来源:FieldMapTests.cs

示例15: FieldMapTests

 public FieldMapTests()
 {
     this.fieldmap = new FieldMap();
 }
开发者ID:BobRoss79,项目名称:quickfixn,代码行数:4,代码来源:FieldMapTests.cs


注:本文中的FieldMap类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。