本文整理汇总了C#中IEditableRoot.CanWriteProperty方法的典型用法代码示例。如果您正苦于以下问题:C# IEditableRoot.CanWriteProperty方法的具体用法?C# IEditableRoot.CanWriteProperty怎么用?C# IEditableRoot.CanWriteProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEditableRoot
的用法示例。
在下文中一共展示了IEditableRoot.CanWriteProperty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
public static IFieldInfo Create(PropertyInfo prop, IEditableRoot editableRoot, IField field, object rawValue, IValidationContext validationContext)
{
var customAttr = prop.GetCustomAttribute<CommonSettingsAttribute>();
var promptAttr = prop.GetCustomAttribute<PromptAttribute>();
var docAttr = prop.GetCustomAttribute<DocumentationAttribute>();
var fieldTypeAttr = prop.GetCustomAttribute<FieldTypeAttribute>();
var hasCalculatedAttr = prop.GetCustomAttributes(typeof(CalculatedAttribute), false).Any();
var hasDefaultExpressionAttr = prop.GetCustomAttributes(typeof(HasDefaultExpressionAttribute), false).Any();
//Set common properties
var fieldInfo = CreateFieldInfo(fieldTypeAttr.ColumnType, prop, rawValue, editableRoot);
fieldInfo.Id = editableRoot.Id;
fieldInfo.SystemName = field.SystemName;
fieldInfo.DisplayName = customAttr.Name;
fieldInfo.Width = customAttr.Width;
fieldInfo.CanRead = editableRoot.CanReadProperty(prop.Name);
fieldInfo.IsRequired = validationContext != null && validationContext.IsRequired(editableRoot.ProcessName, field.SystemName, editableRoot.GetCurrentStateGuid());
fieldInfo.CanRead = editableRoot.CanReadProperty(prop.Name);
fieldInfo.CanWrite = editableRoot.CanWriteProperty(prop.Name) && !hasCalculatedAttr;
fieldInfo.BackColor = GetBackColor(editableRoot, prop);
fieldInfo.Prompt = promptAttr == null
? string.Format(CultureInfo.InvariantCulture,
LanguageService.Translate("Tooltip_EnterPrompt"), customAttr.Name)
: promptAttr.PromptString;
fieldInfo.IsDocumentationAvailable = docAttr != null;
if (hasCalculatedAttr || hasDefaultExpressionAttr)
{
fieldInfo.ExpressionType = hasCalculatedAttr ? FieldExpressionType.Calculated : FieldExpressionType.Default;
fieldInfo.Expression = GetExpression(editableRoot, prop);
}
// docAttr == null ? string.Empty : ClrUnicodeConverter.ToText(docAttr.DocumentationBody),
return fieldInfo;
}
示例2: FieldReadModel
/// <summary>
/// Initializes a new instance of the <see cref="FieldReadModel"/> class.
/// </summary>
/// <param name="baseModel">
/// The base model.
/// </param>
/// <param name="property">
/// The property.
/// </param>
public FieldReadModel(IEditableRoot baseModel, PropertyInfo property)
{
if (baseModel == null)
{
throw new ArgumentNullException("baseModel");
}
if (property == null)
{
throw new ArgumentNullException("property");
}
Ioc.SatisfyImportsOnce(this);
SystemName = property.Name;
var commonSettingsAttr = property.GetCustomAttributes(typeof(CommonSettingsAttribute), false).Select(d => d).FirstOrDefault() as CommonSettingsAttribute;
Name = commonSettingsAttr == null ? property.Name : commonSettingsAttr.Name;
SectionName = commonSettingsAttr == null ? string.Empty : commonSettingsAttr.Section;
var fieldTypeAttr = property.GetCustomAttributes(typeof(FieldTypeAttribute), false).Select(d => d).FirstOrDefault() as FieldTypeAttribute;
FieldType = fieldTypeAttr == null ? ColumnTypes.String : fieldTypeAttr.ColumnType;
var hasCalculatedAttr = property.GetCustomAttributes(typeof(CalculatedAttribute), false).Any();
CanWrite = baseModel.CanWriteProperty(property.Name) && !hasCalculatedAttr;
CanRead = baseModel.CanReadProperty(property.Name);
BackColor = GetBackColor(baseModel, property);
HideFromDetails = commonSettingsAttr != null && commonSettingsAttr.HideFromDetails;
bool valueObtained = false;
switch (this.FieldType)
{
case ColumnTypes.String:
var testFieldAttr = property.GetCustomAttributes(typeof(TextFieldAttribute), false).Select(d => d).FirstOrDefault() as TextFieldAttribute;
var stringLengthAttr = property.GetCustomAttributes(typeof(StringLengthAttribute), false).Select(d => d).FirstOrDefault() as StringLengthAttribute;
var richTextAttr = property.GetCustomAttributes(typeof(RichTextAttribute), false).Select(d => d).FirstOrDefault() as RichTextAttribute;
this.Options = StringFieldOptions.Create(testFieldAttr, stringLengthAttr, richTextAttr);
break;
case ColumnTypes.Integer:
case ColumnTypes.Numeric:
case ColumnTypes.Double:
var numericOptionsAttr = property.GetCustomAttributes(typeof(NumericAttribute), false).Select(d => d).FirstOrDefault() as NumericAttribute;
var rangeAttr = property.GetCustomAttributes(typeof(RangeAttribute), false).Select(d => d).FirstOrDefault() as RangeAttribute;
this.Options = NumericFieldOptions.Create(numericOptionsAttr, rangeAttr);
break;
case ColumnTypes.DateTime:
var dateTimeAttr = property.GetCustomAttributes(typeof(DateTimeFormatAttribute), false).Select(d => d).FirstOrDefault() as DateTimeFormatAttribute;
this.Options = DateTimeFieldOptions.Create(dateTimeAttr);
if (CanRead)
{
Value = string.Format(CultureInfo.InvariantCulture, "{0:yyyy-MM-ddTHH:mm:ss}", property.GetValue(baseModel));
}
valueObtained = true;
break;
case ColumnTypes.Boolean:
this.Options = BooleanFieldOptions.Create(property);
break;
case ColumnTypes.Reference:
this.Options = SingleCrossRefFieldOptions.Create(property, baseModel);
break;
case ColumnTypes.File:break;
case ColumnTypes.DisplayList:
if (CanRead)
{
var displayItemList = (IDisplayListItemList) baseModel.GetValueByPropertyName(property.Name);
Options = DisplayListFieldOptions.Create(property, displayItemList);
var displayListFieldOptions = (DisplayListFieldOptions) Options;
if (displayListFieldOptions != null)
{
var baseType = displayItemList.GetType().BaseType;
if (baseType != null)
{
var itemType = baseType.GetGenericArguments()[1];
var columns = displayListFieldOptions.Columns;
var displayListModels = new List<DisplayListItemModel>();
foreach (var displayItem in displayItemList)
{
var item = new DisplayListItemModel
{
Id = (int) displayItem.GetType().GetProperty(Constants.IdColumnName).GetValue(displayItem)
//.........这里部分代码省略.........