예제 #1
0
        // PRIVATE METHODS //////////////////////////////////////////////////
        #region Methods
        private static string CreateName(ApiPathMixin apiPathMixin)
        {
            Contract.Requires(apiPathMixin != null);

            var apiNodeMixinKind = apiPathMixin.ApiKind;

            switch (apiNodeMixinKind)
            {
            case ApiPathMixinKind.Null:
                return("ApiCollection");

            case ApiPathMixinKind.Property:
                var apiPropertyNodeMixin = (ApiPropertyPathMixin)apiPathMixin;
                var apiPropertyName      = apiPropertyNodeMixin.ApiName;
                return($"ApiCollection [apiPropertyName={apiPropertyName}]");

            case ApiPathMixinKind.CollectionItem:
                var apiCollectionItemNodeMixin = (ApiCollectionItemPathMixin)apiPathMixin;
                var apiCollectionItemIndex     = apiCollectionItemNodeMixin.ApiIndex;
                return($"ApiCollection [apiCollectionIndex={apiCollectionItemIndex}]");

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        // PRIVATE METHODS //////////////////////////////////////////////////
        #region Methods
        private static string CreateName(ApiPathMixin apiPathMixin, ApiResourceIdentifier apiResourceIdentifier)
        {
            Contract.Requires(apiPathMixin != null);
            Contract.Requires(apiResourceIdentifier != null);

            var apiType          = apiResourceIdentifier.ApiType;
            var apiIdString      = apiResourceIdentifier.ApiIdString;
            var apiIdTypeName    = apiResourceIdentifier.ApiIdTypeName;
            var apiNodeMixinKind = apiPathMixin.ApiKind;

            switch (apiNodeMixinKind)
            {
            case ApiPathMixinKind.Null:
                return($"ApiResource [apiType={apiType} apiId={apiIdString} {{{apiIdTypeName}}}]");

            case ApiPathMixinKind.Property:
                var apiPropertyNodeMixin = (ApiPropertyPathMixin)apiPathMixin;
                var apiPropertyName      = apiPropertyNodeMixin.ApiName;
                return($"ApiResource [apiPropertyName={apiPropertyName} apiType={apiType} apiId={apiIdString} {{{apiIdTypeName}}}]");

            case ApiPathMixinKind.CollectionItem:
                var apiCollectionItemNodeMixin = (ApiCollectionItemPathMixin)apiPathMixin;
                var apiCollectionItemIndex     = apiCollectionItemNodeMixin.ApiIndex;
                return($"ApiResource [apiCollectionIndex={apiCollectionItemIndex} apiType={apiType} apiId={apiIdString} {{{apiIdTypeName}}}]");

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
예제 #3
0
        protected ApiNode(string apiName, ApiPathMixin apiPathMixin, IEnumerable <ApiNode> apiNodes)
            : base(apiName, apiNodes)
        {
            Contract.Requires(apiPathMixin != null);

            this.ApiPathMixin = apiPathMixin;
        }
예제 #4
0
        // PRIVATE METHODS //////////////////////////////////////////////////
        #region Methods
        private static string GetDocumentPathSegmentString(ApiPathMixin apiPathMixin)
        {
            Contract.Requires(apiPathMixin != null);

            var apiNodeMixinKind = apiPathMixin.ApiKind;

            switch (apiNodeMixinKind)
            {
            case ApiPathMixinKind.Property:
            {
                var apiPropertyNodeMixin         = (ApiPropertyPathMixin)apiPathMixin;
                var apiDocumentPathStringSegment = apiPropertyNodeMixin.ApiName;
                return(apiDocumentPathStringSegment);
            }

            case ApiPathMixinKind.CollectionItem:
            {
                var apiCollectionItemNodeMixin   = (ApiCollectionItemPathMixin)apiPathMixin;
                var apiCollectionItemIndex       = apiCollectionItemNodeMixin.ApiIndex;
                var apiDocumentPathStringSegment = $"[{apiCollectionItemIndex}]";
                return(apiDocumentPathStringSegment);
            }

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
예제 #5
0
        /// <summary>Creates an API collection node of API nodes.</summary>
        /// <param name="apiPathMixin">Represents the path relationship from the API collection node to parent API node.</param>
        /// <param name="apiNodes">Represents the collection of API nodes owned by the API collection node.</param>
        public static ApiCollectionNode Create(ApiPathMixin apiPathMixin, params ApiNode[] apiNodes)
        {
            Contract.Requires(apiPathMixin != null);

            var apiCollectionNode = new ApiCollectionNode(apiPathMixin, apiNodes.AsEnumerable());

            return(apiCollectionNode);
        }
        /// <summary>Creates an API resource node that has API child nodes.</summary>
        /// <param name="apiPathMixin">Represents the path relationship from the API resource node to parent API node.</param>
        /// <param name="apiResourceIdentifier">Represents the API identity of the API resource node.</param>
        /// <param name="apiNodes">Represents the collection of API nodes owned by the API resource node indexed by API property name.</param>
        public ApiResourceNode(ApiPathMixin apiPathMixin, ApiResourceIdentifier apiResourceIdentifier, IEnumerable <ApiNode> apiNodes)
            : base(apiPathMixin, apiResourceIdentifier.ApiType, CreateName(apiPathMixin, apiResourceIdentifier), apiNodes)
        {
            Contract.Requires(apiPathMixin != null);
            Contract.Requires(apiResourceIdentifier != null);

            this.ApiResourceIdentifier = apiResourceIdentifier;
        }
예제 #7
0
        // PUBLIC METHODS ///////////////////////////////////////////////////
        #region Factory Methods
        /// <summary>Factory method that creates a strongly typed API scalar node object.</summary>
        /// <typeparam name="TScalar">CLR scalar type the API scalar node represents.</typeparam>
        /// <param name="apiPathMixin">Represents the path relationship from the API scalar node to parent API node.</param>
        /// <param name="clrValue">CLR scalar value that is contained by the API scalar node.</param>
        /// <returns>Newly created strongly typed API scalar node object.</returns>
        public static ApiScalarNode Create <TScalar>(ApiPathMixin apiPathMixin, TScalar clrValue)
        {
            Contract.Requires(apiPathMixin != null);

            var apiScalarNode = new ApiScalarNode <TScalar>(apiPathMixin, clrValue);

            return(apiScalarNode);
        }
예제 #8
0
        protected ApiObjectNode(ApiPathMixin apiPathMixin, string apiType, string apiName, params ApiNode[] apiNodes)
            : base(apiName, apiPathMixin, apiNodes.AsEnumerable())
        {
            Contract.Requires(apiPathMixin != null);
            Contract.Requires(apiType.SafeHasContent());

            this.ApiType = apiType;
        }
예제 #9
0
        // PROTECTED CONSTRUCTORS ///////////////////////////////////////////
        #region Constructors
        protected ApiObjectNode(ApiPathMixin apiPathMixin, string apiType, string apiName)
            : base(apiName, apiPathMixin)
        {
            Contract.Requires(apiPathMixin != null);
            Contract.Requires(apiType.SafeHasContent());

            this.ApiType = apiType;
        }
예제 #10
0
        /// <summary>Factory method that creates an API null node object.</summary>
        /// <param name="apiPathMixin">Represents the path relationship from the API null node to parent API node.</param>
        /// <returns>Newly created API null node.</returns>
        public static ApiNullNode Create(ApiPathMixin apiPathMixin)
        {
            Contract.Requires(apiPathMixin != null);

            var apiNullNode = new ApiNullNode(apiPathMixin);

            return(apiNullNode);
        }
예제 #11
0
        /// <summary>Creates an API object node that has child API nodes.</summary>
        /// <param name="apiPathMixin">Represents the path relationship from the API object node to parent API node.</param>
        /// <param name="apiType">Represents the API object type.</param>
        /// <param name="apiNodes">Represents the collection of API nodes owned by the API object node indexed by API property name.</param>
        public ApiObjectNode(ApiPathMixin apiPathMixin, string apiType, IEnumerable <ApiNode> apiNodes)
            : base(CreateName(apiPathMixin, apiType), apiPathMixin, apiNodes)
        {
            Contract.Requires(apiPathMixin != null);
            Contract.Requires(apiType.SafeHasContent());

            this.ApiType = apiType;
        }
예제 #12
0
        /// <summary>Factory method that creates an API object node object.</summary>
        /// <param name="apiPathMixin">Represents the path relationship from the API object node to parent API node.</param>
        /// <param name="apiType">Represents the API object type.</param>
        /// <param name="apiNodes">Represents the collection of API nodes owned by the API object node indexed by API property name.</param>
        /// <returns>Newly created API object node.</returns>
        public static ApiObjectNode Create(ApiPathMixin apiPathMixin, string apiType, params ApiNode[] apiNodes)
        {
            Contract.Requires(apiPathMixin != null);
            Contract.Requires(apiType.SafeHasContent());

            var apiObjectNode = new ApiObjectNode(apiPathMixin, apiType, apiNodes.AsEnumerable());

            return(apiObjectNode);
        }
예제 #13
0
        /// <summary>Factory method that creates an API resource node object.</summary>
        /// <param name="apiPathMixin">Represents the path relationship from the API resource node to parent API node.</param>
        /// <param name="apiResourceIdentifier">Represents the API identity of the API resource node.</param>
        /// <param name="apiNodes">Represents the collection of API nodes owned by the API resource node indexed by API property name.</param>
        /// <returns>Newly created API resource node.</returns>
        public static ApiResourceNode Create(ApiPathMixin apiPathMixin, ApiResourceIdentifier apiResourceIdentifier, params ApiNode[] apiNodes)
        {
            Contract.Requires(apiPathMixin != null);
            Contract.Requires(apiResourceIdentifier != null);

            var apiResourceNode = new ApiResourceNode(apiPathMixin, apiResourceIdentifier, apiNodes.AsEnumerable());

            return(apiResourceNode);
        }
예제 #14
0
        // PUBLIC METHODS ///////////////////////////////////////////////////
        #region Factory Methods
        /// <summary>Factory method that creates a strongly typed API enumeration node object.</summary>
        /// <typeparam name="TEnum">CLR enumeration type the API enumeration node represents.</typeparam>
        /// <param name="apiPathMixin">Represents the path relationship from the API enumeration node to parent API node.</param>
        /// <param name="apiValue">API enumeration value that is contained by the API enumeration node.</param>
        /// <param name="clrValue">CLR enumeration value that is contained by the API enumeration node.</param>
        /// <returns>Newly created strongly typed API enumeration node object.</returns>
        public static ApiEnumerationNode Create <TEnum>(ApiPathMixin apiPathMixin, string apiValue, TEnum clrValue)
            where TEnum : Enum
        {
            Contract.Requires(apiPathMixin != null);
            Contract.Requires(apiValue.SafeHasContent());

            var apiEnumNode = new ApiEnumerationNode <TEnum>(apiPathMixin, apiValue, clrValue);

            return(apiEnumNode);
        }
예제 #15
0
 protected ApiNode(string apiName, ApiPathMixin apiPathMixin)
     : this(apiName, apiPathMixin, Enumerable.Empty <ApiNode>())
 {
 }
예제 #16
0
 // PROTECTED CONSTRUCTORS ///////////////////////////////////////////
 #region Constructors
 protected ApiScalarNode(string apiName, ApiPathMixin apiPathMixin)
     : base(apiName, apiPathMixin)
 {
 }
예제 #17
0
 // PROTECTED CONSTRUCTORS ///////////////////////////////////////////
 #region Constructors
 protected ApiEnumerationNode(string apiName, ApiPathMixin apiPathMixin)
     : base(apiName, apiPathMixin)
 {
 }
예제 #18
0
 // PUBLIC CONSTRUCTORS //////////////////////////////////////////////
 #region Constructors
 /// <summary>Creates an API null node.</summary>
 /// <param name="apiPathMixin">Represents the path relationship from the API null node to parent API node.</param>
 public ApiNullNode(ApiPathMixin apiPathMixin)
     : base(CreateName(apiPathMixin), apiPathMixin)
 {
 }
예제 #19
0
 /// <summary>Creates an API collection node of API nodes.</summary>
 /// <param name="apiPathMixin">Represents the path relationship from the API collection node to parent API node.</param>
 /// <param name="apiNodes">Represents the collection of API nodes owned by the API collection node.</param>
 public ApiCollectionNode(ApiPathMixin apiPathMixin, IEnumerable <ApiNode> apiNodes)
     : base(CreateName(apiPathMixin), apiPathMixin, apiNodes)
 {
 }
예제 #20
0
 /// <summary>Creates an API collection node of API nodes.</summary>
 /// <param name="apiPathMixin">Represents the path relationship from the API collection node to parent API node.</param>
 /// <param name="apiNodes">Represents the collection of API nodes owned by the API collection node.</param>
 public ApiCollectionNode(ApiPathMixin apiPathMixin, params ApiNode[] apiNodes)
     : base(CreateName(apiPathMixin), apiPathMixin, apiNodes.AsEnumerable())
 {
 }
예제 #21
0
 // PUBLIC CONSTRUCTORS //////////////////////////////////////////////
 #region Constructors
 /// <summary>Creates an empty API collection node.</summary>
 /// <param name="apiPathMixin">Represents the path relationship from the API collection node to parent API node.</param>
 public ApiCollectionNode(ApiPathMixin apiPathMixin)
     : base(CreateName(apiPathMixin), apiPathMixin)
 {
 }