当前位置: 首页>>代码示例>>C#>>正文


C# IService.GetType方法代码示例

本文整理汇总了C#中IService.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# IService.GetType方法的具体用法?C# IService.GetType怎么用?C# IService.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IService的用法示例。


在下文中一共展示了IService.GetType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RegisterService

        public void RegisterService(IService service)
        {
            IService existingService;

            if (services.TryGetValue(service.GetType(), out existingService))
            {
                // TODO: log: service already exists

                existingService = service;
            }
            else
            {
                services.Add(service.GetType(), service);
            }
        }
开发者ID:supermuk,项目名称:iudico,代码行数:15,代码来源:LMS.cs

示例2: RunService

        public async Task RunService(IService service, CancellationToken token)
        {
            _logger.InfoFormat("Running service {0}", service.Name);

            await TaskEx.Yield();

            var blobs = _client.GetContainerReference("locks");
            await blobs.CreateIfNotExistAsync();

            var blob = blobs.GetBlobReference(service.Name);

            while (!token.IsCancellationRequested)
            {
                try
                {
                    if (service is IScheduledService)
                        await HandleScheduledService((IScheduledService)service, blob, token);
                    else if (service is IClusteredService)
                        await HandleClusteredService((IClusteredService)service, blob, token);
                    else if (service is IContinuousService)
                        await HandleContinuousService((IContinuousService)service, blob, token);
                }
                catch (OperationCanceledException)
                {
                    // no-op
                }
                catch (Exception e)
                {
                    _logger.ErrorFormat("The main task of service \"{0}\" threw an exception.", e, service.Name);
                }
            }

            _logger.InfoFormat("Service {0} stopped", service.GetType().Name);
            throw new OperationCanceledException(token);
        }
开发者ID:bytenik,项目名称:CloudServiceHost,代码行数:35,代码来源:ServiceHost.cs

示例3: GetEventField

 private static FieldInfo GetEventField(IService serviceInstance, EventInfo eventInfo)
 {
     return serviceInstance.GetType()
         .GetField(eventInfo.Name,
             BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public |
             BindingFlags.FlattenHierarchy);
 }
开发者ID:Vrijdagonline,项目名称:TheDashboard,代码行数:7,代码来源:UmbracoRepository.cs

示例4: GetCustomEvents

 public IEnumerable<CustomEventDto> GetCustomEvents(IService serviceInstance)
 {
     return serviceInstance.GetType().GetEvents()
         .Select(x => new CustomEventDto
         {
             EventName = x.Name,
             Handlers = GetCustomEventHandlers(serviceInstance, x)
         })
         .Where(x => x.Handlers != null && x.Handlers.Any());
 }
开发者ID:Vrijdagonline,项目名称:TheDashboard,代码行数:10,代码来源:UmbracoRepository.cs

示例5: RegisterCacheEntry

        private void RegisterCacheEntry(IService Service)
        {
            try
            {
                if (HttpContext.Current.Cache[Service.GetType().Name] != null)
                    return;

                HttpContext.Current.Cache.Add(Service.GetType().Name, Service, null,
                    DateTime.Now.AddMinutes(Service.Interval), System.Web.Caching.Cache.NoSlidingExpiration,
                    CacheItemPriority.Normal,
                    new CacheItemRemovedCallback(CacheItemRemovedCallback));
            }
            catch (Exception ex)
            {
            }
        }
开发者ID:bscarlavai,项目名称:social-gamer,代码行数:16,代码来源:Global.asax.cs

示例6: AddService

		public void AddService( IService service )
		{
			services.Add( service );
			NTrace.Debug( "Added " + service.GetType().Name );
		}
开发者ID:nobled,项目名称:mono,代码行数:5,代码来源:ServiceManager.cs

示例7: IsInstanceOfType

        // HACK: MONO BUGFIX
        // this doesn't work on mono:serviceType.IsInstanceOfType(service)
        bool IsInstanceOfType(Type type, IService service)
        {
            Type serviceType = service.GetType();

            foreach (Type iface in serviceType.GetInterfaces()) {
                if (iface == type) {
                    return true;
                }
            }

            while (serviceType != typeof(System.Object)) {
                if (type == serviceType) {
                    return true;
                }
                serviceType = serviceType.BaseType;
            }
            return false;
        }
开发者ID:slluis,项目名称:monodevelop-prehistoric,代码行数:20,代码来源:ServiceManager.cs

示例8: CacheService

 private void CacheService(IService Service)
 {
     //Ping the "CacheService" page which will trigger Application_BeginRequest and register another cache item
     WebClient client = new WebClient();
     client.DownloadData(new Uri(_url + "/CacheService.aspx?Type=" + Service.GetType().Name));
 }
开发者ID:bscarlavai,项目名称:social-gamer,代码行数:6,代码来源:Global.asax.cs

