Ejemplo n.º 1
0
 public void Initialize()
 {
     _entityHandler       = Container.Resolve <IEntityHandler>();
     _entitySchemaHandler = Container.Resolve <IEntitySchemaHandler>();
     _appSetting          = Container.Resolve <IAppSetting>();
     InstallSchema();
 }
Ejemplo n.º 2
0
 public DeltaModelDictionary(IEntityHandler parent, string property, DeltaModelManager manager, TypeConfiguration configuration)
 {
     _manager     = manager;
     _typeConfig  = configuration;
     Parent       = parent;
     NameInParent = property;
 }
Ejemplo n.º 3
0
        private void AddChange(ChangeType type, IEntityHandler parent, string key, object value)
        {
            string path = GetPath(parent, key);

            Subscriptions.NotifyChange(null, type, parent, key, value);
            _clients.ForEach(client => AddChange(client, type, path, parent, key, value));
        }
Ejemplo n.º 4
0
 public object DeserializeAndApplyReplace(IEntityHandler parent, string key, object oldValue, TypeConfiguration typeConfig, Change change, DeserializingContext context)
 {
     change.OldValue = oldValue;
     SetObjectParent(oldValue, null, null);
     change.Value = DeserializeMemeberValue(typeConfig, parent, key, context);
     return(change.Value);
 }
 public void Initialize()
 {
     _entityHandler = Container.Resolve<IEntityHandler>();
     _entitySchemaHandler = Container.Resolve<IEntitySchemaHandler>();
     _appSetting = Container.Resolve<IAppSetting>();
     InstallSchema();
 }
