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


C# IEditableRoot.GetType方法代码示例

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


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

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

示例2: Execute

        /// <summary>
        /// Executes the specified item.
        /// </summary>
        /// <param name="item">The target item.</param>
        /// <param name="oldItem">The old item.</param>
        public override void Execute(IEditableRoot item, IEditableRoot oldItem)
        {
            if (item == null)
                throw new ArgumentNullException("item");

            var approval = item.ReadValueByPropertyName<IApprovalEdit>(ApprovalFieldName);

            if (approval == null)
                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Approval field \"{0}\" not found in item \"{1}\" or you don't have access. Action will not run.", ApprovalFieldName, item.GetType()), "item");

            var membersFound = new HashSet<int>();

            foreach (var member in approval.MemberResults.Where(am => am.ApprovalLevel == approval.CurrentLevel))
            {
                if (member.GetApprovalMemberResult() != ApprovalMemberResults.Undecided)
                    continue;

                if (!member.Person.HasValue || !member.OriginalApprover.HasValue || membersFound.Contains(member.OriginalApprover.Value))
                    continue;

                membersFound.Add(member.OriginalApprover.Value);

                var person = PersonManager.GetPerson(member.Person.Value);
                if (person == null)
                    continue;

                var basePersonId = member.OriginalApprover.Value;
                var actionItem = DynamicTypeManager.NewActionItem();
                actionItem.ActionGuid = Guid.ToString();
                actionItem.Process = item.ProcessName;
                actionItem.PersonId = person.Id;
                actionItem.BasePersonId = basePersonId;
                actionItem.ItemId = item.Id;
                actionItem.IsActionNew = true;

                var supportStates = item as ISupportStates;
                if (supportStates != null)
                    actionItem.ItemStateId = supportStates.CurrentState;

                actionItem.Save();
                CommunicationService.NotifyActionsChanged(person.Id);

                if (SendEmail && !string.IsNullOrWhiteSpace(person.Email))
                {
                    SendMessage(item, person);
                }
            }

            if (SendEmail && !string.IsNullOrWhiteSpace(EmailFieldName))
            {
                var email = item.ReadValueByPropertyName<string>(EmailFieldName);

                if (!string.IsNullOrWhiteSpace(email))
                {
                    SendMessage(item, email);
                }
            }

            base.Execute(item, oldItem);
        }
开发者ID:mparsin,项目名称:Elements,代码行数:65,代码来源:ApprovalActionDefinition.cs

示例3: IsTabbedUI

 private static bool IsTabbedUI(IEditableRoot editableRoot)
 {
     var tabbedUiAttribute =
         editableRoot.GetType()
             .GetCustomAttributes(typeof(TabbedUIAttribute), false)
             .OfType<TabbedUIAttribute>()
             .FirstOrDefault();
     return tabbedUiAttribute != null && tabbedUiAttribute.IsTabbedUI;
 }
开发者ID:mparsin,项目名称:Elements,代码行数:9,代码来源:DetailsCommand.cs

示例4: GetValue

 private static object GetValue(PropertyInfo prop, IEditableRoot editableRoot)
 {
     if (editableRoot == null) throw new ArgumentNullException("editableRoot");
     if (editableRoot.GetType().GetProperty(prop.Name) != null)
         return prop.GetValue(editableRoot);
     return GetValue(prop, editableRoot.GetBaseEdit());
 }
开发者ID:mparsin,项目名称:Elements,代码行数:7,代码来源:DetailsCommand.cs

