.net

Regex replace all within a set of tags

I need to replace all instances of a match but only within certain tags. For example, consider an HTML page that has a <body>...</body> within these tags I need to replace all occurance of say: {embed=xxx} to <a href="xxx">xxx</a> I can do this for the whole page using something like (attempt #1): match={embed=(.*?)} replace=<a...

DotNetOpenAuth: Why I am not getting always the same OpenID given an e-mail?

Im trying to log in using OpenID/Relying Party (Google, Yahoo!..). My login page is as follows. What I want to do is simple: Get the OpenID from an user, store it, and associate it with an user account. Every time that unique OpenID is returned from the provider, I would know that the user associated is now logged in. Simple. The ...

Is it a good practice to call methods from constructors?

Is it a good practice to call methods from constructors? ...

Making One Unit Test Count as Several

Using Visual Studio Test Suite, is there a way to make a single unit test behave and give results as if it were several tests? I would like to have a test for each set of input parameters I will provide. But I'd rather have all the varieties of input be data-driven, rather than having to write a seperate test for each one. This questi...

Connecting to the .NET Development Server

I'm a Delphi programmer and wish to create my own code to directly connect to the .NET Development Server. Do you know of any reference material that is very much up to date that I can use please Best regards, j Lex Dean. ...

How Can I tell When a Socket has Disconnected

Hi All, I am using an ElSSLSocket from C#. This is a SecureBlackBox socket. SecureBlackBox is a third party library to handle secure sockets. I can see that the ElSSLSocket object has a property called 'Socket' so the underlying socket is a normal .NET socket. My question, is there some kind of event that I can subscribe to so that I ...

Different application settings depending on configuration mode

Is anyone aware of a way that I can set application (or user) level settings in a .Net application that are conditional on the applications current development mode? IE: Debug/Release To be more specific, I have a url reference to my webservices held in my application settings. During release mode I would like those settings to point to...

How do I map an inheritance hierarchy with Automapper?

I have the following example classes being used in an MVC/MVVM type app: class A { public string Property1 { get; set; } } class B : A { public string Property2 { get; set; } } class ViewModel { public string Property1 { get; set; } public string Property2 { get; set; } } A is my base class and B is the derived class. Vi...

Collision detecting custom sketched shape, represented as list of points

I have a set of points, drawn by the user. They will be drawing around some objects. I need to somehow turn this set of points into a shape, so I can find the area to detect collisions. An image will clarify: . The best idea I have had so far involves iterating over every pixel determining if it is 'inside' or 'outside' the shape, b...

Why does inheriting a WPF Button change the appearance of the image in a toolbar.

Using the following code btn2 looks different to btn1 and btn3 yet they are using exactly the same image. Public Class MyToolBar Inherits ToolBar Public Sub New() MyBase.New() Dim bmp1 = New BitmapImage(ImageUri.DeleteItem) Dim bmp2 = New BitmapImage(ImageUri.DeleteItem) Dim bmp3 = New BitmapIma...

read file in aspx.net authorize issue

Hello. I made a simple webpage with asp.net 3.5 and I wrote a code below var lines = File.ReadAllLines(@"\ad1-sunglim\Share\test.ini"); yes, ad1-sunglim is my PC. and that directory has a file, test.ini. and permission to read. But everytime I try to execute this code, I got UnauthorizedAccessException. do I have to imper...

Tool to verify compatibility of a public APIs

I work on a platform product which requires public compatibility between versions, so some code that was compiled against our previous build should be able to work against our new build without the need to recompile. Is there a tool that would automated this verification, all I could find was How to test binary compatibility automatical...

git->Process->git round trip text encoding

I'm trying to write a utility to migrate code from our custom source control to git. The 'commit' messages in the old system were added incrementally to a text file in the project path, so I'm using git to diff these files from one version to the next, then using that diff as a commit message. Unsurprisingly, I'm having trouble with ac...

.Net Object validation

Can I use Validation Application Block, for a high performance program? I mean when I'm getting objects from a stream and I need to validate their values as I parse data coming. As I understand reflection is involved... Is there any alternative tools that i can use for object validation? ...

can i call a .net 2.0 dll in .net 3.5?

Hi All, I am migrating to .net 3.5 and I want to know whether I can call from my 3.5 application, old .net 2.0 dll's methods? Some external API's are in .net 2.0 dll. So I need those. Kindly let me know. Thanks. ...

Why BufferedGraphics is Slow in Drawing using c#

I am using BufferedGraphics on Form_Paint function. Its draw my required graphic but its too much slow. Kindly give me the hints to solve this problem or any suggest me any other drawing technique for the quick response. BufferedGraphicsContext currentContext; BufferedGraphics myBuffer; // Gets a reference to the...

Loading a custom section from XML

Hi, I want to add an ability to an application that I'm developing for accessing configuration. The application will search by default in the app.config file for a section that I give it. If it was not found in the app.config, it will look for it in the DB, in a specific table that has the following columns: SectionType, SectionName, S...

Entity Framework 4 doesn't support Curiously-Recurring Generic Pattern?

it seems if i use an custom class as base of an entity,the ObjectContext.CreateObjectSet will fail with stackoverflow exception code is: // This is generated by EF4 and i modify it to my custom class public partial class EntityA : GClass<EntityA> { ...... } public partial class TestEntities : ObjectContext { public ObjectSet<E...

Robustness of file handling in windows mobile against power failure (data recovery)

I am writing a c# .net CF application for windows mobile 6, which does some file handling. I wanted to know if there is any built-in way to make the file handling robust against power failure. For instance, if there is a power failure while writing the file, the file contents should be intact without corruption(maybe there is loss of th...

How do I make asynchronous calls to sprocs using the Entity Framework in .NET?

The only way that I know of to make an async call using Linq to SQL is to compose an IQueryable and then ask the data context for the equivalent SqlCommand using GetCommand, which provides the BeginExecuteReader method. This approach didn't work for stored procedures and required some hackery to essentially use reflection to generate the...