本文整理汇总了C#中IProperty类的典型用法代码示例。如果您正苦于以下问题:C# IProperty类的具体用法?C# IProperty怎么用?C# IProperty使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IProperty类属于命名空间,在下文中一共展示了IProperty类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HasPublicModifier
public static bool HasPublicModifier(IProperty property)
{
try
{
if (property.Getter == null)
{
return false;
}
var declaration = property.GetDeclarations().FirstOrDefault();
if (declaration == null)
{
return false;
}
var memberDeclaration = declaration as ICSharpTypeMemberDeclaration;
if (memberDeclaration == null)
{
return false;
}
return memberDeclaration.ModifiersList.Modifiers.Any(m => m.GetTokenType() == CSharpTokenType.PUBLIC_KEYWORD);
}
catch (Exception exn)
{
Debug.WriteLine(exn);
return false;
}
}
示例2: PropertyDefinition
public override string PropertyDefinition(IProperty property)
{
bool hasTick = property.PropertyType.IsRef && !property.PropertyType.IsGenericTypeArg;
StringBuilder sb = new StringBuilder("public:").AppendLine();
sb.Append("property ").Append(TypeName(property.PropertyType)).Append(' ');
if (hasTick)
sb.Append('^');
sb.Append(property.DisplayName).AppendLine(" {");
if (property.HasGetter)
{
sb.Append(Tabulator).Append(TypeName(property.PropertyType)).Append(' ');
if (hasTick)
sb.Append('^');
sb.AppendLine("get();");
}
if (property.HasSetter)
{
sb.Append(Tabulator);
if (property.SetterAccess.HasValue && property.SetterAccess.Value == AccessModifier.Protected)
sb.Append("protected: ");
sb.Append("void set(")
.Append(TypeName(property.PropertyType))
.Append(' ');
if (hasTick)
sb.Append('^');
sb.AppendLine("value);");
}
sb.Append("}");
return sb.ToString();
}
示例3: ForeignKeyPropertyChangedAction
private void ForeignKeyPropertyChangedAction(InternalEntityEntry entry, IProperty property, object oldValue, object newValue)
{
foreach (var foreignKey in entry.EntityType.GetForeignKeys().Where(p => p.Properties.Contains(property)).Distinct())
{
var navigations = _model.GetNavigations(foreignKey).ToList();
var oldPrincipalEntry = entry.StateManager.GetPrincipal(entry.RelationshipsSnapshot, foreignKey);
if (oldPrincipalEntry != null)
{
Unfixup(navigations, oldPrincipalEntry, entry);
}
var principalEntry = entry.StateManager.GetPrincipal(entry, foreignKey);
if (principalEntry != null)
{
if (foreignKey.IsUnique)
{
var oldDependents = entry.StateManager.GetDependents(principalEntry, foreignKey).Where(e => e != entry).ToList();
// TODO: Decide how to handle case where multiple values found (negative case)
// Issue #739
if (oldDependents.Count > 0)
{
StealReference(foreignKey, oldDependents[0]);
}
}
DoFixup(navigations, principalEntry, new[] { entry });
}
}
}
示例4: NextAsync
public virtual async Task<object> NextAsync(StateEntry stateEntry, IProperty property, CancellationToken cancellationToken = default(CancellationToken))
{
Check.NotNull(stateEntry, "stateEntry");
Check.NotNull(property, "property");
var newValue = GetNextValue();
// If the chosen value is outside of the current block then we need a new block.
// It is possible that other threads will use all of the new block before this thread
// gets a chance to use the new new value, so use a while here to do it all again.
while (newValue.Current >= newValue.Max)
{
// Once inside the lock check to see if another thread already got a new block, in which
// case just get a value out of the new block instead of requesting one.
using (await _lock.LockAsync(cancellationToken))
{
if (newValue.Max == _currentValue.Max)
{
var commandInfo = PrepareCommand(stateEntry.Configuration);
var newCurrent = (long)await _executor.ExecuteScalarAsync(commandInfo.Item1.DbConnection, commandInfo.Item1.DbTransaction, commandInfo.Item2, cancellationToken).ConfigureAwait(false);
newValue = new SequenceValue(newCurrent, newCurrent + _blockSize);
_currentValue = newValue;
}
else
{
newValue = GetNextValue();
}
}
}
return Convert.ChangeType(newValue.Current, property.PropertyType);
}
示例5: PropertyResult
public PropertyResult(IProperty source)
{
if (source == null) return;
_alias = source.Alias;
_value = source.Value;
}
示例6: TryMatchFieldName
public virtual FieldInfo TryMatchFieldName(
IProperty property, PropertyInfo propertyInfo, Dictionary<string, FieldInfo> dclaredFields)
{
Check.NotNull(property, nameof(property));
Check.NotNull(propertyInfo, nameof(propertyInfo));
Check.NotNull(dclaredFields, nameof(dclaredFields));
var propertyName = propertyInfo.Name;
var propertyType = propertyInfo.PropertyType.GetTypeInfo();
var camelized = char.ToLowerInvariant(propertyName[0]) + propertyName.Substring(1);
FieldInfo fieldInfo;
return (dclaredFields.TryGetValue(camelized, out fieldInfo)
&& fieldInfo.FieldType.GetTypeInfo().IsAssignableFrom(propertyType))
|| (dclaredFields.TryGetValue("_" + camelized, out fieldInfo)
&& fieldInfo.FieldType.GetTypeInfo().IsAssignableFrom(propertyType))
|| (dclaredFields.TryGetValue("_" + propertyName, out fieldInfo)
&& fieldInfo.FieldType.GetTypeInfo().IsAssignableFrom(propertyType))
|| (dclaredFields.TryGetValue("m_" + camelized, out fieldInfo)
&& fieldInfo.FieldType.GetTypeInfo().IsAssignableFrom(propertyType))
|| (dclaredFields.TryGetValue("m_" + propertyName, out fieldInfo)
&& fieldInfo.FieldType.GetTypeInfo().IsAssignableFrom(propertyType))
? fieldInfo
: null;
}
示例7: GetTypeMapping
public virtual RelationalTypeMapping GetTypeMapping(IProperty property)
=> GetTypeMapping(
property.Relational().ColumnType,
property.Relational().Column,
property.ClrType.UnwrapNullableType(),
property.IsKey() || property.IsForeignKey(),
property.IsConcurrencyToken);
示例8: GetOrAdd
public virtual ValueGenerator GetOrAdd(IProperty property, Func<IProperty, ValueGenerator> factory)
{
Check.NotNull(property, nameof(property));
Check.NotNull(factory, nameof(factory));
return _cache.GetOrAdd(property, factory);
}
示例9: ForeignKeyPropertyChanged
public virtual void ForeignKeyPropertyChanged(StateEntry entry, IProperty property, object oldValue, object newValue)
{
Check.NotNull(entry, "entry");
Check.NotNull(property, "property");
PerformFixup(() => ForeignKeyPropertyChangedAction(entry, property, oldValue, newValue));
}
示例10: Next
public override object Next(StateEntry entry, IProperty property)
{
Check.NotNull(entry, "entry");
Check.NotNull(property, "property");
return Convert.ChangeType(Interlocked.Increment(ref _current), property.PropertyType);
}
示例11: CreatePool
private static IValueGeneratorPool CreatePool(IProperty property, IValueGeneratorFactory factory)
{
var poolSize = factory.GetPoolSize(property);
return poolSize == 1
? (IValueGeneratorPool)new SingleValueGeneratorPool(factory, property)
: new ValueGeneratorPool(factory, property, poolSize);
}
示例12: Next
public override object Next(StateEntry entry, IProperty property)
{
Check.NotNull(property, "property");
Contract.Assert(property.IsForeignKey());
var entityType = property.EntityType;
var stateManager = entry.Configuration.StateManager;
foreach (var foreignKey in entityType.ForeignKeys)
{
for (var propertyIndex = 0; propertyIndex < foreignKey.Properties.Count; propertyIndex++)
{
if (property == foreignKey.Properties[propertyIndex])
{
foreach (var navigation in entityType.Navigations
.Concat(foreignKey.ReferencedEntityType.Navigations)
.Where(n => n.ForeignKey == foreignKey)
.Distinct())
{
var principal = TryFindPrincipal(stateManager, navigation, entry.Entity);
if (principal != null)
{
var principalEntry = stateManager.GetOrCreateEntry(principal);
return principalEntry[foreignKey.ReferencedProperties[propertyIndex]];
}
}
}
}
}
return null;
}
示例13: Next
public override object Next(StateEntry entry, IProperty property)
{
Check.NotNull(entry, "entry");
Check.NotNull(property, "property");
return Guid.NewGuid();
}
示例14: WrapProperty
IProperty WrapProperty(IProperty result)
{
if (result == null) return null;
if (!(result is AlienOwnedProperty))
return new AlienOwnedProperty(this, _realMember, result);
return result;
}
示例15: ParameterDescriptorImpl
public ParameterDescriptorImpl(IProperty property)
{
if (property == null) throw new ArgumentNullException("property");
this.property = property;
SetEnumerable();
}