示例5: GetChartDescriptor

        private static ChartPanel GetChartDescriptor(IEditableRoot instance, string exprFieldName, string spcFieldName, ChartTypesEnum chartType, int subgroupSize, int dataPoints = 0)
        {
            ChartPanel chartDescriptor = null;

            MobileDictionary<string, ChartPanel> dict = null;
            if (!exprFieldName.Contains("_Rule"))
            {
                dict = instance.GetValueByPropertyName("ChartDescriptorExp") as MobileDictionary<string, ChartPanel>;
                if (dict != null)
                    dict.TryGetValue(string.Format("{0}{1}", exprFieldName, spcFieldName), out chartDescriptor);
                else
                    dict = new MobileDictionary<string, ChartPanel>();
            }

            if (chartDescriptor == null)
            {
                chartDescriptor = SpcManager.CreateChartDescriptor(chartType);
                chartDescriptor.DataPoints = dataPoints;
                chartDescriptor.SubgroupSize = subgroupSize;

                chartDescriptor = MethodCaller.CallFactoryMethod(instance.GetType(), "GetSampleDataForSPC", spcFieldName, instance, chartType, chartDescriptor, true) as ChartPanel;

                if (!exprFieldName.Contains("_Rule"))
                {
                    ChartPanel chartPanel;
                    if (dict.TryGetValue(string.Format("{0}{1}", exprFieldName, spcFieldName), out chartPanel))
                        dict[string.Format("{0}{1}", exprFieldName, spcFieldName)] = chartDescriptor;
                    else
                        dict.Add(string.Format("{0}{1}", exprFieldName, spcFieldName), chartDescriptor);

                    instance.LoadValueByPropertyName("ChartDescriptorExp", dict);
                }
            }
            else
            {
                chartDescriptor.DataPoints = dataPoints;
                chartDescriptor.SubgroupSize = subgroupSize;

                chartDescriptor = MethodCaller.CallFactoryMethod(instance.GetType(), "GetSampleDataForSPC", spcFieldName, instance, chartType, chartDescriptor, true) as ChartPanel;
            }

            return chartDescriptor;
        }        
开发者ID:mparsin,项目名称:Elements,代码行数:43,代码来源:SpcExpressionHelperModule.cs

示例6: GetChartDescriptorAsync

        private static Task<ChartPanel> GetChartDescriptorAsync(IEditableRoot instance, string exprFieldName, string spcFieldName, ChartTypesEnum chartType, int subgroupSize, int dataPoints = 0)
        {
            ChartPanel chartDescriptor = null;

            var dict = instance.GetValueByPropertyName("ChartDescriptorExp") as MobileDictionary<string, ChartPanel>;
            if (dict != null)
                dict.TryGetValue(string.Format("{0}{1}", exprFieldName, spcFieldName), out chartDescriptor);
            else
                dict = new MobileDictionary<string, ChartPanel>();

            if (chartDescriptor == null)
            {
                return SpcManager.CreateChartDescriptorAsync(chartType)
                    .ContinueWith(async task =>
                    {
                        if (task.Result != null)
                        {
                            chartDescriptor = task.Result;
                            chartDescriptor.DataPoints = dataPoints;
                            chartDescriptor.SubgroupSize = subgroupSize;

                            var getDataTask = MethodCaller.CallFactoryMethod(
                                instance.GetType(), "GetSampleDataForSPCAsync", instance, spcFieldName, chartType, chartDescriptor, true) as Task<ChartPanel>;
                            chartDescriptor = await getDataTask;

                            ChartPanel chartPanel;
                            if (dict.TryGetValue(string.Format("{0}{1}", exprFieldName, spcFieldName), out chartPanel))
                                dict[string.Format("{0}{1}", exprFieldName, spcFieldName)] = chartDescriptor;
                            else
                                dict.Add(string.Format("{0}{1}", exprFieldName, spcFieldName), chartDescriptor);

                            instance.LoadValueByPropertyName("ChartDescriptorExp", dict);

                            return chartDescriptor;
                        }

                        return task.Result;
                    }
                    , CancellationToken.None, TaskContinuationOptions.NotOnFaulted, TaskScheduler.FromCurrentSynchronizationContext()).Unwrap();
            }

            chartDescriptor.DataPoints = dataPoints;
            chartDescriptor.SubgroupSize = subgroupSize;

            var getSamplesTask = MethodCaller.CallFactoryMethod(
                instance.GetType(), "GetSampleDataForSPCAsync", instance, spcFieldName, chartType, chartDescriptor, true) as Task<ChartPanel>;
            return getSamplesTask;
        }
开发者ID:mparsin,项目名称:Elements,代码行数:48,代码来源:SpcExpressionHelperModule.cs

示例7: SetCurrentState

        /// <summary>
        /// Sets the current state.
        /// </summary>
        /// <param name="item">The editable root.</param>
        /// <param name="stateGuid">The state unique identifier.</param>
        public static void SetCurrentState(IEditableRoot item, Guid stateGuid)
        {
            using (new ThreadLocalBypassPropertyCheckContext())
            {
                if (stateGuid.Equals(Guid.Empty))
                    return;

                var supportStates = item as ISupportStates;
                if (supportStates == null)
                    return;

                var stateToSet = supportStates.StateManager.States.FirstOrDefault(s => s.Guid.Equals(stateGuid));
                if (stateToSet != null)
                    item.GetType().GetProperty(Constants.CurrentStateColumnName).SetValue(item, stateToSet.Id, null);
            }
        }
开发者ID:mparsin,项目名称:Elements,代码行数:21,代码来源:ChecklistHelper.cs

示例8: GetFields

        private static List<FieldInfo> GetFields(IEditableRoot editableRoot, ICollection<string> visibleFields, IList<FieldVisibilityRule> visibilityRules = null)
        {
            var props =
                editableRoot.GetType()
                            .GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.FlattenHierarchy);

            var fields = new List<FieldInfo>();

            var baseEdit = props.FirstOrDefault(p => p.Name == Constants.BaseEditPropertyName);
            if (baseEdit != null && baseEdit.DeclaringType != null)
            {
                var baseEditValue = baseEdit.DeclaringType.InvokeMember(Constants.BaseEditPropertyName, BindingFlags.GetProperty, null, editableRoot, null);

                if (baseEditValue != null)
                    fields.AddRange(GetFields((IEditableRoot)baseEditValue, visibleFields, visibilityRules));
            }

            foreach (var prop in props)
            {
                if (prop == baseEdit)
                    continue;

                if (!visibleFields.Contains(prop.Name))
                    continue;

                var field = new FieldInfo();//TheFieldFactory.Value.CreateField(prop, _detailsModel, model, this);
                field.Model = editableRoot;
                field.SystemName = prop.Name;
                var commonAttr = prop.GetCustomAttributes(typeof(CommonSettingsAttribute), false).FirstOrDefault() as CommonSettingsAttribute;
                field.Name = commonAttr.Name;

                var fieldEditorAttr =
                    prop.GetCustomAttributes(typeof (FieldEditorAttribute), false).FirstOrDefault() as
                    FieldEditorAttribute;
                if (fieldEditorAttr != null)
                    field.FieldEditor = fieldEditorAttr.DataType;
                
                fields.Add(field);
            }

            return fields;
        }
开发者ID:mparsin,项目名称:Elements,代码行数:42,代码来源:ActionController.cs

示例9: GetExpression

        /// <summary>
        /// Extracts and returns field Default or Calculated expression, if specified. 
        /// </summary>
        /// <param name="baseModel">Editable root model.</param>
        /// <param name="property">Field property.</param>
        /// <returns>
        /// Expression definition in JSON format.
        /// </returns>
        private static string GetExpression(IEditableRoot baseModel, PropertyInfo property)
        {
            if (baseModel == null)
            {
                throw new ArgumentNullException("baseModel");
            }

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

            var expressionFieldName = property.Name + "ExpressionXml";

            var expressionProperty = baseModel.GetType().GetField(expressionFieldName);
            if (expressionProperty != null)
            {
                var expressionXml = (string) expressionProperty.GetRawConstantValue();

                var expressionService = new ExpressionServiceBase();
                Ioc.SatisfyImportsOnce(expressionService);

                var expressionSerializer = expressionService.ExpressionsSerializer;
                var expressionContainer = expressionSerializer.Deserialize(expressionXml);

                var expressionNodeFactory = expressionService.ExpressionNodeFactory;
                var destinationNode = expressionNodeFactory.CreateExpressionNodes(expressionContainer.Expressions);

                var expressionTranslator = new ExpressionsTranslator();

                var expression = expressionTranslator.ConvertNodeToExpression(destinationNode);
                expression.Source = new ExpressionSource
                {
                    Out =
                        expressionService.GetExpressionSourceFieldsList(expressionXml, true)
                            .Select(
                                f => new ExpressionSourcePoint {Key = f.SystemName, DataType = f.DataType.ToString()})
                };

                var jsonSerializerSettings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() };
                return JsonConvert.SerializeObject(expression, Formatting.Indented, jsonSerializerSettings);
            }

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


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