• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IEditableRoot类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IEditableRoot的典型用法代码示例。如果您正苦于以下问题:C# IEditableRoot类的具体用法?C# IEditableRoot怎么用?C# IEditableRoot使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IEditableRoot类属于命名空间,在下文中一共展示了IEditableRoot类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
        }
开发者ID:mparsin,项目名称:Elements,代码行数:31,代码来源:SampleFieldOptions.cs


示例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;
        }
开发者ID:mparsin,项目名称:Elements,代码行数:38,代码来源:ResultFieldOptions.cs


示例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;
        }
开发者ID:mparsin,项目名称:Elements,代码行数:34,代码来源:MultiCrossRefFieldOptions.cs


示例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;
                }
            }
        }
开发者ID:mparsin,项目名称:Elements,代码行数:33,代码来源:FieldVisibilityRule.cs


示例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;
        }
开发者ID:mparsin,项目名称:Elements,代码行数:71,代码来源:ChecklistFieldOptions.cs


示例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;
        }
开发者ID:mparsin,项目名称:Elements,代码行数:15,代码来源:SamplingTechniqueFieldOptions.cs


示例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;
        }
开发者ID:mparsin,项目名称:Elements,代码行数:56,代码来源:DetailsCommand.cs


示例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;
        }
开发者ID:mparsin,项目名称:Elements,代码行数:22,代码来源:SampleTypeFieldTypeHandler.cs


示例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;
        }
开发者ID:mparsin,项目名称:Elements,代码行数:26,代码来源:EditableRootDataContext.cs


示例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;
        }
开发者ID:mparsin,项目名称:Elements,代码行数:12,代码来源:ImageFieldTypeHandler.cs


示例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;
        }
开发者ID:mparsin,项目名称:Elements,代码行数:58,代码来源:FileFieldTypeHandler.cs


示例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));
                    }
                }
            }
        }
开发者ID:mparsin,项目名称:Elements,代码行数:64,代码来源:ChecklistHelper.cs


示例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;
        }
开发者ID:mparsin,项目名称:Elements,代码行数:27,代码来源:ProcessItemUpdatedEvent.cs


示例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;
        }
开发者ID:mparsin,项目名称:Elements,代码行数:56,代码来源:FieldInfoFactory.cs


示例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;
        }
开发者ID:mparsin,项目名称:Elements,代码行数:46,代码来源:SingleCrossRefFieldOptions.cs


示例16: Update

        /// <summary>
        /// Updates the specified source.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="destination">The destination.</param>
        public void Update(IDynamicObject source, IEditableRoot destination)
        {
            var currentState = ESyncTypeConverter.Convert<string>(_valueCalculator.GetValue(source, _field.MappingKey));

            if (currentState == null)
                return;

            var supportStates = destination as ISupportStates;

            if (supportStates == null)
                return;

            var state =
                supportStates.StateManager.States.FirstOrDefault(
                    s => string.Compare(s.Name, currentState, StringComparison.OrdinalIgnoreCase) == 0);

            if (state != null)
                supportStates.CurrentState = state.Id;
        }
开发者ID:mparsin,项目名称:Elements,代码行数:24,代码来源:CurrentStateFieldUpdater.cs


示例17: Create

        /// <summary>
        /// The create.
        /// </summary>
        /// <returns>
        /// The <see cref="SampleTypeFieldOptions"/>.
        /// </returns>
        public static SampleTypeFieldOptions Create(PropertyInfo property, IEditableRoot model)
        {
            if (property == null)
            {
                throw new ArgumentNullException("property");
            }

            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            var result = new SampleTypeFieldOptions();

            var list = (from object sampleType in Enum.GetValues(typeof(SampleTypes)) select sampleType.ToString()).ToList();
            result.PossibleValues = list;

            var trueLabelProperty = model.GetPropertyByName(property.Name + Constants.SampleTrueLabel);
            var falseLabelProperty = model.GetPropertyByName(property.Name + Constants.SampleFalseLabel);

            if (trueLabelProperty != null)
            {
                result.TrueLabel = trueLabelProperty.GetValue(model, null) as string;
                if (string.IsNullOrEmpty(result.TrueLabel))
                {
                    result.TrueLabel = LanguageService.Translate("Item_Pass");
                }
            }

            if (falseLabelProperty != null)
            {
                result.FalseLabel = falseLabelProperty.GetValue(model, null) as string;
                if (string.IsNullOrEmpty(result.FalseLabel))
                {
                    result.FalseLabel = LanguageService.Translate("Item_Fail");
                }
            }

            return result;
        }
开发者ID:mparsin,项目名称:Elements,代码行数:46,代码来源:SampleTypeFieldOptions.cs


示例18: 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;
        }
开发者ID:mparsin,项目名称:Elements,代码行数:37,代码来源:FieldInfoFactory.cs


示例19: UpdateFields

        private void UpdateFields(IDataContext dataContext, IEditableRoot item)
        {
            foreach (var fieldMapping in ChildMappings)
            {
                fieldMapping.Update(dataContext, item);

                if (fieldMapping.IsKey)
                {
                    item.KeyFields.Add(fieldMapping.FieldName);
                }
            }
        }
开发者ID:mparsin,项目名称:Elements,代码行数:12,代码来源:MultiCrossReferenceFieldMapping.cs


示例20: Update

        /// <summary>
        /// Updates the specified item.
        /// </summary>
        /// <param name="dataContext">
        /// The data context.
        /// </param>
        /// <param name="item">
        /// The destination item.
        /// </param>
        public void Update(IDataContext dataContext, IEditableRoot item)
        {
            if (item == null)
                throw new ArgumentNullException("item");

            var crList = (ICrossRefItemList)item.GetValueByPropertyName(Property.Name);
            if (crList == null)
                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Cross reference field \"{0}\" is null.", Property.Name), "item");

            try
            {
            if (ValueExpression != null)
            {
                var items = ValueExpression(dataContext) as IEnumerable;

                if (items != null)
                {
                    var enumerator = items.GetEnumerator();

                    while (enumerator.MoveNext())
                    {
                        InsertOrUpdateChildren(dataContext, crList);
                    }
                }
            }
            else
            {
                InsertOrUpdateChildren(dataContext, crList);
            }
        }
            catch (Exception ex)
            {
                var message = new StringBuilder();
                message.AppendFormat(CultureInfo.InvariantCulture, "Could not update the field \"{0}\" in process \"{1}\".", DisplayName, item.ProcessDisplayName);

                throw new InvalidOperationException(message.ToString(), ex);
            }
        }
开发者ID:mparsin,项目名称:Elements,代码行数:47,代码来源:MultiCrossReferenceFieldMapping.cs



注:本文中的IEditableRoot类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IEditor类代码示例发布时间:2022-05-24
下一篇:
C# IEdgePredicate类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap