• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Record类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: DeserializeRecord

        public Record DeserializeRecord(ArraySegment<byte> segment) {
            var text = Encoding.UTF8.GetString(segment.Array, segment.Offset, segment.Count);
            var fields = this.GetFields(text);

            var attributes = this.AttributeMappings;

            var record = new Record {
                Logger = SafeGetFieldByIndex(fields, this.LoggerFieldIndex),
                Level = this.GetLevel(fields),
                Message = SafeGetFieldByIndex(fields, this.MessageFieldIndex),
                Exception = SafeGetFieldByIndex(fields, this.ExceptionFieldIndex)
            };

            DateTime timestamp;

            if (DateTime.TryParse(SafeGetFieldByIndex(fields, this.TimestampFieldIndex), out timestamp))
                record.Timestamp = timestamp;

            if (attributes != null)
                record.Attributes = attributes
                    .Select(x => new KeyValuePair<string, string>(x.Item2, SafeGetFieldByIndex(fields, x.Item1)))
                    .ToArray();

            return record;
        }
开发者ID:SmartFire,项目名称:LogWatch,代码行数:25,代码来源:CsvLogFormat.cs


示例2: MapToType_Should_Return_Mapped_Instance

        public void MapToType_Should_Return_Mapped_Instance()
        {
            var expected = new Record
            {
                Prop1 = 5,
                Prop2 = "prop2",
                Prop3 = new DateTime(2000, 4, 2),
                Prop4 = true
            };

            var type = typeof(Record);
            var properties = type.GetProperties();

            var dataRecordMock = new Mock<IDataRecord>();

            var fieldNames = properties.Select(p => p.Name).ToArray();
            var fieldValues = properties.Select(p => p.GetValue(expected)).ToArray();

            dataRecordMock.Setup(r => r.FieldCount).Returns(4);

            for (int i = 0; i < fieldNames.Length; i++)
            {
                dataRecordMock.Setup(r => r.GetName(i)).Returns(fieldNames[i]);
                dataRecordMock.Setup(r => r.GetValue(i)).Returns(fieldValues[i]);
            }

            var dataRecord = dataRecordMock.Object;

            var actual = dataRecord.MapToType<Record>();

            actual.Prop1.Should().Be(expected.Prop1);
            actual.Prop2.Should().Be(expected.Prop2);
            actual.Prop3.Should().Be(expected.Prop3);
            actual.Prop4.Should().Be(expected.Prop4);
        }
开发者ID:ivelten,项目名称:NBoost,代码行数:35,代码来源:DataRecordTest.cs


示例3: TableHeader

 public TableHeader(Record R)
     : base(RECORD_LEN)
 {
     if (R.Count != RECORD_LEN) 
         throw new Exception("Header-Record supplied has an invalid length");
     this._data = R.BaseArray;
 }
开发者ID:pwdlugosz,项目名称:Horse,代码行数:7,代码来源:TableHeader.cs


示例4: PageInfo

 public PageInfo()
 {
     Page = 1;
     PageSize = 10;
     RecordCollection a = new RecordCollection();
     Record b = new Record();
 }
开发者ID:sosokk,项目名称:YiFen.Library,代码行数:7,代码来源:PageInfo.cs


示例5: WriteToReceptionDoctor

 public Record WriteToReceptionDoctor(int id_Doctor, Pacient thePacient)
 {
     AddPacient(thePacient);
     Record theRecord = new Record(id_Doctor, thePacient.Id, GetTimeDoctor(id_Doctor));
     AddRecord(theRecord);
     return theRecord;
 }
开发者ID:WilliamRobertMontgomery,项目名称:asp-dot-net-training-project,代码行数:7,代码来源:Registry.cs


