本文整理汇总了C#中Binary类的典型用法代码示例。如果您正苦于以下问题:C# Binary类的具体用法?C# Binary怎么用?C# Binary使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Binary类属于命名空间,在下文中一共展示了Binary类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CanCompareToOtherBytes
public void CanCompareToOtherBytes()
{
var lhs = new Binary(new Byte[] { 1, 2, 3 });
var rhs = new Binary(new Byte[] { 1, 2, 3 });
Assert.Equal(0, lhs.CompareTo(rhs));
}
开发者ID:SparkSoftware,项目名称:infrastructure,代码行数:7,代码来源:BinaryTests.cs
示例2: CanSerializeToBson
public void CanSerializeToBson()
{
var binary = new Binary(Guid.Parse("a6c45a28-c572-4d5b-ac18-7b0ec2d723fb").ToByteArray());
var bson = WriteBson(new BinaryContainer { Value = binary });
Validate(bson, "IQAAAAVWYWx1ZQAQAAAAAChaxKZyxVtNrBh7DsLXI/sA");
}
开发者ID:SparkSoftware,项目名称:infrastructure,代码行数:7,代码来源:BinaryConverterTests.cs
示例3: WrapUnderlyingBytes
public void WrapUnderlyingBytes()
{
var rawBytes = new Byte[0];
var bytes = new Binary(rawBytes);
Assert.Same(rawBytes, (Byte[])bytes);
}
开发者ID:SparkSoftware,项目名称:infrastructure,代码行数:7,代码来源:BinaryTests.cs
示例4: CanCompareToBoxedRawBytes
public void CanCompareToBoxedRawBytes()
{
var lhs = new Binary(new Byte[] { 1, 2, 3 });
var rhs = new Byte[] { 1, 2, 3 };
Assert.Equal(0, lhs.CompareTo((Object)rhs));
}
开发者ID:SparkSoftware,项目名称:infrastructure,代码行数:7,代码来源:BinaryTests.cs
示例5: CanBeCloned
public void CanBeCloned(){
var binarySource = new Binary(new byte[] {10, 20}, BinarySubtype.UserDefined);
var binaryDest = binarySource.Clone() as Binary;
Assert.IsNotNull(binaryDest);
Assert.AreEqual(binarySource.Bytes,binaryDest.Bytes);
Assert.AreEqual(binarySource.Subtype,binaryDest.Subtype);
}
开发者ID:gaoninggn,项目名称:mongodb-csharp,代码行数:7,代码来源:TestBinary.cs
示例6: TestUpdates
public void TestUpdates()
{
SessionStateItemCollection items = new SessionStateItemCollection();
items["Val1"] = "value";
byte[] serializedItems = Serialize(items);
Binary b = new Binary(serializedItems);
List<string> ids = new List<string>();
ICursor allSessions;
using (var mongo = new Mongo(config))
{
mongo.Connect();
allSessions = mongo["session_store"]["sessions"].FindAll();
foreach (Document session in allSessions.Documents)
{
string id = (string)session["SessionId"];
ids.Add(id);
}
}
foreach (string s in ids)
{
var sessionStore = new SessionStore("test");
sessionStore.UpdateSession(s, 2, b, "AppName", items.Count, 0);
}
}
开发者ID:GunioRobot,项目名称:MongoSessionStore,代码行数:25,代码来源:ConnectionTest.cs
示例7: SaveMacroPlanTest
public void SaveMacroPlanTest(string imagepath)
{
//assign
var shapemodelpath = "filepath";
var note = "note";
var exportUnit = "mm";
var image = new HImage(imagepath);
var imageBinData = new Binary(ImageConventer.ConvertHalconImageToByteArray(image, false));
var matchingParam = new MatchingParam();
var matchingParamByteArray = ModelSerializer.DoSerialize(matchingParam);
var matchingParamBinData = new Binary(matchingParamByteArray);
BindingList<GeoDataGridViewModel> a = new BindingList<GeoDataGridViewModel>();
a.Add(new GeoDataGridViewModel() { RecordID = "aaa" });
var measureBinData = ModelSerializer.DoSerialize(a);
//BindingList a;
var ma = new MeasureAssistant();
var maParam = ma.GetMeasureAssistantParam();
var maParamBin = ModelSerializer.DoSerialize(maParam);
LightChannel upper = new LightChannel() { Channel = "00", Intensity = 100, OnOff = LightSwitch.On };
LightChannel bottom = new LightChannel() { Channel = "01", Intensity = 200, OnOff = LightSwitch.OFF };
//act
var success = SDMSRepo.SaveMacroPlan("Test", Guid.NewGuid().ToString(), shapemodelpath, note, imageBinData, exportUnit, matchingParamBinData, measureBinData, maParamBin, upper, bottom, new ShapeViewModel() { }, "system", "");
//assert
Assert.True(success);
}
开发者ID:Joncash,项目名称:HanboAOMClassLibrary,代码行数:35,代码来源:SDMSRepoTest.cs
示例8: CanDeserializeValidJson
public void CanDeserializeValidJson()
{
var expected = new Binary(Guid.Parse("a6c45a28-c572-4d5b-ac18-7b0ec2d723fb").ToByteArray());
var actual = ReadJson<Binary>("\"KFrEpnLFW02sGHsOwtcj+w==\"");
Assert.Equal(expected, actual);
}
开发者ID:SparkSoftware,项目名称:infrastructure,代码行数:7,代码来源:BinaryConverterTests.cs
示例9: ConvertBinaryToItemId
private string ConvertBinaryToItemId(Binary binary)
{
byte[] binaryString = binary.ToArray();
// if the original encoding was ASCII
string x = Encoding.ASCII.GetString(binaryString);
// if the original encoding was UTF-8
string y = Encoding.UTF8.GetString(binaryString);
// if the original encoding was UTF-16
string z = Encoding.Unicode.GetString(binaryString);
string strBinary = binary.ToString();
StringBuilder result = new StringBuilder(strBinary.Length / 8 + 1);
// TODO: check all 1's or 0's... Will throw otherwise
int mod4Len = binary.Length % 8;
if (mod4Len != 0)
{
// pad to length multiple of 8
strBinary = strBinary.PadLeft(((strBinary.Length / 8) + 1) * 8, '0');
}
for (int i = 0; i < binary.Length; i += 8)
{
string eightBits = strBinary.Substring(i, 8);
result.AppendFormat("{0:X2}", System.Convert.ToByte(eightBits, 2));
}
return result.ToString();
}
开发者ID:Velir,项目名称:Sitecore-Analytics,代码行数:33,代码来源:TestVariationGrouping.cs
示例10: Load
public static UIConfig Load()
{
var cfg = XConfig.Current;
if (cfg.Extend.IsNullOrWhiteSpace()) return null;
Byte[] buf = null;
try
{
buf = cfg.Extend.ToBase64();
}
catch { return null; }
var ms = new MemoryStream(buf);
var binary = new Binary();
binary.EncodeInt = true;
binary.AddHandler<BinaryFont>(11);
binary.AddHandler<BinaryColor>(12);
binary.AddHandler<BinaryUnknown>(20);
binary.Stream = ms;
//binary.Debug = true;
//binary.EnableTrace();
try
{
return binary.Read(typeof(UIConfig)) as UIConfig;
}
catch { return null; }
}
开发者ID:,项目名称:,代码行数:30,代码来源:
示例11: Compile
internal Binary Compile()
{
//CSharpCompiler = new CSharpCodeProvider().CreateCompiler();
//parameters = new CompilerParameters();
//foreach (var require in Require) {
// parameters.ReferencedAssemblies.Add(string.Format("{0}.dll", require));
//}
//parameters.GenerateInMemory = true;
var compiler = CodeDomProvider.CreateProvider("CSharp");
var parameters = new CompilerParameters(Require.ToArray());
var codeUnit = new CodeCompileUnit();
codeNamespace = new CodeNamespace("Unahi.CRake.RuntimeGenerated");
codeUnit.Namespaces.Add(codeNamespace);
binary = new Binary();
foreach (var item in Imports) {
codeNamespace.Imports.Add(new CodeNamespaceImport(item));
}
CompileClass("", Tasks, Namespaces, null);
//CompileTasks(binary, "", Tasks, this, codeNamespace, null);
//CompileNamespaces(binary, "", Namespaces, codeNamespace, null);
binary.CompiledResult = compiler.CompileAssemblyFromDom(parameters, codeUnit);
return binary;
}
开发者ID:felipecvo,项目名称:crake,代码行数:29,代码来源:Compiler.cs
示例12: CanSerializeToJson
public void CanSerializeToJson()
{
var binary = new Binary(Guid.Parse("a6c45a28-c572-4d5b-ac18-7b0ec2d723fb").ToByteArray());
var json = WriteJson(binary);
Validate(json, "\"KFrEpnLFW02sGHsOwtcj+w==\"");
}
开发者ID:SparkSoftware,项目名称:infrastructure,代码行数:7,代码来源:BinaryConverterTests.cs
示例13: CanImplicitConvertedToBytes
public void CanImplicitConvertedToBytes(){
var bytes = new byte[]{10,12};
var binary = new Binary(bytes);
var converted = (byte[])binary;
Assert.IsNotNull(converted);
Assert.AreEqual(bytes, converted);
}
开发者ID:gaoninggn,项目名称:mongodb-csharp,代码行数:7,代码来源:TestBinary.cs
示例14: ToString
/// <summary>
/// Converts binary value to string.
/// </summary>
/// <param name="version">Binary version number.</param>
/// <returns>Base64 version number.</returns>
public static string ToString(Binary version)
{
if (version == null)
return null;
return Convert.ToBase64String(version.ToArray());
}
开发者ID:ronymaychan,项目名称:demos,代码行数:12,代码来源:VersionConverter.cs
示例15: fluDocument_UploadedComplete
protected void fluDocument_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
{
if (this.fluDocument.HasFile)
{
if (this.fluDocument.PostedFile.ContentType.Equals("image/pjpeg") || this.fluDocument.PostedFile.ContentType.Equals("image/x-png"))
{
byte[] fileByte = this.fluDocument.FileBytes;
Binary binaryObj = new Binary(fileByte);
Ajancy.Kimia_Ajancy db = new Ajancy.Kimia_Ajancy(Public.ConnectionString);
Ajancy.Doument doc = db.Douments.FirstOrDefault<Ajancy.Doument>(d => d.PersonID == Public.ActiveUserRole.User.PersonID && d.DocumentType == 1);
if (doc == null)
{
doc = new Ajancy.Doument
{
DocumentType = Public.ToByte(this.drpType.SelectedValue),
PersonID = Public.ActiveUserRole.User.PersonID,
Picture = binaryObj,
SubmitDate = DateTime.Now
};
db.Douments.InsertOnSubmit(doc);
}
else
{
doc.Picture = binaryObj;
}
db.SubmitChanges();
db.Dispose();
}
}
}
开发者ID:BehnamAbdy,项目名称:Ajancy,代码行数:31,代码来源:UploadDocument.aspx.cs
示例16: SetAndReleaseItemExclusive
public override void SetAndReleaseItemExclusive(HttpContext context, string id, SessionStateStoreData item, object lockId, bool newItem)
{
var sessionStore = SessionStore.Instance;
try
{
byte[] serializedItems = Serialize((SessionStateItemCollection)item.Items);
Binary sessionItems = new Binary(serializedItems);
if (newItem)
{
// Delete an existing expired session if it exists.
sessionStore.EvictExpiredSession(id, _applicationName);
// insert new session item.
Session session = new Session(id, this._applicationName, item.Timeout, sessionItems, item.Items.Count, 0);
sessionStore.Insert(session);
}
else
{
sessionStore.UpdateSession(id, item.Timeout, sessionItems, this._applicationName, item.Items.Count, lockId);
}
}
catch (Exception e)
{
if (WriteExceptionsToEventLog)
{
WriteToEventLog(e, "SetAndReleaseItemExclusive");
throw new ProviderException(e.Message, e.InnerException);
}
else
throw e;
}
}
开发者ID:jango2015,项目名称:MongoSessionStore,代码行数:34,代码来源:MongoSessionStoreProvider.cs
示例17: BinaryExpression
public BinaryExpression(Binary Operator, Expression Left, Expression Right)
{
this.op = Operator;
this.left = Left;
this.right = Right;
}
开发者ID:lekararikoldprojects,项目名称:AlgebraSystem,代码行数:7,代码来源:BinaryExpression.cs
示例18: ConvertToIntTest
public void ConvertToIntTest()
{
Binary bin = new Binary(new byte[] { 0, 0, 4 });
int expected = 4;
int actual;
actual = Extensions.ConvertToInt(bin);
Assert.AreEqual(expected, actual);
}
开发者ID:MaxWarren,项目名称:EECS-393-Project,代码行数:8,代码来源:ExtensionsTest.cs
示例19: ConvertTypeToBinaryTest
public void ConvertTypeToBinaryTest()
{
TaskType type = TaskType.Development;
Binary expected = new Binary(new byte[] { 0, 0, 1 });
Binary actual;
actual = Extensions.ConvertToBinary(type);
Assert.AreEqual(expected, actual);
}
开发者ID:MaxWarren,项目名称:EECS-393-Project,代码行数:8,代码来源:ExtensionsTest.cs
示例20: BinaryToImage
/// <summary>
/// 將二進位資料轉換為 Bitmap,指定寬高
/// </summary>
/// <param name="data"></param>
/// <param name="width">長</param>
/// <param name="height">寬</param>
/// <returns></returns>
public static Bitmap BinaryToImage(Binary data, int width, int height)
{
var image = BinaryToImage(data);
if (image != null)
return new Bitmap(image, new Size(width, height));
else
return null;
}
开发者ID:Joncash,项目名称:HanboAOMClassLibrary,代码行数:15,代码来源:ImageHelper.cs
注:本文中的Binary类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论