public ConfigServiceContext(IConfigData dataProvider, bool cacheable, BaseContext context)
 {
     DataProvider = dataProvider;
     _Cacheable = cacheable;
     _Context = context;
     ConfigServiceContext.Begin(this);
 }
Example #2
0
        public MainWindow()
        {
            InitializeComponent();

            _ioc = IocMaker.NewIocWith(new List<IIocRegister>
                {
                    new IocRegisterSampleWpf(),
                    this
                });

            _sampleType2 = _ioc.Resolve<ISampleType2>();
            _configData = _ioc.Resolve<IConfigData>();
        }
Example #3
0
        public static void CopyFrom(this CompilerEngine dst, IConfigData src)
        {

            dst.Configuration = src.Configuration;
            dst.CsProject = src.CsProject;
            dst.OutDir = src.OutDir;
            dst.Referenced.Clear();
            dst.TranlationHelpers.Clear();
            dst.ReferencedPhpLibsLocations.Clear();

            // src and dest can be in different application domain
            // we need to add item by item
            foreach (var q in src.Referenced.ToArray())
                dst.Referenced.Add(q);
            foreach (var q in src.TranlationHelpers.ToArray())
                dst.TranlationHelpers.Add(q);
            foreach (var a in src.ReferencedPhpLibsLocations)
                dst.ReferencedPhpLibsLocations.Add(a.Key, a.Value);

            dst.BinaryOutputDir = src.BinaryOutputDir;
            Debug.Assert(dst.Referenced.Count == src.Referenced.Count);
            Debug.Assert(dst.TranlationHelpers.Count == src.TranlationHelpers.Count);
            Debug.Assert(dst.ReferencedPhpLibsLocations.Count == src.ReferencedPhpLibsLocations.Count);
        }
 public ConfigServiceContext(IConfigData dataProvider, bool cacheable, params Guid[] levels)
     : this(dataProvider, cacheable, new BaseContext(levels))
 {
 }
 public ContextMenuFactory(IConfigData configData)
 {
     _configData = configData;
 }
Example #6
0
        /// <summary>
        /// Removes a entity from the system and files
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public bool RemoveEntity(IConfigData entity)
        {
            string fileName = GetEntityFilename(entity);

            return(ArchiveFile(fileName, fileName));
        }
        private static IServicesConfig GetServicesConfig(IConfigData configData)
        {
            var connstring = configData.GetString(IOTHUB_CONNSTRING_KEY);

            if (connstring.ToLowerInvariant().Contains("connection string"))
            {
                // In order to connect to Azure IoT Hub, the service requires a connection
                // string. The value can be found in the Azure Portal. For more information see
                // https://docs.microsoft.com/azure/iot-hub/iot-hub-csharp-csharp-getstarted
                // to find the connection string value.
                // The connection string can be stored in the 'appsettings.ini' configuration
                // file, or in the PCS_IOTHUB_CONNSTRING environment variable. When
                // working with VisualStudio, the environment variable can be set in the
                // WebService project settings, under the "Debug" tab.

                ShowIoTHubConnStringInstructions();

                throw new Exception("The service configuration is incomplete. " +
                                    "Please provide your Azure IoT Hub connection string. " +
                                    "For more information, see the environment variables " +
                                    "used in project properties and the 'iothub_connstring' " +
                                    "value in the 'appsettings.ini' configuration file.");
            }

            var hubImportStorageAccount = configData.GetString(IOTHUB_IMPORT_STORAGE_CONNSTRING_KEY);

            if (hubImportStorageAccount.ToLowerInvariant().Contains("connection string"))
            {
                throw new Exception("The service configuration is incomplete. " +
                                    "Please provide your Azure Storage Account connection string. " +
                                    "For more information, see the environment variables " +
                                    "used in project properties and the 'iothub_connstring' " +
                                    "value in the 'appsettings.ini' configuration file.");
            }

            var azureManagementAdapterApiUrl = configData.GetString(AZURE_MANAGEMENT_ADAPTER_API_URL_KEY);

            if (!azureManagementAdapterApiUrl.ToLowerInvariant().StartsWith("https:"))
            {
                throw new Exception("The service configuration is incomplete. " +
                                    "Azure Management API url must start with https. " +
                                    "For more information, see the environment variables " +
                                    "used in project properties and the 'webservice_url' " +
                                    "value in the 'appsettings.ini' configuration file.");
            }

            return(new ServicesConfig
            {
                DeviceModelsFolder = MapRelativePath(configData.GetString(DEVICE_MODELS_FOLDER_KEY)),
                DeviceModelsScriptsFolder = MapRelativePath(configData.GetString(DEVICE_MODELS_SCRIPTS_FOLDER_KEY)),
                IoTHubConnString = connstring,
                IoTHubImportStorageAccount = hubImportStorageAccount,
                IoTHubSdkDeviceClientTimeout = configData.GetOptionalUInt(IOTHUB_SDK_DEVICE_CLIENT_TIMEOUT_KEY),
                StorageAdapterApiUrl = configData.GetString(STORAGE_ADAPTER_API_URL_KEY),
                StorageAdapterApiTimeout = configData.GetInt(STORAGE_ADAPTER_API_TIMEOUT_KEY),
                AzureManagementAdapterApiUrl = azureManagementAdapterApiUrl,
                AzureManagementAdapterApiTimeout = configData.GetInt(AZURE_MANAGEMENT_ADAPTER_API_TIMEOUT_KEY),
                AzureManagementAdapterApiVersion = configData.GetString(AZURE_MANAGEMENT_ADAPTER_API_VERSION),
                TwinReadWriteEnabled = configData.GetBool(TWIN_READ_WRITE_ENABLED_KEY, true),
                MainStorage = GetStorageConfig(configData, MAIN_STORAGE_KEY),
                NodesStorage = GetStorageConfig(configData, NODES_STORAGE_KEY),
                SimulationsStorage = GetStorageConfig(configData, SIMULATIONS_STORAGE_KEY),
                DevicesStorage = GetStorageConfig(configData, DEVICES_STORAGE_KEY),
                PartitionsStorage = GetStorageConfig(configData, PARTITIONS_STORAGE_KEY),
                StatisticsStorage = GetStorageConfig(configData, STATISTICS_STORAGE_KEY),
                DiagnosticsEndpointUrl = configData.GetString(LOGGING_DIAGNOSTICS_URL_KEY)
            });
        }