示例9: EventsFromInstance

 public static EventInfo[] EventsFromInstance(IService instance)
 {
     var t = instance.GetType();
     return t.GetEvents();
 }
开发者ID:JPVenson,项目名称:svnproj,代码行数:5,代码来源:TypeReflection.cs

示例10: RegisterService

 /// <summary>
 /// Registers a service into the system.
 /// </summary>
 /// <param name="serviceInstance"></param>
 public void RegisterService(IService serviceInstance)
 {
     RegisterService(serviceInstance.GetType(), serviceInstance);
 }
开发者ID:moszinet,项目名称:HomeAutomation,代码行数:8,代码来源:ServiceRegistry.cs

示例11: AddService

 public void AddService(IService service)
 {
     _services.Add(service);
     log.Debug("Added " + service.GetType().Name);
 }
开发者ID:alfeg,项目名称:nunit,代码行数:5,代码来源:ServiceManager.cs

示例12: GetCategorizedItems

        /// <summary>
        /// Gets the categorized items.
        /// </summary>
        /// <param name="serviceInstance">The service instance.</param>
        /// <param name="categoryId">The category id.</param>
        /// <param name="showUnnamedEntityItems">if set to <c>true</c> [show unnamed entity items].</param>
        /// <returns></returns>
        private IQueryable<ICategorized> GetCategorizedItems( IService serviceInstance, int categoryId, bool showUnnamedEntityItems )
        {
            if ( serviceInstance != null )
            {
                MethodInfo getMethod = serviceInstance.GetType().GetMethod( "Get", new Type[] { typeof( ParameterExpression ), typeof( Expression ) } );
                if ( getMethod != null )
                {
                    ParameterExpression paramExpression = serviceInstance.ParameterExpression;
                    MemberExpression propertyExpression = Expression.Property( paramExpression, "CategoryId" );
                    BinaryExpression compareExpression = null;
                    ConstantExpression constantExpression = Expression.Constant( categoryId );

                    if ( propertyExpression.Type == typeof( int? ) )
                    {
                        var zeroExpression = Expression.Constant( 0 );
                        var coalesceExpression = Expression.Coalesce( propertyExpression, zeroExpression );
                        compareExpression = Expression.Equal( coalesceExpression, constantExpression );
                    }
                    else
                    {
                        compareExpression = Expression.Equal( propertyExpression, constantExpression );
                    }

                    var result = getMethod.Invoke( serviceInstance, new object[] { paramExpression, compareExpression } ) as IQueryable<ICategorized>;

                    if ( !showUnnamedEntityItems )
                    {
                        result = result.Where( a => a.Name != null && a.Name != string.Empty );
                    }

                    return result;
                }
            }

            return null;
        }
开发者ID:tcavaletto,项目名称:Rock-CentralAZ,代码行数:43,代码来源:CategoriesController.Partial.cs

示例13: AddService

        public bool AddService(IService service)
        {
            if (!this.CanLoad(service))
            {
                Debug.WriteLine(this + ": " + service + " konnte nicht geladen werden");
                return false;
            }
            Debug.WriteLine(this + ": loading " + service.GetType());
            /*			foreach (IService ser in this.services)
            {
                if ((ser).GetType() == service.GetType())
                {
                    Debug.WriteLine(typeof(this) + ": Service bereits geladen!");
                    return;
                }
            }
            */
            if (this.services.ContainsKey(service.GetType()))
            {
                Debug.WriteLine(this + ": Service bereits geladen!");
                return false;
            }

            this.services.Add(service.GetType(), service);
            service.Load();
            // TODO: return service.Load()
            return true;
        }
开发者ID:BackupTheBerlios,项目名称:storm-ircd-svn,代码行数:28,代码来源:ServiceManager.cs

示例14: SearchService

        private bool SearchService(Type type, IService service)
        {
            Type stype = service.GetType();

            foreach (Type ia in stype.GetInterfaces())
            {
                if (type == ia)
                    return true;
            }

            while (stype != typeof(object))
            {
                if (type == stype)
                    return true;
                stype = stype.BaseType;
            }
            return false;
        }
开发者ID:BackupTheBerlios,项目名称:storm-ircd-svn,代码行数:18,代码来源:ServiceManager.cs

示例15: Unload

        public bool Unload(IService service)
        {
            if (!this.CanUnload(service))
            {
                Debug.WriteLine(this + ": kann " + service + "nicht entladen");
                return false;
            }

            Debug.WriteLine(this + ": entlade " + service.GetType()  + "...");
            if (service.Loaded)
                service.Unload();

            this.services.Remove(service.GetType());
            return true;
        }
开发者ID:BackupTheBerlios,项目名称:storm-ircd-svn,代码行数:15,代码来源:ServiceManager.cs


注:本文中的IService.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。