|
I tend to think that they're just as good an idea as any.
If you don't need to subtype the existing class, you don't need to change the way it performs its existing behavior, there's no composition model in place but need to be able to optionally rearrange the way the custom object wraps around a structurally subtyped object, I say "sure."
"I need build Skynet. Plz send code"
|
|
|
|
|
Hi every body,,
I write an app on android and i want send a string with sms to my server, because my length of string is bigger than one sms, i have to compress sms and send to my server, in my server i have a app that wrote with .net, and my problem in here!!!
I can`t find a solution for compress data in Android(Java) and decompress in C#....
Please Help......
|
|
|
|
|
whatever compression algorithm you use, IMO you're going to need two different but compatible implementations. That isn't elegant, it isn't a big deal either.
|
|
|
|
|
|
Act as a programmer: look at the one source code, then write an equivalent one in the other language. What else?
|
|
|
|
|
That`s right,, but for example we used native code, sign and unsigned numbers,, and more,,
For example , i found good algorithm in .net(http://dotnetzip.codeplex.com/[^]) ,, this lib used native code, and i have to implement this algorithm in Java that is my biiiiiiiiiiiig problem!!
So,, do you can implement a compress algorithm as same as dotnetzip in Java??
|
|
|
|
|
1. You have to work around the limitations of any particular language; e.g. if Java doesn't offer unsigned numbers, use signed ones and add some code to compensate.
2. I doubt very much a complex scheme such as Lempel-Ziv-Welch (used by ZIP) is suited for small amounts of text. IMO you have to roll your own anyway. If you can make reasonable assumptions on the input, compressing it by a factor of 2 should be quite easy. Maybe use ideas such as the ones base64 is based on.
3. Keep in mind no compression is absolute, whatever scheme (or set of schemes) you choose, there will always be inputs that don't get compressed (e.g. try putting a JPEG image in a ZIP file).
|
|
|
|
|
Thanks for attention and your time
and thanks for your guide ,,
but i tired for solved this problem,,,,,,,,
|
|
|
|
|
Hi,
In C++ I found a simple class that toggles a bool when it goes out of scope very useful.
The implementation is simple...
class CAutoBOOL
{
public:
CAutoBOOL( BOOL* pBool )
: m_pBool( pBool )
{
assert( m_pBool );
}
~CAutoBOOL()
{
*m_pBool = !(*m_pBool);
}
protected:
BOOL* m_pBool;
};
And its use is also easy...
void MyClass::foo()
{
m_bInFoo = TRUE;
CAutoBOOL ab( &m_bInFoo );
if( bDoIt )
{
return;
}
}
Whatever the code path m_bInFoo is garentied to set to FALSE when exiting Foo().
I would like to do a similar thing in C#, is it posible?
Thanks - John.
|
|
|
|
|
Member 3331570 wrote: very useful
For what? I can't think of a reason and I don't think your example helps.
As for .net in general and C# specifically, the destructor may not be called by the garbage collector for a while so I suggest a Dispose method and the using statement. But the big problem is in storing a reference to the variable, perhaps it would be easier to write a class that holds a boolean and use that instead.
public sealed class Toggler : System.IDisposable
{
public bool State { get ; set ; }
public Toggler
(
bool State
)
{
this.State = State ;
return ;
}
public void
Dispose
(
)
{
this.State = false ;
return ;
}
}
Toggler t = new Toggler ( true ) ;
using ( t )
{
System.Console.WriteLine ( t.State ) ;
}
System.Console.WriteLine ( t.State ) ;
|
|
|
|
|
Ok, I have made some progress on this.
I think I can do it using "using" as follows
MyClass::Foo()
{
using (ToggleBool tb = new ToggleBool(ref _baseControl._bReadingLog))
{
}
}
The problem I am now having is with my ToggleBool class...
class ToggleBool : IDisposable
{
public ToggleBool(ref bool bVal)
{
_bVal = bVal;
}
public void Dispose()
{
_bVal = !(bool)_bVal;
GC.SuppressFinalize(this);
}
private object _bVal;
}
It is not toggling the origional bool ref that is passed to its constructor. Is my ref, somewhere along the line becoming a value?
Or is it some other error?
Thanks - John.
|
|
|
|
|
Member 3331570 wrote: Is my ref, somewhere along the line becoming a value?
Yes, immediately when you assigned its value to _bVar.
Why are you even doing this, though? No matter what you do, it's going to be a giant hack. It already was in C++, and in C# it's going to be worse.
|
|
|
|
|
Why is it a hack? It makes my code more reliable and easy to maintain. If I introduce a new code path with a new return point, I don’t have to remember to do ‘the thing’ every time. You are not limited to toggling a bool, you could call a function, signal a synchronisation object or change the cursor. Microsoft use it in their CWaitCursor class. It’s no hack, its brilliant!
|
|
|
|
|
Well maybe. But it's "invisible logic". That something happens even if you forget it may seem nice, but it's the dirtiest possible side effect if } executes code. Combined with threading it would be the recipe for certain disaster. In C# you can't even do it without abusing using, which is meant for disposing things, not for "doing whatever".
As for MS doing it, well they can't rely on programmers doing what they're supposed to do. But if you are the programmer, certainly you can do what you tell yourself to do. You do it all the time, and forgetting to do so is called a bug.
Anyway here's a suggestion: don't have multiple return points. Problem solved.
If you really want multiple return point, you could wrap the whole thing in a try/finally. You won't have to remember "the thing" all the time (just once ... same as when using using), and the side effect is explicit.
|
|
|
|
|
So far a C# is concerned I agree, try/finaly is the best aproach.
|
|
|
|
|
You need something like this[^]. But it's a dirty hack and you should treat it accordingly.
|
|
|
|
|
Hi all,
I am using xslt transformation and converting the xml file code and storing it in one string.
When i try to display it in textbox or any other control its just printing the code of the xml file,actuall the xml file is in html format.
I want to display the code as a html page in the c# form in one control.How can i do it ?
Thanks in advance.
Its Urgent.
|
|
|
|
|
If you're using Windows Forms, use a WebBrowser control and set its DocumentText[^] property.
/ravi
|
|
|
|
|
Is there any control in c# other than webcontrol to display the html pages.
|
|
|
|
|
Hi,
I am using the WebBrowser control in a winform application. Is there a way where in WebBrowser can show the popup window as a part of navigating to a URL.
Scenario:
- Navigate to a login URL using the WebBrowser control.
- Navigating to this login URL popups a window (in the IE) which shows the session/usage. I need to show this popup in the same WebBrowser control itself and not in IE. Can this be achieved.
-Sunil
|
|
|
|
|
Hi All,
Kinda need some help with this.
i have a WSDL with inline schema imports to different xsds, i would like to take the entire wsdl and convert it into a single xsd.
<wsdl:types>
<xsd:schema targetNamespace="http://tempuri.org/Imports">
<xsd:import schemaLocation="http://XXXX/XXXX.svc?xsd=xsd0" namespace="http://tempuri.org/" />
<xsd:import schemaLocation="http://XXXX/XXX.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/" />
<xsd:import schemaLocation="http://XXXX/XXX.svc?xsd=xsd2" namespace="http://schemas.datacontract.org/2004/07/XXXX.Contract" />
</xsd:schema>
</wsdl:types>
how can i achieve this in C# code?
thanks in advance!
living life on the flip side
|
|
|
|
|
Hi all,
I want to add context menu for files with specific extensions like .pdf, .doc, .docx etc. How to do this?
Also, after clicking the menu item I want to perform operations like reading the file, manipulating it etc on the selected file. Can anyone help me ?
Thanks in advance !
Amit
|
|
|
|
|
Lots of suggestions here[^].
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
ok. Thanks
Amit
|
|
|
|
|
Does any one knows how to make different colors in different trangles ? I mean , how to use many GeometryModel3D to declare this ?
|
|
|
|