示例6: button1_Click

        private void button1_Click(object sender, EventArgs e)
        {
            Record entries = new Record();

            #region Database Handling
            list.Clear();
            var id = StudentID.Text;
            // Open a connection to the database...
            MySqlConnection conn = new MySqlConnection("server=localhost;user=root;database=students;port=3306;password=;");
            conn.Open();
            // Perform the first query...
            String sql = "SELECT * FROM students.demographics WHERE id = '" + id + "'";
            MySqlCommand cmd = new MySqlCommand(sql, conn);
            cmd.ExecuteNonQuery();
            MySqlDataReader sqlReader = cmd.ExecuteReader();
            #endregion

            // Parse through results and store in a list...
            while (sqlReader.Read())
            {
                entries.AddRecord(Convert.ToInt32(sqlReader.GetValue(0)), sqlReader.GetValue(1).ToString(), sqlReader.GetValue(2).ToString(), sqlReader.GetValue(3).ToString());
                // Add the record to the list of records...
                list.Add(entries);
            }

            // If we have an empty list, let the user know.
            if (list.Count == 0)
            {
                MessageBox.Show("ID returned no matches", "No results");
            }
            else
            {
                MessageBox.Show("Confirm:\nYour name is: " + entries.FirstName + " " + entries.LastName, "Confirmation", MessageBoxButtons.YesNo);
            }
        }
开发者ID:sean97140,项目名称:TutoringApp,代码行数:35,代码来源:OpenStudent.cs


示例7: TaxiPath

 public TaxiPath(Record rec)
 {
     Id = rec[0];
     From = rec[1];
     To = rec[2];
     Cost = rec[3];
 }
开发者ID:Bia10,项目名称:meshReader,代码行数:7,代码来源:TaxiPath.cs


示例8: Given_an_invalid_heading_name__should_throw_an_exception

 public void Given_an_invalid_heading_name__should_throw_an_exception()
 {
     var record = new Record(new string[] { }, new Dictionary<string, int>());
     // ReSharper disable ReturnValueOfPureMethodIsNotUsed
     record.GetField("foo");
     // ReSharper restore ReturnValueOfPureMethodIsNotUsed
 }
开发者ID:mvbalaw,项目名称:EtlGate,代码行数:7,代码来源:RecordTests.cs


示例9: Save_a_copy_of_a_record_when_no_history_record_exists

        public void Save_a_copy_of_a_record_when_no_history_record_exists()
        {
            var stringDef = new FieldDescriptorRef { ItemType = typeof(string), FieldName = "StringDef" };
            var intDef = new FieldDescriptorRef { ItemType = typeof(int), FieldName = "IntDef" };

            var fieldString = new FieldValue { FieldDescriptorRef = stringDef, Value = "1" };
            var fieldInt = new FieldValue { FieldDescriptorRef = intDef, Value = 2 };

            var record = new Record
            {
                Id = "Record1",
                Fields = new List<FieldValue> { fieldString, fieldInt }
            };

            session.Store(record);
            session.SaveChanges();

            using (var newSession = ds.OpenSession())
            {
                var history = newSession.Load<RecordHistory>("recordHistory/Record1");
                //var recordInner = JsonConvert.DeserializeObject<Record>(history.Record.ToString());

                Assert.IsNotNull(history);
            }
        }
开发者ID:kelly-cliffe,项目名称:SoftModel,代码行数:25,代码来源:RecordHistoryTests.cs


示例10: NesuiPriceLevel

        public NesuiPriceLevel(Record record)
        {
            dynamic self = record;

            this.Id = self.internalId;
            this.Name = self.name;
        }
开发者ID:Parsimotion,项目名称:restsuite,代码行数:7,代码来源:NesuiPriceLevel.cs


示例11: Write

        public bool Write(Dictionary<Guid,string> source, Adam.Core.Application app)
        {
            Record r = new Record(app);
            Excel.Application EApp;
            Excel.Workbook EWorkbook;
            Excel.Worksheet EWorksheet;
            Excel.Range Rng;
            EApp = new Excel.Application();
            object misValue = System.Reflection.Missing.Value;
            EWorkbook = EApp.Workbooks.Add(misValue);
            EWorksheet = (Excel.Worksheet)EWorkbook.Worksheets.Item[1];                         
            EWorksheet.get_Range("A1", misValue).Formula = "UPC code";
            EWorksheet.get_Range("B1", misValue).Formula = "Link";            
            Rng = EWorksheet.get_Range("A2", misValue).get_Resize(source.Count,misValue);
            Rng.NumberFormat = "00000000000000";
            int row = 2;
            foreach(KeyValuePair<Guid,string> pair in source)
            {              
                EWorksheet.Cells[row,1] = pair.Value;                
                r.Load(pair.Key);
                Rng = EWorksheet.get_Range("B"+row, misValue);
                EWorksheet.Hyperlinks.Add(Rng, r.Fields.GetField<TextField>("Content Url").Value);               
                //myExcelWorksheet.Cells[row, 2] = r.Fields.GetField<TextField>("Content Url").Value;                                
                row++;
            }
            ((Excel.Range)EWorksheet.Cells[2, 1]).EntireColumn.AutoFit();
            ((Excel.Range)EWorksheet.Cells[2, 2]).EntireColumn.AutoFit();
            EWorkbook.SaveAs(_fileName, Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue,
                Excel.XlSaveAsAccessMode.xlExclusive,
                misValue, misValue, misValue, misValue, misValue);

            EWorkbook.Close(true, misValue, misValue);
            EApp.Quit();
            return true;
        }
