本文整理汇总了C#中Record类的典型用法代码示例。如果您正苦于以下问题:C# Record类的具体用法?C# Record怎么用?C# Record使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Record类属于命名空间,在下文中一共展示了Record类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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);
}
示例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;
}
示例4: PageInfo
public PageInfo()
{
Page = 1;
PageSize = 10;
RecordCollection a = new RecordCollection();
Record b = new Record();
}
示例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;
}
示例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);
}
}
示例7: TaxiPath
public TaxiPath(Record rec)
{
Id = rec[0];
From = rec[1];
To = rec[2];
Cost = rec[3];
}
示例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
}
示例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);
}
}
示例10: NesuiPriceLevel
public NesuiPriceLevel(Record record)
{
dynamic self = record;
this.Id = self.internalId;
this.Name = self.name;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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");
}