コード例 #1
0
        public void RegisterThreadLocalCleanupBean(IThreadLocalCleanupBean threadLocalCleanupBean)
        {
            Lock writeLock = listeners.GetWriteLock();

            writeLock.Lock();
            try
            {
                listeners.Register(threadLocalCleanupBean);
                cachedForkStateEntries = null;
                IServiceContext currentBeanContext = BeanContextInitializer.GetCurrentBeanContext();
                if (currentBeanContext != null)
                {
                    extensionToContextMap.Put(threadLocalCleanupBean, new WeakReference(currentBeanContext));
                    if (alreadyHookedContextSet.PutIfNotExists(currentBeanContext, null))
                    {
                        ParamHolder <bool?> inactive = new ParamHolder <bool?>();

                        currentBeanContext.RegisterDisposeHook(new IBackgroundWorkerParamDelegate <IServiceContext>(delegate(IServiceContext state)
                        {
                            if (inactive.Value.HasValue && inactive.Value.Value)
                            {
                                return;
                            }
                            foreignContextHook(state);
                        }));
                        alreadyHookedContextSet.Put(currentBeanContext, inactive);
                    }
                }
            }
            finally
            {
                writeLock.Unlock();
            }
        }
コード例 #2
0
ファイル: CmdLine.cs プロジェクト: janproch/datadmin
        public static void LoadHolders(object obj, List <ParamHolder> res, string prefix)
        {
            int position = 0;

            foreach (PropertyInfo prop in obj.GetType().GetProperties())
            {
                foreach (CommandLineParameterAttribute attr in prop.GetCustomAttributes(typeof(CommandLineParameterAttribute), true))
                {
                    ParamHolder hld = new ParamHolder();
                    hld.m_attrib   = attr;
                    hld.m_property = prop;
                    hld.m_object   = obj;
                    hld.m_prefix   = prefix;

                    if (attr.Positional)
                    {
                        hld.m_position = position;
                        position++;
                    }
                    res.Add(hld);
                }
                foreach (CommandLineParameterCollectionAttribute attr in prop.GetCustomAttributes(typeof(CommandLineParameterCollectionAttribute), true))
                {
                    object pval = prop.GetGetMethod().Invoke(obj, new object[] { });
                    LoadHolders(pval, res, attr.Prefix != null ? (prefix ?? "") + attr.Prefix : prefix);
                }
            }
        }
コード例 #3
0
        private T[] GetDefaultInfoFull <T>(CCTVInfoType type)
        {
            checkRegister(type);
            ParamHolder <T> ph = _syncParams[type] as ParamHolder <T>;

            checkUpdate(ph);
            return(ph.Sync.Values.ToArray());
        }
コード例 #4
0
    public ParamHolder DatasToBookmark()
    {
        ParamHolder result = new ParamHolder();

        result.Set("posX", Datas.GetString("posX"));
        result.Set("posY", Datas.GetString("posY"));
        result.Set("posZ", Datas.GetString("posZ"));

        return(result);
    }
コード例 #5
0
ファイル: CCTVInfoSync.cs プロジェクト: windygu/SeecoolCCTV2
        /// <summary>
        /// 手动刷新用户自定义注册的信息。
        /// </summary>
        /// <typeparam name="T"></typeparam>
        public void UpdateRegistered <T>()
        {
            Type t = typeof(T);

            if (_dictSyncs.ContainsKey(t))
            {
                ParamHolder <T> holder = _dictSyncs[t] as ParamHolder <T>;
                holder.Sync.GetUpdate();
            }
        }
コード例 #6
0
        private T GetDefaultInfo <T>(CCTVInfoType type, string key)
        {
            checkRegister(type);
            ParamHolder <T> ph = _syncParams[type] as ParamHolder <T>;

            checkUpdate(ph);
            T value;

            ph.Sync.TryGetValue(key, out value);
            return(value);
        }
コード例 #7
0
ファイル: CCTVInfoSync.cs プロジェクト: windygu/SeecoolCCTV2
        public void UnregisterSynchronizer <T>()
        {
            Type t = typeof(T);

            if (_dictSyncs.ContainsKey(t))
            {
                ParamHolder <T> holder = _dictSyncs[t] as ParamHolder <T>;
                holder.Sync.Dispose();
                _dictSyncs.Remove(t);
            }
        }