开发者ID:eduard-posmetuhov,项目名称:ADAM.Practic.SecondTask,代码行数:35,代码来源:ExcelWriter.cs


示例12: RecordToMonoChromeBitmap

        public static Bitmap RecordToMonoChromeBitmap(int X, int Y, double Threshold, Record Datum)
        {

            if (Datum.Count != X * Y)
                throw new Exception(string.Format("Bitmap dimensions are invalid for record lenght"));

            Bitmap map = new Bitmap(X, Y);

            int index = 0;

            for (int x = 0; x < X; x++)
            {

                for (int y = 0; y < Y; y++)
                {

                    if (Datum[index].DOUBLE >= Threshold)
                    {
                        map.SetPixel(x, y, Color.Black);
                    }

                    index++;

                }

            }

            return map;

        }
开发者ID:pwdlugosz,项目名称:Horse,代码行数:30,代码来源:Exchange.cs


示例13: RecordObject

 /// <summary>
 /// Record an object-to-copy mapping into the current serialization context.
 /// Used for maintaining the .NET object graph during serialization operations.
 /// Used in generated code.
 /// </summary>
 /// <param name="original">Original object.</param>
 /// <param name="copy">Copy object that will be the serialized form of the original.</param>
 public void RecordObject(object original, object copy)
 {
     if (!processedObjects.ContainsKey(original))
     {
         processedObjects[original] = new Record(copy);                
     }
 }
开发者ID:jdom,项目名称:orleans,代码行数:14,代码来源:SerializationContext.cs


示例14: SaveUGCContentToAgility

        /// <summary>
        /// Saves content to UGC (new and existing) and return RecordID
        /// </summary>
        /// <param name="record"></param>
        public static int SaveUGCContentToAgility(Record record)
        {
            int recordID = -1;

            using (Agility_UGC_API_WCFClient client = UGCAPIUtil.APIClient)
            {
                DataServiceAuthorization auth = UGCAPIUtil.GetDataServiceAuthorization(-1);

                try
                {
                    recordID = client.SaveRecord(auth, record);

                    if (record.State == RecordState.Published)
                        client.SetRecordState(auth, recordID, 1, "");

                    Utilities.LogEvent(string.Format("Saved - {0}", recordID));
                }
                catch (Exception e)
                {
                    Utilities.LogEvent(string.Format("{0}:{1} - {2}", record.RecordTypeName, record.ID, e.Message));
                }
            }

            return recordID;
        }
开发者ID:pimbrouwers,项目名称:agility-utils,代码行数:29,代码来源:AgilityUGCExtensions.cs


示例15: Master

    public static void Master(int port, bool async, bool ack)
    {
        ReplicationMasterStorage db = StorageFactory.Instance.CreateReplicationMasterStorage(new string[] { "localhost:" + port }, async ? asyncBufSize : 0);
        db.SetProperty("perst.file.noflush", true);
        db.SetProperty("perst.replication.ack", ack);
        db.Open("master.dbs", pagePoolSize);

        FieldIndex root = (FieldIndex)db.GetRoot();
        if (root == null)
        {
            root = db.CreateFieldIndex(typeof(Record), "key", true);
            db.SetRoot(root);
        }

        long start = (DateTime.Now.Ticks - 621355968000000000) / 10000;
        for (int i = 0; i < nIterations; i++)
        {
            if (i >= nRecords)
                root.Remove(new Key(i - nRecords));

            Record rec = new Record();
            rec.key = i;
            root.Put(rec);
            if (i >= nRecords && i % transSize == 0)
                db.Commit();
        }

        db.Close();
        Console.Out.WriteLine("Elapsed time for " + nIterations + " iterations: " + ((DateTime.Now.Ticks - 621355968000000000) / 10000 - start) + " milliseconds");
    }
