本文整理汇总了C#中System.Random.NextLong方法的典型用法代码示例。如果您正苦于以下问题:C# Random.NextLong方法的具体用法?C# Random.NextLong怎么用?C# Random.NextLong使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Random
的用法示例。
在下文中一共展示了Random.NextLong方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: testBloomFilter
public void testBloomFilter()
{
// conf.set(HiveConf.ConfVars.HIVE_ORC_ENCODING_STRATEGY.varname, "COMPRESSION");
using (Stream file = File.OpenWrite(TestFilePath))
{
OrcFile.WriterOptions options = new OrcFile.WriterOptions(new Properties(), conf);
options.inspector(ObjectInspectorFactory.getReflectionObjectInspector(typeof(MyRecord)));
options.stripeSize(100000);
options.compress(CompressionKind.ZLIB);
options.bufferSize(10000);
options.rowIndexStride(1000);
options.bloomFilterColumns("S");
using (Writer writer = OrcFile.createWriter(TestFilePath, file, options))
{
Random r1 = new Random(1);
for (int i = 0; i < 21000; ++i)
{
writer.addRow(new MyRecord(r1.Next(), r1.NextLong(),
TestHelpers.words[r1.Next(TestHelpers.words.Length)]));
}
}
}
string outputFilename = "orc-file-dump-bloomfilter.out";
using (CaptureStdout capture = new CaptureStdout(Path.Combine(workDir, outputFilename)))
{
FileDump.Main(new string[] { TestFilePath.ToString(), "--rowindex=3" });
}
TestHelpers.CompareFilesByLine(outputFilename, Path.Combine(workDir, outputFilename));
}
示例2: testJsonDump
public void testJsonDump()
{
ObjectInspector inspector;
inspector = ObjectInspectorFactory.getReflectionObjectInspector(typeof(MyRecord));
// conf.set(HiveConf.ConfVars.HIVE_ORC_ENCODING_STRATEGY.varname, "COMPRESSION");
OrcFile.WriterOptions options = OrcFile.writerOptions(conf)
.inspector(inspector)
.stripeSize(100000)
.compress(CompressionKind.ZLIB)
.bufferSize(10000)
.rowIndexStride(1000)
.bloomFilterColumns("s");
using (Stream file = File.OpenWrite(TestFilePath))
using (Writer writer = OrcFile.createWriter(TestFilePath, file, options))
{
Random r1 = new Random(1);
for (int i = 0; i < 21000; ++i)
{
if (i % 100 == 0)
{
writer.addRow(new MyRecord(r1.Next(), r1.NextLong(), null));
}
else
{
writer.addRow(new MyRecord(r1.Next(), r1.NextLong(),
TestHelpers.words[r1.Next(TestHelpers.words.Length)]));
}
}
}
const string outputFilename = "orc-file-dump.json";
using (CaptureStdout capture = new CaptureStdout(Path.Combine(workDir, outputFilename)))
{
FileDump.Main(new string[] { TestFilePath.ToString(), "-j", "-p", "--rowindex=3" });
}
TestHelpers.CompareFilesByLine(outputFilename, Path.Combine(workDir, outputFilename));
}
示例3: ParseTest
public void ParseTest()
{
Random random = new Random();
for (int i = 0; i != 100; ++i)
{
UInt48 expected = (UInt48)random.NextLong(UInt48.MaxValue + 1);
UInt48 actual = UInt48.Parse(expected.ToString(), NumberStyles.Integer, CultureInfo.InvariantCulture);
Assert.AreEqual(expected, actual);
actual = UInt48.Parse(expected.ToString(), NumberStyles.Integer);
Assert.AreEqual(expected, actual);
actual = UInt48.Parse(expected.ToString(), CultureInfo.InvariantCulture);
Assert.AreEqual(expected, actual);
actual = UInt48.Parse(expected.ToString());
Assert.AreEqual(expected, actual);
}
}
示例4: RandomLong
private long RandomLong(Random random)
{
long val;
switch (random.Next(4))
{
case 0:
val = 1L << (random.Next(63)); // patterns like 0x000000100000 (-1 yields patterns like 0x0000fff)
break;
case 1:
val = -1L << (random.Next(63)); // patterns like 0xfffff00000
break;
default:
val = random.NextLong();
break;
}
val += random.Next(5) - 2;
if (random.NextBoolean())
{
if (random.NextBoolean())
{
val += random.Next(100) - 50;
}
if (random.NextBoolean())
{
val = ~val;
}
if (random.NextBoolean())
{
val = val << 1;
}
if (random.NextBoolean())
{
val = (long)((ulong)val >> 1);
}
}
return val;
}
示例5: RandomSeekPos
private long RandomSeekPos(Random random, long size)
{
if (random == null || size <= 3L)
{
return 0L;
}
return (random.NextLong() & long.MaxValue) % (size / 3);
}
示例6: testBitPack64Large
public void testBitPack64Large()
{
ObjectInspector inspector = ObjectInspectorFactory.getReflectionObjectInspector(typeof(long));
const int size = 1080832;
long[] inp = new long[size];
Random rand = new Random(1234);
for (int i = 0; i < size; i++)
{
inp[i] = rand.NextLong();
}
List<long> input = inp.ToList();
using (Stream file = File.OpenWrite(TestFilePath))
using (Writer writer = OrcFile.createWriter(TestFilePath, file, OrcFile.writerOptions(conf)
.inspector(inspector)
.compress(CompressionKind.ZLIB)))
{
foreach (long l in input)
{
writer.addRow(l);
}
}
Reader reader = OrcFile.createReader(TestFilePath, OrcFile.readerOptions(conf));
using (RecordReader rows = reader.rows())
{
int idx = 0;
while (rows.hasNext())
{
object row = rows.next();
Assert.Equal(input[idx++], ((long)row));
}
}
}
示例7: columnProjection
public void columnProjection()
{
ObjectInspector inspector = ObjectInspectorFactory.getReflectionObjectInspector(typeof(InnerStruct));
int minInt = 0, maxInt = 0;
string minStr = null, maxStr = null;
Random r1 = null, r2 = null;
using (Stream file = FileOpenWrite(TestFilePath))
using (Writer writer = OrcFile.createWriter(TestFilePath, file, OrcFile.writerOptions(conf)
.inspector(inspector)
.stripeSize(1000)
.compress(CompressionKind.NONE)
.bufferSize(100)
.rowIndexStride(1000)))
{
r1 = new Random(1);
r2 = new Random(2);
int x;
string y;
for (int i = 0; i < 21000; ++i)
{
x = r1.Next();
y = Long.toHexString(r2.NextLong());
if (i == 0 || x < minInt)
{
minInt = x;
}
if (i == 0 || x > maxInt)
{
maxInt = x;
}
if (i == 0 || y.CompareTo(minStr) < 0)
{
minStr = y;
}
if (i == 0 || y.CompareTo(maxStr) > 0)
{
maxStr = y;
}
writer.addRow(new InnerStruct(x, y));
}
}
Reader reader = OrcFile.createReader(TestFilePath, OrcFile.readerOptions(conf));
// check out the statistics
ColumnStatistics[] stats = reader.getStatistics();
Assert.Equal(3, stats.Length);
foreach (ColumnStatistics s in stats)
{
Assert.Equal(21000, s.getNumberOfValues());
if (s is IntegerColumnStatistics)
{
Assert.Equal(minInt, ((IntegerColumnStatistics)s).getMinimum());
Assert.Equal(maxInt, ((IntegerColumnStatistics)s).getMaximum());
}
else if (s is StringColumnStatistics)
{
Assert.Equal(maxStr, ((StringColumnStatistics)s).getMaximum());
Assert.Equal(minStr, ((StringColumnStatistics)s).getMinimum());
}
}
// check out the types
IList<OrcProto.Type> types = reader.getTypes();
Assert.Equal(3, types.Count);
Assert.Equal(OrcProto.Type.Types.Kind.STRUCT, types[0].Kind);
Assert.Equal(2, types[0].SubtypesCount);
Assert.Equal(1, (int)types[0].GetSubtypes(0));
Assert.Equal(2, (int)types[0].GetSubtypes(1));
Assert.Equal(OrcProto.Type.Types.Kind.INT, types[1].Kind);
Assert.Equal(0, types[1].SubtypesCount);
Assert.Equal(OrcProto.Type.Types.Kind.STRING, types[2].Kind);
Assert.Equal(0, types[2].SubtypesCount);
// read the contents and make sure they match
using (RecordReader rows1 = reader.rows(new bool[] { true, true, false }))
using (RecordReader rows2 = reader.rows(new bool[] { true, false, true }))
{
r1 = new Random(1);
r2 = new Random(2);
for (int i = 0; i < 21000; ++i)
{
Assert.Equal(true, rows1.hasNext());
Assert.Equal(true, rows2.hasNext());
OrcStruct row1 = (OrcStruct)rows1.next();
OrcStruct row2 = (OrcStruct)rows2.next();
Assert.Equal(r1.Next(), row1.getFieldValue(0));
Assert.Equal(Long.toHexString(r2.NextLong()),
row2.getFieldValue(1).ToString());
}
Assert.Equal(false, rows1.hasNext());
Assert.Equal(false, rows2.hasNext());
}
}
示例8: testZeroCopySeek
public void testZeroCopySeek()
{
ObjectInspector inspector = ObjectInspectorFactory.getReflectionObjectInspector(typeof(BigRow));
const int COUNT = 32768;
long[] intValues = new long[COUNT];
double[] doubleValues = new double[COUNT];
string[] stringValues = new string[COUNT];
byte[][] byteValues = new byte[COUNT][];
string[] words = new string[128];
using (Stream file = FileOpenWrite(TestFilePath))
using (Writer writer = OrcFile.createWriter(TestFilePath, file, OrcFile.writerOptions(conf)
.inspector(inspector)
.stripeSize(200000)
.bufferSize(65536)
.rowIndexStride(1000)))
{
Random rand = new Random(42);
for (int i = 0; i < words.Length; ++i)
{
words[i] = Integer.toHexString(rand.Next());
}
for (int i = 0; i < COUNT / 2; ++i)
{
intValues[2 * i] = rand.NextLong();
intValues[2 * i + 1] = intValues[2 * i];
stringValues[2 * i] = words[rand.Next(words.Length)];
stringValues[2 * i + 1] = stringValues[2 * i];
}
for (int i = 0; i < COUNT; ++i)
{
doubleValues[i] = rand.NextDouble();
byte[] buf = new byte[20];
rand.NextBytes(buf);
byteValues[i] = buf;
}
for (int i = 0; i < COUNT; ++i)
{
writer.addRow(createRandomRow(intValues, doubleValues, stringValues,
byteValues, words, i));
}
}
Reader reader = OrcFile.createReader(TestFilePath, OrcFile.readerOptions(conf));
Assert.Equal(COUNT, reader.getNumberOfRows());
/* enable zero copy record reader */
#if false
Configuration conf = new Configuration();
HiveConf.setBoolVar(conf, HiveConf.ConfVars.HIVE_ORC_ZEROCOPY, true);
#endif
using (RecordReader rows = reader.rows())
{
/* all tests are identical to the other seek() tests */
for (int i = COUNT - 1; i >= 0; --i)
{
rows.seekToRow(i);
OrcStruct row = (OrcStruct)rows.next();
BigRow expected = createRandomRow(intValues, doubleValues,
stringValues, byteValues, words, i);
Assert.Equal(expected.boolean1, row.getFieldValue(0));
Assert.Equal(expected.byte1, row.getFieldValue(1));
Assert.Equal(expected.short1, row.getFieldValue(2));
Assert.Equal(expected.int1, row.getFieldValue(3));
Assert.Equal(expected.long1, row.getFieldValue(4));
Assert.Equal(expected.float1, (float)row.getFieldValue(5), 4);
Assert.Equal(expected.double1, (double)row.getFieldValue(6), 4);
Assert.Equal(expected.bytes1, row.getFieldValue(7));
Assert.Equal(expected.string1, row.getFieldValue(8));
List<InnerStruct> expectedList = expected.middle.list;
List<object> actualList =
(List<object>)((OrcStruct)row.getFieldValue(9)).getFieldValue(0);
compareList(expectedList, actualList);
compareList(expected.list, (List<object>)row.getFieldValue(10));
}
}
IList<StripeInformation> stripes = reader.getStripes();
long offsetOfStripe2 = 0;
long offsetOfStripe4 = 0;
long lastRowOfStripe2 = 0;
for (int i = 0; i < 5; ++i)
{
StripeInformation stripe = stripes[i];
if (i < 2)
{
lastRowOfStripe2 += stripe.getNumberOfRows();
}
else if (i == 2)
{
offsetOfStripe2 = stripe.getOffset();
lastRowOfStripe2 += stripe.getNumberOfRows() - 1;
}
else if (i == 4)
{
offsetOfStripe4 = stripe.getOffset();
}
}
bool[] columns = new bool[reader.getStatistics().Length];
columns[5] = true; // long colulmn
//.........这里部分代码省略.........
示例9: testColumnProjection
public void testColumnProjection()
{
TypeDescription schema = createInnerSchema();
Random r1 = new Random(1);
Random r2 = new Random(2);
int minInt = 0, maxInt = 0;
string minStr = null, maxStr = null;
using (Stream file = File.OpenWrite(TestFilePath))
using (Writer writer = OrcFile.createWriter(TestFilePath, file, OrcFile.writerOptions(conf)
.setSchema(schema)
.stripeSize(1000)
.compress(CompressionKind.NONE)
.bufferSize(100)
.rowIndexStride(1000)))
{
VectorizedRowBatch batch = schema.createRowBatch();
int x;
string y;
batch.size = 1000;
bool first = true;
for (int b = 0; b < 21; ++b)
{
for (int r = 0; r < 1000; ++r)
{
x = r1.Next();
y = Long.toHexString(r2.NextLong());
if (first || x < minInt)
{
minInt = x;
}
if (first || x > maxInt)
{
maxInt = x;
}
if (first || y.CompareTo(minStr) < 0)
{
minStr = y;
}
if (first || y.CompareTo(maxStr) > 0)
{
maxStr = y;
}
first = false;
((LongColumnVector)batch.cols[0]).vector[r] = x;
((BytesColumnVector)batch.cols[1]).setVal(r, y.getBytes());
}
writer.addRowBatch(batch);
}
}
Reader reader = OrcFile.createReader(TestFilePath, OrcFile.readerOptions(conf));
// check out the statistics
ColumnStatistics[] stats = reader.getStatistics();
Assert.Equal(3, stats.Length);
foreach (ColumnStatistics s in stats)
{
Assert.Equal(21000, s.getNumberOfValues());
if (s is IntegerColumnStatistics)
{
Assert.Equal(minInt, ((IntegerColumnStatistics)s).getMinimum());
Assert.Equal(maxInt, ((IntegerColumnStatistics)s).getMaximum());
}
else if (s is StringColumnStatistics)
{
Assert.Equal(maxStr, ((StringColumnStatistics)s).getMaximum());
Assert.Equal(minStr, ((StringColumnStatistics)s).getMinimum());
}
}
// check out the types
IList<OrcProto.Type> types = reader.getTypes();
Assert.Equal(3, types.Count);
Assert.Equal(OrcProto.Type.Types.Kind.STRUCT, types[0].Kind);
Assert.Equal(2, types[0].SubtypesCount);
Assert.Equal(1U, types[0].GetSubtypes(0));
Assert.Equal(2U, types[0].GetSubtypes(1));
Assert.Equal(OrcProto.Type.Types.Kind.INT, types[1].Kind);
Assert.Equal(0, types[1].SubtypesCount);
Assert.Equal(OrcProto.Type.Types.Kind.STRING, types[2].Kind);
Assert.Equal(0, types[2].SubtypesCount);
// read the contents and make sure they match
using (RecordReader rows1 = reader.rows(new bool[] { true, true, false }))
using (RecordReader rows2 = reader.rows(new bool[] { true, false, true }))
{
r1 = new Random(1);
r2 = new Random(2);
for (int i = 0; i < 21000; ++i)
{
Assert.Equal(true, rows1.hasNext());
Assert.Equal(true, rows2.hasNext());
OrcStruct row1 = (OrcStruct)rows1.next();
OrcStruct row2 = (OrcStruct)rows2.next();
Assert.Equal(r1.Next(), row1.getFieldValue(0));
Assert.Equal(Long.toHexString(r2.NextLong()),
row2.getFieldValue(1).ToString());
}
Assert.Equal(false, rows1.hasNext());
//.........这里部分代码省略.........
示例10: testSeek
public void testSeek()
{
TypeDescription schema = createBigRowSchema();
Random rand = new Random(42);
const int COUNT = 32768;
long[] intValues = new long[COUNT];
double[] doubleValues = new double[COUNT];
string[] stringValues = new string[COUNT];
byte[][] byteValues = new byte[COUNT][];
string[] words = new string[128];
using (Stream file = File.OpenWrite(TestFilePath))
using (Writer writer = OrcFile.createWriter(TestFilePath, file, OrcFile.writerOptions(conf)
.setSchema(schema)
.stripeSize(200000)
.bufferSize(65536)
.compress(CompressionKind.NONE) // Compression makes this very slow
.rowIndexStride(1000)))
{
VectorizedRowBatch batch = schema.createRowBatch();
for (int i = 0; i < words.Length; ++i)
{
words[i] = Integer.toHexString(rand.Next());
}
for (int i = 0; i < COUNT / 2; ++i)
{
intValues[2 * i] = rand.NextLong();
intValues[2 * i + 1] = intValues[2 * i];
stringValues[2 * i] = words[rand.Next(words.Length)];
stringValues[2 * i + 1] = stringValues[2 * i];
}
for (int i = 0; i < COUNT; ++i)
{
doubleValues[i] = rand.NextDouble();
byte[] buf = new byte[20];
rand.NextBytes(buf);
byteValues[i] = buf;
}
for (int i = 0; i < COUNT; ++i)
{
appendRandomRow(batch, intValues, doubleValues, stringValues,
byteValues, words, i);
if (batch.size == 1024)
{
writer.addRowBatch(batch);
batch.reset();
}
}
if (batch.size != 0)
{
writer.addRowBatch(batch);
}
}
Reader reader = OrcFile.createReader(TestFilePath,
OrcFile.readerOptions(conf));
Assert.Equal(COUNT, reader.getNumberOfRows());
using (RecordReader rows = reader.rows())
{
// get the row index
MetadataReader meta = ((RecordReaderImpl)rows).getMetadataReader();
RecordReaderImpl.Index index =
meta.readRowIndex(reader.getStripes()[0], null, null, null, null,
null);
// check the primitive columns to make sure they have the right number of
// items in the first row group
for (int c = 1; c < 9; ++c)
{
OrcProto.RowIndex colIndex = index.getRowGroupIndex()[c];
Assert.Equal(1000U,
colIndex.GetEntry(0).Statistics.NumberOfValues);
}
OrcStruct row = null;
for (int i = COUNT - 1; i >= 0; --i)
{
rows.seekToRow(i);
row = (OrcStruct)rows.next();
BigRow expected = createRandomRow(intValues, doubleValues,
stringValues, byteValues, words, i);
Assert.Equal(expected.boolean1, row.getFieldValue(0));
Assert.Equal(expected.byte1, row.getFieldValue(1));
Assert.Equal(expected.short1, row.getFieldValue(2));
Assert.Equal(expected.int1, row.getFieldValue(3));
Assert.Equal(expected.long1, row.getFieldValue(4));
Assert.Equal(expected.float1, (float)row.getFieldValue(5), 4);
Assert.Equal(expected.double1, (double)row.getFieldValue(6), 4);
Assert.Equal(expected.bytes1, row.getFieldValue(7));
Assert.Equal(expected.string1, row.getFieldValue(8));
List<InnerStruct> expectedList = expected.middle.list;
IList<object> actualList =
(IList<object>)((OrcStruct)row.getFieldValue(9)).getFieldValue(0);
compareList(expectedList, actualList);
compareList(expected.list, (IList<object>)row.getFieldValue(10));
}
}
long offsetOfStripe2 = 0;
long offsetOfStripe4 = 0;
long lastRowOfStripe2 = 0;
//.........这里部分代码省略.........
示例11: testDictionaryThreshold
public void testDictionaryThreshold()
{
// conf.set(HiveConf.ConfVars.HIVE_ORC_ENCODING_STRATEGY.varname, "COMPRESSION");
// conf.setFloat(HiveConf.ConfVars.HIVE_ORC_DICTIONARY_KEY_SIZE_THRESHOLD.varname, 0.49f);
using (Stream file = File.OpenWrite(TestFilePath))
{
OrcFile.WriterOptions options = new OrcFile.WriterOptions(new Properties(), conf);
options.inspector(ObjectInspectorFactory.getReflectionObjectInspector(typeof(MyRecord)));
options.stripeSize(100000);
options.compress(CompressionKind.ZLIB);
options.bufferSize(10000);
options.rowIndexStride(1000);
using (Writer writer = OrcFile.createWriter(TestFilePath, file, options))
{
Random r1 = new Random(1);
int nextInt = 0;
for (int i = 0; i < 21000; ++i)
{
// Write out the same string twice, this guarantees the fraction of rows with
// distinct strings is 0.5
if (i % 2 == 0)
{
nextInt = r1.Next(TestHelpers.words.Length);
// Append the value of i to the word, this guarantees when an index or word is repeated
// the actual string is unique.
TestHelpers.words[nextInt] += "-" + i;
}
writer.addRow(new MyRecord(r1.Next(), r1.NextLong(), TestHelpers.words[nextInt]));
}
}
}
string outputFilename = "orc-file-dump-dictionary-threshold.out";
using (CaptureStdout capture = new CaptureStdout(Path.Combine(workDir, outputFilename)))
{
FileDump.Main(new string[] { TestFilePath.ToString(), "--rowindex=1,2,3" });
}
TestHelpers.CompareFilesByLine(outputFilename, Path.Combine(workDir, outputFilename));
}
示例12: GenerateFakeEntities
public IList<Entity> GenerateFakeEntities(string entityName, int howMany)
{
var metadataProvider = _MetadataProvider;
var metadata = metadataProvider.GetEntityMetadata(entityName);
Random rand = new Random();
List<Entity> results = new List<Entity>();
// Used for generating random dates.
DateTime minCrmDate = new DateTime(1900, 1, 1);
int crmDayRange = (DateTime.Today - minCrmDate).Days;
for (int i = 0; i < howMany; i++)
{
var ent = new Microsoft.Xrm.Sdk.Entity(entityName);
ent.Id = Guid.NewGuid();
int stateCode = rand.Next(0, 1);
int statusCode = stateCode + 1;
foreach (var a in metadata.Attributes)
{
switch (a.AttributeType.Value)
{
case AttributeTypeCode.BigInt:
var randomBigInt = (long)rand.NextLong(0, Int64.MaxValue);
ent[a.LogicalName] = randomBigInt;
break;
case AttributeTypeCode.Boolean:
int randomBoolInt = rand.Next(0, 1);
ent[a.LogicalName] = randomBoolInt == 1;
break;
case AttributeTypeCode.CalendarRules:
break;
case AttributeTypeCode.Customer:
int randomCustomerInt = rand.Next(0, 1);
string customerentity = "contact";
Guid customerId = Guid.NewGuid();
if (randomCustomerInt == 1)
{
customerentity = "account";
}
EntityReference customerRef = new EntityReference(customerentity, customerId);
ent[a.LogicalName] = customerRef;
break;
case AttributeTypeCode.DateTime:
DateTime randomDate = rand.NextCrmDate(minCrmDate, crmDayRange);
ent[a.LogicalName] = randomDate;
break;
case AttributeTypeCode.Decimal:
var decAtt = (DecimalAttributeInfo)a;
var scale = decAtt.NumericScale;
byte byteScale = (byte)scale;
var randomDecimal = rand.NextDecimal(byteScale);
ent[a.LogicalName] = randomDecimal;
break;
case AttributeTypeCode.Double:
var doubleAtt = (DoubleAttributeInfo)a;
var doubleScale = doubleAtt.NumericScale;
byte byteDoubleScale = (byte)doubleScale;
// todo apply precision / scale
var randomDouble = rand.NextDouble();
ent[a.LogicalName] = randomDouble;
break;
case AttributeTypeCode.EntityName:
break;
case AttributeTypeCode.Integer:
ent[a.LogicalName] = rand.Next();
break;
case AttributeTypeCode.Lookup:
break;
case AttributeTypeCode.ManagedProperty:
break;
case AttributeTypeCode.Memo:
var randomMemoString = string.Format("Test Memo String {0}", DateTime.UtcNow.Ticks.ToString());
ent[a.LogicalName] = randomMemoString;
break;
case AttributeTypeCode.Money:
var moneyAtt = (MoneyAttributeInfo)a;
var mscale = moneyAtt.NumericScale;
byte bytemScale = (byte)mscale;
var randomMoneyDecimal = rand.NextDecimal(bytemScale);
var randMoney = new Money(randomMoneyDecimal);
ent[a.LogicalName] = randMoney;
break;
case AttributeTypeCode.Owner:
EntityReference ownerRef = new EntityReference("systemuser", Guid.NewGuid());
ent[a.LogicalName] = ownerRef;
break;
case AttributeTypeCode.PartyList:
break;
case AttributeTypeCode.Picklist:
OptionSetValue optValue = new OptionSetValue(rand.Next());
ent[a.LogicalName] = optValue;
break;
case AttributeTypeCode.State:
// todo randomise active and inactive.
var stateCodeOpt = new OptionSetValue(stateCode);
ent[a.LogicalName] = stateCodeOpt;
break;
//.........这里部分代码省略.........