本文整理汇总了C#中MemberPath类的典型用法代码示例。如果您正苦于以下问题:C# MemberPath类的具体用法?C# MemberPath怎么用?C# MemberPath使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MemberPath类属于命名空间,在下文中一共展示了MemberPath类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CanBeModified
/// <summary>
/// Indicate if the referred member can be modified or not due to sealing.
/// </summary>
/// <param name="asset">The asset to modify</param>
/// <param name="path">The path to the member to modify</param>
/// <returns><value>true</value> if it can be modified</returns>
public bool CanBeModified(Asset asset, MemberPath path)
{
if (path.GetNodeOverrides(asset).Any(x => x.IsNew()))
return true;
var assetBase = asset.Base;
while (assetBase != null && assetBase.Asset != null)
{
var parent = assetBase.Asset;
var parentPath = path.Resolve(asset, parent).FirstOrDefault(); // if several paths exist in parent, they should be all equal (same object instance)
if (parentPath == null)
break;
var parentOverrides = parentPath.GetNodeOverrides(parent).ToList();
if (parentOverrides.LastOrDefault().IsSealed())
return false;
if (parentOverrides.Any(x => x.IsNew()))
break;
assetBase = parent.Base;
}
return true;
}
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:31,代码来源:AssetUpdater.cs
示例2: TestCanBeModifiedOrphan
public void TestCanBeModifiedOrphan()
{
// -------------------------------------------
// Check that CanBeModified is always true
// whatever are the values of the overrides
//
// For that set all the possible values of the overrides
// at two first level of fields and check the reset
//
// Field checked is orphan.MyClass.Value
//
// --------------------------------------------
Initialize();
var orphan = new TestAssetUpdate { MyClass = new MyClass() };
var testValues = new[] { OverrideType.Base, OverrideType.Sealed, OverrideType.New, OverrideType.Sealed | OverrideType.New };
var pathToValue = new MemberPath();
pathToValue.Push(memberMyClass);
pathToValue.Push(MemberValue);
foreach (var value1 in testValues)
{
orphan.SetOverride(memberMyClass, value1);
foreach (var value2 in testValues)
{
orphan.MyClass.SetOverride(MemberValue, value2);
Assert.IsTrue(assetUpdater.CanBeModified(orphan, pathToValue));
}
}
}
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:34,代码来源:TestAssetUpdater.cs
示例3: RefLoopAndMemberErrors
public void RefLoopAndMemberErrors()
{
var rootType = typeof(ErrorTypes.With<ErrorTypes.Parent>);
var valueProperty = rootType.GetProperty(nameof(ErrorTypes.With<ErrorTypes.Parent>.Value));
var parentType = typeof(ErrorTypes.Parent);
var childProperty = parentType.GetProperty(nameof(ErrorTypes.Parent.Child));
var parentProperty = typeof(ErrorTypes.Child).GetProperty(nameof(ErrorTypes.Child.Parent));
var path = new MemberPath(rootType)
.WithProperty(valueProperty);
var loopPath = path.WithProperty(childProperty)
.WithProperty(parentProperty)
.WithProperty(childProperty);
var referenceLoop = new ReferenceLoop(loopPath);
var refLoopErrors = ErrorBuilder.Start()
.CreateIfNull(rootType)
.Add(referenceLoop)
.Finnish();
var typeMustNotifyError = TypeMustNotifyError.GetOrCreate(parentType);
var typeErrors = new TypeErrors( parentType, typeMustNotifyError);
var memberErrors = new MemberErrors(path, typeErrors);
var notifyErrors = ErrorBuilder.Start()
.CreateIfNull(rootType)
.Add(memberErrors)
.Finnish();
var merged = ErrorBuilder.Merge(refLoopErrors, notifyErrors);
Assert.AreEqual(2, merged.Errors.Count);
Assert.AreEqual(8, merged.AllErrors.Count);
}
开发者ID:JohanLarsson,项目名称:Gu.State,代码行数:29,代码来源:ErrorBuilderTests.cs
示例4: QueryRewriter
internal QueryRewriter(EdmType generatedType, ViewgenContext context, ViewGenMode typesGenerationMode)
{
Debug.Assert(typesGenerationMode != ViewGenMode.GenerateAllViews);
_typesGenerationMode = typesGenerationMode;
_context = context;
_generatedType = generatedType;
_domainMap = context.MemberMaps.LeftDomainMap;
_config = context.Config;
_identifiers = context.CqlIdentifiers;
_qp = new RewritingProcessor<Tile<FragmentQuery>>(new DefaultTileProcessor<FragmentQuery>(context.LeftFragmentQP));
_extentPath = new MemberPath(context.Extent);
_keyAttributes = new List<MemberPath>(MemberPath.GetKeyMembers(context.Extent, _domainMap));
// populate _fragmentQueries and _views
foreach (var leftCellWrapper in _context.AllWrappersForExtent)
{
var query = leftCellWrapper.FragmentQuery;
Tile<FragmentQuery> tile = CreateTile(query);
_fragmentQueries.Add(query);
_views.Add(tile);
}
Debug.Assert(_views.Count > 0);
AdjustMemberDomainsForUpdateViews();
// must be done after adjusting domains
_domainQuery = GetDomainQuery(FragmentQueries, generatedType);
_usedViews = new HashSet<FragmentQuery>();
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:31,代码来源:QueryRewriter.cs
示例5: WhenError
public void WhenError()
{
var rootType = typeof(ErrorTypes.With<ErrorTypes.Parent>);
var valueProperty = rootType.GetProperty(nameof(ErrorTypes.With<ErrorTypes.Parent>.Value));
var childProperty = typeof(ErrorTypes.Parent).GetProperty(nameof(ErrorTypes.Parent.Child));
var parentProperty = typeof(ErrorTypes.Child).GetProperty(nameof(ErrorTypes.Child.Parent));
var path = new MemberPath(rootType)
.WithProperty(valueProperty)
.WithProperty(childProperty)
.WithProperty(parentProperty)
.WithProperty(childProperty);
var referenceLoop = new ReferenceLoop(path);
var typeErrors = ErrorBuilder.Start()
.CreateIfNull(rootType)
.Add(referenceLoop)
.Finnish();
var errorBuilder = new StringBuilder();
errorBuilder.AppendNotSupported(typeErrors);
var expected = "The property Parent.Child of type Child is in a reference loop.\r\n" +
" - The loop is With<Parent>.Value.Child.Parent.Child...\r\n" +
"The property With<Parent>.Value of type Parent is not supported.\r\n" +
"The property Parent.Child of type Child is not supported.\r\n" +
"The property Child.Parent of type Parent is not supported.\r\n";
var actual = errorBuilder.ToString();
Assert.AreEqual(expected, actual);
Assert.AreEqual(1, typeErrors.Errors.Count);
Assert.AreEqual(7, typeErrors.AllErrors.Count);
}
开发者ID:JohanLarsson,项目名称:Gu.State,代码行数:29,代码来源:ErrorBuilderTests.WithReferenceLoop.cs
示例6: ConstantProjectedSlot
/// <summary>
/// Creates a slot with constant value being <paramref name="value"/>.
/// </summary>
internal ConstantProjectedSlot(Constant value, MemberPath memberPath)
{
Debug.Assert(value != null);
Debug.Assert(value.IsNotNull() == false, "Cannot store NotNull in a slot - NotNull is only for conditions");
m_constant = value;
m_memberPath = memberPath;
}
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:10,代码来源:ConstantProjectedSlot.cs
示例7: DataVisitorBase
/// <summary>
/// Initializes a new instance of the <see cref="DataVisitorBase"/> class.
/// </summary>
/// <param name="typeDescriptorFactory">The type descriptor factory.</param>
/// <exception cref="ArgumentNullException">typeDescriptorFactory</exception>
protected DataVisitorBase(ITypeDescriptorFactory typeDescriptorFactory)
{
if (typeDescriptorFactory == null) throw new ArgumentNullException(nameof(typeDescriptorFactory));
TypeDescriptorFactory = typeDescriptorFactory;
CustomVisitors = new List<IDataCustomVisitor>();
context.DescriptorFactory = TypeDescriptorFactory;
context.Visitor = this;
CurrentPath = new MemberPath(16);
}
开发者ID:cg123,项目名称:xenko,代码行数:14,代码来源:DataVisitorBase.cs
示例8: PopulateKeyConstraintsForEntitySet
// requires: this to correspond to a cell relation for an entityset (m_cellQuery.Extent)
// effects: Adds any key constraints present in this to constraints
private void PopulateKeyConstraintsForEntitySet(BasicSchemaConstraints constraints)
{
var prefix = new MemberPath(m_cellQuery.Extent);
var entityType = (EntityType)m_cellQuery.Extent.ElementType;
// Get all the keys for the entity type and create the key constraints
var keys = ExtentKey.GetKeysForEntityType(prefix, entityType);
AddKeyConstraints(keys, constraints);
}
开发者ID:christiandpena,项目名称:entityframework,代码行数:11,代码来源:BasicCellRelation.cs
示例9: CellQuery
// <summary>
// Copy Constructor
// </summary>
internal CellQuery(CellQuery source)
{
m_basicCellRelation = source.m_basicCellRelation;
m_boolExprs = source.m_boolExprs;
m_selectDistinct = source.m_selectDistinct;
m_extentMemberPath = source.m_extentMemberPath;
m_originalWhereClause = source.m_originalWhereClause;
m_projectedSlots = source.m_projectedSlots;
m_whereClause = source.m_whereClause;
}
开发者ID:jesusico83,项目名称:Telerik,代码行数:13,代码来源:CellQuery.cs
示例10: GetKeysForEntityType
// effects: Determines all the keys (unique and primary for
// entityType) for entityType and returns a key. "prefix" gives the
// path of the extent or end of a relationship in a relationship set
// -- prefix is prepended to the entity's key fields to get the full memberpath
internal static List<ExtentKey> GetKeysForEntityType(MemberPath prefix, EntityType entityType)
{
// CHANGE_ADYA_MULTIPLE_KEYS: currently there is a single key only. Need to support
// keys inside complex types + unique keys
var key = GetPrimaryKeyForEntityType(prefix, entityType);
var keys = new List<ExtentKey>();
keys.Add(key);
return keys;
}
开发者ID:jimmy00784,项目名称:entityframework,代码行数:14,代码来源:ExtentKey.cs
示例11: AsEsql
internal override StringBuilder AsEsql(StringBuilder builder, MemberPath outputMember, string blockAlias)
{
DebugCheck.NotNull(outputMember.LeafEdmMember);
var modelTypeUsage = Helper.GetModelTypeUsage(outputMember.LeafEdmMember);
var modelType = modelTypeUsage.EdmType;
// Some built-in constants
if (BuiltInTypeKind.PrimitiveType
== modelType.BuiltInTypeKind)
{
var primitiveTypeKind = ((PrimitiveType)modelType).PrimitiveTypeKind;
if (primitiveTypeKind == PrimitiveTypeKind.Boolean)
{
// This better be a boolean. Else we crash!
var val = (bool)m_scalar;
var value = StringUtil.FormatInvariant("{0}", val);
builder.Append(value);
return builder;
}
else if (primitiveTypeKind == PrimitiveTypeKind.String)
{
bool isUnicode;
if (!TypeHelpers.TryGetIsUnicode(modelTypeUsage, out isUnicode))
{
// If can't determine - use the safest option, assume unicode.
isUnicode = true;
}
if (isUnicode)
{
builder.Append('N');
}
AppendEscapedScalar(builder);
return builder;
}
}
else if (BuiltInTypeKind.EnumType
== modelType.BuiltInTypeKind)
{
// Enumerated type - we should be able to cast it
var enumMember = (EnumMember)m_scalar;
builder.Append(enumMember.Name);
return builder;
}
// Need to cast
builder.Append("CAST(");
AppendEscapedScalar(builder);
builder.Append(" AS ");
CqlWriter.AppendEscapedTypeName(builder, modelType);
builder.Append(')');
return builder;
}
开发者ID:christiandpena,项目名称:entityframework,代码行数:55,代码来源:ScalarConstant.cs
示例12: PathString
public void PathString()
{
var path = new MemberPath(typeof(MemberPathTypes.With<MemberPathTypes.Parent>));
Assert.AreEqual("With<Parent>", path.PathString());
path = path.WithProperty(ChildProperty);
Assert.AreEqual("With<Parent>.Child", path.PathString());
path = path.WithProperty(ParentProperty);
Assert.AreEqual("With<Parent>.Child.Parent", path.PathString());
}
开发者ID:JohanLarsson,项目名称:Gu.State,代码行数:11,代码来源:MemberPathTests.cs
示例13: AsCqt
internal override DbExpression AsCqt(DbExpression row, MemberPath outputMember)
{
var cqt = m_memberPath.AsCqt(row);
TypeUsage outputMemberTypeUsage;
if (NeedToCastCqlValue(outputMember, out outputMemberTypeUsage))
{
cqt = cqt.CastTo(outputMemberTypeUsage);
}
return cqt;
}
开发者ID:christiandpena,项目名称:entityframework,代码行数:12,代码来源:MemberProjectedSlot.cs
示例14: IndexOf
/// <summary>
/// Returns a non-negative index of the <paramref name="member" /> if found, otherwise -1.
/// </summary>
internal int IndexOf(MemberPath member)
{
int index;
if (m_indexMap.TryGetValue(member, out index))
{
return index;
}
else
{
return -1;
}
}
开发者ID:christiandpena,项目名称:entityframework,代码行数:15,代码来源:MemberProjectionIndex.cs
示例15: GetPrimaryKeyForEntityType
// effects: Returns the key for entityType prefixed with prefix (for
// its memberPath)
internal static ExtentKey GetPrimaryKeyForEntityType(MemberPath prefix, EntityType entityType)
{
var keyFields = new List<MemberPath>();
foreach (var keyMember in entityType.KeyMembers)
{
Debug.Assert(keyMember != null, "Bogus key member in metadata");
keyFields.Add(new MemberPath(prefix, keyMember));
}
// Just have one key for now
var key = new ExtentKey(keyFields);
return key;
}
开发者ID:jimmy00784,项目名称:entityframework,代码行数:15,代码来源:ExtentKey.cs
示例16: SlotInfo
/// <summary>
/// Creates a <see cref="SlotInfo"/> for a <see cref="CqlBlock"/> X with information about whether this slot is needed by X's parent
/// (<paramref name="isRequiredByParent"/>), whether X projects it (<paramref name="isProjected"/>) along with the slot value (<paramref name="slotValue"/>) and
/// the output member path (<paramref name="outputMember"/> (for regular/non-boolean slots) for the slot.
/// </summary>
/// <param name="enforceNotNull">We need to ensure that _from variables are never null since view generation uses 2-valued boolean logic.
/// If <paramref name="enforceNotNull"/>=true, the generated Cql adds a condition (AND <paramref name="slotValue"/> NOT NULL).
/// This flag is used only for boolean slots.</param>
internal SlotInfo(bool isRequiredByParent, bool isProjected, ProjectedSlot slotValue, MemberPath outputMember, bool enforceNotNull)
{
m_isRequiredByParent = isRequiredByParent;
m_isProjected = isProjected;
m_slotValue = slotValue;
m_outputMember = outputMember;
m_enforceNotNull = enforceNotNull;
Debug.Assert(false == m_isRequiredByParent || m_slotValue != null, "Required slots cannot be null");
Debug.Assert(m_slotValue is QualifiedSlot ||
(m_slotValue == null && m_outputMember == null) || // unused boolean slot
(m_slotValue is BooleanProjectedSlot) == (m_outputMember == null),
"If slot is boolean slot, there is no member path for it and vice-versa");
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:21,代码来源:SlotInfo.cs
示例17: AsCqt
internal override DbExpression AsCqt(DbExpression row, MemberPath outputMember)
{
if (m_expr.IsTrue || m_expr.IsFalse)
{
return m_expr.AsCqt(row);
}
else
{
// Produce "CASE WHEN boolExpr THEN True ELSE False END" in order to enforce the two-state boolean logic:
// if boolExpr returns the boolean Unknown, it gets converted to boolean False.
return DbExpressionBuilder.Case(new DbExpression[] { m_expr.AsCqt(row) }, new DbExpression[] { DbExpressionBuilder.True }, DbExpressionBuilder.False);
}
}
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:13,代码来源:BooleanProjectedSlot.cs
示例18: GetKeyForRelationType
// effects: Returns a key correspnding to all the fields in different
// ends of relationtype prefixed with "prefix"
internal static ExtentKey GetKeyForRelationType(MemberPath prefix, AssociationType relationType)
{
var keyFields = new List<MemberPath>();
foreach (var endMember in relationType.AssociationEndMembers)
{
var endPrefix = new MemberPath(prefix, endMember);
var entityType = MetadataHelper.GetEntityTypeForEnd(endMember);
var primaryKey = GetPrimaryKeyForEntityType(endPrefix, entityType);
keyFields.AddRange(primaryKey.KeyFields);
}
var key = new ExtentKey(keyFields);
return key;
}
开发者ID:jimmy00784,项目名称:entityframework,代码行数:16,代码来源:ExtentKey.cs
示例19: WithLoop
public void WithLoop()
{
var rootType = typeof(MemberPathTypes.With<MemberPathTypes.Parent>);
var valueProperty = rootType.GetProperty(nameof(MemberPathTypes.With<MemberPathTypes.Parent>.Value));
var childProperty = typeof(MemberPathTypes.Parent).GetProperty(nameof(MemberPathTypes.Parent.Child));
var parentProperty = typeof(MemberPathTypes.Child).GetProperty(nameof(MemberPathTypes.Child.Parent));
var path = new MemberPath(rootType)
.WithProperty(valueProperty)
.WithProperty(childProperty)
.WithProperty(parentProperty);
Assert.AreEqual(false, path.HasLoop());
path = path.WithProperty(childProperty);
Assert.AreEqual(true, path.HasLoop());
}
开发者ID:JohanLarsson,项目名称:Gu.State,代码行数:15,代码来源:MemberPathTests.cs
示例20: LastMember
public void LastMember()
{
var rootType = typeof(MemberPathTypes.With<MemberPathTypes.Parent>);
var path1 = new MemberPath(rootType);
Assert.AreEqual(rootType, path1.Root.Type);
Assert.AreEqual(null, path1.LastMember);
var path2 = path1.WithProperty(ChildProperty);
Assert.AreNotSame(path1, path2);
Assert.AreEqual(rootType, path2.Root.Type);
Assert.AreEqual(ChildProperty, path2.LastMember);
var path3 = path2.WithProperty(ParentProperty);
Assert.AreEqual(rootType, path3.Root.Type);
Assert.AreEqual(ParentProperty, path3.LastMember);
}
开发者ID:JohanLarsson,项目名称:Gu.State,代码行数:16,代码来源:MemberPathTests.cs
注:本文中的MemberPath类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论