473,401 Members | 2,146 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

Architecture Ques: FormatInfo class

TS
Hi, I had a microsoft guru help my team build a project. I noticed that in 2
situations where a value needed to be formatted in a certain way when viewed
in browser, he would create a new class called "format_nameFormatInfo".

He used 2 functions in each:
Public Function GetFormat(ByVal formatType As System.Type) As Object
Implements System.IFormatProvider.GetFormat

and

Public Function Format(ByVal formatString As String, ByVal argToBeFormatted
As Object, ByVal formatProvider As System.IFormatProvider) As String
Implements System.ICustomFormatter.Format
I'm wondering if this is a common practice for all OO gurus. The reason I
ask is I have to do the same thing in other parts of the app, and also
becuase I just want to know the preferred way to doing things.

Thanks.
Nov 18 '05 #1
2 1031
Hi TS,
Thanks for posting in the community!
From your description, your team has defined a certain custom data/string
formatting class which follow the IFormatProvider/ICustomFormatter pattern
in the dotnet framework. And you wonder whether this is a most popular
pattern in all oo area, yes?

Based on my experience, the Custom formatting interfaces in dotnet are all
well designed based on the existing OO formatting practices. The
System.IFormatProvider interface gives you a way to tell the framework that
your custom class is capable of formatting strings. It is commonly combined
with the ICustomFormatter interface, which defines the method to actually
format the string.

#IFormatProvider Interface
http://msdn.microsoft.com/library/en...iformatprovide
rclasstopic.asp?frame=true

As the ICustomFormatter, the ICustomFormatter interface gives you a way to
implement your own string formatting routines for classes that you cannot
change the formatting of directly. For example, you might want to implement
the ICustomFormatter interface to let you format DateTime objects in your
own special way. This is in comparison to objects that you have the source
for, in which case you would implement the IFormattable interface.The
IFormatProvider interface defines a single method, GetFormat.

MSDN has a good article on customizing format strings. The section, "Adding
Custom Format Strings to Existing Types" applies to the ICustomFormatter
interface.

#Customizing Format Strings
http://msdn.microsoft.com/library/en...omizingformats
trings.asp?frame=true

Please have a view on the above item. Hope this helpful.
Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #2
TS
Thanks for the info, I'll be sure to check it out
Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: news | last post by:
Hi, I am pretty new to PHP I want to do the following but I have been unable to find good info/ or sample code on it; please help; - retrieve a gif/jpeg image using PHP from another site -...
1
by: David2511 | last post by:
Hello, I need a little help. I try to write the following architecture : an abstract template class A Two classes derived from class A : the classes B and C which are concrete. The class...
0
by: Dong | last post by:
Hi All, I am using Visual Studio 2003 (Development Environment version 7.1.3088 and ..NET Framework 1.1 version 1.14322 sp1). But the FormatInfo property never appears in myGridTextBoxColumn...
2
by: hans | last post by:
Hi! I am new to .NET (coming from Java). We have to implement a desktop application which extracts data from a database, does some analysis, filtering etc. and displays the results. I have...
6
by: Gary James | last post by:
This may not be a direct C# question, but since I'll be using using C# for development, I thought I'd pose the question here. I'll soon be involved in the design of a new software product that...
0
by: support | last post by:
Hi all, I could use a little help. I am trying to customize a displayed value in a dataGrid. What i would like to do is create a IFormatProvider that will set my column to be displayed in...
1
by: benmorganpowell | last post by:
I have a small windows service which connects to a POP3 server at defined intervals, scans the available messages, extracts the required information and inserts the data into a SQL database. I am...
6
by: V. Jenks | last post by:
I apologize if this is the wrong forum for this, I could not locate one that was exactly appropriate for this topic. Over the last couple of years I've been doing a lot of reading on design...
7
by: call_me_anything | last post by:
Is char abc different from char abc ?
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.