本文整理汇总了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);
}
}
}
示例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;
}