本文整理汇总了C#中PropertyDefinition类的典型用法代码示例。如果您正苦于以下问题:C# PropertyDefinition类的具体用法?C# PropertyDefinition怎么用?C# PropertyDefinition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PropertyDefinition类属于命名空间,在下文中一共展示了PropertyDefinition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Read
public void Read(ClrModuleReader reader)
{
this.PropertyDefinition = new PropertyDefinition();
this.PropertyDefinition.Attributes = (PropertyAttributes)reader.Binary.ReadUInt16();
this.PropertyDefinition.Name = reader.ReadString();
this.Type = reader.ReadPropertySignature();
}
示例2: GetPropertyTags
private static IEnumerable<string> GetPropertyTags(ContentData content, PropertyDefinition propertyDefinition)
{
var tagNames = content[propertyDefinition.Name] as string;
return tagNames == null
? Enumerable.Empty<string>()
: tagNames.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries);
}
示例3: AssignToProperty
public override void AssignToProperty(object obj, PropertyDefinition property)
{
if (property.CanSet)
property.SetOn(obj, GetTypedValue(collectionDef));
else if (property.CanGet)
PopulateCollection(collectionDef, property.GetFrom(obj));
}
示例4: DoPropertyBind
private void DoPropertyBind(PropertyTreeBinderImpl parent,
PropertyTreeMetaObject target,
PropertyTreeNavigator navigator,
PropertyDefinition property)
{
object ancestor = null;
PropertyTreeMetaObject ancestorMeta = null;
if (property.IsExtender) {
var ancestorType = property.DeclaringTreeDefinition.SourceClrType;
ancestorMeta = target.GetAncestors().Cast<PropertyTreeMetaObject>().FirstOrDefault(
t => ancestorType.IsAssignableFrom(t.ComponentType));
if (ancestorMeta != null)
ancestor = ancestorMeta.Component;
}
var component = target.Component;
PropertyTreeMetaObject propertyTarget = target.CreateChild(property, navigator.QualifiedName, ancestorMeta);
var services = new PropertyBindContext(
component,
property,
ServiceProvider.Compose(ServiceProvider.FromValue(navigator), parent))
{
LineNumber = navigator.LineNumber,
LinePosition = navigator.LinePosition,
};
propertyTarget = parent.Bind(propertyTarget, navigator, services);
target.BindSetMember(property, navigator.QualifiedName, propertyTarget, ancestorMeta, services);
}
示例5: PropertyMapDefinition
public PropertyMapDefinition()
{
this.Source = new ObjectDefinition();
this.Target = new ObjectDefinition();
this.SourceProp = new PropertyDefinition();
this.TargetProp = new PropertyDefinition();
}
示例6: RequiredRule
public RequiredRule(PropertyDefinition propertyDefinition)
: base(propertyDefinition)
{
base.Assertion = oi => !String.IsNullOrWhiteSpace(oi.GetUntypedValue(propertyDefinition).StringValue);
base.ErrorMessageStaticGenerator = () => $"'{propertyDefinition.CurrentName}' is required.";
}
示例7: CreateProperty
static PropertyDefinition CreateProperty()
{
var prop = new PropertyDefinition(Generate.Name.ForMethod(), PropertyAttributes.None, TestModule.TypeSystem.Boolean);
TestType.Properties.Add(prop);
prop.DeclaringType = TestType;
return prop;
}
示例8: GetObservableFromProperty
private IObservable<object> GetObservableFromProperty(PropertyDefinition subscription)
{
return Observable.FromEventPattern<PropertyChangedEventHandler, PropertyChangedEventArgs>(
parentOnPropertyChanged => subscription.Parent.PropertyChanged += parentOnPropertyChanged,
parentOnPropertyChanged => subscription.Parent.PropertyChanged -= parentOnPropertyChanged)
.Where(pattern => pattern.EventArgs.PropertyName == subscription.PropertyName)
.Select(pattern => _mountPoint.Value);
}
示例9: PropertyBasedScheduleConditionDefinition
/// <summary>
/// Initializes a new instance of the <see cref="PropertyBasedScheduleConditionDefinition"/> class.
/// </summary>
/// <param name="contractName">The contract name that is used to identify the current condition.</param>
/// <param name="property">The property that will provide the condition result.</param>
private PropertyBasedScheduleConditionDefinition(string contractName, PropertyDefinition property)
: base(contractName)
{
{
Debug.Assert(property != null, "The property object should not be null.");
}
m_Property = property;
}
示例10: CreateTextBlockControl
/// <summary>
/// Creates the text block control.
/// </summary>
/// <param name="property">The property.</param>
/// <returns>
///
/// </returns>
protected virtual FrameworkElement CreateTextBlockControl(PropertyDefinition property)
{
var tb = new TextBlock
{
HorizontalAlignment = property.HorizontalAlignment,
VerticalAlignment = VerticalAlignment.Center,
Padding = new Thickness(4, 0, 4, 0)
};
tb.SetBinding(TextBlock.TextProperty, property.CreateOneWayBinding());
return tb;
}
示例11: PropertyBasedExportDefinition
/// <summary>
/// Initializes a new instance of the <see cref="PropertyBasedExportDefinition"/> class.
/// </summary>
/// <param name="contractName">The contract name that is used to identify the current export.</param>
/// <param name="declaringType">The type that declares the property on which the import is placed.</param>
/// <param name="property">The property for which the current object stores the serialized data.</param>
private PropertyBasedExportDefinition(
string contractName,
TypeIdentity declaringType,
PropertyDefinition property)
: base(contractName, declaringType)
{
{
Debug.Assert(property != null, "The property object shouldn't be null.");
}
m_Property = property;
}
示例12: CreateEditControl
public override FrameworkElement CreateEditControl(PropertyDefinition propertyDefinition, string bindingPath)
{
var control = propertyDefinition.CreateEditControl(bindingPath);
if (control != null)
return control;
var ctl = CreateExtendedToolkitControl(propertyDefinition, bindingPath);
if (ctl != null)
return ctl;
return base.CreateEditControl(propertyDefinition, bindingPath);
}
示例13: AssignToProperty
public override void AssignToProperty(object obj, PropertyDefinition property)
{
if (property.CanSet)
{
property.SetOn(obj, GetTypedValue());
}
else if (property.CanGet)
{
typedDictionary = property.GetFrom(obj) as IDictionary;
PopulateDictionary();
}
}
示例14: TypeConvertableRule
public TypeConvertableRule(PropertyDefinition propertyDefinition)
: base(propertyDefinition)
{
base.Assertion = oi =>
{
var propertyValue = oi.GetUntypedValue(propertyDefinition);
//a type is converted at the time it's string value is set, so all we need to do is check to see if that was successful.
return propertyValue.TypedValueIsAvailable;
};
base.ErrorMessageStaticGenerator = () =>
$"{propertyDefinition.CurrentName} must be a valid {(App.CurrentContext.IsHumanInterface ? GetHumanNameForType(propertyDefinition.ValueType) : propertyDefinition.ValueType.ToString())}.";
}
示例15: CreateEditControl
/// <summary>
/// Creates the edit control.
/// </summary>
/// <param name="property">The property.</param>
/// <param name="instance">The instance.</param>
/// <returns>
/// The control.
/// </returns>
public virtual FrameworkElement CreateEditControl(PropertyDefinition property, object instance)
{
var propertyType = property.Descriptor.PropertyType;
if (property.ItemsSourceProperty != null || property.ItemsSource != null)
return CreateComboBox(property);
if (propertyType.Is(typeof(Color)))
{
return this.CreateColorPickerControl(property);
}
return CreateTextBox(property);
}