本文整理汇总了C#中System.Data.Metadata.Edm.EdmItemCollection类的典型用法代码示例。如果您正苦于以下问题:C# EdmItemCollection类的具体用法?C# EdmItemCollection怎么用?C# EdmItemCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EdmItemCollection类属于System.Data.Metadata.Edm命名空间,在下文中一共展示了EdmItemCollection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Create
/// <summary>
/// Recursively generates <see cref="MemberPath"/>s for the members of the types stored in the <paramref name="extent"/>.
/// </summary>
internal static MemberProjectionIndex Create(EntitySetBase extent, EdmItemCollection edmItemCollection)
{
// We generate the indices for the projected slots as we traverse the metadata.
MemberProjectionIndex index = new MemberProjectionIndex();
GatherPartialSignature(index, edmItemCollection, new MemberPath(extent), false); // need not only keys
return index;
}
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:10,代码来源:MemberProjectionIndex.cs
示例2: LoadAssembly
internal static void LoadAssembly(
Assembly assembly, bool loadReferencedAssemblies,
KnownAssembliesSet knownAssemblies, EdmItemCollection edmItemCollection, Action<String> logLoadMessage, ref object loaderCookie,
out Dictionary<string, EdmType> typesInLoading, out List<EdmItemError> errors)
{
Debug.Assert(
loaderCookie == null || loaderCookie is Func<Assembly, ObjectItemLoadingSessionData, ObjectItemAssemblyLoader>,
"This is a bad loader cookie");
typesInLoading = null;
errors = null;
using (var lockedAssemblyCache = AquireLockedAssemblyCache())
{
var loadingData = new ObjectItemLoadingSessionData(
knownAssemblies, lockedAssemblyCache, edmItemCollection, logLoadMessage, loaderCookie);
LoadAssembly(assembly, loadReferencedAssemblies, loadingData);
loaderCookie = loadingData.LoaderCookie;
// resolve references to top level types (base types, navigation properties returns and associations, and complex type properties)
loadingData.CompleteSession();
if (loadingData.EdmItemErrors.Count == 0)
{
// do the validation for the all the new types
// Now, perform validation on all the new types
var validator = new EdmValidator();
validator.SkipReadOnlyItems = true;
validator.Validate(loadingData.TypesInLoading.Values, loadingData.EdmItemErrors);
// Update the global cache if there are no errors
if (loadingData.EdmItemErrors.Count == 0)
{
if (ObjectItemAssemblyLoader.IsAttributeLoader(loadingData.ObjectItemAssemblyLoaderFactory))
{
// we only cache items from the attribute loader globally, the
// items loaded by convention will change depending on the cspace
// provided. cspace will have a cache of it's own for assemblies
UpdateCache(lockedAssemblyCache, loadingData.AssembliesLoaded);
}
else if (loadingData.EdmItemCollection != null
&&
ObjectItemAssemblyLoader.IsConventionLoader(loadingData.ObjectItemAssemblyLoaderFactory))
{
UpdateCache(loadingData.EdmItemCollection, loadingData.AssembliesLoaded);
}
}
}
if (loadingData.TypesInLoading.Count > 0)
{
foreach (var edmType in loadingData.TypesInLoading.Values)
{
edmType.SetReadOnly();
}
}
// Update the out parameters once you are done with loading
typesInLoading = loadingData.TypesInLoading;
errors = loadingData.EdmItemErrors;
}
}
开发者ID:jimmy00784,项目名称:entityframework,代码行数:60,代码来源:AssemblyCache.cs
示例3: CreateWrappedMetadataWorkspace
private static MetadataWorkspace CreateWrappedMetadataWorkspace(string metadata, IEnumerable<string> wrapperProviderNames)
{
MetadataWorkspace workspace = new MetadataWorkspace();
// parse Metadata keyword and load CSDL,SSDL,MSL files into XElement structures...
var csdl = new List<XElement>();
var ssdl = new List<XElement>();
var msl = new List<XElement>();
ParseMetadata(metadata, csdl, ssdl, msl);
// fix all SSDL files by changing 'Provider' to our provider and modifying
foreach (var ssdlFile in ssdl)
{
foreach (string providerName in wrapperProviderNames)
{
ssdlFile.Attribute("ProviderManifestToken").Value = ssdl[0].Attribute("Provider").Value + ";" + ssdlFile.Attribute("ProviderManifestToken").Value;
ssdlFile.Attribute("Provider").Value = providerName;
}
}
// load item collections from XML readers created from XElements...
EdmItemCollection eic = new EdmItemCollection(csdl.Select(c => c.CreateReader()));
StoreItemCollection sic = new StoreItemCollection(ssdl.Select(c => c.CreateReader()));
StorageMappingItemCollection smic = new StorageMappingItemCollection(eic, sic, msl.Select(c => c.CreateReader()));
// and create metadata workspace based on them.
workspace = new MetadataWorkspace();
workspace.RegisterItemCollection(eic);
workspace.RegisterItemCollection(sic);
workspace.RegisterItemCollection(smic);
return workspace;
}
开发者ID:peisheng,项目名称:EASYFRAMEWORK,代码行数:32,代码来源:EntityConnectionWrapperUtils.cs
示例4: MemberDomainMap
private MemberDomainMap(Dictionary<MemberPath, CellConstantSet> domainMap,
Dictionary<MemberPath, CellConstantSet> nonConditionDomainMap, EdmItemCollection edmItemCollection)
{
m_conditionDomainMap = domainMap;
m_nonConditionDomainMap = nonConditionDomainMap;
m_edmItemCollection = edmItemCollection;
}
开发者ID:uQr,项目名称:referencesource,代码行数:7,代码来源:MemberDomainMap.cs
示例5: StorageMappingItemCollection
public StorageMappingItemCollection(EdmItemCollection edmCollection, StoreItemCollection storeCollection,
params string[] filePaths)
: base(DataSpace.CSSpace)
{
EntityUtil.CheckArgumentNull(edmCollection, "edmCollection");
EntityUtil.CheckArgumentNull(storeCollection, "storeCollection");
EntityUtil.CheckArgumentNull(filePaths, "filePaths");
this.m_edmCollection = edmCollection;
this.m_storeItemCollection = storeCollection;
// Wrap the file paths in instances of the MetadataArtifactLoader class, which provides
// an abstraction and a uniform interface over a diverse set of metadata artifacts.
//
MetadataArtifactLoader composite = null;
List<XmlReader> readers = null;
try
{
composite = MetadataArtifactLoader.CreateCompositeFromFilePaths(filePaths, XmlConstants.CSSpaceSchemaExtension);
readers = composite.CreateReaders(DataSpace.CSSpace);
this.Init(edmCollection, storeCollection, readers,
composite.GetPaths(DataSpace.CSSpace), true /*throwOnError*/);
}
finally
{
if (readers != null)
{
Helper.DisposeXmlReaders(readers);
}
}
}
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:32,代码来源:StorageMappingItemCollection.cs
示例6: CreateMetadataWorkspaceFromResources
/// <summary>
/// Creates the MetadataWorkspace for the given context type and base context type.
/// </summary>
/// <param name="contextType">The type of the context.</param>
/// <param name="baseContextType">The base context type (DbContext or ObjectContext).</param>
/// <returns>The generated <see cref="MetadataWorkspace"/></returns>
public static MetadataWorkspace CreateMetadataWorkspaceFromResources(Type contextType, Type baseContextType)
{
// get the set of embedded mapping resources for the target assembly and create
// a metadata workspace info for each group
IEnumerable<string> metadataResourcePaths = FindMetadataResources(contextType.Assembly);
IEnumerable<MetadataWorkspaceInfo> workspaceInfos = GetMetadataWorkspaceInfos(metadataResourcePaths);
// Search for the correct EntityContainer by name and if found, create
// a comlete MetadataWorkspace and return it
foreach (var workspaceInfo in workspaceInfos)
{
EdmItemCollection edmItemCollection = new EdmItemCollection(workspaceInfo.Csdl);
Type currentType = contextType;
while (currentType != baseContextType && currentType != typeof(object))
{
EntityContainer container;
if (edmItemCollection.TryGetEntityContainer(currentType.Name, out container))
{
StoreItemCollection store = new StoreItemCollection(workspaceInfo.Ssdl);
StorageMappingItemCollection mapping = new StorageMappingItemCollection(edmItemCollection, store, workspaceInfo.Msl);
MetadataWorkspace workspace = new MetadataWorkspace();
workspace.RegisterItemCollection(edmItemCollection);
workspace.RegisterItemCollection(store);
workspace.RegisterItemCollection(mapping);
workspace.RegisterItemCollection(new ObjectItemCollection());
return workspace;
}
currentType = currentType.BaseType;
}
}
return null;
}
开发者ID:chrissimon-au,项目名称:aspnetwebstack,代码行数:40,代码来源:MetadataWorkspaceUtilities.cs
示例7: HaveSeenInCompatibleContext
public bool HaveSeenInCompatibleContext(object loaderCookie, EdmItemCollection itemCollection)
{
// a new "context" is only when we have not seen this assembly with an itemCollection that is non-null
// and we now have a non-null itemCollection, and we are not already in AttributeLoader mode.
return SeenWithEdmItemCollection ||
itemCollection == null ||
ObjectItemAssemblyLoader.IsAttributeLoader(loaderCookie);
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:8,代码来源:KnownAssemblyEntry.cs
示例8: DefaultObjectMappingItemCollection
/// <summary>
/// Constrcutor to create an instance of DefaultObjectMappingItemCollection.
/// To start with we will create a Schema under which maps will be created.
/// </summary>
/// <param name="edmCollection"></param>
/// <param name="objectCollection"></param>
public DefaultObjectMappingItemCollection(EdmItemCollection edmCollection,
ObjectItemCollection objectCollection) : base(DataSpace.OCSpace)
{
EntityUtil.CheckArgumentNull(edmCollection, "edmCollection");
EntityUtil.CheckArgumentNull(objectCollection, "objectCollection");
this.m_edmCollection = edmCollection;
this.m_objectCollection = objectCollection;
LoadPrimitiveMaps();
}
开发者ID:uQr,项目名称:referencesource,代码行数:15,代码来源:DefaultObjectMappingItemCollection.cs
示例9: InitializeMetadataWorkspace
public static void InitializeMetadataWorkspace(TestContext testContext)
{
StringReader sr = new StringReader(testCsdl);
XmlReader reader = XmlReader.Create(sr);
metadataWorkspace = new MetadataWorkspace();
EdmItemCollection edmItemCollection = new EdmItemCollection(new XmlReader[] { reader });
metadataWorkspace.RegisterItemCollection(edmItemCollection);
metadataWorkspace.RegisterItemCollection(new ObjectItemCollection());
metadataWorkspace.LoadFromAssembly(Assembly.GetExecutingAssembly());
}
开发者ID:AlineGuan,项目名称:odata.net,代码行数:10,代码来源:ObjectContextMetadataTests.cs
示例10: EdmDataModelProvider
public EdmDataModelProvider(Uri serviceUri, bool isReadonly, bool supportPagingAndSorting)
{
var context = new DataServiceContext(serviceUri);
Uri metadataUri = context.GetMetadataUri();
var doc = XDocument.Load(metadataUri.AbsoluteUri);
var itemCollection = new EdmItemCollection(GetSchemas(doc).Select(s => s.CreateReader()));
RelationshipEndLookup = new Dictionary<long, EdmColumnProvider>();
TableEndLookup = new Dictionary<EntityType, EdmTableProvider>();
var tables = new List<TableProvider>();
// Create a dictionary from entity type to entity set. The entity type should be at the root of any inheritance chain.
IDictionary<EntityType, EntitySet> entitySetLookup = itemCollection.GetItems<EntityContainer>().SelectMany(c => c.BaseEntitySets.OfType<EntitySet>()).ToDictionary(e => e.ElementType);
// Create a lookup from parent entity to entity
ILookup<EntityType, EntityType> derivedTypesLookup = itemCollection.GetItems<EntityType>().ToLookup(e => (EntityType)e.BaseType);
_complexTypes = itemCollection.GetItems<ComplexType>();
// Keeps track of the current entity set being processed
EntitySet currentEntitySet = null;
// Do a DFS to get the inheritance hierarchy in order
// i.e. Consider the hierarchy
// null -> Person
// Person -> Employee, Contact
// Employee -> SalesPerson, Programmer
// We'll walk the children in a depth first order -> Person, Employee, SalesPerson, Programmer, Contact.
var objectStack = new Stack<EntityType>();
// Start will null (the root of the hierarchy)
objectStack.Push(null);
while (objectStack.Any()) {
EntityType entityType = objectStack.Pop();
if (entityType != null) {
// Update the entity set when we are at another root type (a type without a base type).
if (entityType.BaseType == null) {
currentEntitySet = entitySetLookup[entityType];
}
var table = CreateTableProvider(currentEntitySet, entityType, isReadonly, supportPagingAndSorting);
tables.Add(table);
}
foreach (EntityType derivedEntityType in derivedTypesLookup[entityType]) {
// Push the derived entity types on the stack
objectStack.Push(derivedEntityType);
}
}
_tables = tables.AsReadOnly();
GenerateClrTypes(serviceUri);
}
开发者ID:davidebbo-test,项目名称:DynamicDataWCFDataService,代码行数:55,代码来源:EdmDataModelProvider.cs
示例11: DefaultObjectMappingItemCollection
/// <summary>
/// Constrcutor to create an instance of DefaultObjectMappingItemCollection.
/// To start with we will create a Schema under which maps will be created.
/// </summary>
/// <param name="edmCollection"></param>
/// <param name="objectCollection"></param>
public DefaultObjectMappingItemCollection(
EdmItemCollection edmCollection,
ObjectItemCollection objectCollection)
: base(DataSpace.OCSpace)
{
//Contract.Requires(edmCollection != null);
//Contract.Requires(objectCollection != null);
m_edmCollection = edmCollection;
m_objectCollection = objectCollection;
LoadPrimitiveMaps();
}
开发者ID:jimmy00784,项目名称:entityframework,代码行数:17,代码来源:DefaultObjectMappingItemCollection.cs
示例12: ClientApiGenerator
public ClientApiGenerator(Schema sourceSchema, EdmItemCollection edmItemCollection, EntityClassGenerator generator, List<EdmSchemaError> errors)
{
Debug.Assert(sourceSchema != null, "sourceSchema is null");
Debug.Assert(edmItemCollection != null, "edmItemCollection is null");
Debug.Assert(generator != null, "generator is null");
Debug.Assert(errors != null, "errors is null");
_edmItemCollection = edmItemCollection;
_sourceSchema = sourceSchema;
_generator = generator;
_errors = errors;
_attributeEmitter = new AttributeEmitter(_typeReference);
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:13,代码来源:ClientApiGenerator.cs
示例13: TryGetKnownAssembly
internal bool TryGetKnownAssembly(Assembly assembly, object loaderCookie, EdmItemCollection itemCollection, out KnownAssemblyEntry entry)
{
if (!_assemblies.TryGetValue(assembly, out entry))
{
return false;
}
if (!entry.HaveSeenInCompatibleContext(loaderCookie, itemCollection))
{
return false;
}
return true;
}
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:14,代码来源:KnownAssembliesSet.cs
示例14: TryCreateEdmItemCollection
/// <summary>
/// Attempts to create a EdmItemCollection from the specified metadata file
/// </summary>
public bool TryCreateEdmItemCollection(string sourcePath, string[] referenceSchemas, out EdmItemCollection edmItemCollection)
{
edmItemCollection = null;
if(String.IsNullOrEmpty(sourcePath))
throw new ArgumentException("sourcePath");
if(referenceSchemas == null)
referenceSchemas = new string[0];
ItemCollection itemCollection = null;
sourcePath = _textTransformation.Host.ResolvePath(sourcePath);
var collectionBuilder = new EdmItemCollectionBuilder(_textTransformation, referenceSchemas.Select(s => _textTransformation.Host.ResolvePath(s)).Where(s => s != sourcePath));
if(collectionBuilder.TryCreateItemCollection(sourcePath, out itemCollection))
edmItemCollection = (EdmItemCollection) itemCollection;
return edmItemCollection != null;
}
开发者ID:hahoyer,项目名称:HWsqlass.cs,代码行数:21,代码来源:MetadataLoader.cs
示例15: Visit
protected override void Visit(StorageEntityContainerMapping storageEntityContainerMapping)
{
Debug.Assert(storageEntityContainerMapping != null, "storageEntityContainerMapping cannot be null!");
// at the entry point of visitor, we setup the versions
Debug.Assert(m_MappingVersion == storageEntityContainerMapping.StorageMappingItemCollection.MappingVersion, "the original version and the mapping collection version are not the same");
this.m_MappingVersion = storageEntityContainerMapping.StorageMappingItemCollection.MappingVersion;
this.m_EdmVersion = storageEntityContainerMapping.StorageMappingItemCollection.EdmItemCollection.EdmVersion;
this.m_EdmItemCollection = storageEntityContainerMapping.StorageMappingItemCollection.EdmItemCollection;
int index;
if (!this.AddObjectToSeenListAndHashBuilder(storageEntityContainerMapping, out index))
{
// if this has been add to the seen list, then just
return;
}
if (this.m_itemsAlreadySeen.Count > 1)
{
// this means user try another visit over SECM, this is allowed but all the previous visit all lost due to clean
// user can visit different SECM objects by using the same visitor to load the SECM object
this.Clean();
Visit(storageEntityContainerMapping);
return;
}
this.AddObjectStartDumpToHashBuilder(storageEntityContainerMapping, index);
#region Inner data visit
this.AddObjectContentToHashBuilder(storageEntityContainerMapping.Identity);
this.AddV2ObjectContentToHashBuilder(storageEntityContainerMapping.GenerateUpdateViews, this.m_MappingVersion);
base.Visit(storageEntityContainerMapping);
#endregion
this.AddObjectEndDumpToHashBuilder();
}
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:41,代码来源:MetadataMappingHasherVisitor.cs
示例16: ToStorageMappingItemCollection
private static StorageMappingItemCollection ToStorageMappingItemCollection(
this DbDatabaseMapping databaseMapping, EdmItemCollection itemCollection,
StoreItemCollection storeItemCollection)
{
//Contract.Requires(databaseMapping != null);
//Contract.Requires(itemCollection != null);
//Contract.Requires(storeItemCollection != null);
var stringBuilder = new StringBuilder();
using (var xmlWriter = XmlWriter.Create(
stringBuilder, new XmlWriterSettings
{
Indent = true
}))
{
new MslSerializer().Serialize(databaseMapping, xmlWriter);
}
using (var xmlReader = XmlReader.Create(new StringReader(stringBuilder.ToString())))
{
return new StorageMappingItemCollection(itemCollection, storeItemCollection, new[] { xmlReader });
}
}
开发者ID:jimmy00784,项目名称:entityframework,代码行数:24,代码来源:DbDatabaseMappingExtensions.cs
示例17: CompileFunctionDefinition
/// <summary>
/// Compiles eSQL <paramref name="functionDefinition"/> and returns <see cref="DbLambda"/>.
/// Guarantees type match of lambda variables and <paramref name="functionParameters"/>.
/// Passes thru all excepions coming from <see cref="CqlQuery"/>.
/// </summary>
internal static DbLambda CompileFunctionDefinition(
string functionDefinition,
IList<FunctionParameter> functionParameters,
EdmItemCollection edmItemCollection)
{
Debug.Assert(functionParameters != null, "functionParameters != null");
Debug.Assert(edmItemCollection != null, "edmItemCollection != null");
var workspace = new MetadataWorkspace();
workspace.RegisterItemCollection(edmItemCollection);
Perspective perspective = new ModelPerspective(workspace);
// Since we compile lambda expression and generate variables from the function parameter definitions,
// the returned DbLambda will contain variable types that match function parameter types.
var functionBody = CqlQuery.CompileQueryCommandLambda(
functionDefinition,
perspective,
null /* use default parser options */,
null /* parameters */,
functionParameters.Select(pInfo => pInfo.TypeUsage.Variable(pInfo.Name)));
Debug.Assert(functionBody != null, "functionBody != null");
return functionBody;
}
开发者ID:jimmy00784,项目名称:entityframework,代码行数:29,代码来源:ExternalCalls.cs
示例18: GatherSignatureFromTypeStructuralMembers
/// <summary>
/// Given the <paramref name="member"/> and one of its <paramref name="possibleType"/>s, determine the attributes that are relevant
/// for this <paramref name="possibleType"/> and return a <see cref="MemberPath"/> signature corresponding to the <paramref name="possibleType"/> and the attributes.
/// If <paramref name="needKeysOnly"/>=true, collect the key fields only.
/// </summary>
/// <param name="possibleType">the <paramref name="member"/>'s type or one of its subtypes</param>
private static void GatherSignatureFromTypeStructuralMembers(MemberProjectionIndex index,
EdmItemCollection edmItemCollection,
MemberPath member,
StructuralType possibleType,
bool needKeysOnly)
{
// For each child member of this type, collect all the relevant scalar fields
foreach (EdmMember structuralMember in Helper.GetAllStructuralMembers(possibleType))
{
if (MetadataHelper.IsNonRefSimpleMember(structuralMember))
{
if (!needKeysOnly || MetadataHelper.IsPartOfEntityTypeKey(structuralMember))
{
MemberPath nonStructuredMember = new MemberPath(member, structuralMember);
// Note: scalarMember's parent has already been added to the projectedSlotMap
index.CreateIndex(nonStructuredMember);
}
}
else
{
Debug.Assert(structuralMember.TypeUsage.EdmType is ComplexType ||
structuralMember.TypeUsage.EdmType is RefType, // for association ends
"Only non-scalars expected - complex types, association ends");
MemberPath structuredMember = new MemberPath(member, structuralMember);
GatherPartialSignature(index,
edmItemCollection,
structuredMember,
// Only keys are required for entities referenced by association ends of an association.
needKeysOnly || Helper.IsAssociationEndMember(structuralMember));
}
}
}
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:41,代码来源:MemberProjectionIndex.cs
示例19: ReduceEnumerableDomainToEnumeratedValues
// effects: Fixes the domains of variables in this as specified in FixEnumerableDomains
private static void ReduceEnumerableDomainToEnumeratedValues(ViewTarget target, Dictionary<MemberPath, CellConstantSet> domainMap, ConfigViewGenerator config,
EdmItemCollection edmItemCollection)
{
foreach (MemberPath member in domainMap.Keys)
{
if (MetadataHelper.HasDiscreteDomain(member.EdmType) == false)
{
continue;
}
CellConstantSet domain = Domain.DeriveDomainFromMemberPath(member, edmItemCollection, true /* leaveDomainUnbounded */);
CellConstantSet extra = domainMap[member].Difference(domain);
extra.Remove(Constant.Undefined);
if (extra.Count > 0)
{ // domainMap has extra members -- we should get rid of them
if (config.IsNormalTracing)
{
Helpers.FormatTraceLine("Changed domain of {0} from {1} - subtract {2}", member, domainMap[member], extra);
}
domainMap[member].Subtract(extra);
}
}
}
开发者ID:uQr,项目名称:referencesource,代码行数:23,代码来源:MemberDomainMap.cs
示例20: Contains
internal bool Contains(Assembly assembly, object loaderCookie, EdmItemCollection itemCollection)
{
KnownAssemblyEntry entry;
return TryGetKnownAssembly(assembly, loaderCookie, itemCollection, out entry);
}
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:5,代码来源:KnownAssembliesSet.cs
注:本文中的System.Data.Metadata.Edm.EdmItemCollection类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论