本文整理汇总了C#中GDID类的典型用法代码示例。如果您正苦于以下问题:C# GDID类的具体用法?C# GDID怎么用?C# GDID使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GDID类属于命名空间,在下文中一共展示了GDID类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GDID_7
public void GDID_7()
{
var gdid1 = new GDID(0, 0, 12321);
var gdid2 = new GDID(0, 1, 0);
Assert.AreEqual(-1, gdid1.CompareTo(gdid2));
Assert.IsFalse( gdid1.Equals(gdid2));
}
示例2: GDID_10
public void GDID_10()
{
var gdid = new GDID(1293, 3, 57);
var s = gdid.ToString();
Console.WriteLine(s);
Assert.AreEqual("GDID[1293:3458764513820540985(3,57)]", s);
}
示例3: GDID_1
public void GDID_1()
{
var gdid = new GDID(2, 5, 89078);
Assert.AreEqual(2, gdid.Era);
Assert.AreEqual(5, gdid.Authority);
Assert.AreEqual(89078, gdid.Counter);
}
示例4: ASYNC_GetSchemaAndTestVariousTypes
public static void ASYNC_GetSchemaAndTestVariousTypes(ICRUDDataStore store)
{
var schema = store.GetSchemaAsync(new Query("CRUD.Types.Load")).Result;
var row = new DynamicRow(schema);
row["GDID"] = new GDID(0, 145);
row["SCREEN_NAME"] = "User1";
row["STRING_NAME"] = "Some user 1";
row["CHAR_NAME"] = "Some user 2";
row["BOOL_CHAR"] = 'T';
row["BOOL_BOOL"] = true;
row["AMOUNT"] = 145670.23m;
row["DOB"] = new DateTime(1980,12,1);
store.Insert( row );
var row2 = store.LoadOneRow(new Query("CRUD.Types.Load", new GDID(0, 145)));
Assert.NotNull(row2);
Assert.AreEqual(145, row2["GDID"]);
Assert.AreEqual("User1", row2["Screen_Name"]);
Assert.AreEqual("Some user 1", row2["String_Name"]);
Assert.AreEqual("Some user 2", row2["Char_Name"]);
Assert.AreEqual(true, row2["BOOL_Char"].AsBool());
Assert.AreEqual(true, row2["BOOL_BOOL"].AsBool());
Assert.AreEqual(145670.23m, row2["Amount"]);
Assert.AreEqual(1980, row2["DOB"].AsDateTime().Year);
}
示例5: GDID_9
public void GDID_9()
{
var gdid1 = new GDID(0, 3, 57);
var gdid2 = new GDID(0, 3, 57);
Assert.AreEqual(0, gdid1.CompareTo(gdid2));
Assert.IsTrue( gdid1.Equals(gdid2));
var gdid3 = new GDID(1, 3, 57);
var gdid4 = new GDID(2, 3, 57);
Assert.AreEqual(-1, gdid3.CompareTo(gdid4));
Assert.IsFalse( gdid3.Equals(gdid4));
}
示例6: MakeFake
public static Charge MakeFake(GDID gdid)
{
var c = new Charge()
{
Amount = new Amount("usd", gdid.ID % 1897),
Qty = (int)(gdid.ID % 29),
G_Product = gdid,
Notes = new String('n', (int)(gdid.ID % 137))
};
return c;
}
示例7: GDID_BinBuffer
public void GDID_BinBuffer()
{
var gdid = new GDID(0,1,0x4b);
var buf = gdid.Bytes;
Console.WriteLine(buf.ToDumpString(DumpFormat.Hex));
var gdid2 = new GDID(buf);
Assert.AreEqual(gdid, gdid2);
}
示例8: GDID_6
public void GDID_6()
{
var gdid = new GDID(0, 0, 0);
Assert.AreEqual(0, gdid.Authority);
Assert.AreEqual(0, gdid.Counter);
}
示例9: GDID_5
public void GDID_5()
{
var gdid = new GDID(0, 0, GDID.COUNTER_MAX);
Assert.AreEqual(0, gdid.Authority);
Assert.AreEqual(GDID.COUNTER_MAX, gdid.Counter);
}
示例10: ELink
/// <summary>
/// Creates an Elink instance initialized with GDID of 0 Era having its ID set to ulong value
/// </summary>
public ELink(UInt64 id, byte[] metadata)
{
m_GDID = new GDID(0, id);
m_Metadata = metadata;
if (m_Metadata!=null && ((m_Metadata.Length*2) > MAX_LINK_CHAR_SIZE))
throw new NFXException(StringConsts.ELINK_CHAR_LENGTH_LIMIT_ERROR.Args("metadata[{0}]".Args(m_Metadata.Length)));
}
示例11: decode
//link -> props
private void decode()
{
List<byte> data = new List<byte>(32);
char pc = (char)0;
for(var i=0; i<m_Link.Length; i++)
{
char c = m_Link[i];
if (c=='-' || c==' ') continue;
if (pc!=(char)0)
{
var seg = string.Concat(pc, c).ToUpperInvariant();
pc = (char)0;
var sid = 0;
if (!RALPHABET.TryGetValue(seg, out sid))
throw new NFXException(StringConsts.ELINK_CHAR_COMBINATION_ERROR.Args(m_Link, seg));
data.Add((byte)sid);
}
else
pc = c;
}
if (data.Count<4 || pc!=(char)0)
throw new NFXException(StringConsts.ELINK_CHAR_LENGTH_ERROR.Args(m_Link));
//2 control bytes
var lead1 = data[0];
var rnd = (lead1 & 0xf0) >> 4;
rnd |= rnd << 4;
var authority = lead1 & 0x0f;
var lead2 = data[1] ^ rnd;
var eraLength = (lead2 & 0xf0) >> 4;
var idLength = lead2 & 0x0f;
var csum = data[2] ^ rnd;
if (eraLength>4 || idLength<1 || idLength>8)
throw new NFXException(StringConsts.ELINK_SEGMENT_LENGTH_ERROR.Args(m_Link));
if (data.Count-3 < eraLength + idLength)
throw new NFXException(StringConsts.ELINK_CHAR_LENGTH_ERROR.Args(m_Link));
UInt32 era = 0;
var idx = 3;
if (eraLength>0)
{
for(var i=0; i<eraLength; i++,idx++)
era |= (UInt32)((byte)(data[idx] ^ rnd)) << (8 * i);
}
UInt64 id = 0;
if (idLength>0)
{
for(var i=0; i<idLength; i++,idx++)
id |= (UInt64)((byte)(data[idx] ^ rnd)) << (8 * i);
}
id |= ((ulong)authority << 60);
byte[] metadata = null;
if (idx<data.Count)
{
metadata = new byte[data.Count - idx];
for(var j=0; idx<data.Count; idx++, j++)
metadata[j] = (byte)(data[idx] ^ rnd);
}
var thiscsum = crc(era, id, metadata);
if (csum!=thiscsum)
throw new NFXException(StringConsts.ELINK_CSUM_MISMATCH_ERROR.Args(m_Link));
m_GDID = new GDID(era, id);
m_Metadata = metadata;
}
示例12: ID_EQ_GDID
public static Query ID_EQ_GDID(GDID id)
{
var result = new Query();
result.Set( NFX.Serialization.BSON.RowConverter.GDID_CLRtoBSON(_ID, id) );
return result;
}
示例13: Parcel
/// <summary>
/// Called by device to load parcel from storage.
/// The new instance is in 'ParcelState.Sealed' state.
/// Business logic devs - do not call
/// </summary>
protected Parcel(GDID id, object payload, IReplicationVersionInfo versInfo)
{
m_GDID = id;
if (payload==null)
throw new DistributedDataAccessException(StringConsts.ARGUMENT_ERROR+GetType().FullName+".ctor(payload==null)");
if (versInfo==null)
throw new DistributedDataAccessException(StringConsts.ARGUMENT_ERROR+GetType().FullName+".ctor(versInfo==null)");
m_State = ParcelState.Sealed;
m_Payload = payload;
m_ReplicationVersionInfo = versInfo;
}
示例14: GDID_Zero
public void GDID_Zero()
{
var zero = GDID.Zero;
Assert.IsTrue( zero.IsZero );
zero = new GDID(0,1,0);
Assert.IsFalse( zero.IsZero );
}
示例15: GDID_BinBufferAndTryParseBin
public void GDID_BinBufferAndTryParseBin()
{
var gdid = new GDID(347827,15,0xaedb3434b);
var buf = gdid.Bytes;
var hex = "0x"+buf.ToDumpString(DumpFormat.Hex).Replace(" ","");
Console.WriteLine(hex);
GDID gdid2;
Assert.IsTrue(GDID.TryParse(hex, out gdid2));
Assert.AreEqual(gdid, gdid2);
}