public void DecorateProperty(CodeMemberProperty propertyDefinition, KeyValuePair<string, JsonSchema> propertyPair)
        {
            propertyDefinition.ThrowIfNull("propertyDefinition");
            propertyPair.ThrowIfNull("propertyPair");

            propertyDefinition.Comments.AddRange(CreateComment(propertyPair.Value));
        }
Example #2
0
        /// <summary>
        /// Creates a new resource for the specified discovery version with the specified name and json dictionary.
        /// </summary>
        internal BaseResource(DiscoveryVersion version, KeyValuePair<string, object> kvp)
        {
            kvp.ThrowIfNull("kvp");
            kvp.Key.ThrowIfNull("kvp");

            DiscoveryVersion = version;
            logger.Debug("Constructing Resource [{0}]", kvp.Key);
            Name = kvp.Key;
            information = kvp.Value as JsonDictionary;
            if (information == null)
            {
                throw new ArgumentException("got no valid dictionary");
            }

            // Initialize subresources.
            if (information.ContainsKey("resources"))
            {
                var resourceJson = (JsonDictionary)information["resources"];
                resources = new Dictionary<string, IResource>();
                foreach (KeyValuePair<string, object> pair in resourceJson)
                {
                    // Create the subresource.
                    var subResource = (BaseResource)CreateResource(pair);
                    subResource.Parent = this;
                    resources.Add(pair.Key, subResource);
                }
            }
        }