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


C# Method.SetAttributeValue方法代码示例

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


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

示例1: CreateUserMethods

        private void CreateUserMethods(Entity userEntity, Entity loginEntity)
        {
            if (userEntity == null) throw new ArgumentNullException("userEntity");

            // LoadByUserLoginInfo
            if (loginEntity != null)
            {
                var loginsProperty = ProjectUtilities.FindByPropertyType(userEntity, PropertyType.UserLogins);
                var providerKeyProperty = ProjectUtilities.FindByPropertyType(loginEntity, PropertyType.UserLoginProviderKey);
                var providerNameProperty = ProjectUtilities.FindByPropertyType(loginEntity, PropertyType.UserLoginProviderName);
                if (loginsProperty != null && providerKeyProperty != null)
                {
                    Method loadByProviderKeyMethod = ProjectUtilities.FindByMethodType(userEntity, MethodType.LoadUserByUserLoginInfo);
                    if (loadByProviderKeyMethod == null)
                    {
                        loadByProviderKeyMethod = new Method();
                        loadByProviderKeyMethod.Name = "LoadByUserLoginInfo";
                        loadByProviderKeyMethod.SetAttributeValue("", "methodType", Constants.NamespaceUri, MethodType.LoadUserByUserLoginInfo);
                        userEntity.Methods.Add(loadByProviderKeyMethod);

                        Body body = new Body();
                        if (providerNameProperty != null)
                        {
                            body.Text = string.Format("LOADONE(string providerKey, string providerName) WHERE {0}.{1} = @providerKey AND {0}.{2} = @providerName", loginsProperty.Name, providerKeyProperty.Name, providerNameProperty.Name);
                        }
                        else
                        {
                            body.Text = string.Format("LOADONE(string providerKey) WHERE {0}.{1} = @providerKey", loginsProperty.Name, providerKeyProperty.Name);
                        }

                        loadByProviderKeyMethod.Bodies.Add(body);
                    }
                }
            }

            // LoadUserByEmail
            var emailProperty = ProjectUtilities.FindByPropertyType(userEntity, PropertyType.UserEmail);
            if (emailProperty != null && !emailProperty.IsCollectionKey)
            {
                Method loadByEmailMethod = ProjectUtilities.FindByMethodType(userEntity, MethodType.LoadUserByEmail);
                if (loadByEmailMethod == null)
                {
                    loadByEmailMethod = new Method();
                    loadByEmailMethod.Name = "LoadByEmail";
                    loadByEmailMethod.SetAttributeValue("", "methodType", Constants.NamespaceUri, MethodType.LoadUserByEmail);
                    userEntity.Methods.Add(loadByEmailMethod);

                    Body body = new Body();
                    body.Text = string.Format("LOADONE({0}) WHERE {0} = @{0}", emailProperty.Name);

                    loadByEmailMethod.Bodies.Add(body);
                }
            }
        }
开发者ID:modulexcite,项目名称:CodeFluent-Entities,代码行数:54,代码来源:ConfigurationForm.cs

示例2: CreateLoginsEntity

        private Entity CreateLoginsEntity()
        {
            Entity entity = GetOrCreateEntity(EntityType.Login, textBoxExternalLoginsEntityName.Text, comboBoxNamespace.Text);
            foreach (var typeProperty in TypeProperty.ExternalLoginProperties)
            {
                if (!MustGenerate(EntityType.Login, typeProperty))
                    continue;

                Property property = GetOrCreateProperty(entity, typeProperty);
                if (typeProperty.IdentityPropertyType == PropertyType.UserKey)
                {
                    property.IsKey = true;
                }
            }


            Method deleteMethod = ProjectUtilities.FindByMethodType(entity, MethodType.DeleteClaim);
            if (deleteMethod == null)
            {
                deleteMethod = new Method();
                deleteMethod.Name = "DeleteByUserAndProviderKey";
                deleteMethod.SetAttributeValue("", "methodType", Constants.NamespaceUri, MethodType.DeleteLogin);
                entity.Methods.Add(deleteMethod);

                Body body = new Body();
                string userPropertyName = ProjectUtilities.FindByPropertyType(entity, PropertyType.User).Name;
                string providerKeyPropertyName = ProjectUtilities.FindByPropertyType(entity, PropertyType.LoginProviderKey).Name;
                body.Text = string.Format("DELETE({0}, {1}) WHERE {0} = @{0} AND {1} = @{1}", userPropertyName, providerKeyPropertyName);

                deleteMethod.Bodies.Add(body);
            }


            return entity;
        }
开发者ID:askitanna,项目名称:CodeFluent-Entities,代码行数:35,代码来源:ConfigurationForm.cs


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