// Carriers ------------------------------------------------

        /// <summary>
        /// Creates the instance of the specified definition.
        /// </summary>
        /// <param name="scope">The scope to consider.</param>
        /// <param name="configuration">The configuration to consider.</param>
        /// <param name="name">The name to consider.</param>
        /// <param name="log">The log to consider.</param>
        /// <param name="scriptVariableSet">The script variable set to use.</param>
        /// <typeparam name="T">The carrier class to return.</typeparam>
        /// <returns>Returns the created carrier.</returns>
        public static T CreateCarrier <T>(
            this IBdoScope scope,
            IBdoCarrierConfiguration configuration = null,
            string name = null,
            IBdoLog log = null,
            IScriptVariableSet scriptVariableSet = null) where T : BdoCarrier
        {
            return(scope.CreateCarrier(configuration, name, log, scriptVariableSet) as T);
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new carrier element.
        /// </summary>
        /// <param name="name">The name to consider.</param>
        /// <param name="id">The ID to consider.</param>
        /// <param name="item">The items to consider.</param>
        public static CarrierElement CreateCarrier(
            string name,
            string id,
            IBdoCarrierConfiguration item)
        {
            var element = CreateCarrier(name, id, item?.DefinitionUniqueId);

            element.WithItems(item);

            return(element);
        }
Beispiel #3
0
        public void CreateCarrierFromScopeTest()
        {
            IBdoCarrierConfiguration config =
                GlobalVariables.Scope.CreateCarrierConfiguration("tests.core$testCarrier")
                .WithItems(
                    ElementFactory.CreateScalar("boolValue", _testData.boolValue),
                    ElementFactory.CreateScalar("enumValue", _testData.enumValue),
                    ElementFactory.CreateScalar("intValue", _testData.intValue),
                    ElementFactory.CreateScalar("stringValue", _testData.stringValue));

            _carrier = GlobalVariables.Scope.CreateCarrier <CarrierFake>(config, "connector");

            Test(_carrier);
        }
        // Carriers ------------------------------------------------

        /// <summary>
        /// Creates the instance of the specified definition.
        /// </summary>
        /// <param name="scope">The scope to consider.</param>
        /// <param name="definitionUniqueId">The unique ID of the definition to consider.</param>
        /// <param name="log">The log to consider.</param>
        public static IBdoCarrierConfiguration CreateCarrierConfiguration(
            this IBdoScope scope,
            string definitionUniqueId,
            IBdoLog log = null)
        {
            IBdoCarrierConfiguration configuration = null;

            IBdoCarrierDefinition definition = scope.ExtensionStore.GetItemDefinitionWithUniqueId <BdoCarrierDefinition>(definitionUniqueId);

            if (definition == null)
            {
                log?.AddError("Could not retrieve the extension item '" + definitionUniqueId + "' of kind '" + BdoExtensionItemKind.Carrier.ToString() + "'");
            }
            else
            {
                configuration = BdoExtensionFactory.CreateCarrierConfiguration(definitionUniqueId);
                configuration.Update(definition);
            }

            return(configuration);
        }
        /// <summary>
        /// Creates the instance of the specified definition.
        /// </summary>
        /// <param name="scope">The scope to consider.</param>
        /// <param name="configuration">The configuration to consider.</param>
        /// <param name="name">The name to consider.</param>
        /// <param name="log">The log to consider.</param>
        /// <param name="scriptVariableSet">The script variable set to use.</param>
        /// <returns>Returns the created carrier.</returns>
        public static BdoCarrier CreateCarrier(
            this IBdoScope scope,
            IBdoCarrierConfiguration configuration = null,
            string name = null,
            IBdoLog log = null,
            IScriptVariableSet scriptVariableSet = null)
        {
            BdoCarrier carrier = null;

            if (scope?.Check(true).HasErrorsOrExceptions() == false)
            {
                if (configuration != null)
                {
                    // we get the carrier class reference

                    IBdoCarrierDefinition definition = scope.ExtensionStore.GetItemDefinitionWithUniqueId <IBdoCarrierDefinition>(configuration.DefinitionUniqueId);
                    if (definition == null)
                    {
                        log?.AddError("Could not retrieve the extension carrier '" + configuration.DefinitionUniqueId + "' definition");
                    }
                    else
                    {
                        // we intantiate the carrier

                        AssemblyHelper.CreateInstance(definition.RuntimeType, out object item).AddEventsTo(log);

                        if (item != null)
                        {
                            carrier      = item as BdoCarrier;
                            carrier.Name = name ?? configuration?.Name;
                            carrier.UpdateFromElementSet <DetailPropertyAttribute>(configuration, scope, scriptVariableSet);
                        }
                    }
                }
            }

            return(carrier);
        }
Beispiel #6
0
        // --------------------------------------------------
        // ITEMS
        // --------------------------------------------------

        #region Items

        /// <summary>
        /// Sets the specified configuration.
        /// </summary>
        /// <param name="configuration"></param>
        /// <returns></returns>
        public ICarrierElement WithConfiguration(IBdoCarrierConfiguration configuration)
        {
            WithItems(configuration);

            return(this);
        }
Beispiel #7
0
 /// <summary>
 /// Initializes a new carrier element.
 /// </summary>
 /// <param name="name">The name to consider.</param>
 /// <param name="item">The items to consider.</param>
 public static CarrierElement CreateCarrier(
     string name,
     IBdoCarrierConfiguration item)
 {
     return(CreateCarrier(name, null, item));
 }
Beispiel #8
0
 /// <summary>
 /// This instantiates a new instance of the Datasource class.
 /// </summary>
 /// <param name="container">The container to consider.</param>
 /// <param name="content">The content to consider.</param>
 /// <param name="name">The name of this instance.</param>
 public Document(IBdoCarrierConfiguration container, IBdoEntityConfiguration content, string name = null)
     : base(name, "document_")
 {
     Container = container as BdoCarrierConfiguration;
     Content   = content as BdoEntityConfiguration;
 }