コード例 #1
0
        /// <summary>
        /// this is to be called from the constructor or initializer of a ConcurrentWeakHashtable instance
        /// </summary>
        internal static void Register(IMaintainable table)
        {
            var node = new ListNode(table);

            //Next may not be assigned correct value yet when garbage sweep starts
            //but this is not a very big deal.
            node.Next = _TableList;
            node.Next = Interlocked.Exchange(ref _TableList, node);
        }
コード例 #2
0
        /// <summary>
        /// Returns new displayer for specified entity
        /// </summary>
        /// <param name="item">Specified entity to display in displayer</param>
        /// <returns></returns>
        public IDisplayingEntity GetDisplayer(IMaintainable item)
        {
            Type displayerType = null;
            Type type          = item.GetType();

            foreach (KeyValuePair <Type, Type> pair in typeHash)
            {
                if (type.IsSubclassOf(pair.Key))
                {
                    displayerType = pair.Value;
                }
            }
            if (null == displayerType)
            {
                throw new ArgumentException("Cannot find displayer for specified type", "type");
            }
            if (displayerType == typeof(DispatcheredDirectiveScreen))
            {
                if ((((BaseDetailDirective)item)).DirectiveType == DirectiveTypeCollection.Instance.OutOffPhaseDirectiveType)
                {
                    displayerType = typeof(DispatcheredOutOffPhaseReferenceScreen);
                }
                else if ((((BaseDetailDirective)item)).DirectiveType == DirectiveTypeCollection.Instance.CPCPDirectiveType)
                {
                    displayerType = typeof(DispatcheredCPCPDirectiveScreen);
                }
            }
            Assembly      assembly   = Assembly.GetAssembly(displayerType);
            List <object> parameters = new List <object>();

            parameters.Add(item);
            object result =
                assembly.CreateInstance(displayerType.FullName, true, BindingFlags.CreateInstance, null,
                                        parameters.ToArray(), CultureInfo.CurrentCulture, null);

            return(result as IDisplayingEntity);
        }
コード例 #3
0
ファイル: MaintenanceTask.cs プロジェクト: lanicon/TomP2P.NET
 public void AddMaintainable(IMaintainable maintainable)
 {
     _maintainables.Add(maintainable);
 }
コード例 #4
0
 public void AddMaintainable(IMaintainable maintainable)
 {
     _maintainables.Add(maintainable);
 }
コード例 #5
0
        /// <summary>
        /// this is to be called from the constructor or initializer of a ConcurrentWeakHashtable instance
        /// </summary>
        internal static void Register(IMaintainable table)
        {
            var node = new ListNode(table);

            //Next may not be assigned correct value yet when garbage sweep starts
            //but this is not a very big deal.
            node.Next = _TableList;
            node.Next = Interlocked.Exchange(ref _TableList, node);
        }