Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / ndp / fx / src / DataEntity / System / Data / Objects / Internal / complextypematerializer.cs / 1 / complextypematerializer.cs
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....]
// @backupOwner [....]
//---------------------------------------------------------------------
using System.Data.Metadata.Edm;
using System.Data.Common;
using System.Diagnostics;
using System.Data.Mapping;
namespace System.Data.Objects.Internal
{
///
/// Supports materialization of complex type instances from records. Used
/// by the ObjectStateManager.
///
internal class ComplexTypeMaterializer
{
private readonly MetadataWorkspace _workspace;
private const int MaxPlanCount = 4;
private Plan[] _lastPlans;
private int _lastPlanIndex;
internal ComplexTypeMaterializer(MetadataWorkspace workspace)
{
_workspace = workspace;
}
internal object CreateComplex(IExtendedDataRecord record, DataRecordInfo recordInfo, object result)
{
Debug.Assert(null != record, "null IExtendedDataRecord");
Debug.Assert(null != recordInfo, "null DataRecordInfo");
Debug.Assert(null != recordInfo.RecordType, "null TypeUsage");
Debug.Assert(null != recordInfo.RecordType.EdmType, "null EdmType");
Debug.Assert(Helper.IsEntityType(recordInfo.RecordType.EdmType) ||
Helper.IsComplexType(recordInfo.RecordType.EdmType),
"not EntityType or ComplexType");
Plan plan = GetPlan(record, recordInfo);
if (null == result)
{
result = ((Func