Ejemplo n.º 6
0
        private void RootChange(Change change, DeserializingContext context)
        {
            _root        = DeserializeAndApplyReplace(null, "", _root, _configurations[_rootHandler.ProxyType], change, context);
            _rootHandler = ((IEntityHandlerProvider)_root).GetHandler();

            RootChanged?.Invoke(this, EventArgs.Empty);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 删除此记录
        /// </summary>
        /// <returns></returns>
        public virtual bool Delete(IDataBaseHandler handler)
        {
            ORMContext ctx = new ORMContext(handler.DbContext.ConnectionInfo);
            IEntityHandler <EntityBase> hand = ctx.CreateHandler <EntityBase>(this, handler);
            int i = hand.Delete();

            return(i > 0);
        }
Ejemplo n.º 8
0
 /// <summary>注册</summary>
 /// <param name="handler"></param>
 /// <returns></returns>
 public EntityHandlerManager Register(IEntityHandler handler)
 {
     if (handler != null)
     {
         Handlers.Add(handler);
     }
     return(this);
 }
Ejemplo n.º 9
0
 public EntityController(
     IEntityHandler entityHandler,
     IImplementationsContainer implementationsContainer,
     IPermissionService permissionService)
 {
     _entityHandler            = entityHandler;
     _implementationsContainer = implementationsContainer;
     _permissionService        = permissionService;
 }
Ejemplo n.º 10
0
 public HistoryController(
     LobToolsDbContext dbContext,
     IDataLogImplementation dataLogImplementation,
     IEntityHandler entityHandler)
 {
     _dbContext             = dbContext;
     _dataLogImplementation = dataLogImplementation;
     _entityHandler         = entityHandler;
 }
Ejemplo n.º 11
0
 public EntityController(
     IEntityHandler entityHandler,
     IImplementationsContainer implementationsContainer,
     IPermissionService permissionService,
     IObjectGraphHandler objectGraphHandler)
 {
     _entityHandler            = entityHandler;
     _implementationsContainer = implementationsContainer;
     _permissionService        = permissionService;
     _objectGraphHandler       = objectGraphHandler;
 }
        private void InjectSenderName(Event @event)
        {
            IEntityHandler handler = EntityHandlers[@event.SenderId];

            if (handler == null || !String.IsNullOrEmpty(@event.Sender))
            {
                return;
            }

            @event.Sender = !String.IsNullOrEmpty(handler.Name) ? handler.Name : handler.GetType().Name;
        }
Ejemplo n.º 13
0
 private bool IsRooted(IEntityHandler handler)
 {
     while (handler != null)
     {
         if (handler == _rootHandler)
         {
             return(true);
         }
         handler = handler.Parent;
     }
     return(false);
 }
Ejemplo n.º 14
0
 private void SetObjectParent(object obj, string key, IEntityHandler newParent)
 {
     if (obj is IEntityHandlerProvider provider)
     {
         var handler = provider.GetHandler();
         handler.Parent = newParent;
         if (key != null) //we want to keep to get id after object is detached
         {
             handler.NameInParent = key;
         }
     }
 }
Ejemplo n.º 15
0
 private void AddChange(ModelClient client, ChangeType type, string path, IEntityHandler parent, string key, object value)
 {
     if (CheckFilterToRoot(parent, key, client.Filter))
     {
         client.AddChange(new Change
         {
             Type       = type,
             Path       = path,
             Serialized = type == ChangeType.Remove ? null : Serialize(value, client.Filter)
         });
     }
 }
Ejemplo n.º 16
0
 internal void ChangeRemove(IEntityHandler parent, string key, object oldValue)
 {
     lock (this)
     {
         SetObjectParent(oldValue, null, null);
         if (IsRooted(parent))
         {
             AddChange(ChangeType.Remove, parent, key, null);
             DetachOldItem(null, oldValue);
         }
     }
 }
Ejemplo n.º 17
0
 private void ensureHandler(Dictionary <string, string> switches)
 {
     if (mHandler == null)
     {
         if (switches != null && switches.ContainsKey(HandlerAssembly))
         {
             var handlerPackage = this.ActorService.Context.CodePackageActivationContext.GetDataPackageObject("Handlers");
             var handlerPath    = Path.Combine(handlerPackage.Path, switches[HandlerAssembly]);
             var assembly       = Assembly.LoadFrom(handlerPath);
             mHandler = (IEntityHandler)assembly.CreateInstance(switches[HandlerType]);
         }
     }
 }
Ejemplo n.º 18
0
        internal void ChangeAdd(IEntityHandler parent, string key, object value)
        {
            lock (this)
            {
                SetObjectParent(value, key, parent);

                if (IsRooted(parent))
                {
                    AddChange(ChangeType.Add, parent, key, value);
                    AttachNewItem(null, value);
                }
            }
        }
Ejemplo n.º 19
0
 public ReportController(
     IImplementationsContainer implementationsContainer,
     IUsersService usersService,
     IRichTextDocumentHandler richTextDocumentHandler,
     IEntityHandler entityHandler,
     MetadataDbContext metadataDbContext)
 {
     _implementationsContainer = implementationsContainer;
     _usersService             = usersService;
     _richTextDocumentHandler  = richTextDocumentHandler;
     _entityHandler            = entityHandler;
     _metadataDbContext        = metadataDbContext;
 }
Ejemplo n.º 20
0
 public object DeserializeBsonValue(TypeConfiguration typeConfig, IEntityHandler parent, string property, BsonDeserializingContext context)
 {
     if (typeConfig.Creator != null)
     {
         var result  = typeConfig.Creator(parent, property);
         var handler = (IEntityHandlerProvider)result;
         handler.GetHandler().DeserializeBson(context);
         return(result);
     }
     else
     {
         return(BsonSerializer.Deserialize(context.BsonReader, typeConfig.Type));
     }
 }
Ejemplo n.º 21
0
        private string GetPath(IEntityHandler handler, string key)
        {
            LinkedList <string> result = new LinkedList <string>();

            result.AddFirst(key);

            while (handler != null)
            {
                key = handler.NameInParent;
                result.AddFirst(key);
                handler = handler.Parent;
            }

            return(string.Join("/", result));
        }
Ejemplo n.º 22
0
        protected virtual void ProcessMessage(Message message)
        {
            IEntityHandler handler = Context.EntityHandlers[message.TargetId];

            if (handler != null)
            {
                handler.ProcessMessage(message);
                _lastClientMessage = DateTime.Now;
            }
            else
            {
                string msg = String.Format("Invalid message target: {0}", message.TargetId);
                Platform.Log(LogLevel.Debug, msg);
                //throw new ArgumentException(msg);
            }
        }
Ejemplo n.º 23
0
 public object DeserializeMemeberValue(TypeConfiguration typeConfig, IEntityHandler parent, string property, DeserializingContext context)
 {
     if (typeConfig.IsExternalType)
     {
         return(context.Serializer.Deserialize(context.Reader, typeConfig.Type));
     }
     else if (typeConfig.Creator != null)
     {
         var result  = typeConfig.Creator(parent, property);
         var handler = (IEntityHandlerProvider)result;
         handler.GetHandler().Deserialize(context);
         return(result);
     }
     else
     {
         throw new Exception();
     }
 }
Ejemplo n.º 24
0
        private bool CheckFilterToRoot(IEntityHandler handler, string key, Filter filter)
        {
            if (handler == null)
            {
                return(true);
            }
            do
            {
                if (!filter.IsOk(handler.Proxy, handler.ProxyType, key))
                {
                    return(false);
                }

                key     = handler.NameInParent;
                handler = handler.Parent;
            }while (handler != null);

            return(true);
        }
        public DeltaModelInterceptor(TypeConfiguration configuration, DeltaModelManager manager, IEntityHandler parent, string property)
        {
            _typeConfig  = configuration;
            _manager     = manager;
            Parent       = parent;
            NameInParent = property;

            foreach (var prop in configuration.Members)
            {
                if (prop.Value.TypeConfiguration.ValueType != null)
                {
                    _values[prop.Key] = prop.Value.TypeConfiguration.Creator(this, prop.Key);
                }

                if (prop.Value.DefaultValue != null)
                {
                    _values[prop.Key] = prop.Value.DefaultValue;
                }
            }
        }
Ejemplo n.º 26
0
        protected object Create(Type type, IEntityHandler parent, string property)
        {
            var config      = _configurations[type];
            var interceptor = new DeltaModelInterceptor(config, this, parent, property);

            var interfaces = new List <Type> {
                typeof(INotifyPropertyChanged), typeof(IEntityHandlerProvider)
            };

            if (config.LocalCreator != null)
            {
                interfaces.Add(typeof(ILocalHolder));
            }

            var result = s_proxyGenerator.CreateInterfaceProxyWithoutTarget(type,
                                                                            interfaces.ToArray(),
                                                                            interceptor);

            interceptor.Proxy = result;
            return(result);
        }
Ejemplo n.º 27
0
        ////TODO (CR May 2010): We should add in the capability for handler extensions,
        /// much like the applicationcomponent views.
        public static ActionNodeEntityHandler Create(ActionModelNode modelNode)
        {
            if (modelNode is ActionNode)
            {
                IAction action = ((ActionNode)modelNode).Action;
                if (action is DropDownButtonAction)
                {
                    IEntityHandler handler = Create <DropDownButtonActionEntityHandler>();
                    handler.SetModelObject(action);
                    return((ActionNodeEntityHandler)handler);
                }
                if (action is DropDownAction)
                {
                    IEntityHandler handler = Create <DropDownActionEntityHandler>();
                    handler.SetModelObject(action);
                    return((ActionNodeEntityHandler)handler);
                }
                if (action is LayoutChangerAction)
                {
                    IEntityHandler handler = Create <LayoutChangerActionEntityHandler>();
                    handler.SetModelObject(action);
                    return((ActionNodeEntityHandler)handler);
                }
                if (action is IClickAction)
                {
                    IEntityHandler handler = Create <ClickActionEntityHandler>();
                    handler.SetModelObject(action);
                    return((ActionNodeEntityHandler)handler);
                }
            }
            else if (modelNode.ChildNodes.Count > 0)
            {
                IEntityHandler handler = Create <BranchActionEntityHandler>();
                handler.SetModelObject(modelNode);
                return((ActionNodeEntityHandler)handler);
            }

            //TODO (CR May 2010): although we won't get here, if we did, we should throw
            return(null);
        }
Ejemplo n.º 28
0
        /// <summary>
        /// 根据查询条件取得第一条记录的第一个字段值
        /// </summary>
        /// <param name="ReturnField"></param>
        /// <param name="Stru"></param>
        /// <param name="handler"></param>
        /// <returns></returns>
        public static object GetOneFieldBy(string ReturnField, TblStruBase Stru, IDataBaseHandler handler)
        {
            ORMContext ctx = new ORMContext(handler.DbContext.ConnectionInfo);
            IEntityHandler <TblStruBase> hand = ctx.CreateHandler <TblStruBase>(Stru, handler);

            if (!String.IsNullOrEmpty(Stru.ParameterSQL))
            {
                IDataParameter[] paras = null;
                Hashtable        hash  = Stru.__Parameters;
                if (hash != null && hash.Count > 0)
                {
                    IDataParameters dps = new DataParameters(handler.DbAdapter);
                    foreach (String key in hash)
                    {
                        dps.AddParameterValue(key, hash[key]);
                    }
                    paras = dps.Parameters;
                }
                return(hand.GetOneField(ReturnField, Stru.ParameterSQL, paras));
            }
            return(hand.GetOneField(ReturnField));
        }
Ejemplo n.º 29
0
 public void Initialize(Vector3 gravity, int seed)
 {
     TerrainContext = new TerrainContext(seed);
     PhysicsHandler = new JitterPhysicsHandler(gravity);
     EntityHandler = new EntityHandler();
 }
Ejemplo n.º 30
0
 public EdgeService(IConfiguration config, IEntityHandler <TDataModel, TTypeDataId> handler)
 {
     _handler = handler;
     _edgeElasticIndexName = config["TransactionsIndexName"];
 }
Ejemplo n.º 31
0
 internal void SetEntityHandler(IEntityHandler <EntityType> entityHandler) =>
 _entityHandler ??= entityHandler;
Ejemplo n.º 32
0
		public void Add(IEntityHandler handler)
		{
			lock (_syncLock)
				_handlers.Add(handler.Identifier, handler);
		}
Ejemplo n.º 33
0
		public void Remove(IEntityHandler handler)
		{
			lock (_syncLock)
				_handlers.Remove(handler.Identifier);
		}
Ejemplo n.º 34
0
 public Simulator(IEntityHandler handler, int entityCount)
 {
     this.handler     = handler;
     this.entityCount = entityCount;
 }
Ejemplo n.º 35
0
 public void Initialize(GameContext context, Vector2i viewDistance, Vector3 gravity, int seed)
 {
     TerrainContext = new TerrainContext(context, viewDistance, seed);
     PhysicsHandler = new JitterPhysicsHandler(gravity);
     EntityHandler = new EntityHandler();
 }