当前位置: 首页>>代码示例>>C#>>正文


C# IEditableRoot.GetPropertyByName方法代码示例

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


在下文中一共展示了IEditableRoot.GetPropertyByName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: GetApprovalFieldManager

        private static IApprovalFieldManager GetApprovalFieldManager(IEditableRoot item, string approvalFieldName)
        {
            var approvalProperty = item.GetPropertyByName(approvalFieldName);
            if (approvalProperty == null)
            {
                throw new ArgumentOutOfRangeException(
                    "approvalFieldName",
                    string.Format(CultureInfo.InvariantCulture, "Could not find the field '{0}' in process '{1}'.", approvalFieldName, item.ProcessName));
            }

            var declaringType = approvalProperty.DeclaringType;
            if (declaringType == null)
            {
                throw new ArgumentException("Declaring type is null.");
            }

            var approvalManagerPropertyName = string.Format(CultureInfo.InvariantCulture, "{0}Manager", approvalProperty.Name);
            var approvalManagerProperty = declaringType.GetProperty(approvalManagerPropertyName, BindingFlags.Public | BindingFlags.Static);

            if (approvalManagerProperty == null)
            {
                throw new ArgumentException(
                    string.Format(
                        CultureInfo.InvariantCulture,
                        "Could not find the property '{0}' in type '{1}'.",
                        approvalManagerPropertyName,
                        declaringType.FullName));
            }

            return approvalManagerProperty.GetValue(null, null) as IApprovalFieldManager;
        }
开发者ID:mparsin,项目名称:Elements,代码行数:31,代码来源:ApprovalManager.cs

示例5: 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>
        public 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) || baseModel == null)
                {
                    return string.Empty;
                }

                var bcProperty = baseModel.GetPropertyByName(backcolorFieldName);
                if (bcProperty != null)
                {
                    var longColor = (long)(bcProperty.GetValue(baseModel, null) ?? 0);
                    return longColor == 0 ? string.Empty : ColorTranslator.ToHtml(Color.FromArgb((int)longColor));
                }

                return string.Empty;
            }

            return null;
        }
开发者ID:mparsin,项目名称:Elements,代码行数:45,代码来源:FieldReadModel.cs

示例6: IsCalculated

 private bool IsCalculated(IEditableRoot obj)
 {
     return obj.GetPropertyByName(PrimaryProperty.Name).GetCustomAttributes(typeof(CalculatedAttribute), false).Any();
 }
开发者ID:mparsin,项目名称:Elements,代码行数:4,代码来源:RequiredFieldRule.cs

示例7: IsRichText

 /// <summary>
 /// Determines whether [is rich text] [the specified object].
 /// </summary>
 /// <param name="obj">The object.</param>
 /// <returns><c>true</c> if [is rich text] [the specified object]; otherwise, <c>false</c>.</returns>
 private bool IsRichText(IEditableRoot obj)
 {
     return obj.GetPropertyByName(PrimaryProperty.Name).GetCustomAttributes(typeof(RichTextAttribute), false).Any();
 }
开发者ID:mparsin,项目名称:Elements,代码行数:9,代码来源:RequiredFieldRule.cs


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