|
"Inherited members are not considered"
Nice
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Thanks BillWoodruff.
I have solved the problem with your suggestion.
Solution
****************
.GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);
|
|
|
|
|
Write an algorithm to add and multiply two large integers, which cannot be represented by built-in types
need the solution for this..
|
|
|
|
|
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.
Try it yourself, you may find it is not as difficult as you think!
If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!
Hint: there is a framework structure which handles arbitrarily large integers: BigInteger[^] - you might want to see what that provides...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
update: examining the value of the MemoryStream's 'Position property after the decompressed GZipStream was put into it with 'CopyTo showed it to be set to the length of the decompressed GZipStream: setting the MemoryStream's 'Position property to #0 resulted in being able to correctly call Serializer.ReadObject on the MemoryStream and create the desired outcome.
Interesting that in all the searching/reading I did here and on StackOverFlow, I came across no mention of this. Time for a Tip/Trick ?
~
Serializing a class-instance/object using WCF [DataContract] and [DataMember] Attributes is very easy; compressing it with the GZip library, and saving the compressed stream to a file is straightforward: no problems.
Currently my working code for de-serialization from GZip file does the following:
1. open the saved .gz file in the standard way
2. create a new file to hold the un-gzipped .xml whose name is the same as the GZip file, with the .gz extension replaced with .xml.
// compressedstuff.gz => compressedstuff.xml
3. create a new GZip compression stream with Decompress option
4. copy the Gzip compression stream into the new file
5. re-create the "object" in the standard way from file using WCF Serializer What I want to do is go from the uncompressed GZip file directly to using the WCF Serializer to "resurrect" the object without creating a new file. This code dies with the error "Unexpected end of file:"
using System.Runtime.Serialization;
using System.IO;
using System.IO.Compression;
public static SomeClass GZToObject(string gzFilePath)
{
DataContractSerializer serializer = new DataContractSerializer(typeof(SomeClass));
SomeClass someClassInstance = null;
FileInfo fileToDecompress = new FileInfo(gzFilePath);
using (MemoryStream xmlStream = new MemoryStream())
{
using (GZipStream deCompStream = new GZipStream(File.Open(gzFilePath, FileMode.Open), CompressionMode.Decompress, true))
{
deCompStream .CopyTo(xmlStream);
deCompStream .Close();
someClassInstance = (SomeClass) serializer.ReadObject(xmlStream);
}
}
return someClassInstance;
} Is it possible that using GZip facilities requires creating a 'temp file ?
thanks, Bill
«I want to stay as close to the edge as I can without going over. Out on the edge you see all kinds of things you can't see from the center» Kurt Vonnegut.
modified 20-Sep-15 9:33am.
|
|
|
|
|
What if you try to end the using block a bit earlier. In other words:
using (MemoryStream xmlStream = new MemoryStream())
{
using (GZipStream deCompStream = new GZipStream(File.Open(gzFilePath, FileMode.Open), CompressionMode.Decompress, true))
{
deCompStream.CopyTo(xmlStream);
deCompStream.Close();
}
someClassInstance = (SomeClass) serializer.ReadObject(xmlStream);
}
modified 20-Sep-15 14:54pm.
|
|
|
|
|
Thanks, Mika,
I've tried many combinations of varying the code, including the one you recommend.
I also tried just creating a new MemoryStream and saving it; i.e., not using it within a 'Using block. Both these variations gave the same error as in the code above.
«I want to stay as close to the edge as I can without going over. Out on the edge you see all kinds of things you can't see from the center» Kurt Vonnegut.
|
|
|
|
|
Not sure if this helps with your problem but when thinking about your question, why use the memorystream at all.
Consider the following:
public class SomeClass {
[DataMember()]
public string FirstName;
[DataMember]
public string LastName;
public static bool ObjectToGZ(SomeClass instance, string gzFilePath) {
using (GZipStream zipstream
= new GZipStream(File.Open(gzFilePath, FileMode.Create), CompressionMode.Compress, false)) {
DataContractSerializer ser = new DataContractSerializer(typeof(SomeClass));
ser.WriteObject(zipstream, instance);
zipstream.Close();
}
return true;
}
public static SomeClass GZToObject(string gzFilePath) {
DataContractSerializer serializer = new DataContractSerializer(typeof(SomeClass));
SomeClass someClassInstance = null;
using (GZipStream deCompStream
= new GZipStream(File.Open(gzFilePath, FileMode.Open), CompressionMode.Decompress, false)) {
someClassInstance = (SomeClass)serializer.ReadObject(deCompStream);
}
return someClassInstance;
}
}
And the call
SomeClass some1 = new SomeClass() { FirstName = "A", LastName = "B" };
SomeClass.ObjectToGZ(some1, "C:\\TEMP\\BillTest1.gz");
SomeClass some2 = SomeClass.GZToObject("C:\\TEMP\\BillTest1.gz");
|
|
|
|
|
BillWoodruff wrote: Interesting that in all the searching/reading I did here and on StackOverFlow, I came across no mention of this. Time for a Tip/Trick ?
You just need some Google-fu.
Searching for "memorystream write read" gave me:
Reset the position of the stream before reading.
You also have to set the position to 0 if you want to read data from the beginning.
a usual error is to forget to set Position[^] to 0 after having written to a memory stream
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I was hoping someone could tell me how I can change the font size of text without selecting the text. I found a font example on CP that does that but not the size
Thanks
|
|
|
|
|
The usual procedure is to select text and set its properties.
Why "without selecting text"?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
maybe I will have to do it like that then but if I select the text is there a way that as I change sizes it shows the text changing as well
|
|
|
|
|
Like this[^]?
Use "richTextBox1.SelectionFont.FontFamily" to keep the same font.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
You will have to create a selection in the RichTextBox to change the font-size.
However, you can do that programmatically in a way that the visual state change the user will see is minimized. For example:
private void SetFontSize(int start, int end, float fontsize)
{
int currentselstart = richTextBox1.SelectionStart;
int currentsellength = richTextBox1.SelectionLength;
richTextBox1.SuspendLayout();
richTextBox1.Select(start, end);
richTextBox1.SelectionFont = new Font(richTextBox1.Font.FontFamily, fontsize);
richTextBox1.ResumeLayout();
richTextBox1.Select(currentselstart, currentsellength);
richTextBox1.Focus();
}
«I want to stay as close to the edge as I can without going over. Out on the edge you see all kinds of things you can't see from the center» Kurt Vonnegut.
|
|
|
|
|
HI,
What is the use of get and set property,and why we have to use get and set property and in which condition???
Can Anyone Help???
|
|
|
|
|
Why not read the documentation? For example:
|
|
|
|
|
|
You could always look at the answers you got the last time you posted this question.
After all, it was only four days ago...the answers aren't going to change much in that time...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
|
Hello there,
WORK:
I am working on a project, in which the output of some methods create a excel sheet.
PROBLEM:
When I run the project from IDE, the excel file is created properly and with all data from List<t>. But, when its run from the compiled EXE file, I am getting no output in the excel file.
Please help.
modified 19-Sep-15 3:39am.
|
|
|
|
|
Wow. You're expecting a lot from us here. No code, only a description of the problem. I'm not sure you're going to get much more help than this I'm afraid.
|
|
|
|
|
Have you recompiled your project making sure that 'release' is selected in the configuration dropdown?
It could be that you have 'debug' selected and when you run from the IDE you are running in debug mode but never recompiling in release mode.
“That which can be asserted without evidence, can be dismissed without evidence.”
― Christopher Hitchens
|
|
|
|
|
Hi GuyThiebaut,
I tried that too, but getting no success.
|
|
|
|
|
Hearty Sorry for not posting the code:
Here is the code:
public void WardList()
{
#region Load Values...
int count = 1;
List WWList = new List();
Engine E = new Engine();
SQLiteCommand CMD = new SQLiteCommand(E.SelectSQL("WARDS") + " ORDER BY [WARDNUMBER];", E.Conn);
SQLiteDataReader RDR = CMD.ExecuteReader();
while (RDR.Read())
{
WardWise WW = new WardWise();
WW.Serial = count;
WW.WardNumber = Convert.ToInt32(RDR["WARDNUMBER"]);
WW.WardCount = WardCount(WW.WardNumber);
WW.Name = RDR["NAME"].ToString();
WW.Manager = RDR["MANAGER"].ToString();
WW.TotalTax = WardExists(WW.WardNumber) ? WardWiseTax(WW.WardNumber) : 0;
WW.TotalPaid = WardExists(WW.WardNumber) ? WardWiseTax(WW.WardNumber, false) : 0;
WW.Balance = WW.TotalTax - WW.TotalPaid;
count++;
WWList.Add(WW);
}
#endregion
using (ExcelPackage EP = new ExcelPackage(Masters, Template))
{
double hook = 8;
ExcelWorksheet Sheet = EP.Workbook.Worksheets["AWW"];
foreach (WardWise WW in WWList)
{
Sheet.Cells["A" + hook].Value = WW.Serial;
Sheet.Cells["B" + hook].Value = WW.WardNumber + " [" + WW.WardCount + "]";
Sheet.Cells["C" + hook].Value = WW.Name;
Sheet.Cells["D" + hook].Value = WW.Manager;
Sheet.Cells["E" + hook].Value = WW.TotalTax;
Sheet.Cells["F" + hook].Value = WW.TotalPaid;
Sheet.Cells["G" + hook].Formula = ("E" + hook) + "-" + ("F" + hook);
hook++;
}
Sheet.Cells["A8:G" + (hook - 1)].Style.Border.Top.Style =
Sheet.Cells["A8:G" + (hook - 1)].Style.Border.Bottom.Style =
Sheet.Cells["A8:G" + (hook - 1)].Style.Border.Left.Style =
Sheet.Cells["A8:G" + (hook - 1)].Style.Border.Right.Style = ExcelBorderStyle.Thin;
Sheet.Cells["G" + (hook + 1)].Formula = string.Format("SUM(G8:G{0})", hook - 1);
Sheet.Cells["G" + (hook + 1)].Style.Font.Bold = true;
Sheet.Cells["G" + (hook + 1)].Style.Border.Top.Style =
Sheet.Cells["G" + (hook + 1)].Style.Border.Bottom.Style =
Sheet.Cells["G" + (hook + 1)].Style.Border.Left.Style =
Sheet.Cells["G" + (hook + 1)].Style.Border.Right.Style = ExcelBorderStyle.Thick;
EP.Save();
}
Process P = Process.Start(MastersFile);
handle = P.MainWindowHandle;
SetForegroundWindow(handle);
}
|
|
|
|
|
That is just a code dump, and gives no more clue that your original question. You need to explain where the problem occurs, since we have no idea how this code is supposed to work.
|
|
|
|