Exemple #1
0
        public void Start(ServiceInstanceInfo instance)
        {
            Service s        = null;
            string  typeName = instance.Configuration.Class;

            if (!String.IsNullOrEmpty(typeName))
            {
                Type serviceType = Type.GetType(typeName, true);
                if (!serviceType.IsSubclassOf(typeof(Service)))
                {
                    throw new TypeLoadException("Service type must derive from Service (Edge.Core.Services).");
                }

                // Enforce private constructors
                ConstructorInfo ctor = serviceType.GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public, null, new Type[] { }, null);
                if (ctor == null)
                {
                    throw new MissingMethodException("Service requires a non-public parameterless constructor.");
                }

                // This is not suppoted: ctor.IsDefaultConstructor
                //else if (ctor.DeclaringType != typeof(Service) && !ctor.IsDefaultConstructor)
                //{
                //    throw new Exception("Service constructor cannot be public.");
                //}

                s = (Service)ctor.Invoke(null);
            }
            else
            {
                s = new Service();
            }

            s.Init(instance);
        }
Exemple #2
0
        public ServiceInstanceInfo(ServiceInstance instance)
        {
            _guid           = instance.Guid;
            _accountID      = instance.AccountID;
            _instanceID     = instance.InstanceID;
            _priority       = instance.Priority;
            _config         = instance.Configuration;
            _configFileName = EdgeServicesConfiguration.CurrentFileName;
            _rule           = instance.ActiveSchedulingRule;
            _timeStarted    = instance.TimeStarted;
            _timeScheduled  = instance.TimeScheduled;
            _serviceUrl     = instance.ServiceUrl;

            if (instance.ParentInstance != null)
            {
                _parentInstanceData = new ServiceInstanceInfo(instance.ParentInstance);
            }
        }
Exemple #3
0
        /*=========================*/
        #endregion

        #region Initialization
        /*=========================*/

        /// <summary>
        ///
        /// </summary>
        internal void Init(ServiceInstanceInfo instance)
        {
            _instance = instance;

            if (_wcfHost == null)
            {
                _wcfHost = new ServiceEngineHost(this);

                Binding binding = ServiceEngineCommChannel.GetBinding(instance);

                // Other service endpoints are added automatically from configuration
                _wcfHost.AddServiceEndpoint(typeof(IServiceEngine), binding, instance.ServiceUrl);

                // Open the listener
                _wcfHost.Open();
            }

            OnInit();
        }