本文整理汇总了C#中IEditableRoot类的典型用法代码示例。如果您正苦于以下问题:C# IEditableRoot类的具体用法?C# IEditableRoot怎么用?C# IEditableRoot使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IEditableRoot类属于命名空间,在下文中一共展示了IEditableRoot类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
/// <summary>
/// The create.
/// </summary>
/// <returns>
/// The <see cref="ResultFieldOptions"/>.
/// </returns>
public static SampleFieldOptions Create(PropertyInfo property, IEditableRoot model)
{
if (property == null)
{
throw new ArgumentNullException("property");
}
if (model == null)
{
throw new ArgumentNullException("model");
}
var result = new SampleFieldOptions();
var settingsString = model.GetValueByPropertyName(string.Format(CultureInfo.InvariantCulture, "{0}{1}", property.Name, Constants.SampleSettingPostfix));
if (!string.IsNullOrEmpty(settingsString))
{
var sampleSettings = XElement.Parse(settingsString);
SetProperties(result, sampleSettings, model);
}
result.IsNewItem = model.Id == 0;
return result;
}
示例2: Create
/// <summary>
/// The create.
/// </summary>
/// <returns>
/// The <see cref="ResultFieldOptions"/>.
/// </returns>
public static ResultFieldOptions Create(PropertyInfo property, IEditableRoot model)
{
if (property == null)
{
throw new ArgumentNullException("property");
}
if (model == null)
{
throw new ArgumentNullException("model");
}
var result = new ResultFieldOptions();
result.ChoiceList = new ChoiceModel[0];
var listProperty = model.GetType().GetProperty(string.Format(CultureInfo.InvariantCulture, "{0}{1}", property.Name, Constants.ResultListPostfix));
if (listProperty != null)
{
var listValue = listProperty.GetValue(model, null);
if (listValue != null)
{
result.ChoiceList = ((IEnumerable<ChoiceInfo>)listValue).Select(i => new ChoiceModel(i));
}
else
{
result.IsEditable = true;
}
}
return result;
}
示例3: Create
public static IFieldOptions Create(PropertyInfo property, IEditableRoot obj)
{
if (property == null)
{
throw new ArgumentNullException("property");
}
var crossRefAttr = property.GetCustomAttributes(typeof(CrossRefFieldAttribute), false).Select(d => d).FirstOrDefault() as CrossRefFieldAttribute;
if (crossRefAttr == null)
{
throw new VeyronException("CrossRef attribute not found on Cross-reference field property");
}
var result = new MultiCrossRefFieldOptions { ProcessSystemName = crossRefAttr.ReferenceTableName, FieldName = crossRefAttr.RefFieldName };
result.LinkVisibility = crossRefAttr.MultiCrAllowLinkUnlink && string.IsNullOrEmpty(crossRefAttr.LinkFieldSystemName);
result.UnlinkVisibility = crossRefAttr.MultiCrAllowLinkUnlink;
result.AddNewVisibility = crossRefAttr.MultiCrAllowAddNew;
result.LinkFieldSystemName = crossRefAttr.LinkFieldSystemName;
var recentVersionAttr = (from d in property.GetCustomAttributes(typeof(RecentVersionAttribute), true) select d).FirstOrDefault();
if (recentVersionAttr != null)
{
result.AllowRecentVersion = true;
}
var deepCopyAttr = (from d in property.GetCustomAttributes(typeof(DeepCopyAttribute), true) select d).FirstOrDefault();
if (deepCopyAttr != null)
{
result.AllowDeepCopy = true;
}
return result;
}
示例4: FieldVisibilityRule
/// <summary>
/// Initializes a new instance of the <see cref="FieldVisibilityRule"/> class.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="actionRule">The action rule.</param>
/// <param name="fieldName">Name of the field.</param>
/// <param name="sourceFields">The source fields.</param>
public FieldVisibilityRule(IEditableRoot item, IActionRule actionRule, string fieldName, IEnumerable<string> sourceFields)
{
Item = item;
Rule = actionRule;
FieldName = fieldName;
if (sourceFields != null)
{
_sourceFields = new HashSet<string>(sourceFields);
}
if (_sourceFields != null && _sourceFields.Count > 0)
{
if (Item != null)
{
Item.PropertyChanged += OnItemPropertyChanged;
}
var notifyChildChanged = Item as INotifyChildChanged;
if (notifyChildChanged != null)
{
notifyChildChanged.ChildChanged += OnItemChildChanged;
}
}
}
示例5: Create
/// <summary>
/// The create.
/// </summary>
/// <param name="property">
/// The property.
/// </param>
/// <param name="model">
/// The model.
/// </param>
/// <returns>
/// The <see cref="ChecklistFieldOptions"/>.
/// </returns>
public static ChecklistFieldOptions Create(PropertyInfo property, IEditableRoot model)
{
if (property == null)
{
throw new ArgumentNullException("property");
}
var result = new ChecklistFieldOptions();
Ioc.SatisfyImportsOnce(result);
var value = property.GetValue(model) as ChecklistEdit;
if (value == null)
{
result.NeedSaving = true;
return result;
}
result.AllowAdhocQuestions = value.AllowAdhocQuestions;
result.AnswerProcessSystemName = value.AnswerProcessSystemName;
result.ListDisplayFieldSystemName = value.ListDisplayFieldSystemName;
result.CanChangeItemState = value.CanChangeItemState;
if (!string.IsNullOrEmpty(value.HiddenAnswersId))
{
result.HiddenAnswersId = value.HiddenAnswersId.Split(',').Select(SafeTypeConverter.Convert<int>).ToArray();
}
if (!string.IsNullOrEmpty(value.AnswerProcessSystemName))
{
var editableRootType = result.DynamicTypeManager.GetEditableRootType(value.AnswerProcessSystemName);
result.CanAddItem = Csla.Rules.BusinessRules.HasPermission(Csla.Rules.AuthorizationActions.CreateObject, editableRootType);
result.CanDeleteItem = Csla.Rules.BusinessRules.HasPermission(Csla.Rules.AuthorizationActions.DeleteObject, editableRootType) && model.CanWritePropertyByName(property.Name);
if (value.AnswerProcessList != null && value.AnswerProcessList.Count > 0)
{
result.AnswerProcessFields = result.GetFields((IEditableRoot)value.AnswerProcessList[0]);
}
else
{
result.AnswerProcessFields = result.GetFields((IEditableRoot)DataPortal.Create(editableRootType, null));
}
var displayFieldAttributes = (ChecklistDisplayFieldAttribute[])property.GetCustomAttributes(typeof(ChecklistDisplayFieldAttribute), false);
foreach (var displayFieldAttribute in displayFieldAttributes)
{
result.AnswerDisplayFields.Add(
new FieldSettingsOverride
{
FieldName = displayFieldAttribute.SystemName,
Position = displayFieldAttribute.Sequence,
Width = displayFieldAttribute.Width,
RowSpan = displayFieldAttribute.NumberOfRows
});
}
}
return result;
}
示例6: Create
/// <summary>
/// The create.
/// </summary>
/// <returns>
/// The <see cref="SamplingTechniqueFieldOptions"/>.
/// </returns>
public static SamplingTechniqueFieldOptions Create(PropertyInfo property, IEditableRoot model)
{
var result = new SamplingTechniqueFieldOptions();
var list = (from SampleSizeTypes sampleType in Enum.GetValues(typeof(SampleSizeTypes)) select new { Text = GetDescriptionFromEnumValue(sampleType), Value = sampleType.ToString() }).ToList();
result.PossibleValues = list;
return result;
}
示例7: CreateDetailsResult
private static DetailsCommandResult CreateDetailsResult(IEditableRoot editableRoot)
{
var result = new DetailsCommandResult { Id = editableRoot.Id, DisplayName = editableRoot.ProcessDisplayName, IsTabbedUI = IsTabbedUI(editableRoot) };
var visibleFields = new HashSet<string>(editableRoot.Sections.SelectMany(s => s.Fields).Where(f => !f.IsHidden).Select(f => f.SystemName));
var validationContext = editableRoot.GetValidationContext();
foreach (var sect in editableRoot.Sections)
{
var section = new SectionInfo { Name = sect.Name };
var row = new RowInfo();
var rowLength = 0d;
foreach (var field in sect.Fields)
{
var prop = editableRoot.GetPropertyByName(field.SystemName);
if (!visibleFields.Contains(prop.Name))
{
continue;
}
var fieldInfo = FieldInfoFactory.Create(prop, editableRoot, field, GetValue(prop, editableRoot), validationContext);
if (rowLength + fieldInfo.Width > 100)
{
if (row.Fields.Any())
section.Rows.Add(row);
row = new RowInfo();
rowLength = fieldInfo.Width >= 100 ? 100 : fieldInfo.Width;
}
else
rowLength += fieldInfo.Width;
row.Fields.Add(fieldInfo);
}
if (row.Fields.Any())
section.Rows.Add(row);
if (section.Rows.Any())
result.Sections.Add(section);
}
result.States = new List<IStateInfo>();
var supportStates = editableRoot as ISupportStates;
if (supportStates != null)
{
foreach (var s in supportStates.StateManager.States)
{
result.States.Add(new StateInfo(s.Name, s.Guid));
}
}
result.CurrentStateGuid = editableRoot.GetCurrentStateGuid();
return result;
}
示例8: GetValue
/// <summary>
/// Gets the sample type field value.
/// </summary>
/// <param name="field">
/// The field.
/// </param>
/// <param name="editableRoot">
/// The editable root.
/// </param>
/// <returns>
/// The value.
/// </returns>
public object GetValue(DetailsSaveFieldModel field, IEditableRoot editableRoot)
{
var jObject = field.Value as JObject;
if (jObject != null)
{
return jObject.ToObject<SampleTypeModel>();
}
return field.Value;
}
示例9: EditableRootDataContext
/// <summary>
/// Initializes a new instance of the <see cref="EditableRootDataContext"/> class.
/// </summary>
/// <param name="item">
/// The source item.
/// </param>
/// <param name="retrieverFactory">
/// The retriever factory.
/// </param>
/// <exception cref="ArgumentNullException">
/// The <paramref name="item"/> parameter is null.
/// </exception>
/// <exception cref="ArgumentNullException">
/// The <paramref name="retrieverFactory"/> parameter is null.
/// </exception>
public EditableRootDataContext(IEditableRoot item, IProcessFieldItemsRetrieverFactory retrieverFactory)
{
if (item == null)
throw new ArgumentNullException("item");
if (retrieverFactory == null)
throw new ArgumentNullException("retrieverFactory");
_item = item;
_itemsRetrieverFactory = retrieverFactory;
}
示例10: GetValue
public object GetValue(DetailsSaveFieldModel field, IEditableRoot editableRoot)
{
var bytes = field.Value as byte[];
var base64 = field.Value as string;
if (!string.IsNullOrEmpty(base64))
{
bytes = Convert.FromBase64String(base64);
}
return bytes;
}
示例11: GetValue
/// <summary>
/// Gets the value.
/// </summary>
/// <param name="field">The field.</param>
/// <param name="editableRoot">The editable root.</param>
/// <returns></returns>
public object GetValue(DetailsSaveFieldModel field, IEditableRoot editableRoot)
{
if (field.Settings == null)
return null;
var fileFieldOptions = field.Settings.ToObject<FileFieldOptions>();
if (fileFieldOptions == null)
return null;
IFileProcess fileEdit = editableRoot.GetValueByPropertyName(field.SystemName);
if (fileEdit == null)
return null;
fileEdit.FileName = fileFieldOptions.FileName;
fileEdit.OriginalFileName = fileFieldOptions.OriginalFileName;
if (!fileFieldOptions.Locked)
{
fileEdit.LockedDate = null;
}
else if (!fileEdit.Locked.HasValue || !fileEdit.Locked.Value)
{
fileEdit.LockedDate = DateTime.Now;
}
fileEdit.Locked = fileFieldOptions.Locked;
fileEdit.LockedByAccountId = fileFieldOptions.LockedByAccountId;
fileEdit.LockedByAccountName = fileFieldOptions.LockedByAccountName;
if (fileFieldOptions.AuditLog != null)
{
fileEdit.FileChangeInfo = new AuditLogInfo
{
LogType = fileFieldOptions.AuditLog.LogType,
ProcessName = fileFieldOptions.AuditLog.ProcessName,
ItemId = fileFieldOptions.AuditLog.ItemId,
FieldName = fileFieldOptions.AuditLog.FieldName,
OldValue = fileFieldOptions.AuditLog.OldValue,
NewValue = fileFieldOptions.AuditLog.NewValue,
DateUpdated = fileFieldOptions.AuditLog.DateUpdated,
User = fileFieldOptions.AuditLog.User
};
}
var newModel = ((IBusinessBase)fileEdit).Save();
if (fileFieldOptions.FileId == 0)
{
editableRoot.SetValueByPropertyName(string.Format("{0}Id", field.SystemName), ((IDynamicObject)newModel).Id);
}
return newModel;
}
示例12: CopyAnswerData
/// <summary>
/// Copies the answer data.
/// </summary>
/// <param name="answerFieldValues">
/// The answer field values.
/// </param>
/// <param name="answerItem">
/// The answer item.
/// </param>
/// <exception cref="ArgumentNullException">
/// The <paramref name="answerFieldValues"/> parameter is null.
/// </exception>
/// <exception cref="ArgumentNullException">
/// The <paramref name="answerItem"/> parameter is null.
/// </exception>
public static void CopyAnswerData(ICollection<ChecklistAnswerFieldValue> answerFieldValues, IEditableRoot answerItem)
{
if (answerFieldValues == null)
throw new ArgumentNullException("answerFieldValues");
if (answerItem == null)
throw new ArgumentNullException("answerItem");
using (new ThreadLocalBypassPropertyCheckContext())
{
foreach (var fieldValue in answerFieldValues.Where(f => f.Value != null))
{
var answerProperty = answerItem.GetPropertyByName(fieldValue.FieldName);
var answerValue = answerItem.GetValueByPropertyName(fieldValue.FieldName);
if (fieldValue.Value is ICrossRefItemList && answerValue is ICrossRefItemList)
{
var qList = (ICrossRefItemList)fieldValue.Value;
var aList = (ICrossRefItemList)answerValue;
aList.Clear();
foreach (var crItem in qList.Cast<ICrossRefItemInfo>())
{
#if !SILVERLIGHT
aList.Assign(crItem.Id);
#else
aList.Assign(crItem.Id, (o, e) => { });
#endif
}
continue;
}
if (answerProperty.PropertyType.IsInstanceOfType(fieldValue.Value))
{
answerItem.SetValueByPropertyName(fieldValue.FieldName, fieldValue.Value);
}
else
{
throw new VeyronException(
string.Format(
CultureInfo.InvariantCulture,
"Cannot assign value of type \"{0}\" to property \"{1}\".",
fieldValue.Value.GetType().AssemblyQualifiedName,
fieldValue.FieldName));
}
}
}
}
示例13: ProcessItemUpdatedEvent
/// <summary>
/// Initializes a new instance of the <see cref="ProcessItemUpdatedEvent"/> class.
/// </summary>
/// <param name="item">
/// The item that was modified.
/// </param>
/// <param name="rootWindow">
/// The root window.
/// </param>
/// <param name="depth">
/// The depth.
/// </param>
public ProcessItemUpdatedEvent(IEditableRoot item, ITopLevelWindow rootWindow, int depth)
{
if (item == null)
throw new ArgumentNullException("item");
if (rootWindow == null)
throw new ArgumentNullException("rootWindow");
if (depth < 0)
throw new ArgumentOutOfRangeException("depth", @"Depth cannot be negative.");
Item = item;
RootWindow = rootWindow;
Depth = depth;
}
示例14: GetBackColor
/// <summary>
/// Extracts and returns field back color, if specified.
/// </summary>
/// <param name="baseModel">Editable root model.</param>
/// <param name="property">Field property.</param>
/// <returns>
/// HTML color string (like "#ffffff") if field has back color.
/// Empty string if field does not have back color.
/// null if field does not support back color change.
/// </returns>
private static string GetBackColor(IEditableRoot baseModel, PropertyInfo property)
{
if (baseModel == null)
{
throw new ArgumentNullException("baseModel");
}
if (property == null)
{
throw new ArgumentNullException("property");
}
var fieldBackgoundAttr =
(FieldBackgroundAttribute)
property.GetCustomAttributes(typeof(FieldBackgroundAttribute), false)
.Select(d => d)
.FirstOrDefault();
if (fieldBackgoundAttr != null)
{
var backcolorFieldName = fieldBackgoundAttr.BackcolorFieldName;
if (string.IsNullOrEmpty(backcolorFieldName))
{
return string.Empty;
}
var bcProperty = baseModel.GetPropertyByName(backcolorFieldName);
if (bcProperty != null)
{
long longColor = 0;
try
{
longColor = (long)(bcProperty.GetValue(baseModel, null) ?? 0);
}
catch {
}
return longColor == 0 ? string.Empty : ColorTranslator.ToHtml(Color.FromArgb((int)longColor));
}
return string.Empty;
}
return null;
}
示例15: Create
public static IFieldOptions Create(PropertyInfo property, IEditableRoot editableRoot)
{
if (property == null)
{
throw new ArgumentNullException("property");
}
if (editableRoot == null)
{
throw new ArgumentNullException("editableRoot");
}
var crossRefAttr = property.GetCustomAttributes(typeof(CrossRefFieldAttribute), false).Select(d => d).FirstOrDefault() as CrossRefFieldAttribute;
if (crossRefAttr == null)
{
throw new VeyronException("CrossRef attribute not found on Cross-reference field property");
}
string valueAsText = "Unknown";
var crId = editableRoot.GetValueByPropertyName(property.Name) as int?;
if (crId.HasValue)
{
var ancestor = editableRoot.GetAncestor(property);
if (ancestor != null)
{
var crItem = DynamicTypeManager.Instance.GetCrossReferenceItem(ancestor.ProcessName, property.Name, crId.Value);
if (crItem != null)
{
valueAsText = crItem.GetValueByPropertyName(crossRefAttr.RefFieldName) == null ? "Unknown" : crItem.GetValueByPropertyName(crossRefAttr.RefFieldName).ToString();
}
}
}
var result = new SingleCrossRefFieldOptions
{
ValueAsText = valueAsText,
ProcessSystemName = crossRefAttr.ReferenceTableName,
FieldName = crossRefAttr.RefFieldName,
AllowViewDetail = crossRefAttr.AllowViewDetail,
AllowClear = crossRefAttr.AllowClear
};
return result;
}