Esempio n. 1
0
        /// <summary>
        /// Returns true if the specified JSON property is a property annotation for the specified property.
        /// </summary>
        /// <param name="jsonProperty">The JSON property to test.</param>
        /// <param name="propertyName">The property name for which annotation to test for.</param>
        /// <returns>true if <paramref name="jsonProperty"/> is a property annotation for a property with name <paramref name="propertyName"/>.</returns>
        public static bool IsPropertyAnnotation(this JsonProperty jsonProperty, string propertyName)
        {
            ExceptionUtilities.CheckObjectNotNull(jsonProperty, "jsonProperty can't be null.");
            ExceptionUtilities.CheckStringNotNullOrEmpty(propertyName, "Property name must be a valid EDM name.");

            return(jsonProperty.Name.StartsWith(propertyName + JsonLightConstants.ODataPropertyAnnotationSeparator));
        }
Esempio n. 2
0
        /// <summary>
        /// Determine if a property is an annotation property with the specified name.
        /// </summary>
        /// <param name="jsonProperty">The JSON property to inspect.</param>
        /// <param name="annotationName">The name of the annotation to look for.</param>
        /// <returns>true if the property is an annotation of the specified name, or it's a property annotation
        /// with the specified annotation name.</returns>
        public static bool IsAnnotationWithName(this JsonProperty jsonProperty, string annotationName)
        {
            ExceptionUtilities.CheckObjectNotNull(jsonProperty, "jsonProperty can't be null.");
            ExceptionUtilities.CheckStringNotNullOrEmpty(annotationName, "Annotation name must be a valid name.");

            string propertyName = jsonProperty.Name;

            if (propertyName == annotationName)
            {
                // It's an object level annotation with the specified name.
                return(true);
            }

            int propertyAnnotationNameIndex = propertyName.IndexOf(JsonLightConstants.ODataPropertyAnnotationSeparator);

            if (propertyAnnotationNameIndex >= 0)
            {
                string propertyAnnotationName = propertyName.Substring(propertyAnnotationNameIndex + 1);
                if (propertyAnnotationName == annotationName)
                {
                    // It's a property annotation with the specified name.
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 3
0
        /// <summary>
        /// Adds an alias for a namespace.
        /// </summary>
        /// <param name="namespaceName">The namespace.</param>
        /// <param name="alias">The alias for the namespace.</param>
        public void AddNamespaceAlias(string namespaceName, string alias)
        {
            ExceptionUtilities.CheckStringNotNullOrEmpty(namespaceName, "Namespace name cannot be null or empty.");
            ExceptionUtilities.CheckStringNotNullOrEmpty(alias, "alias cannot be null or empty.");
            ExceptionUtilities.Assert(!this.namespaceToAlias.ContainsKey(namespaceName), "Alias for Namespace " + namespaceName + " already exists!");

            this.namespaceToAlias.Add(namespaceName, alias);
        }
Esempio n. 4
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="name">The name of the dimension</param>
        /// <param name="values">The values of the dimension. This is enumerated in this constructor and the values are stored in a seprate list.</param>
        public CombinatorialDimension(string name, IEnumerable values)
        {
            ExceptionUtilities.CheckStringNotNullOrEmpty(name, "Name of the dimension needs to be specified and must not be empty.");
            ExceptionUtilities.CheckArgumentNotNull(values, "values");

            this.name   = name;
            this.values = new List <object>(values.Cast <object>()).AsReadOnly();
        }