예제 #1
0
 public static List <DTObject> CreateObjects(bool isPinned)
 {
     return(isPinned ? new List <DTObject>() : Symbiosis.TryMark(_objectsPool, () =>
     {
         return new List <DTObject>();
     }));
 }
예제 #2
0
 public static Dictionary <string, object> CreateDictionary(bool isPinned)
 {
     return(isPinned ? new Dictionary <string, object>() : Symbiosis.TryMark(_dicValuePool, () =>
     {
         return new Dictionary <string, object>();
     }));
 }
예제 #3
0
 public static List <DTEntity> CreateDTEntities(bool isPinned)
 {
     return(isPinned ? new List <DTEntity>() : Symbiosis.TryMark(_entitiesPool, () =>
     {
         return new List <DTEntity>();
     }));
 }
예제 #4
0
        private RunContext GetRunContextFromAppSession(Guid runId)
        {
            var ctxs = AppSession.GetOrAddItem("RunContext", () =>
            {
                var pool = DictionaryPool <Guid, RunContext> .Instance;
                return(Symbiosis.TryMark <Dictionary <Guid, RunContext> >(pool, () =>
                {
                    return new Dictionary <Guid, RunContext>();
                }));
            });

            RunContext ctx = null;

            if (!ctxs.TryGetValue(runId, out ctx))
            {
                lock (ctxs)
                {
                    if (!ctxs.TryGetValue(runId, out ctx))
                    {
                        ctx = new RunContext();
                        ctxs.Add(runId, ctx);
                    }
                }
            }
            return(ctx);
        }
예제 #5
0
 /// <summary>
 /// 获得一个验证结果对象,该对象会与数据山下文共享生命周期
 /// </summary>
 /// <returns></returns>
 public static ValidationResult Create()
 {
     return(Symbiosis.TryMark(_resultPool, () =>
     {
         return new ValidationResult();
     }));
 }
예제 #6
0
        public static DTObjectList CreateObjectList(DTEList owner, bool isPinned)
        {
            var list = isPinned ? new DTObjectList() : Symbiosis.TryMark(_objectListPool, () =>
            {
                return(new DTObjectList());
            });

            list.Init(owner, isPinned);
            return(list);
        }
예제 #7
0
        public static DTObjects CreateDTOjects(IList <DTObject> items, bool isPinned)
        {
            var objs = isPinned ? new DTObjects() : Symbiosis.TryMark(_DTObjectsPool, () =>
            {
                return(new DTObjects());
            });

            objs.SetList(items);
            return(objs);
        }
예제 #8
0
        public static DTEList CreateDTEList(string name, DTObject template, DTObjectList items, bool isPinned)
        {
            var dte = isPinned ? new DTEList() : Symbiosis.TryMark(_dteListPool, () =>
            {
                return(new DTEList());
            });

            dte.InitByClone(name, template, items, isPinned);
            return(dte);
        }
예제 #9
0
        public static DTEList CreateDTEList(List <DTObject> members, bool isPinned)
        {
            var dte = isPinned ? new DTEList() : Symbiosis.TryMark(_dteListPool, () =>
            {
                return(new DTEList());
            });

            dte.Init(isPinned, members);
            return(dte);
        }
예제 #10
0
        public static DTEObject CreateDTEObject(bool isPinned)
        {
            var dte = isPinned ? new DTEObject() : Symbiosis.TryMark(_dteObjectPool, () =>
            {
                return(new DTEObject());
            });

            dte.Init(isPinned);
            return(dte);
        }
예제 #11
0
        /// <summary>
        /// 获取事件参数
        /// </summary>
        /// <param name="objectType"></param>
        /// <param name="eventType"></param>
        /// <returns></returns>
        private static StatusEventArgs GetEventArgs(Type objectType)
        {
            string eventName = GetEventName(objectType, StatusEventType.Any); //通一会话中,同一个对象类型的状态事件的参数只有一个,不需要通过事件类型再来划分,因为这样用起来不灵活
            string argsName  = _getStatusEventArgsName(eventName);

            return(AppSession.GetOrAddItem <StatusEventArgs>(argsName, () =>
            {
                return Symbiosis.TryMark <StatusEventArgs>(StatusEventArgs.Pool, () => { return new StatusEventArgs(); });
            }));
        }
예제 #12
0
 private Dictionary <string, object> GetDatasFromAppSession()
 {
     return(AppSession.GetOrAddItem(_appSessionDatasKey, () =>
     {
         var pool = DictionaryPool <string, object> .Instance;
         return Symbiosis.TryMark <Dictionary <string, object> >(pool, () =>
         {
             return new Dictionary <string, object>();
         });
     }));
 }
예제 #13
0
        private static ValidationError CreateError(string errorCode, string message)
        {
            var error = Symbiosis.TryMark(_errorPool, () =>
            {
                return(new ValidationError());
            });

            error.ErrorCode = errorCode;
            error.Message   = message;
            return(error);
        }
예제 #14
0
        public static DTObject CreateObject(DTEObject root, bool isReadOnly, bool isPinned)
        {
            var obj = isPinned ? new DTObject() : Symbiosis.TryMark(_objectPool, () =>
            {
                return(new DTObject());
            });

            obj._root      = root;
            obj.IsReadOnly = isReadOnly;
            obj.IsPinned   = isPinned;
            return(obj);
        }
예제 #15
0
        public static DTEValue CreateDTEValue(string name, object value, bool isPinned)
        {
            var dte = isPinned ? new DTEValue() : Symbiosis.TryMark(_dteValuePool, () =>
            {
                return(new DTEValue());
            });

            dte.Init(isPinned);
            dte.Name  = name;
            dte.Value = value;
            return(dte);
        }
예제 #16
0
        private static PropertyValidationError CreatePropertyError(string propertyName, string errorCode, string message)
        {
            var error = Symbiosis.TryMark(_propertyErrorPool, () =>
            {
                return(new PropertyValidationError());
            });

            error.PropertyName = propertyName;
            error.ErrorCode    = errorCode;
            error.Message      = message;
            return(error);
        }
예제 #17
0
        private IEnumerable <T> GetObjectsFromEntries <T>(IQueryBuilder exp, Action <DynamicData> fillArg, QueryLevel level)
        {
            var list = Symbiosis.TryMark(ListPool <T> .Instance, () =>
            {
                return(new List <T>());
            });

            UseDataEntries(exp, fillArg, (entry) =>
            {
                var obj = GetObjectFromEntry(entry, level);
                list.Add((T)obj);
            });
            return(list);
        }