コード例 #8
0
ファイル: MergeServiceRegistry.cs プロジェクト: vogelb/ambeth
        protected ICUDResult MergeCudResult(ICUDResult cudResult, ICUDResult explAndImplCudResult, Object implyingHandle,
                                            ParamHolder <Boolean> hasAtLeastOneImplicitChange, IncrementalMergeState state)
        {
            if (explAndImplCudResult == null || Object.ReferenceEquals(cudResult, explAndImplCudResult))
            {
                return(cudResult);
            }
            ICUDResult diffCUDResult = CudResultComparer.DiffCUDResult(cudResult, explAndImplCudResult);

            if (diffCUDResult == null)
            {
                return(cudResult);
            }
            hasAtLeastOneImplicitChange.Value = true;
            CudResultApplier.ApplyCUDResultOnEntitiesOfCache(diffCUDResult, false, state);
            if (Log.DebugEnabled)
            {
                Object currHandle = implyingHandle;
                if (currHandle is IProxyTargetAccessor)
                {
                    IInterceptor interceptor = ((IProxyTargetAccessor)currHandle).GetInterceptors()[0];
                    while (interceptor is CascadedInterceptor)
                    {
                        Object target = ((CascadedInterceptor)interceptor).Target;
                        if (target is IInterceptor)
                        {
                            interceptor = ((IInterceptor)target);
                            continue;
                        }
                        currHandle = target;
                        break;
                    }
                }
                if (currHandle == null)
                {
                    currHandle = implyingHandle;
                }
                if (CudResultPrinter != null)
                {
                    Log.Debug("Incremental merge [" + RuntimeHelpers.GetHashCode(state) + "] (" + currHandle.GetType().Name + "):\n"
                              + CudResultPrinter.PrintCUDResult(diffCUDResult, state));
                }
                else
                {
                    Log.Debug("Incremental merge [" + RuntimeHelpers.GetHashCode(state) + "]  (" + currHandle.GetType().Name + "). No Details printable");
                }
            }
            return(explAndImplCudResult);
        }
コード例 #9
0
ファイル: Animation.cs プロジェクト: CyrilToonkit/TK_BaseLib
        public List <string> GetAttributes()
        {
            List <string> attrs        = new List <string>();
            List <string> paramHolders = new List <string>(ParamHolder.Split(','));

            for (int i = 0; i < paramHolders.Count; i++)
            {
                paramHolders[i] = paramHolders[i].Trim();
            }

            if (Split)
            {
                if (paramHolders.Count < 2)
                {
                    paramHolders.Add(paramHolders[0]);
                }

                if (paramHolders[0].Contains("."))
                {
                    attrs.Add(paramHolders[0].Replace("$NAME", ExposedName).Replace("$SIDE", "Left"));
                }
                else
                {
                    attrs.Add(string.Format("{0}.Left_{1}", paramHolders[0].Replace("$NAME", ExposedName).Replace("$SIDE", "Left"), ExposedName));
                }

                if (paramHolders[1].Contains("."))
                {
                    attrs.Add(paramHolders[1].Replace("$NAME", ExposedName).Replace("$SIDE", "Right"));
                }
                else
                {
                    attrs.Add(string.Format("{0}.Right_{1}", paramHolders[1].Replace("$NAME", ExposedName).Replace("$SIDE", "Right"), ExposedName));
                }
            }
            else
            {
                if (paramHolders[0].Contains("."))
                {
                    attrs.Add(paramHolders[0].Replace("$NAME", ExposedName).Replace("$SIDE_", string.Empty).Replace("$SIDE", string.Empty));
                }
                else
                {
                    attrs.Add(string.Format("{0}.{1}", paramHolders[0].Replace("$NAME", ExposedName).Replace("$SIDE_", string.Empty).Replace("$SIDE", string.Empty), ExposedName));
                }
            }

            return(attrs);
        }
コード例 #10
0
        private void PutDefaultInfo <T>(CCTVInfoType type, string key, T info, bool isDeleted)
        {
            checkRegister(type);
            ParamHolder <T> ph = _syncParams[type] as ParamHolder <T>;

            ph.Sync.PutUpdate(new List <ObjectItem <T> >()
            {
                new ObjectItem <T>()
                {
                    Key       = key,
                    IsDeleted = isDeleted,
                    Item      = info
                }
            });
        }
コード例 #11
0
ファイル: CCTVInfoSync.cs プロジェクト: windygu/SeecoolCCTV2
        public void RegisterSynchronizer <T>(SyncParams <T> param)
        {
            Type t = typeof(T);

            if (_dictSyncs.ContainsKey(t))
            {
                ParamHolder <T> holder = _dictSyncs[t] as ParamHolder <T>;
                holder.Sync.Dispose();
            }
            StaticInfoSynchronizer <T> newSync = new StaticInfoSynchronizer <T>(_baseAddress, param.Section, param.Interval, param.SavePath, param.OnUpdate);

            _dictSyncs[t] = new ParamHolder <T>()
            {
                Sync  = newSync,
                Param = param
            };
        }