开发者ID:kjk,项目名称:tenderbase,代码行数:30,代码来源:TestReplic.cs


示例16: TestClickDataGridView

 public void TestClickDataGridView()
 {
     EZMoneyModel ezMoneyModel = new EZMoneyModel(); // TODO: 初始化為適當值
     StatisticPresentationModel statisticPModel = new StatisticPresentationModel(ezMoneyModel); // TODO: 初始化為適當值
     CategoryModel categoryModel = ezMoneyModel.CategoryModel;
     RecordModel recordModel = ezMoneyModel.RecordModel;
     Category category1 = new Category(CATEGORY_NAME_WORK);
     Category category2 = new Category(CATEGORY_NAME_MOVIE);
     categoryModel.AddCategory(category1);
     categoryModel.AddCategory(category2);
     DateTime date = DateTime.Now;
     Record record1 = new Record(date, category1, 100);
     Record record2 = new Record(date, category1, 200);
     Record record3 = new Record(date, category1, 300);
     Record record4 = new Record(date, category1, 400);
     Record record5 = new Record(date, category2, -100);
     Record record6 = new Record(date, category2, -200);
     Record record7 = new Record(date, category2, -300);
     recordModel.AddRecord(record1);
     recordModel.AddRecord(record2);
     recordModel.AddRecord(record3);
     recordModel.AddRecord(record4);
     recordModel.AddRecord(record5);
     recordModel.AddRecord(record6);
     recordModel.AddRecord(record7);
     statisticPModel.InitializeState();
     BindingList<Record> records = statisticPModel.ClickDataGridView(category1);
     Assert.AreEqual(4, statisticPModel.RecordList.Count);
     Assert.AreEqual(records, statisticPModel.RecordList);
     statisticPModel.ChangeRadioButton(false);
     statisticPModel.ClickDataGridView(category2);
     Assert.AreEqual(3, statisticPModel.RecordList.Count);
 }
开发者ID:housemeow,项目名称:ezMoney,代码行数:33,代码来源:StatisticPresentationModelTest.cs


示例17: CollectEntityByID

 void CollectEntityByID(MooDB db, int id)
 {
     record = (from r in db.Records
             where r.ID == id
             select r).SingleOrDefault<Record>();
     info = record == null ? null : record.JudgeInfo;
 }
开发者ID:MooDevTeam,项目名称:MooOJ,代码行数:7,代码来源:Default.aspx.cs


示例18: NesuiLocation

        public NesuiLocation(Record record)
        {
            dynamic self = record;

            this.Id = self.internalId;
            this.Name = self.name;
        }
开发者ID:Parsimotion,项目名称:restsuite,代码行数:7,代码来源:NesuiLocation.cs


示例19: Parse

        public Account Parse(Record record)
        {
            DashPipeDigitParser dashPipeNumberExtractor = new DashPipeDigitParser();

            char[] line1, line2, line3;
            int initialPosition = 0;
            string recordContent = record.Content;
            int lineLength = record.LineLength;
            
            string accountNumber = "";
            for (int currentDigit = 0; currentDigit < 9; currentDigit++)
            {
                initialPosition = currentDigit * DigitWidth;
                line1 = recordContent.Substring(initialPosition, DigitWidth).ToCharArray();
                line2 = recordContent.Substring(initialPosition + lineLength, DigitWidth).ToCharArray();
                line3 = recordContent.Substring(initialPosition + (2 * lineLength), DigitWidth).ToCharArray();

                accountNumber += dashPipeNumberExtractor.Parse(line1, line2, line3);
            }

            return new Account
            {
                Number = accountNumber,
                OriginalPreParsed = recordContent
            };
        }
开发者ID:gophlb,项目名称:KataBankOCR,代码行数:26,代码来源:DashPipeRecordToAccountParser.cs


示例20: Explosion

 public Explosion(CoordDouble pos)
 {
     Position = pos;
     Radius = 2;
     Records = new Record[0];
     PlayerMotion = new float[3];
 }
开发者ID:mctraveler,项目名称:MineSharp,代码行数:7,代码来源:Explosion.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# RecordClass类代码示例发布时间:2022-05-24
下一篇:
C# Recipe类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap