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


C# DefinitionBase.GetType方法代码示例

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


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

示例1: DeployModel

        public override void DeployModel(object modelHost, DefinitionBase model)
        {
            var props = model.GetType()
                             .GetProperties()
                             .Where(p => p.GetCustomAttributes(typeof(ExpectRequired), true).Any());

            var requiredPropsGroups = props
                             .GroupBy(g => (g.GetCustomAttributes(typeof(ExpectRequired), true).First() as ExpectRequired).GroupName);

            foreach (var group in requiredPropsGroups)
            {
                // all set is requred
                if (string.IsNullOrEmpty(group.Key))
                {
                    var isAllValid = AllOfThem(model, group.ToList());

                    if (!isAllValid)
                        throw new Exception("Not all of them");
                }
                else
                {
                    // skip 'Web part content' for typed web part definitions
                    //  a big todo

                    if (group.Key == "Web part content" && (model.GetType() != typeof(WebPartDefinition)))
                        continue;

                    var oneOfThem = OneOfThem(model, group.ToList());

                    if (!oneOfThem)
                        throw new Exception("Not one of them");
                }
            }
        }
开发者ID:Uolifry,项目名称:spmeta2,代码行数:34,代码来源:DefaultRequiredPropertiesValidationService.cs

示例2: DeployModel

        public override void DeployModel(object modelHost, DefinitionBase model)
        {
            //var aggregateException = new c();
            var exceptions = new List<SPMeta2ModelValidationException>();

            var props = ReflectionUtils.GetPropertiesWithCustomAttribute<ExpectRequired>(model, true);

            var requiredPropsGroups = props
                             .GroupBy(g => (g.GetCustomAttributes(typeof(ExpectRequired), true).First() as ExpectRequired).GroupName);

            foreach (var group in requiredPropsGroups)
            {
                // all set is requred
                if (string.IsNullOrEmpty(group.Key))
                {
                    var isAllValid = AllOfThem(model, group.ToList());

                    if (isAllValid.Count > 0)
                    {
                        exceptions.AddRange(isAllValid);
                    }
                }
                else
                {
                    // skip 'Web part content' for typed web part definitions
                    //  a big todo

                    if (group.Key == "Web part content" && (model.GetType() != typeof(WebPartDefinition)))
                        continue;

                    var oneOfThem = OneOfThem(model, group.ToList());

                    if (!oneOfThem)
                    {
                        var ex = new SPMeta2ModelValidationException(
                            string.Format("One of the properties with [{0}] attribute should be set. Definition:[{1}]",
                            group.Key, model))
                        {
                            Definition = model
                        };

                        exceptions.Add(ex);
                    }
                }
            }

            if (exceptions.Count > 0)
            {
                throw new SPMeta2AggregateException("Required properties validation error", 
                    exceptions.OfType<Exception>());
            }
        }
开发者ID:karayakar,项目名称:spmeta2,代码行数:52,代码来源:DefaultRequiredPropertiesModelHandler.cs

示例3: GetDefinitionIdentityKey

        public string GetDefinitionIdentityKey(DefinitionBase def)
        {
            var result = string.Empty;

            var definitionType = def.GetType();

            var isSingleIdenity = definitionType.GetCustomAttributes(typeof(SingletonIdentityAttribute), true).Any();
            var isInstanceIdentity = !definitionType.GetCustomAttributes(typeof(SingletonIdentityAttribute), true).Any();

            if (isSingleIdenity)
            {
                throw new SPMeta2ReverseException("isSingleIdenity is true. Was not implemented yet");
            }

            if (isInstanceIdentity)
            {
                var props = definitionType.GetProperties();

                var identityKeyNames = props
                    .Where(p => p.GetCustomAttributes(typeof(IdentityKeyAttribute), true).Any())
                    .Select(p => p.Name)
                    .OrderBy(s => s)
                    .ToList();

                // url gets transformed by SharePoint to the full one
                // so that lookup by identity won't work
                // rely only on title for the time being
                if (def is NavigationNodeDefinitionBase)
                {
                    identityKeyNames.Remove("Url");
                }

                // skipping list view URLs fro the tiime being
                if (def is ListViewDefinition)
                {
                    identityKeyNames.Remove("Url");
                }

                foreach (var keyName in identityKeyNames)
                {
                    var prop = props.FirstOrDefault(p => p.Name == keyName);
                    var keyValue = ConvertUtils.ToString(prop.GetValue(def, null));

                    result += keyValue;
                }

            }

            return result;
        }
开发者ID:SubPointSolutions,项目名称:spmeta2-reverse,代码行数:50,代码来源:ReverseModelIdentityService.cs


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