Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Runtime.Serialization.Formatters.Binary;
- namespace Test
- {
- class Program
- {
- static void Main(string[] args)
- {
- #region рефлексия
- //A firstObj = new A() { count = 10, lst = new List<string>() { "asdasd", "asd123as123sd" } };
- //A secondObj = new A();
- //List<object> s = firstObj.GetType().GetFields().Select(x => x.GetValue(firstObj)).ToList();
- //int i = 0;
- //foreach (var fd in secondObj.GetType().GetFields())
- //{
- // fd.SetValue(secondObj, s[i]);
- // i++;
- //}
- #endregion
- List<A> aa = new List<A>();
- List<B> bb = new List<B>();
- for (int i = 0; i < 10000; i++)
- {
- aa.Add(new A());
- bb.Add(new B());
- }
- using (Stream stream = new MemoryStream())
- {
- BinaryFormatter formatter = new BinaryFormatter();
- formatter.Serialize(stream, aa);
- Console.WriteLine("С int " + stream.Length);
- }
- using (Stream stream = new MemoryStream())
- {
- BinaryFormatter formatter = new BinaryFormatter();
- formatter.Serialize(stream, bb);
- Console.WriteLine("С byte " + stream.Length);
- }
- }
- }
- [Serializable]
- class A
- {
- public ReportType reportType = ReportType.REPORT_FILE_SA;
- }
- [Serializable]
- class B
- {
- public ReportTypeB reportType = ReportTypeB.REPORT_FILE_SA;
- }
- public enum ReportType // Can we remove this enumerator due to its unused in class?
- {
- /// <summary>
- /// report will be saved as file with static analysis results
- /// </summary>
- REPORT_FILE_SA,
- /// <summary>
- /// report will be saved as file with no static analysis results
- /// </summary>
- REPORT_FILE_NOSA,
- /// <summary>
- /// report will be displayed as table with static analysis results
- /// </summary>
- REPORT_TABLE_SA,
- /// <summary>
- /// report will be displayed as table with no static analysis results
- /// </summary>
- REPORT_TABLE_NOSA,
- /// <summary>
- /// report will be displayed as tree with static analysis results
- /// </summary>
- REPORT_TREE_SA,
- /// <summary>
- /// report will be displayed as tree with no static analysis results
- /// </summary>
- REPORT_TREE_NOSA
- }
- public enum ReportTypeB : byte // Can we remove this enumerator due to its unused in class?
- {
- /// <summary>
- /// report will be saved as file with static analysis results
- /// </summary>
- REPORT_FILE_SA,
- /// <summary>
- /// report will be saved as file with no static analysis results
- /// </summary>
- REPORT_FILE_NOSA,
- /// <summary>
- /// report will be displayed as table with static analysis results
- /// </summary>
- REPORT_TABLE_SA,
- /// <summary>
- /// report will be displayed as table with no static analysis results
- /// </summary>
- REPORT_TABLE_NOSA,
- /// <summary>
- /// report will be displayed as tree with static analysis results
- /// </summary>
- REPORT_TREE_SA,
- /// <summary>
- /// report will be displayed as tree with no static analysis results
- /// </summary>
- REPORT_TREE_NOSA
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment