.net

Is there a more concise way I could do my sorting in C#?

Lets say I have an entity like: public class Car { public string Make { get; set; } public string Model { get; set; } public DateTime ReleaseDate { get; set; } public int NumCreated { get; set; } } We are using a simple MVP architecture for our site with a View Layer (ASP.NET website, Presenter Layer (C# Class Library)...

Flash rotating banner won't start playing in Firefox

This issue has been boggling me a few days, I would appreciate any input. On this site, the rotating flash banner at the top works fine in IE and Chrome, but when opened in Firefox, it doesn't load the picture or advance automatically. If you click on one of the other buttons to advance to another item, it works fine, but on page load, ...

ItemsSource vs DataContext in binding case

Hi My main question is about binding case in the scene that we have multiple sources for a control(a combobox inside a datagrid)(or having both datacontext and itemssource). Then how can we know which source the binding will use? (any syntax to clarify that) Assuming a datagrid has an itemssource="List of Players" datacontext="Manager" ...

How to cache 'IQueryable<>.First' result?

I have 2 similar queries: ICmOption optionRes = CmOptionRepository<ICmOption> .GetAll() .Where(option => option.Name == strCommandName && option.Data == strCommandOption) .FirstOrDefault() ; IErrorType errorType = ErrorTypeRepository<IErrorType> .GetAll() ...

Get Rectangle of Image JPG and generate thumbnail in rectangle

I try explain: I have a JPG image (img A). This A.jpg has contents -colors, it's a picture of persons- and a one more little white rectangle (color white; the head of person is a white rectangle). I need get the position of rectangle in A.jpg. Then, I have another B.jpg image, more little; and I'll generate thumbnail of B.jpg , with R...

How to determine if an object is a collection of objects implementing a common interface.

I have the following method which returns true when a PropertyInfo instance references an object that is a collection of IDataExtractor objects: private bool IsCollectionOfIDataExtractors( PropertyInfo propInfo ) { var result = false; var extractors = propInfo.GetValue(dataExtractor, null); if (typeof (...

Should generic constraints be preferred to using interfaces as parameter types?

Consider this trivial function: public static bool IsPositive(IComparable<int> value) { return value.CompareTo(0) > 0; } Now, if I pass an int to this method, it gets boxed. Wouldn't it therefore be better to define the above method as follows? public static bool IsPositive<T>(T value) where T : IComparable<int> { return valu...

Why doesn't the dot symbol work in this Regex?

Hello I have a .NET Regex. (with ignore-case) I want it to match field_x_12 field_a_ABC field_r_something etc My question is why the . operator doesn't work in this regex: field_[.]_.* yet this (equivalent basically) regex does work: field_[a-z]_.* Is there something I'm missing about the dot operator . ? ...

Silverlight datafields content alignment

I simple form which have some fields. So i decided to add few DataField with textboxes and labels. Labels manageable and their length can be changed and i need to place my textboxes on the same distance from left side. How can i do this thing? ...

binding dateGridView column to list

Hello, My project in c# cantains dataGridView and i have a object contain data. public class Data { public List list {get;set;} } the data is init at program start up and the length of list can change. i want to bind the gridView to object that when gridView show each columns in gridview is bound to list in data object like this: if ...

A more complete error log.

When I log errors, I typically include the stack trace. This is good, but often, it's difficult to tell where the error actually is. Is it possible to set up a routine that collects, perhaps via reflection, the parameters, the local variables, etc... at the time the error has occurred? ...

GDI+ Paint Queue Problem

Hello, comrades) I've found some interesting behavior of Invalidate method in multithreaded applications. I hope you could help me with a problem... I experience troubles while trying to invalidate different controls at one time: while they're identical, one succesfully repaints itself, but another - not. Here is an example: I have a f...

Do Windows Forms Controls run without the form?

Can I use some features of a control without rendering it? Can I use some features of a control in a console app? NB: I tried to use a hidden WebBrowser control, but it didn't work. ...

COM security on Windows Server 2008

I have a .NET library that I'm registering for COM interop. Everything works fine on my machine (windows 7 x64) -- I register the library using regasm and VBScript can run CreateObject just fine. I unregister it and CreateObject fails. Just as you'd expect. However, when I put this exact same library on my server (Windows Server 2008...

Is there a difference in use or not the "this" keyword to reference a method inside the same class?

Possible Duplicate: When do you use the this keyword? If I have the following example: public class MyClass { private void MyMethod1() { ... } private void MyMethod2() { this.MyMethod1(); ... } } In the "MyMethod2" is there a difference in use "this.MyMethod1()" or just "MyMethod1()"? Performance, security, g...

Forms WeBrowser Document Ready event. How do I know when all Ajax calls are complete?

I am responding to the System.Windows.WebBrowser.DocumentComplete event in my application. However this event fires every time an ajax call completes on the page. I would like to know when the document is ready. Meaning when all calls out have returned. Any ideas? void WebBrowser_DocumentCompleted(object sender, WebBrowserDocumentComple...

SubSonic 3 Linq Joining error after using CleanUp

I am using the ActiveRecord SubSonic3 templates. Everything was working just dandy, then I decided I wanted things to look a bit better. See my database has field that look like this: SomeKey_id SomeOtherKey_id I wanted to clean it up so that it would instead be SomeKeyID SomeOtherKeyID when accessing it through SubSonic. So I ad...

How to document functions in described technique of creating C++ .Net dll's?

So here we have a technique, and here some more on it, of creating C++ DLLs with functions readable by .Net languages such as C#. The main Idea of technique as I use it (I can be ideologically wrong but it totally works for me) - you created a C++ project, it worked, now you want to use some of its functions from C# (for example you kee...

Very Strange Binding issue: Commands & Custom Properties

Here's the top of my usercontrol: <UserControl x:Class="MyApp.Common.Controls.Views.SimpleView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" ...

databinding list of double with invariant culture

I happen to have a list of double in a class and databind it to a combobox. The problem I am experiencing is that the displayed text for double has a comma instead of the dot. Ex 2,56 isntead of 2.56. The combo box seems to convert my doubles to string using the application culture I cannot just change the application culture to Invar...