本文整理汇总了C#中NodeType.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# NodeType.Contains方法的具体用法?C# NodeType.Contains怎么用?C# NodeType.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NodeType
的用法示例。
在下文中一共展示了NodeType.Contains方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddConcurrencyAttributes
//---------------------------------------------------------------------
// Adds concurrency attributes to resource types.
//---------------------------------------------------------------------
protected virtual void AddConcurrencyAttributes(Workspace w)
{
if (!GetType().Name.Contains("Concurrency"))
return;
HashSet<ResourceType> typesWithETags = new HashSet<ResourceType>();
foreach (ResourceContainer container in w.ServiceContainer.ResourceContainers)
{
ResourceType baseType = container.BaseType;
if (!typesWithETags.Add(baseType))
continue;
// set up ETags
NodeType[] etagTypes = new NodeType[] { Clr.Types.String, Clr.Types.Int16, Clr.Types.Int32, Clr.Types.Int64, Clr.Types.Guid };
List<ResourceProperty> possibleETagProperties = baseType.Properties.OfType<ResourceProperty>()
.Where(p => etagTypes.Contains(p.Type) && !p.IsComplexType && !p.IsNavigation && p.PrimaryKey == null
&& p.Facets.IsDeclaredProperty && !p.Facets.FixedLength && p.ResourceType == baseType
&& p.Facets.UnderlyingType == UnderlyingType.Same && !p.Facets.IsStoreBlob
&& (p.Type != Clr.Types.String || (p.Facets.MaxSize.HasValue && p.Facets.MaxSize.Value < 512)))
.ToList();
if (possibleETagProperties.Any())
baseType.Facets.Add(NodeFacet.Attribute(new ConcurrencyAttribute(baseType, possibleETagProperties.Choose(2).Select(p => p.Name).ToArray())));
}
}
示例2: WorkspaceCallback
protected override void WorkspaceCallback(Workspace workspace)
{
Microsoft.OData.Client.ODataProtocolVersion maxProtocolVersion = Microsoft.OData.Client.ODataProtocolVersion.V4;
if (workspace.Settings.MaxProtocolVersion.HasValue)
{
maxProtocolVersion = workspace.Settings.MaxProtocolVersion.Value;
}
workspace.GenerateCallOrderInterceptors = true;
// use custom concurrency provider for workspaces that can
if(workspace.DataLayerProviderKind == DataLayerProviderKind.InMemoryLinq)
{
if (workspace.Settings.UpdatableImplementation == UpdatableImplementation.DataServiceUpdateProvider)
{
workspace.ServiceModifications.Interfaces.IServiceProvider.Services[typeof(Microsoft.OData.Service.Providers.IDataServiceUpdateProvider)]
= "new UpdateProviderWrapper(this.CurrentDataSource)";
}
else
{
workspace.ServiceModifications.Interfaces.IServiceProvider.Services[typeof(Microsoft.OData.Service.IUpdatable)]
= "new UpdatableWrapper(this.CurrentDataSource)";
}
}
else if (workspace.DataLayerProviderKind == DataLayerProviderKind.NonClr)
{
workspace.Settings.UpdatableImplementation = UpdatableImplementation.DataServiceUpdateProvider;
workspace.Settings.UseLazyPropertyLoading = false;
// do this NOW instead of later, so that we can refer to these settings
(workspace as NonClrWorkspace).DefineClrProperties();
if (AstoriaTestProperties.UseOpenTypes)
{
OpenTypesUtil.SetupDefaultOpenTypeAttributes(workspace);
}
}
workspace.ServiceContainer.ResourceContainers.Remove("Invoices");
#region set up etags
if (workspace.DataLayerProviderKind != DataLayerProviderKind.LinqToSql)
{
HashSet<ResourceType> typesWithETags = new HashSet<ResourceType>();
foreach (ResourceContainer container in workspace.ServiceContainer.ResourceContainers)
{
ResourceType baseType = container.BaseType;
if (!typesWithETags.Add(baseType))
continue;
// set up ETags
NodeType[] etagTypes = new NodeType[] { Clr.Types.String, Clr.Types.Int16, Clr.Types.Int32, Clr.Types.Int64, Clr.Types.Guid };
List<ResourceProperty> possibleETagProperties = baseType.Properties.OfType<ResourceProperty>()
.Where(p => etagTypes.Contains(p.Type) && !p.IsComplexType && !p.IsNavigation && p.PrimaryKey == null
&& p.Facets.IsDeclaredProperty && !p.Facets.FixedLength && p.ResourceType == baseType
&& p.Facets.UnderlyingType == UnderlyingType.Same && !p.Facets.IsStoreBlob
&& (p.Type != Clr.Types.String || (p.Facets.MaxSize.HasValue && p.Facets.MaxSize.Value < 512)))
.ToList();
if (possibleETagProperties.Any())
baseType.Facets.Add(NodeFacet.Attribute(new ConcurrencyAttribute(baseType, possibleETagProperties.Choose(2).Select(p => p.Name).ToArray())));
}
}
#endregion
#region set up blobs
if (Versioning.Server.SupportsLiveFeatures && workspace.DataLayerProviderKind != DataLayerProviderKind.LinqToSql)
{
var edmWorkspace = workspace as EdmWorkspace;
if (edmWorkspace != null)
{
edmWorkspace.CsdlCallbacks.Add(delegate(XmlDocument doc)
{
doc.InnerXml = doc.InnerXml.Replace(TestUtil.TestNamespaceManager.LookupNamespace("csdl"), TestUtil.TestNamespaceManager.LookupNamespace("csdl2"));
});
edmWorkspace.SsdlCallbacks.Add(delegate(XmlDocument doc)
{
doc.InnerXml = doc.InnerXml.Replace("http://schemas.microsoft.com/ado/2006/04/edm/ssdl", "http://schemas.microsoft.com/ado/2009/02/edm/ssdl");
});
edmWorkspace.MslCallbacks.Add(delegate(XmlDocument doc)
{
doc.InnerXml = doc.InnerXml.Replace("urn:schemas-microsoft-com:windows:storage:mapping:CS", "http://schemas.microsoft.com/ado/2008/09/mapping/cs");
});
}
foreach(ResourceContainer container in workspace.ServiceContainer.ResourceContainers.Where(rc => !(rc is ServiceOperation)))
{
if (workspace.DataLayerProviderKind == DataLayerProviderKind.Edm)
{
// After named-stream redesign, adding streams to EF is non-trivial
continue;
}
if (container.ResourceTypes.Any(rt => rt.Facets.NamedStreams.Any()))
{
continue;
}
// because we don't represent streams as properties, having streams appear on anything other than the absolute base type
// makes call order prediction very hard
if (container.BaseType.BaseTypes.Any())
//.........这里部分代码省略.........