Beispiel #1
0
        public override int Compare(IServiceObject a, IServiceObject b)
        {
            // default implementation: string compare
            object oA = (a == null) ? 0 : a.GetObject(ID);
            object oB = (b == null) ? 0 : b.GetObject(ID);

            if (oA == null)
                oA = 0;
            if (oB == null)
                oB = 0;
            return ((int)oA) - ((int)oB);
        }
Beispiel #2
0
        public virtual int Compare(IServiceObject a, IServiceObject b)
        {
            // default implementation: string compare
            string textA = (a == null) ? "" : a.GetText(ID);
            string textB = (b == null) ? "" : b.GetText(ID);

            if (textA == null)
                textA = "";
            if (textB == null)
                textB = "";
            return textA.CompareTo(textB);
        }
        public override int Compare(IServiceObject a, IServiceObject b)
        {
            // default implementation: string compare
            object oA = (a == null) ? new TimeSpan() : a.GetObject(ID);
            object oB = (b == null) ? new TimeSpan() : b.GetObject(ID);

            if (oA == null)
                oA = new TimeSpan();
            if (oB == null)
                oB = new TimeSpan();
            return ((TimeSpan)oA).CompareTo(oB);
        }
Beispiel #4
0
        static SvrBase()
        {
            //highly optimistic approach to getting the name of the executable...
            _executableName = System.Reflection.Assembly.GetExecutingAssembly().Location.Split("\\".ToCharArray()).Last();

            //look for every object that implements IServiceObject. This code could be a little cleaner, but it's only called once...
            foreach (Type t in System.Reflection.Assembly.GetExecutingAssembly().GetTypes().Where(c => c.GetInterfaces().Contains(typeof(IServiceObject))))
            {
                IServiceObject service = Activator.CreateInstance(t) as IServiceObject;
                _serviceObjects.Add(service);
                _serviceThreads.Add(new Thread(new ThreadStart(service.Start)));
            }
        }
Beispiel #5
0
        internal Result RegisterService(IServiceObject service, ServiceName serviceName)
        {
            Result rc = ValidateServiceName(serviceName);

            if (rc.IsFailure())
            {
                return(rc);
            }

            if (!Services.TryAdd(serviceName, service))
            {
                return(ResultSm.AlreadyRegistered.Log());
            }

            return(Result.Success);
        }
        public override int Compare(IServiceObject a, IServiceObject b)
        {
            // default implementation: string compare
            object oA = (a == null) ? 0L : a.GetObject(ID);
            object oB = (b == null) ? 0L : b.GetObject(ID);

            if (oA == null)
                oA = 0L;
            if (oB == null)
                oB = 0L;
            long delta = (long)oA - (long)oB;
            if (delta > 0)
                return 1;
            if (delta < 0)
                return -1;
            return 0;
        }
Beispiel #7
0
        private void Process(object serviceObject)
        {
            IServiceObject iso = serviceObject as IServiceObject;

            if (ServiceBeginning != null)
            {
                ServiceBeginning(this, serviceObject);
            }
            if (iso != null)
            {
                iso.OnServiceBeginning(this);
            }
            m_available      = false;
            m_startedService = m_model.Executive.Now;
            DateTime when = m_model.Executive.Now + m_periodicity.GetNext();

            m_model.Executive.RequestEvent(new ExecEventReceiver(CompleteProcessing), when, 0.0, serviceObject);
        }
Beispiel #8
0
        private void CompleteProcessing(IExecutive exec, object serviceObject)
        {
            IServiceObject iso = serviceObject as IServiceObject;

            if (iso != null)
            {
                iso.OnServiceCompleting(this);
            }
            if (ServiceCompleted != null)
            {
                ServiceCompleted(this, serviceObject);
            }
            m_output.OwnerPut(serviceObject);
            m_available = true;
            if (m_inService)
            {
                TryToCommenceService();
            }
        }
Beispiel #9
0
        private void CompleteProcessing(IExecutive exec, object serviceObject)
        {
            OnPreCompletionTeardown(this, serviceObject);

            if (m_supportsServerObjects)
            {
                IServiceObject iso = serviceObject as IServiceObject;
                if (iso != null)
                {
                    iso.OnServiceCompleting(this);
                }
            }
            if (ServiceCompleted != null)
            {
                ServiceCompleted(this, serviceObject);
            }
            m_output.OwnerPut(serviceObject);
            if (m_inService)
            {
                TryToPullServiceObject();
            }
        }
Beispiel #10
0
        public override int Compare(IServiceObject a, IServiceObject b)
        {
            // default implementation: string compare
            object oA = (a == null) ? (uint)0 : a.GetObject(ID);
            object oB = (b == null) ? (uint)0 : b.GetObject(ID);

            if (oA == null)
                oA = (uint)0;
            if (oB == null)
                oB = (uint)0;

            uint A = (uint)oA;
            uint B = (uint)oB;

            if (A == B)
                return 0;

            if( A < B )
                return 1;

            return -1;
        }
Beispiel #11
0
 public Result RegisterService(IServiceObject serviceObject, ReadOnlySpan <char> name)
 {
     return(Server.RegisterService(serviceObject, ServiceName.Encode(name)));
 }
Beispiel #12
0
 public int Compare(IServiceObject a, IServiceObject b)
 {
     return Wrapper.Compare(a, b);
 }