コード例 #12
0
ファイル: CCTVInfoSync.cs プロジェクト: windygu/SeecoolCCTV2
        public T[] GetAllRegisteredInfos <T>()
        {
            Type t = typeof(T);

            if (_dictSyncs.ContainsKey(t))
            {
                ParamHolder <T> holder = _dictSyncs[t] as ParamHolder <T>;
                if (!holder.HasUpdated())
                {
                    holder.Update();
                }
                return(holder.Sync.Values.ToArray());
            }
            else
            {
                throw new InvalidOperationException("尚未注册此类型的刷新服务:" + t);
            }
        }
コード例 #13
0
ファイル: CCTVInfoSync.cs プロジェクト: windygu/SeecoolCCTV2
        public T GetRegisteredInfo <T>(string key)
        {
            Type t = typeof(T);

            if (_dictSyncs.ContainsKey(t))
            {
                ParamHolder <T> holder = _dictSyncs[t] as ParamHolder <T>;
                if (!holder.HasUpdated())
                {
                    holder.Update();
                }
                T value = default(T);
                holder.Sync.TryGetValue(key, out value);
                return(value);
            }
            else
            {
                throw new InvalidOperationException("尚未注册此类型的刷新服务:" + t);
            }
        }
コード例 #14
0
ファイル: CCTVInfoSync.cs プロジェクト: windygu/SeecoolCCTV2
        public void PutRegisteredInfo <T>(string key, T info, bool isDeleted)
        {
            Type t = typeof(T);

            if (_dictSyncs.ContainsKey(t))
            {
                ParamHolder <T> holder = _dictSyncs[t] as ParamHolder <T>;
                holder.Sync.PutUpdate(new List <ObjectItem <T> >()
                {
                    new ObjectItem <T>()
                    {
                        Key       = key,
                        IsDeleted = isDeleted,
                        Item      = info
                    }
                });
            }
            else
            {
                throw new InvalidOperationException("尚未注册此类型的刷新服务:" + t);
            }
        }
コード例 #15
0
ファイル: MergeServiceRegistry.cs プロジェクト: vogelb/ambeth
        protected ICUDResult WhatIfMerged(ICUDResult cudResult, IMethodDescription methodDescription, List <MergeOperation> mergeOperationSequence,
                                          IncrementalMergeState incrementalState)
        {
            IList <MergeOperation> lastMergeOperationSequence;

            while (true)
            {
                IMap <Type, IList <IChangeContainer> > sortedChanges = BucketSortChanges(cudResult.AllChanges);
                lastMergeOperationSequence = CreateMergeOperationSequence(sortedChanges);

                ParamHolder <bool>     hasAtLeastOneImplicitChange = new ParamHolder <bool>(false);
                IList <MergeOperation> fLastMergeOperationSequence = lastMergeOperationSequence;
                cudResult = CacheContext.ExecuteWithCache(incrementalState.GetStateCache(), delegate(ICUDResult cudResult2)
                {
                    for (int a = 0, size = fLastMergeOperationSequence.Count; a < size; a++)
                    {
                        MergeOperation mergeOperation = fLastMergeOperationSequence[a];
                        IMergeServiceExtension mergeServiceExtension = mergeOperation.MergeServiceExtension;

                        ICUDResult explAndImplCudResult = mergeServiceExtension.EvaluateImplicitChanges(cudResult2, incrementalState);
                        cudResult2 = MergeCudResult(cudResult2, explAndImplCudResult, mergeServiceExtension, hasAtLeastOneImplicitChange,
                                                    incrementalState);
                    }
                    return(cudResult2);
                }, cudResult);
                foreach (IMergeListener mergeListener in mergeListeners.GetExtensions())
                {
                    ICUDResult explAndImplCudResult = mergeListener.PreMerge(cudResult, incrementalState.GetStateCache());
                    cudResult = MergeCudResult(cudResult, explAndImplCudResult, mergeListener, hasAtLeastOneImplicitChange, incrementalState);
                }
                if (!hasAtLeastOneImplicitChange.Value)
                {
                    break;
                }
            }
            mergeOperationSequence.AddRange(lastMergeOperationSequence);
            return(cudResult);
        }
