コード例 #1
0
			public CSharpResolvedAttribute(CSharpTypeResolveContext context, CSharpAttribute unresolved)
			{
				this.context = context;
				this.unresolved = unresolved;
				// Pretty much any access to the attribute checks the type first, so
				// we don't need to use lazy-loading for that.
				this.attributeType = unresolved.AttributeType.Resolve(context);
			}
        // ValidateSet
        public static CSharpAttribute CreateValidateSetAttribute(IEnumerable <string> validValues)
        {
            if (validValues == null)
            {
                throw new ArgumentNullException(nameof(validValues));
            }

            CSharpAttribute result = new CSharpAttribute(
                nameof(PS.ValidateSetAttribute),
                validValues.Select(value => $"@\"{value}\""));

            return(result);
        }
        // DerivedType
        public static CSharpAttribute CreateDerivedTypeAttribute(string derivedTypeFullName)
        {
            if (derivedTypeFullName == null)
            {
                throw new ArgumentNullException(nameof(derivedTypeFullName));
            }

            CSharpAttribute result = new CSharpAttribute(
                nameof(DerivedTypeAttribute),
                $"\"{derivedTypeFullName}\"".SingleObjectAsEnumerable());

            return(result);
        }
        // ODataType
        public static CSharpAttribute CreateODataTypeAttribute(string oDataTypeFullName, IEnumerable <string> subTypeFullNames)
        {
            if (oDataTypeFullName == null)
            {
                throw new ArgumentNullException(nameof(oDataTypeFullName));
            }
            if (subTypeFullNames == null)
            {
                throw new ArgumentNullException(nameof(subTypeFullNames));
            }

            CSharpAttribute result = new CSharpAttribute(
                nameof(ODataTypeAttribute),
                $"\"{oDataTypeFullName}\"".SingleObjectAsEnumerable()     // the main type
                .Concat(subTypeFullNames.Select(name => $"\"{name}\""))); // subtypes

            return(result);
        }
        // EntityIdParameter
        public static CSharpAttribute CreateResourceIdParameterAttribute()
        {
            CSharpAttribute result = new CSharpAttribute(nameof(ResourceIdParameterAttribute));

            return(result);
        }
        // TypeCastParameter
        public static CSharpAttribute CreateTypeCastParameterAttribute()
        {
            CSharpAttribute result = new CSharpAttribute(nameof(TypeCastParameterAttribute));

            return(result);
        }