Here are the examples of the csharp api System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(System.IO.Stream) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
693 Examples
19
Source : DataManager.cs
with MIT License
from azsumas
with MIT License
from azsumas
public static object ReadBinaryPersistentPath<T>(string fileName)
{
Debug.Log("PersistentDataPath: " + Application.persistentDataPath);
string pathFile = Application.persistentDataPath + "/Data/Slots/" + fileName;
T data;
using(Stream stream = File.Open(pathFile, FileMode.Open))
{
var bformatter = new BinaryFormatter();
data = (T)bformatter.Deserialize(stream);
}
return data;
}
19
Source : DBEntry.cs
with The Unlicense
from BAndysc
with The Unlicense
from BAndysc
public void Attach()
{
if (Data != null && Data.Rows.Count > 0)
return;
using (FileStream fs = new(Path.Combine(TempFolder, Tag + ".cache"), FileMode.Open))
using (MemoryMappedFile mmf = MemoryMappedFile.CreateFromFile(fs,
Tag,
fs.Length,
MemoryMappedFileAccess.ReadWrite,
HandleInheritability.None,
false))
using (MemoryMappedViewStream stream = mmf.CreateViewStream(0, fs.Length, MemoryMappedFileAccess.Read))
{
BinaryFormatter formatter = new BinaryFormatter();
Data = (DataTable) formatter.Deserialize(stream);
}
}
19
Source : StoreSerializer.cs
with MIT License
from Bannerlord-Coop-Team
with MIT License
from Bannerlord-Coop-Team
public object Deserialize(byte[] raw)
{
var buffer = new MemoryStream(raw);
return Factory == null
? new BinaryFormatter().Deserialize(buffer)
: Factory.Unwrap(new BinaryFormatter().Deserialize(buffer));
}
19
Source : ExceptionSerializationTests.cs
with GNU Lesser General Public License v3.0
from Barsonax
with GNU Lesser General Public License v3.0
from Barsonax
[Theory]
[ClreplacedData(typeof(ExceptionSerializationTheoryData))]
public void AuthorizationRequiredException_serialization_deserialization_test(Exception originalException)
{
//ARRANGE
var buffer = new byte[4096];
var ms = new MemoryStream(buffer);
var ms2 = new MemoryStream(buffer);
var formatter = new BinaryFormatter();
//ACT
formatter.Serialize(ms, originalException);
var deserializedException = (Exception)formatter.Deserialize(ms2);
//replacedERT
replacedert.Equal(originalException.InnerException?.Message, deserializedException.InnerException?.Message);
replacedert.Equal(originalException.Message, deserializedException.Message);
}
19
Source : Utils.cs
with MIT License
from bartekmotyl
with MIT License
from bartekmotyl
public static T DeepClone<T>(this T obj)
{
using (MemoryStream memory_stream = new MemoryStream())
{
// Serialize the object into the memory stream.
BinaryFormatter formatter = new BinaryFormatter();
formatter.Serialize(memory_stream, obj);
// Rewind the stream and use it to create a new object.
memory_stream.Position = 0;
return (T)formatter.Deserialize(memory_stream);
}
}
19
Source : SaveGameBinarySerializer.cs
with MIT License
from BayatGames
with MIT License
from BayatGames
public T Deserialize<T> ( Stream stream, Encoding encoding )
{
T result = default(T);
#if !UNITY_WSA || !UNITY_WINRT
try
{
BinaryFormatter formatter = new BinaryFormatter ();
result = ( T )formatter.Deserialize ( stream );
}
catch ( Exception ex )
{
Debug.LogException ( ex );
}
#else
Debug.LogError ( "SaveGameFree: The Binary Serialization isn't supported in Windows Store and UWP." );
#endif
return result;
}
19
Source : Config.cs
with Apache License 2.0
from BeichenDream
with Apache License 2.0
from BeichenDream
public static void init() {
using (FileStream stream = new FileStream("MysqlT.bin", FileMode.OpenOrCreate))
{
if (stream.Length > 0)
{
BinaryFormatter binary = new BinaryFormatter();
config = (Config)binary.Deserialize(stream);
}
}
GetConfig();
}
19
Source : Patch.cs
with MIT License
from BepInEx
with MIT License
from BepInEx
internal static PatchInfo Deserialize(byte[] bytes)
{
var formatter = new BinaryFormatter { Binder = new Binder() };
var streamMemory = new MemoryStream(bytes);
return (PatchInfo)formatter.Deserialize(streamMemory);
}
19
Source : Patch.cs
with GNU General Public License v3.0
from BepInEx
with GNU General Public License v3.0
from BepInEx
public static PatchInfo Deserialize(byte[] bytes)
{
var formatter = new BinaryFormatter { Binder = new Binder() };
#pragma warning disable XS0001
var streamMemory = new MemoryStream(bytes);
#pragma warning restore XS0001
return (PatchInfo)formatter.Deserialize(streamMemory);
}
19
Source : UI_Teleport.cs
with GNU General Public License v3.0
from berichan
with GNU General Public License v3.0
from berichan
private void loadAnchors()
{
BinaryFormatter bf = new BinaryFormatter();
FileStream file = File.Open(TeleportPath, FileMode.OpenOrCreate);
var anchors = file.Length > 0 ? (PosRotAnchor[])bf.Deserialize(file) : new PosRotAnchor[0];
file.Close();
if (anchors != null)
teleports = new List<PosRotAnchor>(anchors);
updateGUI();
}
19
Source : BaseOptionModel.cs
with MIT License
from bert2
with MIT License
from bert2
protected virtual object DeserializeValue(string value, Type type) {
byte[] b = Convert.FromBase64String(value);
using (var stream = new MemoryStream(b)) {
var formatter = new BinaryFormatter();
return formatter.Deserialize(stream);
}
}
19
Source : ReferenceFinderData.cs
with MIT License
from blueberryzzz
with MIT License
from blueberryzzz
public bool ReadFromCache()
{
replacedetDict.Clear();
if (!File.Exists(CACHE_PATH))
{
return false;
}
var serializedGuid = new List<string>();
var serializedDependencyHash = new List<string>();
var serializedDenpendencies = new List<int[]>();
//反序列化数据
FileStream fs = File.OpenRead(CACHE_PATH);
try
{
BinaryFormatter bf = new BinaryFormatter();
string cacheVersion = (string) bf.Deserialize(fs);
if (cacheVersion != CACHE_VERSION)
{
return false;
}
EditorUtility.DisplayCancelableProgressBar("Import Cache", "Reading Cache", 0);
serializedGuid = (List<string>) bf.Deserialize(fs);
serializedDependencyHash = (List<string>) bf.Deserialize(fs);
serializedDenpendencies = (List<int[]>) bf.Deserialize(fs);
EditorUtility.ClearProgressBar();
}
catch
{
//兼容旧版本序列化格式
return false;
}
finally
{
fs.Close();
}
for (int i = 0; i < serializedGuid.Count; ++i)
{
string path = replacedetDatabase.GUIDToreplacedetPath(serializedGuid[i]);
if (!string.IsNullOrEmpty(path))
{
var ad = new replacedetDescription();
ad.name = Path.GetFileNameWithoutExtension(path);
ad.path = path;
ad.replacedetDependencyHash = serializedDependencyHash[i];
replacedetDict.Add(serializedGuid[i], ad);
}
}
for(int i = 0; i < serializedGuid.Count; ++i)
{
string guid = serializedGuid[i];
if (replacedetDict.ContainsKey(guid))
{
var guids = serializedDenpendencies[i].
Select(index => serializedGuid[index]).
Where(g => replacedetDict.ContainsKey(g)).
ToList();
replacedetDict[guid].dependencies = guids;
}
}
UpdateReferenceInfo();
return true;
}
19
Source : SaveManager.cs
with MIT License
from bonzaiferroni
with MIT License
from bonzaiferroni
public static T Load<T>(string identifier) {
var path = GetPath(identifier);
if (File.Exists(path)) {
BinaryFormatter bf = new BinaryFormatter();
FileStream file = File.Open(path, FileMode.Open);
var obj = (T) bf.Deserialize(file);
file.Close();
return obj;
} else {
throw new Exception("no file saved");
}
}
19
Source : ObjectAssertionsExtensions.cs
with Apache License 2.0
from BoundfoxStudios
with Apache License 2.0
from BoundfoxStudios
private static object CreateCloneUsingBinarySerializer(object subject)
{
using (var stream = new MemoryStream())
{
var binaryFormatter = new BinaryFormatter
{
Binder = new SimpleBinder(subject.GetType())
};
binaryFormatter.Serialize(stream, subject);
stream.Position = 0;
return binaryFormatter.Deserialize(stream);
}
}
19
Source : CopyHelper.cs
with MIT License
from brunurd
with MIT License
from brunurd
public static T DeepCopy<T>(T other)
{
using(var ms = new MemoryStream())
{
var formatter = new BinaryFormatter();
formatter.Serialize(ms, other);
ms.Position = 0;
return (T) formatter.Deserialize(ms);
}
}
19
Source : InvalidDotNetSolutionExceptionTests.cs
with MIT License
from ByteDev
with MIT License
from ByteDev
[Test]
public void WhenSerialized_ThenDeserializeCorrectly()
{
var sut = new InvalidDotNetSolutionException(ExMessage);
var formatter = new BinaryFormatter();
using (var stream = new MemoryStream())
{
formatter.Serialize(stream, sut);
stream.Seek(0, 0);
var result = (InvalidDotNetSolutionException)formatter.Deserialize(stream);
replacedert.That(result.ToString(), Is.EqualTo(sut.ToString()));
}
}
19
Source : InvalidDotNetProjectExceptionTests.cs
with MIT License
from ByteDev
with MIT License
from ByteDev
[Test]
public void WhenSerialized_ThenDeserializeCorrectly()
{
var sut = new InvalidDotNetProjectException(ExMessage);
var formatter = new BinaryFormatter();
using (var stream = new MemoryStream())
{
formatter.Serialize(stream, sut);
stream.Seek(0, 0);
var result = (InvalidDotNetProjectException)formatter.Deserialize(stream);
replacedert.That(result.ToString(), Is.EqualTo(sut.ToString()));
}
}
19
Source : SaveManager.cs
with MIT License
from CandyCoded
with MIT License
from CandyCoded
public static T LoadData<T>(string fileName, string directory)
{
var path = Path.Combine(directory, fileName);
var binaryFormatter = new BinaryFormatter();
using (var fs = File.OpenRead(path))
{
T data;
try
{
data = (T)binaryFormatter.Deserialize(fs);
}
catch (Exception err)
{
Debug.LogError(err.Message);
throw;
}
finally
{
fs.Close();
}
return data;
}
}
19
Source : GameData.cs
with MIT License
from ccajas
with MIT License
from ccajas
public bool LoadGame(int loadNumber)
{
string fileName = saveFolder + "Player_" + loadNumber.ToString() + saveExt;
bool success = true;
if (File.Exists(fileName) == false)
{
Console.WriteLine("File does not exist: " + fileName);
return false;
}
FileStream fs = new FileStream(fileName, FileMode.Open);
try
{
BinaryFormatter formatter = new BinaryFormatter();
// Set new deserialized data
if (fs.Length != 0)
{
playerData = (Player.PlayerData)formatter.Deserialize(fs);
}
else
{
Player.PlayerData data = new Player.PlayerData()
{
position = new Vector3(200, 150, -20),
orientation = 0
};
playerData = data;
}
}
catch (SerializationException e)
{
success = false;
Console.WriteLine("Failed to deserialize data. Reason: " + e.Message);
throw;
}
finally { fs.Close(); }
return success;
}
19
Source : Utils.cs
with BSD 3-Clause "New" or "Revised" License
from celechii
with BSD 3-Clause "New" or "Revised" License
from celechii
public static T DeepCopy<T>(T other) {
using(MemoryStream ms = new MemoryStream()) {
BinaryFormatter formatter = new BinaryFormatter();
formatter.Serialize(ms, other);
ms.Position = 0;
return (T)formatter.Deserialize(ms);
}
}
19
Source : LocalData.cs
with GNU General Public License v3.0
from Ch3shireDev
with GNU General Public License v3.0
from Ch3shireDev
public void LoadColumns(ref ListViewEx PlaylistView)
{
if (PlaylistView == null) return;
var Name = Path + "columns.dat";
if (!File.Exists(Name)) return;
try
{
var fs = new FileStream(Name, FileMode.Open);
if (!fs.CanRead) return;
var formatter = new BinaryFormatter();
var Widths = formatter.Deserialize(fs) as List<int>;
fs.Close();
if (Widths == null) return;
for (var i = 0; i < PlaylistView.Columns.Count; i++)
{
if (i >= Widths.Count) return;
PlaylistView.Columns[i].Width = Widths[i];
}
}
catch
{
try
{
File.Delete(Name);
}
catch
{
Debug.WriteLine("Can't delete file!");
}
Debug.WriteLine("Can't read from columns file!");
}
Debug.WriteLine("Data loaded from " + Name);
}
19
Source : LocalData.cs
with GNU General Public License v3.0
from Ch3shireDev
with GNU General Public License v3.0
from Ch3shireDev
private MusicPage LoadPlaylist(int i)
{
var Name = GetFullPath(i);
if (!File.Exists(Name)) return null;
var fs = new FileStream(Name, FileMode.Open);
if (!fs.CanRead) return null;
if (fs == null) return null;
var formatter = new BinaryFormatter();
if (fs.Length == 0) return null;
var data = formatter.Deserialize(fs) as PlaylistData;
fs.Close();
if (data == null) return null;
return data.GetMusicPage();
}
19
Source : SerializationTests.cs
with MIT License
from Chris3606
with MIT License
from Chris3606
private void TestSerialization<T>(T typeToSerialize, System.Func<T, T, bool> equality = null)
{
if (equality == null)
equality = (t1, t2) => t1.Equals(t2);
string name = $"{typeof(T)}.bin";
var formatter = new BinaryFormatter();
using (var stream = new FileStream(name, FileMode.Create, FileAccess.Write))
formatter.Serialize(stream, typeToSerialize);
T reSerialized = default;
using (var stream = new FileStream(name, FileMode.Open, FileAccess.Read))
reSerialized = (T)formatter.Deserialize(stream);
replacedert.AreEqual(true, equality(typeToSerialize, reSerialized));
}
19
Source : SerializableDataExtension.cs
with MIT License
from CitiesSkylinesMods
with MIT License
from CitiesSkylinesMods
private static void DeserializeData(byte[] data) {
bool error = false;
try {
if (data != null && data.Length != 0) {
Log.Info($"Loading Data from New Load Routine! Length={data.Length}");
var memoryStream = new MemoryStream();
memoryStream.Write(data, 0, data.Length);
memoryStream.Position = 0;
var binaryFormatter = new BinaryFormatter();
binaryFormatter.replacedemblyFormat = System
.Runtime.Serialization.Formatters
.FormatterreplacedemblyStyle.Simple;
_configuration = (Configuration)binaryFormatter.Deserialize(memoryStream);
} else {
Log.Info("No data to deserialize!");
}
}
catch (Exception e) {
Log.Error($"Error deserializing data: {e}");
Log.Info(e.StackTrace);
error = true;
}
if (!error) {
LoadDataState(out error);
}
if (error) {
throw new ApplicationException("An error occurred while loading");
}
}
19
Source : SerializationUtil.cs
with MIT License
from CitiesSkylinesMods
with MIT License
from CitiesSkylinesMods
public static object Deserialize(byte[] data) {
if (data == null)
return null;
var memoryStream = new MemoryStream();
memoryStream.Write(data, 0, data.Length);
memoryStream.Position = 0;
return GetBinaryFormatter.Deserialize(memoryStream);
}
19
Source : BinarySerializer.cs
with MIT License
from Cloet
with MIT License
from Cloet
public object DeserializeBytesToObject(byte[] bytes, Type objType)
{
using (var memStream = new MemoryStream(bytes))
{
return new BinaryFormatter().Deserialize(memStream);
}
}
19
Source : UsbDeviceFinder.cs
with GNU General Public License v3.0
from ClusterM
with GNU General Public License v3.0
from ClusterM
public static UsbDeviceFinder Load(Stream deviceFinderStream)
{
BinaryFormatter formatter = new BinaryFormatter();
return formatter.Deserialize(deviceFinderStream) as UsbDeviceFinder;
}
19
Source : BinarySerializationHelper.cs
with GNU Lesser General Public License v3.0
from cnAbp
with GNU Lesser General Public License v3.0
from cnAbp
public static object Deserialize(Stream stream)
{
return CreateBinaryFormatter().Deserialize(stream);
}
19
Source : BinarySerializationHelper.cs
with GNU Lesser General Public License v3.0
from cnAbp
with GNU Lesser General Public License v3.0
from cnAbp
public static object DeserializeExtended(byte[] bytes)
{
using (var memoryStream = new MemoryStream(bytes))
{
return CreateBinaryFormatter(true).Deserialize(memoryStream);
}
}
19
Source : BinarySerializationHelper.cs
with GNU Lesser General Public License v3.0
from cnAbp
with GNU Lesser General Public License v3.0
from cnAbp
public static object DeserializeExtended(Stream stream)
{
return CreateBinaryFormatter(true).Deserialize(stream);
}
19
Source : DefaultBinarySerializer.cs
with MIT License
from cocosip
with MIT License
from cocosip
public object Deserialize(byte[] data, Type type)
{
using (var stream = new MemoryStream(data))
{
stream.Position = 0;
return _binaryFormatter.Deserialize(stream);
}
}
19
Source : DefaultBinarySerializer.cs
with MIT License
from cocosip
with MIT License
from cocosip
public T Deserialize<T>(byte[] data)
{
using (var stream = new MemoryStream(data))
{
stream.Position = 0;
return (T)_binaryFormatter.Deserialize(stream);
}
}
19
Source : SerializationMethodBinary.cs
with MIT License
from coryleach
with MIT License
from coryleach
public object Load(Type savedObjectType, FileStream fileStream)
{
object loadedObj = null;
//Creating the formatter every time because this may get used in a task and I'm not sure if it's thread safe
var formatter = new BinaryFormatter();
loadedObj = formatter.Deserialize(fileStream);
return loadedObj;
}
19
Source : SerializationMethodBinary.cs
with MIT License
from coryleach
with MIT License
from coryleach
public object Copy(object copyObject)
{
using (var stream = new MemoryStream())
{
var formatter = new BinaryFormatter();
formatter.Serialize(stream, copyObject);
stream.Position = 0;
return formatter.Deserialize(stream);
}
}
19
Source : Tag.cs
with GNU General Public License v3.0
from Corsinvest
with GNU General Public License v3.0
from Corsinvest
private static T DeepClone<T>(T obj)
{
using (var stream = new MemoryStream())
{
var formatter = new BinaryFormatter();
formatter.Serialize(stream, obj);
stream.Seek(0, SeekOrigin.Begin);
return (T)formatter.Deserialize(stream);
}
}
19
Source : SerializationMethodBinaryEncrypted.cs
with MIT License
from coryleach
with MIT License
from coryleach
public object Load(Type savedObjectType, FileStream fileStream)
{
object loadedObj = null;
using (var memoryStream = new MemoryStream())
{
EncryptionUtility.Decrypt(fileStream,memoryStream,_key,_salt);
memoryStream.Position = 0;
//Creating the formatter every time because this may get used in a task and I'm not sure if it's thread safe
var formatter = new BinaryFormatter();
loadedObj = formatter.Deserialize(memoryStream);
}
return loadedObj;
}
19
Source : MessageTemplateCachePreheater.cs
with Apache License 2.0
from cosmos-loops
with Apache License 2.0
from cosmos-loops
public void AddFromStream(Stream stream) {
try {
var bf = new BinaryFormatter();
if (bf.Deserialize(stream) is List<MessageTemplate> buffer) {
AddInternal(buffer);
}
} catch {
InternalLogger.WriteLine("Throw exception when deserialize stream to List<MessageTemplate>.");
}
}
19
Source : ObjectExtension.cs
with MIT License
from cq-panda
with MIT License
from cq-panda
public static object ToObject(this byte[] source)
{
using (var memStream = new MemoryStream())
{
var bf = new BinaryFormatter();
memStream.Write(source, 0, source.Length);
memStream.Seek(0, SeekOrigin.Begin);
var obj = bf.Deserialize(memStream);
return obj;
}
}
19
Source : Services.cs
with Apache License 2.0
from cqjjjzr
with Apache License 2.0
from cqjjjzr
protected void LoadCookie()
{
var path = Path.Combine(SessionFolder, $"{GetType().Name}.session");
CookieContainer container;
if (File.Exists(path))
using (Stream stream = File.OpenRead(path))
container = (CookieContainer) new BinaryFormatter().Deserialize(stream);
else
container = new CookieContainer();
UpdateCookie(container);
}
19
Source : GlobalSettings.cs
with MIT License
from crouvpony47
with MIT License
from crouvpony47
public static void GlobalSettingsInit()
{
Settings = new GlobalSettings();
appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
settingsFN = Path.Combine(appDataPath, "furdown\\furdown.conf");
// true portable mode
if (File.Exists("./furdown-portable.conf"))
{
settingsFN = "./furdown-portable.conf";
}
// if settings file exists, load it
bool needToSetDefaults = false;
if (File.Exists(settingsFN))
{
using (Stream stream = File.Open(settingsFN, FileMode.Open))
{
var bformatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
try
{
Settings = (GlobalSettings)bformatter.Deserialize(stream);
}
// settings file is present, but failed to be loaded
catch
{
needToSetDefaults = true;
Console.WriteLine("Settings file is incompatible or corrupted, restoring defaults.");
}
}
}
else
{
needToSetDefaults = true;
}
// set defaults, if settings file does not exist or otherwise not loaded
if (needToSetDefaults)
{
Settings.downloadPath = Path.Combine(appDataPath, "furdown\\downloads");
Settings.systemPath = Path.Combine(appDataPath, "furdown\\system");
Settings.filenameTemplate = "%ARTIST%%SCRAPS%\\%SUBMID%.%FILEPART%";
Settings.descrFilenameTemplate = "%ARTIST%%SCRAPS%\\%SUBMID%.%FILEPART%.dsc.htm";
Settings.downloadOnlyOnce = true;
Settings.scrapsTemplateActive = ".scraps";
Settings.scrapsTemplateActive = "";
try
{
Directory.CreateDirectory(Settings.downloadPath);
Directory.CreateDirectory(Settings.systemPath);
}
catch
{
Console.WriteLine("[Error] Default paths are invalid!");
}
}
else
{
if (!Directory.Exists(Settings.downloadPath))
Directory.CreateDirectory(Settings.downloadPath);
if (!Directory.Exists(Settings.systemPath))
Directory.CreateDirectory(Settings.systemPath);
}
SubmissionsDB.Load();
}
19
Source : SubmissionsDB.cs
with MIT License
from crouvpony47
with MIT License
from crouvpony47
public static void Load()
{
try
{
string dbFN = Path.Combine(GlobalSettings.Settings.systemPath, "furdown.db");
using (Stream stream = File.Open(dbFN, FileMode.Open))
{
var bformatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
try
{
DB = (SubmissionsDB)bformatter.Deserialize(stream);
}
// DB file is present, but failed to be loaded
catch
{
Console.WriteLine("Failed to load DB, using empty one.");
}
}
}
catch
{
Console.WriteLine("No DB found.");
}
}
19
Source : CloneHelper.cs
with Apache License 2.0
from cs-util-com
with Apache License 2.0
from cs-util-com
public static T DeepCopySerializable<T>(T objectToDeepCopy) {
if (!typeof(T).IsSerializable) { throw new ArgumentException("The preplaceded objectToDeepCopy must be serializable"); }
var formatter = new BinaryFormatter();
var stream = new MemoryStream();
using (stream) {
formatter.Serialize(stream, objectToDeepCopy);
stream.Seek(0, SeekOrigin.Begin);
return (T)formatter.Deserialize(stream);
}
}
19
Source : Screen.cs
with MIT License
from ctsecurity
with MIT License
from ctsecurity
private void startRead()
{
try
{
stream = client.GetStream();
eventSender = new StreamWriter(stream);
while (true)
{
BinaryFormatter bFormat = new BinaryFormatter();
Bitmap inImage = bFormat.Deserialize(stream) as Bitmap;
resolutionX = inImage.Width;
resolutionY = inImage.Height;
theImage.Image = (Image)inImage;
//Image theDesktop;
//Bitmap tD
//theImage.Image = Bitmap.FromStream(stream);
//theDesktop = Image.FromStream(stream);
//tD.Save("C:\\Users\\Sean\\Desktop\\test.png",ImageFormat.Png);
//theImage.Image = Image.FromFile("C:\\Users\\Sean\\Desktop\\test.png");
}
}
catch (Exception) { }
/*try
{
Image theDesktop;
stream = client.GetStream();
theDesktop.Save(stream,new ImageFormat(
while (true)
{
while (stream.Read(buffer, 0, 1024) > 0)
theDesktop.Read(buffer, 0, 1024);
if(theDesktop != null) {
theDesktop.
theImage.Image = temp;
}
}
catch (Exception gay) { }*/
}
19
Source : AssetBundleInspectTab.cs
with GNU General Public License v3.0
from Cytoid
with GNU General Public License v3.0
from Cytoid
internal void OnEnable(Rect pos)
{
m_Position = pos;
if (m_Data == null)
m_Data = new InspectTabData();
//LoadData...
var dataPath = System.IO.Path.GetFullPath(".");
dataPath = dataPath.Replace("\\", "/");
dataPath += "/Library/replacedetBundleBrowserInspect.dat";
if (File.Exists(dataPath))
{
BinaryFormatter bf = new BinaryFormatter();
FileStream file = File.Open(dataPath, FileMode.Open);
var data = bf.Deserialize(file) as InspectTabData;
if (data != null)
m_Data = data;
file.Close();
}
if (m_BundleList == null)
m_BundleList = new Dictionary<string, List<string>>();
if (m_BundleTreeState == null)
m_BundleTreeState = new TreeViewState();
m_BundleTreeView = new InspectBundleTree(m_BundleTreeState, this);
RefreshBundles();
}
19
Source : AssetBundleBuildTab.cs
with GNU General Public License v3.0
from Cytoid
with GNU General Public License v3.0
from Cytoid
internal void OnEnable(EditorWindow parent)
{
m_InspectTab = (parent as replacedetBundleBrowserMain).m_InspectTab;
//LoadData...
var dataPath = System.IO.Path.GetFullPath(".");
dataPath = dataPath.Replace("\\", "/");
dataPath += "/Library/replacedetBundleBrowserBuild.dat";
if (File.Exists(dataPath))
{
BinaryFormatter bf = new BinaryFormatter();
FileStream file = File.Open(dataPath, FileMode.Open);
var data = bf.Deserialize(file) as BuildTabData;
if (data != null)
m_UserData = data;
file.Close();
}
m_ToggleData = new List<ToggleData>();
m_ToggleData.Add(new ToggleData(
false,
"Exclude Type Information",
"Do not include type information within the replacedet bundle (don't write type tree).",
m_UserData.m_OnToggles,
BuildreplacedetBundleOptions.DisableWriteTypeTree));
m_ToggleData.Add(new ToggleData(
false,
"Force Rebuild",
"Force rebuild the replacedet bundles",
m_UserData.m_OnToggles,
BuildreplacedetBundleOptions.ForceRebuildreplacedetBundle));
m_ToggleData.Add(new ToggleData(
false,
"Ignore Type Tree Changes",
"Ignore the type tree changes when doing the incremental build check.",
m_UserData.m_OnToggles,
BuildreplacedetBundleOptions.IgnoreTypeTreeChanges));
m_ToggleData.Add(new ToggleData(
false,
"Append Hash",
"Append the hash to the replacedetBundle name.",
m_UserData.m_OnToggles,
BuildreplacedetBundleOptions.AppendHashToreplacedetBundleName));
m_ToggleData.Add(new ToggleData(
false,
"Strict Mode",
"Do not allow the build to succeed if any errors are reporting during it.",
m_UserData.m_OnToggles,
BuildreplacedetBundleOptions.StrictMode));
m_ToggleData.Add(new ToggleData(
false,
"Dry Run Build",
"Do a dry run build.",
m_UserData.m_OnToggles,
BuildreplacedetBundleOptions.DryRunBuild));
m_ForceRebuild = new ToggleData(
false,
"Clear Folders",
"Will wipe out all contents of build directory as well as Streamingreplacedets/replacedetBundles if you are choosing to copy build there.",
m_UserData.m_OnToggles);
m_CopyToStreaming = new ToggleData(
false,
"Copy to Streamingreplacedets",
"After build completes, will copy all build content to " + m_streamingPath + " for use in stand-alone player.",
m_UserData.m_OnToggles);
m_TargetContent = new GUIContent("Build Target", "Choose target platform to build for.");
m_CompressionContent = new GUIContent("Compression", "Choose no compress, standard (LZMA), or chunk based (LZ4)");
if(m_UserData.m_UseDefaultPath)
{
ResetPathToDefault();
}
}
19
Source : CacheProvider.cs
with MIT License
from daixinkai
with MIT License
from daixinkai
private static T DeserializeFromCache<T>(byte[] data)
{
using (var stream = new MemoryStream(data))
{
return (T)new BinaryFormatter().Deserialize(stream);
}
}
19
Source : UnusedStateMethodsExceptionTests.cs
with Apache License 2.0
from danielcrenna
with Apache License 2.0
from danielcrenna
[Fact]
public void Round_trip_serialization_test()
{
var left = new UnusedStateMethodsException(typeof(MissingStateForStateMethod).GetMethods());
var buffer = new byte[4096];
var formatter = new BinaryFormatter();
using (var serialized = new MemoryStream(buffer))
{
using (var deserialized = new MemoryStream(buffer))
{
formatter.Serialize(serialized, left);
var right = (UnusedStateMethodsException) formatter.Deserialize(deserialized);
replacedert.Equal(left.StateMethods, right.StateMethods);
replacedert.Equal(left.InnerException?.Message, right.InnerException?.Message);
replacedert.Equal(left.Message, right.Message);
}
}
}
19
Source : MQShutDownServerMessage.cs
with MIT License
from Dartanlla
with MIT License
from Dartanlla
public static MQShutDownServerMessage Deserialize(byte[] data)
{
MQShutDownServerMessage messageToReturn = new MQShutDownServerMessage();
BinaryFormatter binaryFormatter = new BinaryFormatter();
using (MemoryStream memoryStream = new MemoryStream(data))
{
try
{
messageToReturn = (MQShutDownServerMessage)binaryFormatter.Deserialize(memoryStream);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
return messageToReturn;
}
19
Source : MQSpinUpServerMessage.cs
with MIT License
from Dartanlla
with MIT License
from Dartanlla
public static MQSpinUpServerMessage Deserialize(byte[] data)
{
MQSpinUpServerMessage messageToReturn = new MQSpinUpServerMessage();
BinaryFormatter binaryFormatter = new BinaryFormatter();
using (MemoryStream memoryStream = new MemoryStream(data))
{
try
{
messageToReturn = (MQSpinUpServerMessage)binaryFormatter.Deserialize(memoryStream);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
return messageToReturn;
}
19
Source : FieldConverterTest.cs
with MIT License
from DataObjects-NET
with MIT License
from DataObjects-NET
private static ObservableCollection<int> Deserialize(byte[] bytes)
{
var bf = new BinaryFormatter();
var ms = new MemoryStream(bytes);
return (ObservableCollection<int>) bf.Deserialize(ms);
}
See More Examples