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


C# PropertyAccess类代码示例

本文整理汇总了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");
        }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:16,代码来源:PropertyAccessTranslator.cs

示例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;
        }
开发者ID:garuma,项目名称:dbus-explorer,代码行数:19,代码来源:ElementFactory.cs

示例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;
        }
开发者ID:mgagne-atman,项目名称:Projects,代码行数:43,代码来源:NamingHelper.cs

示例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;
		}
开发者ID:Ravenwolfe,项目名称:ServUO,代码行数:91,代码来源:Properties.cs

示例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)
		{
		}
开发者ID:nlhepler,项目名称:mono,代码行数:3,代码来源:PropertySetAccessRule.cs

示例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;
        }
开发者ID:mgagne-atman,项目名称:Projects,代码行数:13,代码来源:CodeGenerationHelper.cs

示例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);
        }
开发者ID:mgagne-atman,项目名称:Projects,代码行数:24,代码来源:CodeGenerationHelper.cs

示例8: Parse

		public static Property Parse( Type type, string binding, PropertyAccess access )
		{
			Property prop = new Property( binding );

			prop.BindTo( type, access );

			return prop;
		}
开发者ID:greeduomacro,项目名称:unknown-shard-1,代码行数:8,代码来源:Properties.cs

示例9: GetPrivateMemberFieldOfCompositeClass

 private CodeMemberField GetPrivateMemberFieldOfCompositeClass(CodeTypeDeclaration compositeClass, PropertyAccess access)
 {
     return GetMemberField(compositeClass.Name, compositeClass.Name, Accessor.Private, access);
 }
开发者ID:mgagne-atman,项目名称:Projects,代码行数:4,代码来源:CodeGenerationHelper.cs

示例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");
			}
		}
开发者ID:sheefa,项目名称:Castle.ActiveRecord,代码行数:39,代码来源:PropertyAccess.cs

示例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 );
		}
开发者ID:greeduomacro,项目名称:unknown-shard-1,代码行数:9,代码来源:Properties.cs

示例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)
 {
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:3,代码来源:PropertyAccessRule.cs

示例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;
                }
            }
开发者ID:thebug,项目名称:SuperXml,代码行数:49,代码来源:Compiler.cs

示例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)
 {
 }
开发者ID:chcosta,项目名称:corefx,代码行数:16,代码来源:ActiveDirectorySecurity.cs

示例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;
        }
开发者ID:chcosta,项目名称:corefx,代码行数:34,代码来源:ActiveDirectorySecurity.cs


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