本文整理汇总了C#中PropertyAccess类的典型用法代码示例。如果您正苦于以下问题:C# PropertyAccess类的具体用法?C# PropertyAccess怎么用?C# PropertyAccess使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PropertyAccess类属于命名空间,在下文中一共展示了PropertyAccess类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AccessMaskFromPropertyAccess
internal static int AccessMaskFromPropertyAccess(PropertyAccess access)
{
if ((access < PropertyAccess.Read) || (access > PropertyAccess.Write))
{
throw new InvalidEnumArgumentException("access", (int) access, typeof(PropertyAccess));
}
switch (access)
{
case PropertyAccess.Read:
return ActiveDirectoryRightsTranslator.AccessMaskFromRights(ActiveDirectoryRights.ReadProperty);
case PropertyAccess.Write:
return ActiveDirectoryRightsTranslator.AccessMaskFromRights(ActiveDirectoryRights.WriteProperty);
}
throw new ArgumentException("access");
}
示例2: FromPropertyDefinition
public IElement FromPropertyDefinition(string name, string type, PropertyAccess access)
{
string spec = Concat (access.ToString().ToLowerInvariant(),
" property ", name, " : ", type);
Dictionary<string, LangProcesser> temp = new Dictionary<string,LangProcesser>();
foreach (KeyValuePair<ILangDefinition, IParserVisitor<string>> visitor in visitors) {
temp.Add(visitor.Key.Name, delegate {
string realType = Parser.ParseDBusTypeExpression(type, visitor.Value);
return visitor.Key.PropertyFormat(name, realType, access);
});
}
Element elem = new Element (name, new ElementRepresentation (spec, temp), propertyPb, 3);
elem.Data = new InvocationData (type, Enumerable.Empty<Argument> (), true);
elem.Data.PropertyAcces = access;
return elem;
}
示例3: GetName
public static string GetName(string name, PropertyAccess access, FieldCase fieldCase)
{
switch (access)
{
case PropertyAccess.Property:
switch (fieldCase)
{
case FieldCase.Unchanged:
return name;
case FieldCase.Camelcase:
return MakeCamel(name);
case FieldCase.CamelcaseUnderscore:
return "_" + MakeCamel(name);
case FieldCase.CamelcaseMUnderscore:
return "m_" + MakeCamel(name);
case FieldCase.Pascalcase:
return MakePascal(name);
case FieldCase.PascalcaseUnderscore:
return "_" + MakePascal(name);
case FieldCase.PascalcaseMUnderscore:
return "m_" + MakePascal(name);
}
break;
case PropertyAccess.Field:
return name;
case PropertyAccess.FieldCamelcase:
case PropertyAccess.NosetterCamelcase:
return MakeCamel(name);
case PropertyAccess.FieldCamelcaseUnderscore:
case PropertyAccess.NosetterCamelcaseUnderscore:
return "_" + MakeCamel(name);
case PropertyAccess.FieldPascalcaseMUnderscore:
case PropertyAccess.NosetterPascalcaseMUnderscore:
return "m_" + MakePascal(name);
case PropertyAccess.FieldLowercaseUnderscore:
case PropertyAccess.NosetterLowercaseUnderscore:
return "_" + name.ToLowerInvariant();
case PropertyAccess.NosetterLowercase:
return name.ToLowerInvariant();
}
return name;
}
示例4: GetPropertyInfoChain
public static PropertyInfo[] GetPropertyInfoChain(
Mobile m, Type type, string propertyString, PropertyAccess endAccess, ref string failReason)
{
var split = propertyString.Split('.');
if (split.Length == 0)
{
return null;
}
var info = new PropertyInfo[split.Length];
for (int i = 0; i < info.Length; ++i)
{
string propertyName = split[i];
if (CIEqual(propertyName, "current"))
{
continue;
}
var props = type.GetProperties(BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public);
bool isFinal = i == info.Length - 1;
PropertyAccess access = endAccess;
if (!isFinal)
{
access |= PropertyAccess.Read;
}
foreach (PropertyInfo p in props)
{
if (!CIEqual(p.Name, propertyName))
{
continue;
}
CPA attr = GetCPA(p);
if (attr == null)
{
failReason = String.Format("Property '{0}' not found.", propertyName);
return null;
}
if ((access & PropertyAccess.Read) != 0 && m.AccessLevel < attr.ReadLevel)
{
failReason = String.Format(
"You must be at least {0} to get the property '{1}'.", Mobile.GetAccessLevelName(attr.ReadLevel), propertyName);
return null;
}
if ((access & PropertyAccess.Write) != 0 && m.AccessLevel < attr.WriteLevel)
{
failReason = String.Format(
"You must be at least {0} to set the property '{1}'.", Mobile.GetAccessLevelName(attr.WriteLevel), propertyName);
return null;
}
if ((access & PropertyAccess.Read) != 0 && !p.CanRead)
{
failReason = String.Format("Property '{0}' is write only.", propertyName);
return null;
}
if ((access & PropertyAccess.Write) != 0 && (!p.CanWrite || attr.ReadOnly) && isFinal)
{
failReason = String.Format("Property '{0}' is read only.", propertyName);
return null;
}
info[i] = p;
type = p.PropertyType;
break;
}
if (info[i] != null)
{
continue;
}
failReason = String.Format("Property '{0}' not found.", propertyName);
return null;
}
return info;
}
示例5: PropertySetAccessRule
public PropertySetAccessRule (IdentityReference identity, AccessControlType type, PropertyAccess access, Guid propertySetType, ActiveDirectorySecurityInheritance inheritanceType, Guid inheritedObjectType) : base(identity, (int)AccessControlType.Allow, type, propertySetType, false, InheritanceFlags.None, PropagationFlags.None, inheritedObjectType)
{
}
示例6: GetGenericMemberField
private CodeMemberField GetGenericMemberField(string typeName, string name, string fieldType, Accessor accessor, PropertyAccess access)
{
CodeMemberField memberField = GetMemberFieldWithoutType(name, accessor, access);
CodeTypeReference type = new CodeTypeReference(fieldType);
if (!TypeHelper.ContainsGenericDecleration(fieldType, _language))
{
type.TypeArguments.Add(typeName);
}
memberField.Type = type;
return memberField;
}
示例7: AddInternalWatchedListProperty
private void AddInternalWatchedListProperty(CodeTypeDeclaration typeDeclaration, CodeTypeReference propertyTypeReference, string propertyName, string fieldName, bool implementPropertyChanged, bool implementPropertyChanging, PropertyAccess propertyAccess)
{
CodeMemberProperty property = new CodeMemberProperty();
property.Name = propertyName + "Internal";
property.Type = propertyTypeReference;
var list = new CodePropertyReferenceExpression(new CodeFieldReferenceExpression(null, fieldName), "List");
property.GetStatements.Add(new CodeMethodReturnStatement(list));
// If the user specifies that they access the data through the property, then we
// would want the change events to fire as if the property was being set. If the
// field is being accessed directly, we want to avoid the change events.
if (implementPropertyChanging && propertyAccess == PropertyAccess.Property)
property.SetStatements.Add(new CodeMethodInvokeExpression(null, Context.Model.PropertyChangingMethodName, new CodePrimitiveExpression(propertyName)));
property.SetStatements.Add(new CodeAssignStatement(list, new CodeArgumentReferenceExpression("value")));
if (implementPropertyChanged && propertyAccess == PropertyAccess.Property)
property.SetStatements.Add(new CodeMethodInvokeExpression(null, Context.Model.PropertyChangedMethodName, new CodePrimitiveExpression(propertyName)));
typeDeclaration.Members.Add(property);
}
示例8: Parse
public static Property Parse( Type type, string binding, PropertyAccess access )
{
Property prop = new Property( binding );
prop.BindTo( type, access );
return prop;
}
示例9: GetPrivateMemberFieldOfCompositeClass
private CodeMemberField GetPrivateMemberFieldOfCompositeClass(CodeTypeDeclaration compositeClass, PropertyAccess access)
{
return GetMemberField(compositeClass.Name, compositeClass.Name, Accessor.Private, access);
}
示例10: ToString
/// <summary>
/// Convert <param name="access"/> to its NHibernate string
/// </summary>
public static string ToString(PropertyAccess access)
{
switch (access)
{
case PropertyAccess.Property:
return "property";
case PropertyAccess.Field:
return "field";
case PropertyAccess.AutomaticProperty:
return "backfield";
case PropertyAccess.ReadOnly:
return "readonly";
case PropertyAccess.FieldCamelcase:
return "field.camelcase";
case PropertyAccess.FieldCamelcaseUnderscore:
return "field.camelcase-underscore";
case PropertyAccess.FieldPascalcaseMUnderscore:
return "field.pascalcase-m-underscore";
case PropertyAccess.FieldLowercaseUnderscore:
return "field.lowercase-underscore";
case PropertyAccess.NosetterCamelcase:
return "nosetter.camelcase";
case PropertyAccess.NosetterCamelcaseUnderscore:
return "nosetter.camelcase-underscore";
case PropertyAccess.NosetterPascalcaseMUndersc:
return "nosetter.pascalcase-m-underscore";
case PropertyAccess.NosetterPascalcaseUnderscore:
return "nosetter.pascalcase-underscore";
case PropertyAccess.NosetterLowercaseUnderscore:
return "nosetter.lowercase-underscore";
case PropertyAccess.NosetterLowercase:
return "nosetter.lowercase";
default:
throw new InvalidOperationException("Invalid value for PropertyAccess");
}
}
示例11: GetPropertyInfo
public static PropertyInfo GetPropertyInfo( Mobile from, ref object obj, string propertyName, PropertyAccess access, ref string failReason )
{
PropertyInfo[] chain = GetPropertyInfoChain( from, obj.GetType(), propertyName, access, ref failReason );
if ( chain == null )
return null;
return GetPropertyInfo( ref obj, chain, ref failReason );
}
示例12: PropertyAccessRule
public PropertyAccessRule(IdentityReference identity, AccessControlType type, PropertyAccess access, Guid propertyType, ActiveDirectorySecurityInheritance inheritanceType, Guid inheritedObjectType) : base(identity, PropertyAccessTranslator.AccessMaskFromPropertyAccess(access), type, propertyType, false, ActiveDirectoryInheritanceTranslator.GetInheritanceFlags(inheritanceType), ActiveDirectoryInheritanceTranslator.GetPropagationFlags(inheritanceType), inheritedObjectType)
{
}
示例13: GetValueFromScope
public dynamic GetValueFromScope(string propertyName, string format = null)
{
try
{
var keys = propertyName.Split('.');
var digTo = keys.Count(x => x == "$parent");
var d = 0;
var p = this;
while (digTo > 0 && digTo + 1 > d)
{
p = p.Parent;
d += p.Scope != null ? 1 : 0;
}
if (digTo > 0) keys = keys.Where(x => x != "$parent").ToArray();
var property = new PropertyAccess(keys[0]);
var scope = p.Scope;
var parent = this;
while (scope == null || !scope.ContainsKey(property.Name))
{
parent = parent.Parent;
scope = parent.Scope;
}
var obj = scope[property.Name];
var level = 1;
while (level < keys.Length)
{
obj = property.GetValue(obj);
property = new PropertyAccess(keys[level]);
var t = obj.GetType();
obj = t == typeof(Dictionary<string, dynamic>) || t.IsArray
? obj[property.Name]
: t.GetProperty(property.Name).GetValue(obj, null);
level++;
}
if (string.IsNullOrWhiteSpace(format))
return property.GetValue(obj);
return property.GetValue(obj).ToString(format);
}
catch (Exception)
{
Trace.WriteLine(propertyName + " not found. default value returned = false");
return false;
}
}
示例14: PropertyAccessRule
public PropertyAccessRule(
IdentityReference identity,
AccessControlType type,
PropertyAccess access,
ActiveDirectorySecurityInheritance inheritanceType)
: base(
identity,
(int)PropertyAccessTranslator.AccessMaskFromPropertyAccess(access),
type,
Guid.Empty, // all properties
false,
ActiveDirectoryInheritanceTranslator.GetInheritanceFlags(inheritanceType),
ActiveDirectoryInheritanceTranslator.GetPropagationFlags(inheritanceType),
Guid.Empty)
{
}
示例15: AccessMaskFromPropertyAccess
internal static int AccessMaskFromPropertyAccess(PropertyAccess access)
{
int accessMask = 0;
if (access < PropertyAccess.Read || access > PropertyAccess.Write)
{
throw new InvalidEnumArgumentException("access", (int)access, typeof(PropertyAccess));
}
switch (access)
{
case PropertyAccess.Read:
{
accessMask = ActiveDirectoryRightsTranslator.AccessMaskFromRights(ActiveDirectoryRights.ReadProperty);
break;
}
case PropertyAccess.Write:
{
accessMask = ActiveDirectoryRightsTranslator.AccessMaskFromRights(ActiveDirectoryRights.WriteProperty);
break;
}
default:
//
// This should not happen. Indicates a problem with the
// internal logic.
//
Debug.Fail("Invalid PropertyAccess value");
throw new ArgumentException("access");
}
return accessMask;
}