|
I'm not sure how to do this with a BitArray, short of doing a foreach and copying the elements you want.
Instead of BitArray, could you just use a List<bool> or a bool[]?
Life, family, faith: Give me a visit.
From my latest post: "And you think, 'To keep my anti-Judaic theology alive I must reinterpret this verse too as being a blessing for Christians and not for Jews. I know it strains all manner of principles of interpretation. I don’t read the newspaper this sloppily, but, man, I have a theology to defend.'"
Judah Himango
|
|
|
|
|
The functionality to copy a segment of a BitArray into another BitArray probably got prioritized away at the design stage.
I partially support that decision, for these reasons:
- The operation could be surprisingly expensive. In case you specified a start index not a multiple of the underlying byte/ushort/uint/ulong type used for packing the bits, it could potentially take lots of shifting and oring to do the job (depending on size - but as the type is there to make huge bit arrays more compact, the size would usually be significant). I don't think the CPU blitting support can handle that kind of operations, so the framework would have no way of optimizing it under the hood.
- The expensiveness of the operation would be nondeterministic. You have no way of knowing what the underlying storage is, and it may change from platform to platform (I would guess that the 32-bit framework uses UInt32 and the 64-bit uses UInt64), so you could never optimize it yourself.
For the exact same reasons, Buffer.BlockCopy() would be useless.
However, I find it strange that the CopyTo() method doesn't have an overload that lets you specify source start index and count. The existing version should be just as expensive as a "segmentized" version... go figure!
If you really need it - write your own CustomBitArray clone - the stuff it does isn't all that complicated... If you were to make the starting bit offset into the first word (of whatever length you use) variable (as in a private member keeping track of it), you could implement a fast segment cloner using Buffer.BlockCopy() (it would copy the words involved and adjust start offset and length of the newly created destination array). Copying a segment into a segment of a preexisting CustomBitArray wouldn't be optimizable, though.
--
Peter
|
|
|
|
|
That is what I was afraid of. I suppose it is not common to use a BitArray that is several hundred K in size and read 1K chunks out more or less at random. I suppose this is not all that bad...
BitArray ReturnArray = new BitArray(LENGTH);
for (int i = 0; i < LENGTH; i++)
{
ReturnArray[i] = iIndexer[POS + i];
}
return ReturnArray;
|
|
|
|
|
Hey All,
I'm working on Multi language application, which supports around 22 languages.
The problem is how do I show standerd "Open File", "Save" and "Print" Dailogue in other languages ?
Thanks in Advance...
|
|
|
|
|
The common dialogues will automatically be displayed in the operating systems language.
Simon
|
|
|
|
|
Currently, I am working on a Web project that retrieves it's many, sometimes 1000+, records from the SQL database and stores them into Generic lists of objects. The project also is using .NET framework caching for storing much of the same SQL data returned and other web data. In my opinion this is doing double storage. Is there something I'm missing and which is the better way to go?
Thanks,
Steve
|
|
|
|
|
Your missing the fact that Db retrieval is quite heavy and retrieval from the Server's memory (which is where the "cache" is) is very quick.
|
|
|
|
|
This is something that confuses me. When I retrieve records, I use a reader to add objects to generic lists. Is what you are saying is that the retrival should be done directly into the cach and then fill the generic lists from there? If this is the case, should I be filling datatables directly to cach, and when needed, fill the generic lists at that point?
Thanks,
Steve
|
|
|
|
|
You are missing the point. When you get the data from the database, you only store it in the cache for later use. You get the gain later, when you can get the data from the cache instead of calling the database again.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
See, what I don't understand is this, getting the data from the database and storing it into generic list of objects seem to serve the same purpose as going from the database directly to cach. The point is that I am designing a system. Now, what I am thinking is, for example, having a PatientManager object which stores a generic list of Patient objects. In the PatientManager should I get the list of Patient objects directly from the database and not use cach or should I have both a cach table in the PatientManager object and load the generic list of Patient objects as needed? I need advise before I start with the UML.
Very much thanks for the help!
Steve
|
|
|
|
|
Steve Holdorf wrote: I am working on a Web project
So what to do you intend to use as the scope of this PatientManager instance? Unless you put it in the Application or Session memory you will have to load it for every request which is where the cache comes into play. Get it?
led mike
|
|
|
|
|
Sorry for being such a pain in the A##. The way I think the design should be laid out is that there is only one static PatientManager. Now this PatientManager calls a DAO object for SQL/DB access and the DAO object would return either a Generic List of the Patinet (instance objects) or the DAO should return a complete DataTable for cach. First question is which would you do? Now, if it returns a DataTable to cach then I think when data binding, sorting, etc. is needed the PatientManager should load the Generic list from the PatientManager's cach datatable thus not having to hit the database again. Does this way sound better using the cach DataTable storage and not re-hitting the database or the first way, using the Generic List, without cach, for storage and not re-hitting the database.
Again sorry for being a dummy and any help in getting a concrete design would be great.
Steve
|
|
|
|
|
Just so you know I think if you use both a generic list and cash, the static PatientManager should maintain both. Am I wrong?
|
|
|
|
|
Just so anyone reading knows. I am not really creating a Patient application. I am just using this type of application as my example. My application is different!
Steve
|
|
|
|
|
One last thing, to answer your last question. The static PatientManager object is part of the BL and not presentation layer so Application/Session objects should not be needed. Am I missing anything?
|
|
|
|
|
Steve Holdorf wrote: The static PatientManager object is part of the BL and not presentation layer so Application/Session objects should not be needed. Am I missing anything?
That does not seem clear to me. This static PatientManager is a static instance in what process? The ASP.NET process? This is the same process in which Application and Session memory are located (unless of course you use out of proc session but I don't see you mentioning that). Therefore you have no distinction between your presentation layer and your business layer in terms of memory management. If you are placing the PatientManager in the COM+ server then it's not part of the presentation tier of your system. If you are using COM+ for this PatientManager you can configure it in COM+ as a Single Instance so you don't need to make it a static instance.
Steve Holdorf wrote: the static PatientManager should maintain both. Am I wrong?
That sounds like you are planning to use it for write operations yes? So if you have a static instance in a multi-threaded environment you are going to deal with all the synchronization issues yourself then? If so it sounds like you are headed down a long hard path. Good luck.
led mike
|
|
|
|
|
If you are storing the patient list in a static variable, then you don't need to store it in the cache also.
You should be really careful with static variables in a web application, though. The variable is shared by all threads running in the application, so if you ever change it, you need to use locking every time that you access it.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Thanks Guy's
My trouble has been going from a WinForms developer to an ASP developer. I now realize that the generic list I was using was not persistent but the cache is. What I am doing is if it is the first call to PatientManager.GetPatients, I get the list from the database. Now, on the same page (After postback), if it is needed again (for sorting, paging, etc.) then I get it from the PatientManager.GetPatients cache. Do I now make sense?
Thanks again for all of your help!!!!!!!!!!!!!!!!!!!!!!!! I Got it.
Steve
|
|
|
|
|
I have a C#.Net class library called myProcessor.dll in which i am running one VB Script written in myDoc.txt and this VB Script is calling a public method in myProcessor.dll. This is throwing an exception in C# "object required 'MyProcessor'". Here MyProcessor is the object I used in VB Script to invoke the method.
like
MyProcessor.SetValue
The same logic works fine in VB dll and it is installed in "c:\WINDOWS\System32", but here .Net Dll is installed in the path "c:\Program Files\MyPath\"
I haven't created the object by using CreateObject() as without that it is working fine in VB. The same VB Script i used in .Net.
Can anybody tell me the difference in VB and .Net calls to VB Script and the usage of its objects and methods in VB Scripts?
With Regards,
Abraham Chethuvelil
|
|
|
|
|
I would guess that you should use CreateObject and make your C# code a COM dll.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi,
Is there any way other than that, as I am trying to migrate something fromVB to .Net and in VB version it is not a COM dll.....
With Regards,
Abraham Chethuvelil
|
|
|
|
|
I have no idea how VB6 works, sorry. I do know that VB.NET is a whole new language, I would not be surprised if something like this was there and is gone.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
One more query,
I used set MyProcessor = CreateObject("Processor.myProcessor")
MyProcessor.SetValue
but it is giving another error "ActiveX can't create the object 'Processor.myProcessor'"
It seems like The dll is not registered as ActiveX Object.
What I did was in the project properties -> Build -> Output, I checked the option register for COM interop
and in Project properties -> Application -> Assembly Information -> Make assemble visible is too checked.
What else i have to do to register this dll.
Please note regsvr32 wont work as it is saying could not find the entry point.
Please advise
With Regards,
Abraham Chethuvelil
|
|
|
|
|
Hi!
Deep under the "Visual Studio" part of the documentation there is a chapter named "Exposing .NET Framework Components to COM" (under ".NET Framework Development...", ".NET Framework Advanced Development", "Interoperability", "Interoperating with Unmanaged Code"). You will find your options there, under "Registering Assemblies with COM". Or google that for the MSDN location of the piece.
The tool you use (corresponds to regsvr32) is regasm. The other settings you have made should cover the rest of what is needed. Additionally, you can use the ClassInterface, ProgId and Guid attributes on your class if you want to override the defaults (look them up in the docs). As long as you only call your component via late binding (using COM, that is), you needn't worry about versioning (script engines are by definition late bound).
Hope this helped.
--
Peter
|
|
|
|
|
Arun Abraham Jose wrote: in VB version it is not a COM dll
I am pretty sure that it is, otherwise VBScript can not use it.
A COM dll is also commonly known as an ActiveX dll. (This statement may not be totally accurate in every aspect, but for your purpose they are interchangeable.)
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|