コード例 #16
0
        public void RegisterDefault(CCTVInfoType type, TimeSpan interval, SyncUpdateHandler updateHandler, string savePath)
        {
            if (_syncParams.ContainsKey(type))
            {
                IDisposable dis = _syncParams[type] as IDisposable;
                dis.Dispose();
            }
            switch (type)
            {
            case CCTVInfoType.TargetTrackInfo:
            {
                SyncParams <CCTVTargetTrack>             sp   = new SyncParams <CCTVTargetTrack>(DefaultSections.TargetTrackInfo, interval, updateHandler, savePath);
                StaticInfoSynchronizer <CCTVTargetTrack> sync = new StaticInfoSynchronizer <CCTVTargetTrack>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate);
                _syncParams[type] = new ParamHolder <CCTVTargetTrack>()
                {
                    Sync  = sync,
                    Param = sp
                };
            }
            break;

            case CCTVInfoType.VideoAnalyzeInfo:
            {
                SyncParams <CCTVVideoAnalyze>             sp   = new SyncParams <CCTVVideoAnalyze>(DefaultSections.VideoAnalyzeInfo, interval, updateHandler, savePath);
                StaticInfoSynchronizer <CCTVVideoAnalyze> sync = new StaticInfoSynchronizer <CCTVVideoAnalyze>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate);
                _syncParams[type] = new ParamHolder <CCTVVideoAnalyze>()
                {
                    Sync  = sync,
                    Param = sp
                };
            }
            break;

            case CCTVInfoType.VideoTrackInfo:
            {
                SyncParams <CCTVVideoTrack>             sp   = new SyncParams <CCTVVideoTrack>(DefaultSections.VideoTrackInfo, interval, updateHandler, savePath);
                StaticInfoSynchronizer <CCTVVideoTrack> sync = new StaticInfoSynchronizer <CCTVVideoTrack>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate);
                _syncParams[type] = new ParamHolder <CCTVVideoTrack>()
                {
                    Sync  = sync,
                    Param = sp
                };
            }
            break;

            case CCTVInfoType.CameraLimitsInfo:
            {
                SyncParams <CCTVCameraLimits>             sp   = new SyncParams <CCTVCameraLimits>(DefaultSections.CameraLimitsInfo, interval, updateHandler, savePath);
                StaticInfoSynchronizer <CCTVCameraLimits> sync = new StaticInfoSynchronizer <CCTVCameraLimits>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate);
                _syncParams[type] = new ParamHolder <CCTVCameraLimits>()
                {
                    Sync  = sync,
                    Param = sp
                };
            }
            break;

            case CCTVInfoType.DynamicInfo:
            {
                SyncParams <CCTVDynamicInfo>             sp   = new SyncParams <CCTVDynamicInfo>(DefaultSections.DynamicInfo, interval, updateHandler, savePath);
                StaticInfoSynchronizer <CCTVDynamicInfo> sync = new StaticInfoSynchronizer <CCTVDynamicInfo>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate);
                _syncParams[type] = new ParamHolder <CCTVDynamicInfo>()
                {
                    Sync  = sync,
                    Param = sp
                };
            }
            break;

            case CCTVInfoType.GlobalInfo:
            {
                SyncParams <CCTVGlobalInfo>             sp   = new SyncParams <CCTVGlobalInfo>(DefaultSections.GlobalInfo, interval, updateHandler, savePath);
                StaticInfoSynchronizer <CCTVGlobalInfo> sync = new StaticInfoSynchronizer <CCTVGlobalInfo>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate);
                _syncParams[type] = new ParamHolder <CCTVGlobalInfo>()
                {
                    Sync  = sync,
                    Param = sp
                };
            }
            break;

            case CCTVInfoType.HierarchyInfo:
            {
                SyncParams <CCTVHierarchyInfo>             sp   = new SyncParams <CCTVHierarchyInfo>(HierarchyInfoUtil.CreateSection("Default"), interval, updateHandler, savePath);
                StaticInfoSynchronizer <CCTVHierarchyInfo> sync = new StaticInfoSynchronizer <CCTVHierarchyInfo>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate);
                _syncParams[type] = new ParamHolder <CCTVHierarchyInfo>()
                {
                    Sync  = sync,
                    Param = sp
                };
            }
            break;

            case CCTVInfoType.LogicalTree:
            {
                SyncParams <CCTVLogicalTree>             sp   = new SyncParams <CCTVLogicalTree>(DefaultSections.LogicalTree, interval, updateHandler, savePath);
                StaticInfoSynchronizer <CCTVLogicalTree> sync = new StaticInfoSynchronizer <CCTVLogicalTree>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate);
                _syncParams[type] = new ParamHolder <CCTVLogicalTree>()
                {
                    Sync  = sync,
                    Param = sp
                };
            }
            break;

            case CCTVInfoType.OnlineStatus:
            {
                SyncParams <CCTVOnlineStatus>             sp   = new SyncParams <CCTVOnlineStatus>(DefaultSections.OnlineStatus, interval, updateHandler, savePath);
                StaticInfoSynchronizer <CCTVOnlineStatus> sync = new StaticInfoSynchronizer <CCTVOnlineStatus>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate);
                _syncParams[type] = new ParamHolder <CCTVOnlineStatus>()
                {
                    Sync  = sync,
                    Param = sp
                };
            }
            break;

            case CCTVInfoType.ServerInfo:
            {
                SyncParams <CCTVServerInfo>             sp   = new SyncParams <CCTVServerInfo>(DefaultSections.ServerInfo, interval, updateHandler, savePath);
                StaticInfoSynchronizer <CCTVServerInfo> sync = new StaticInfoSynchronizer <CCTVServerInfo>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate);
                _syncParams[type] = new ParamHolder <CCTVServerInfo>()
                {
                    Sync  = sync,
                    Param = sp
                };
            }
            break;

            case CCTVInfoType.StaticInfo:
            {
                SyncParams <CCTVStaticInfo>             sp   = new SyncParams <CCTVStaticInfo>(DefaultSections.StaticInfo, interval, updateHandler, savePath);
                StaticInfoSynchronizer <CCTVStaticInfo> sync = new StaticInfoSynchronizer <CCTVStaticInfo>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate);
                _syncParams[type] = new ParamHolder <CCTVStaticInfo>()
                {
                    Sync  = sync,
                    Param = sp
                };
            }
            break;

            case CCTVInfoType.ControlConfig:
            {
                SyncParams <CCTVControlConfig>             sp   = new SyncParams <CCTVControlConfig>(DefaultSections.ControlConfig, interval, updateHandler, savePath);
                StaticInfoSynchronizer <CCTVControlConfig> sync = new StaticInfoSynchronizer <CCTVControlConfig>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate);
                _syncParams[type] = new ParamHolder <CCTVControlConfig>()
                {
                    Sync  = sync,
                    Param = sp
                };
            }
            break;

            case CCTVInfoType.DeviceInfo:
            {
                SyncParams <CCTVDeviceInfo>             sp   = new SyncParams <CCTVDeviceInfo>(DefaultSections.DeviceInfo, interval, updateHandler, savePath);
                StaticInfoSynchronizer <CCTVDeviceInfo> sync = new StaticInfoSynchronizer <CCTVDeviceInfo>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate);
                _syncParams[type] = new ParamHolder <CCTVDeviceInfo>()
                {
                    Sync  = sync,
                    Param = sp
                };
            }
            break;

            case CCTVInfoType.UserInfo:
            {
                SyncParams <CCTVUserInfo>             sp   = new SyncParams <CCTVUserInfo>(DefaultSections.UserInfo, interval, updateHandler, savePath);
                StaticInfoSynchronizer <CCTVUserInfo> sync = new StaticInfoSynchronizer <CCTVUserInfo>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate);
                _syncParams[type] = new ParamHolder <CCTVUserInfo>()
                {
                    Sync  = sync,
                    Param = sp
                };
            }
            break;

            case CCTVInfoType.Privilege:
            {
                SyncParams <CCTVPrivilege>             sp   = new SyncParams <CCTVPrivilege>(DefaultSections.Privilege, interval, updateHandler, savePath);
                StaticInfoSynchronizer <CCTVPrivilege> sync = new StaticInfoSynchronizer <CCTVPrivilege>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate);
                _syncParams[type] = new ParamHolder <CCTVPrivilege>()
                {
                    Sync  = sync,
                    Param = sp
                };
            }
            break;

            case CCTVInfoType.UserPrivilege:
            {
                {
                    SyncParams <CCTVUserPrivilege>             sp   = new SyncParams <CCTVUserPrivilege>(DefaultSections.UserPrivilege, interval, updateHandler, savePath);
                    StaticInfoSynchronizer <CCTVUserPrivilege> sync = new StaticInfoSynchronizer <CCTVUserPrivilege>(_baseAddress, sp.Section, sp.Interval, sp.SavePath, sp.OnUpdate);
                    _syncParams[type] = new ParamHolder <CCTVUserPrivilege>()
                    {
                        Sync  = sync,
                        Param = sp
                    };
                }
            }
            break;

            default:
                break;
            }
        }
コード例 #17
0
 public PointOfInterest(int id, int sector)
 {
     ID     = id;
     Sector = sector;
     Datas  = new ParamHolder();
 }