Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / clr / src / BCL / System / Globalization / CalendarTable.cs / 1 / CalendarTable.cs
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
namespace System.Globalization {
using System.Runtime.Remoting;
using System;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Runtime.Versioning;
using System.Runtime.InteropServices;
/*==============================================================================
*
* Calendar Data table for DateTimeFormatInfo classes. Used by System.Globalization.DateTimeFormatInfo.
*
==============================================================================*/
internal class CalendarTable : BaseInfoTable {
// The default instance of calendar table. We should only create one instance per app-domain.
private static CalendarTable m_defaultInstance;
unsafe CalendarTableData* m_calendars;
[ResourceExposure(ResourceScope.Machine)]
[ResourceConsumption(ResourceScope.Machine)]
static CalendarTable()
{
m_defaultInstance = new CalendarTable("culture.nlp", true);
}
[ResourceExposure(ResourceScope.Machine)]
[ResourceConsumption(ResourceScope.Machine)]
internal CalendarTable(String fileName, bool fromAssembly) : base(fileName, fromAssembly) {
// Do nothing here.
}
////////////////////////////////////////////////////////////////////////
//
// Set Data Item Pointers that are unique to calendar table
//
////////////////////////////////////////////////////////////////////////
internal override unsafe void SetDataItemPointers()
{
m_itemSize = m_pCultureHeader->sizeCalendarItem;
m_numItem = m_pCultureHeader->numCalendarItems;
m_pDataPool = (ushort*)(m_pDataFileStart + m_pCultureHeader->offsetToDataPool);
// We subtract item size because calender indices start at 1 but our table doesn't have an entry for 0
m_pItemData = m_pDataFileStart + m_pCultureHeader->offsetToCalendarItemData - m_itemSize;
// Get calendar list. We subtract 1 because calender indices start at 1 but our table doesn't have an entry for 0
m_calendars = (CalendarTableData*)(m_pDataFileStart + m_pCultureHeader->offsetToCalendarItemData) - 1;
}
internal static CalendarTable Default {
get {
BCLDebug.Assert(m_defaultInstance != null, "CalendarTable.Default: default instance is not created.");
return (m_defaultInstance);
}
}
internal unsafe int ICURRENTERA(int id)
{
BCLDebug.Assert(id > 0 && id <= m_numItem,
"[CalendarTable.ICURRENTERA]id out of calendar range");
return m_calendars[id].iCurrentEra;
}
internal unsafe int IFORMATFLAGS(int id)
{
BCLDebug.Assert(id > 0 && id <= m_numItem,
"[CalendarTable.IFORMATFLAGS]id out of calendar range");
return m_calendars[id].iFormatFlags;
}
internal unsafe String[] SDAYNAMES(int id)
{
BCLDebug.Assert(id > 0 && id <= m_numItem,
"[CalendarTable.SDAYNAMES]id out of calendar range");
return GetStringArray(m_calendars[id].saDayNames);
}
internal unsafe String[] SABBREVDAYNAMES(int id)
{
BCLDebug.Assert(id > 0 && id <= m_numItem,
"[CalendarTable.SABBREVDAYNAMES]id out of calendar range");
return GetStringArray(m_calendars[id].saAbbrevDayNames);
}
internal unsafe String[] SSUPERSHORTDAYNAMES(int id)
{
BCLDebug.Assert(id > 0 && id <= m_numItem,
"[CalendarTable.SSUPERSHORTDAYNAMES]id out of calendar range");
return GetStringArray(m_calendars[id].saSuperShortDayNames);
}
internal unsafe String[] SMONTHNAMES(int id)
{
BCLDebug.Assert(id > 0 && id <= m_numItem,
"[CalendarTable.SMONTHNAMES]id out of calendar range");
return GetStringArray(m_calendars[id].saMonthNames);
}
internal unsafe String[] SABBREVMONTHNAMES(int id)
{
BCLDebug.Assert(id > 0 && id <= m_numItem,
"[CalendarTable.SABBREVMONTHNAMES]id out of calendar range");
return GetStringArray(m_calendars[id].saAbbrevMonthNames);
}
internal unsafe String[] SLEAPYEARMONTHNAMES(int id)
{
BCLDebug.Assert(id > 0 && id <= m_numItem,
"[CalendarTable.SLEAPYEARMONTHNAMES]id out of calendar range");
return GetStringArray(m_calendars[id].saLeapYearMonthNames);
}
internal unsafe String[] SSHORTDATE(int id)
{
BCLDebug.Assert(id > 0 && id <= m_numItem,
"[CalendarTable.SSHORTDATE]id out of calendar range");
return GetStringArray(m_calendars[id].saShortDate);
}
internal unsafe String[] SLONGDATE(int id)
{
BCLDebug.Assert(id > 0 && id <= m_numItem,
"[CalendarTable.SLONGDATE]id out of calendar range");
return GetStringArray(m_calendars[id].saLongDate);
}
internal unsafe String[] SYEARMONTH(int id)
{
BCLDebug.Assert(id > 0 && id <= m_numItem,
"[CalendarTable.SYEARMONTH]id out of calendar range");
return GetStringArray(m_calendars[id].saYearMonth);
}
internal unsafe String SMONTHDAY(int id)
{
BCLDebug.Assert(id > 0 && id <= m_numItem,
"[CalendarTable.SMONTHDAY]id out of calendar range");
return GetStringPoolString(m_calendars[id].sMonthDay);
}
internal unsafe int[][] SERARANGES(int id)
{
BCLDebug.Assert(id > 0 && id <= m_numItem,
"[CalendarTable.SERARANGES]id out of calendar range");
return GetWordArrayArray(m_calendars[id].waaEraRanges);
}
internal unsafe String[] SERANAMES(int id)
{
BCLDebug.Assert(id > 0 && id <= m_numItem,
"[CalendarTable.SERANAMES]id out of calendar range");
return GetStringArray(m_calendars[id].saEraNames);
}
internal unsafe String[] SABBREVERANAMES(int id)
{
BCLDebug.Assert(id > 0 && id <= m_numItem,
"[CalendarTable.SABBREVERANAMES]id out of calendar range");
return GetStringArray(m_calendars[id].saAbbrevEraNames);
}
internal unsafe String[] SABBREVENGERANAMES(int id)
{
BCLDebug.Assert(id > 0 && id <= m_numItem,
"[CalendarTable.SABBREVENGERANAMES]id out of calendar range");
return GetStringArray(m_calendars[id].saAbbrevEnglishEraNames);
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern String nativeGetEraName(int culture, int calID);
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
namespace System.Globalization {
using System.Runtime.Remoting;
using System;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Runtime.Versioning;
using System.Runtime.InteropServices;
/*==============================================================================
*
* Calendar Data table for DateTimeFormatInfo classes. Used by System.Globalization.DateTimeFormatInfo.
*
==============================================================================*/
internal class CalendarTable : BaseInfoTable {
// The default instance of calendar table. We should only create one instance per app-domain.
private static CalendarTable m_defaultInstance;
unsafe CalendarTableData* m_calendars;
[ResourceExposure(ResourceScope.Machine)]
[ResourceConsumption(ResourceScope.Machine)]
static CalendarTable()
{
m_defaultInstance = new CalendarTable("culture.nlp", true);
}
[ResourceExposure(ResourceScope.Machine)]
[ResourceConsumption(ResourceScope.Machine)]
internal CalendarTable(String fileName, bool fromAssembly) : base(fileName, fromAssembly) {
// Do nothing here.
}
////////////////////////////////////////////////////////////////////////
//
// Set Data Item Pointers that are unique to calendar table
//
////////////////////////////////////////////////////////////////////////
internal override unsafe void SetDataItemPointers()
{
m_itemSize = m_pCultureHeader->sizeCalendarItem;
m_numItem = m_pCultureHeader->numCalendarItems;
m_pDataPool = (ushort*)(m_pDataFileStart + m_pCultureHeader->offsetToDataPool);
// We subtract item size because calender indices start at 1 but our table doesn't have an entry for 0
m_pItemData = m_pDataFileStart + m_pCultureHeader->offsetToCalendarItemData - m_itemSize;
// Get calendar list. We subtract 1 because calender indices start at 1 but our table doesn't have an entry for 0
m_calendars = (CalendarTableData*)(m_pDataFileStart + m_pCultureHeader->offsetToCalendarItemData) - 1;
}
internal static CalendarTable Default {
get {
BCLDebug.Assert(m_defaultInstance != null, "CalendarTable.Default: default instance is not created.");
return (m_defaultInstance);
}
}
internal unsafe int ICURRENTERA(int id)
{
BCLDebug.Assert(id > 0 && id <= m_numItem,
"[CalendarTable.ICURRENTERA]id out of calendar range");
return m_calendars[id].iCurrentEra;
}
internal unsafe int IFORMATFLAGS(int id)
{
BCLDebug.Assert(id > 0 && id <= m_numItem,
"[CalendarTable.IFORMATFLAGS]id out of calendar range");
return m_calendars[id].iFormatFlags;
}
internal unsafe String[] SDAYNAMES(int id)
{
BCLDebug.Assert(id > 0 && id <= m_numItem,
"[CalendarTable.SDAYNAMES]id out of calendar range");
return GetStringArray(m_calendars[id].saDayNames);
}
internal unsafe String[] SABBREVDAYNAMES(int id)
{
BCLDebug.Assert(id > 0 && id <= m_numItem,
"[CalendarTable.SABBREVDAYNAMES]id out of calendar range");
return GetStringArray(m_calendars[id].saAbbrevDayNames);
}
internal unsafe String[] SSUPERSHORTDAYNAMES(int id)
{
BCLDebug.Assert(id > 0 && id <= m_numItem,
"[CalendarTable.SSUPERSHORTDAYNAMES]id out of calendar range");
return GetStringArray(m_calendars[id].saSuperShortDayNames);
}
internal unsafe String[] SMONTHNAMES(int id)
{
BCLDebug.Assert(id > 0 && id <= m_numItem,
"[CalendarTable.SMONTHNAMES]id out of calendar range");
return GetStringArray(m_calendars[id].saMonthNames);
}
internal unsafe String[] SABBREVMONTHNAMES(int id)
{
BCLDebug.Assert(id > 0 && id <= m_numItem,
"[CalendarTable.SABBREVMONTHNAMES]id out of calendar range");
return GetStringArray(m_calendars[id].saAbbrevMonthNames);
}
internal unsafe String[] SLEAPYEARMONTHNAMES(int id)
{
BCLDebug.Assert(id > 0 && id <= m_numItem,
"[CalendarTable.SLEAPYEARMONTHNAMES]id out of calendar range");
return GetStringArray(m_calendars[id].saLeapYearMonthNames);
}
internal unsafe String[] SSHORTDATE(int id)
{
BCLDebug.Assert(id > 0 && id <= m_numItem,
"[CalendarTable.SSHORTDATE]id out of calendar range");
return GetStringArray(m_calendars[id].saShortDate);
}
internal unsafe String[] SLONGDATE(int id)
{
BCLDebug.Assert(id > 0 && id <= m_numItem,
"[CalendarTable.SLONGDATE]id out of calendar range");
return GetStringArray(m_calendars[id].saLongDate);
}
internal unsafe String[] SYEARMONTH(int id)
{
BCLDebug.Assert(id > 0 && id <= m_numItem,
"[CalendarTable.SYEARMONTH]id out of calendar range");
return GetStringArray(m_calendars[id].saYearMonth);
}
internal unsafe String SMONTHDAY(int id)
{
BCLDebug.Assert(id > 0 && id <= m_numItem,
"[CalendarTable.SMONTHDAY]id out of calendar range");
return GetStringPoolString(m_calendars[id].sMonthDay);
}
internal unsafe int[][] SERARANGES(int id)
{
BCLDebug.Assert(id > 0 && id <= m_numItem,
"[CalendarTable.SERARANGES]id out of calendar range");
return GetWordArrayArray(m_calendars[id].waaEraRanges);
}
internal unsafe String[] SERANAMES(int id)
{
BCLDebug.Assert(id > 0 && id <= m_numItem,
"[CalendarTable.SERANAMES]id out of calendar range");
return GetStringArray(m_calendars[id].saEraNames);
}
internal unsafe String[] SABBREVERANAMES(int id)
{
BCLDebug.Assert(id > 0 && id <= m_numItem,
"[CalendarTable.SABBREVERANAMES]id out of calendar range");
return GetStringArray(m_calendars[id].saAbbrevEraNames);
}
internal unsafe String[] SABBREVENGERANAMES(int id)
{
BCLDebug.Assert(id > 0 && id <= m_numItem,
"[CalendarTable.SABBREVENGERANAMES]id out of calendar range");
return GetStringArray(m_calendars[id].saAbbrevEnglishEraNames);
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern String nativeGetEraName(int culture, int calID);
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- GifBitmapDecoder.cs
- Variant.cs
- LiteralControl.cs
- SafeNativeMethods.cs
- TdsParserStaticMethods.cs
- CustomError.cs
- Pen.cs
- BinaryMethodMessage.cs
- ContentTextAutomationPeer.cs
- ExpressionNormalizer.cs
- UrlPropertyAttribute.cs
- UriGenerator.cs
- IConvertible.cs
- PeerNearMe.cs
- ByteAnimationBase.cs
- FlowLayoutPanel.cs
- DirectionalLight.cs
- RemotingConfiguration.cs
- StrokeFIndices.cs
- AutomationEventArgs.cs
- ClientScriptItemCollection.cs
- CounterSet.cs
- TextEditorContextMenu.cs
- TextAction.cs
- ObjectDataSourceDesigner.cs
- Nullable.cs
- ParserStreamGeometryContext.cs
- HttpConfigurationContext.cs
- FlowDocumentFormatter.cs
- Attributes.cs
- ProxyWebPartConnectionCollection.cs
- GridViewCancelEditEventArgs.cs
- SafeWaitHandle.cs
- AvtEvent.cs
- ObjectDataSourceMethodEventArgs.cs
- RootProfilePropertySettingsCollection.cs
- SymbolEqualComparer.cs
- SingleAnimationUsingKeyFrames.cs
- SendActivityDesigner.cs
- UriSchemeKeyedCollection.cs
- DrawingVisual.cs
- ClientSideProviderDescription.cs
- Type.cs
- ellipse.cs
- TableLayoutRowStyleCollection.cs
- VerticalAlignConverter.cs
- ColumnProvider.cs
- BindingContext.cs
- ComplexTypeEmitter.cs
- ping.cs
- WebBrowser.cs
- StateMachine.cs
- InternalMappingException.cs
- MediaEntryAttribute.cs
- ProxyHwnd.cs
- NativeMethods.cs
- UserNameServiceElement.cs
- ContentElement.cs
- EdmProviderManifest.cs
- WsdlImporterElement.cs
- AsyncOperationContext.cs
- OleDbPermission.cs
- SspiSecurityToken.cs
- Timer.cs
- SizeAnimationClockResource.cs
- COM2ExtendedTypeConverter.cs
- translator.cs
- DefaultBindingPropertyAttribute.cs
- ValueSerializerAttribute.cs
- ControlOperationBehavior.cs
- shaperfactoryquerycacheentry.cs
- Exceptions.cs
- Point3D.cs
- GridViewUpdateEventArgs.cs
- MostlySingletonList.cs
- SQLByteStorage.cs
- PeerMessageDispatcher.cs
- SiteMapNodeItemEventArgs.cs
- ExternalFile.cs
- SingleConverter.cs
- Point.cs
- ComPlusAuthorization.cs
- SendKeys.cs
- Rfc2898DeriveBytes.cs
- IDQuery.cs
- TableItemStyle.cs
- StatusBarItem.cs
- Permission.cs
- SqlPersistenceWorkflowInstanceDescription.cs
- ColumnResizeUndoUnit.cs
- _ContextAwareResult.cs
- PageAsyncTaskManager.cs
- DbConnectionFactory.cs
- ListMarkerSourceInfo.cs
- HtmlInputFile.cs
- Brush.cs
- ControlEvent.cs
- BaseValidator.cs
- AuthenticationSection.cs
- PropertyTabChangedEvent.cs