Beispiel #1
0
        internal BaseService(IServiceFactory factory, JsonDictionary values, FactoryParameters param)
            : this(factory)
        {
            values.ThrowIfNull("values");
            param = param ?? new FactoryParameters();

            // Set required properties
            Version     = values.GetMandatoryValue <string>("version");
            Name        = values.GetMandatoryValue <string>("name");
            information = values;

            // Set optional properties
            Id                = values.GetValueAsNull("id") as string;
            Labels            = values.GetValueAsStringListOrEmpty("labels").ToList().AsReadOnly();
            Features          = values.GetValueAsStringListOrEmpty("features").ToList().AsReadOnly();
            DocumentationLink = values.GetValueAsNull("documentationLink") as string;
            Protocol          = values.GetValueAsNull("protocol") as string;
            Description       = values.GetValueAsNull("description") as string;
            Title             = values.GetValueAsNull("title") as string;
            Scopes            = LoadScopes();
            Parameters        = LoadParameters();

            // Load resources
            rootResource = CreateResource(new KeyValuePair <string, object>("", information));

            // Determine the Server URL and (optional) Base Path
            param.ServerUrl.ThrowIfNull("param.ServerUrl");
            ServerUrl = param.ServerUrl;
            BasePath  = param.BasePath;
        }
 /// <summary>
 /// Sets BasePath property. If the the given factory params contain BasePath use it, otherwise use the given
 /// base path field to query the dicsovery doc.
 /// </summary>
 protected void SetBasePath(FactoryParameters param, string basePathField)
 {
     if (param != null && param.BasePath != null)
     {
         BasePath = param.BasePath;
     }
     else
     {
         BasePath = discoveryDoc.GetMandatoryValue <string>(basePathField);
     }
 }
        internal BaseService(IServiceFactory factory, JsonDictionary discoveryDoc, FactoryParameters param)
            : this(factory)
        {
            discoveryDoc.ThrowIfNull("discoveryDoc");
            this.discoveryDoc = discoveryDoc;

            // Set required properties
            Version       = discoveryDoc.GetMandatoryValue <string>("version");
            Name          = discoveryDoc.GetMandatoryValue <string>("name").Replace(" ", "");
            CanonicalName = discoveryDoc.GetValueAsNull("canonicalName") as string;
            if (!string.IsNullOrEmpty(CanonicalName))
            {
                CanonicalName = CanonicalName.Replace(" ", "");
            }

            // Set optional properties
            Id                = discoveryDoc.GetValueAsNull("id") as string;
            Labels            = discoveryDoc.GetValueAsStringListOrEmpty("labels").ToList().AsReadOnly();
            Features          = discoveryDoc.GetValueAsStringListOrEmpty("features").ToList().AsReadOnly();
            DocumentationLink = discoveryDoc.GetValueAsNull("documentationLink") as string;
            Protocol          = discoveryDoc.GetValueAsNull("protocol") as string;
            Description       = discoveryDoc.GetValueAsNull("description") as string;
            Title             = discoveryDoc.GetValueAsNull("title") as string;
            Scopes            = LoadScopes();
            Parameters        = LoadParameters();

            // Load resources
            rootResource = CreateResource(new KeyValuePair <string, object>("", discoveryDoc));

            // Sets the Server URL (Base Path will be set on the concete class)
            if (param != null && param.ServerUrl != null)
            {
                ServerUrl = param.ServerUrl;
            }
            else
            {
                ServerUrl = discoveryDoc.GetMandatoryValue("rootUrl") as string;
            }
        }