public static List <DTObject> CreateObjects(bool isPinned)
 {
     return(isPinned ? new List <DTObject>() : Symbiosis.TryMark(_objectsPool, () =>
     {
         return new List <DTObject>();
     }));
 }
 public static Dictionary <string, object> CreateDictionary(bool isPinned)
 {
     return(isPinned ? new Dictionary <string, object>() : Symbiosis.TryMark(_dicValuePool, () =>
     {
         return new Dictionary <string, object>();
     }));
 }
Beispiel #3
0
 /// <summary>
 /// 获得一个验证结果对象,该对象会与数据山下文共享生命周期
 /// </summary>
 /// <returns></returns>
 public static ValidationResult Create()
 {
     return(Symbiosis.TryMark(_resultPool, () =>
     {
         return new ValidationResult();
     }));
 }
 public static List <DTEntity> CreateDTEntities(bool isPinned)
 {
     return(isPinned ? new List <DTEntity>() : Symbiosis.TryMark(_entitiesPool, () =>
     {
         return new List <DTEntity>();
     }));
 }
        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);
        }
        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);
        }
        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);
        }
        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);
        }
        public static DTEObject CreateDTEObject(bool isPinned)
        {
            var dte = isPinned ? new DTEObject() : Symbiosis.TryMark(_dteObjectPool, () =>
            {
                return(new DTEObject());
            });

            dte.Init(isPinned);
            return(dte);
        }
Beispiel #10
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);
        }
Beispiel #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(); });
            }));
        }
Beispiel #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>();
         });
     }));
 }
Beispiel #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);
        }
Beispiel #14
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);
        }
Beispiel #15
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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
 protected override void EachTestInitialize()
 {
     try
     {
         PreEnterScene();
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         Symbiosis.Open();
         EnteredScene();
     }
 }
 protected override void EachTestCleanup()
 {
     try
     {
         PreLeaveScene();
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         Symbiosis.Close();
         LeftScene();
     }
 }
 protected override void EachTestCleanup()
 {
     Symbiosis.Close();
 }
 protected override void EachTestInitialize()
 {
     Symbiosis.Open();
 }
Beispiel #22
0
        public static Composite SymbCast( Symbiosis id, UnitSelectionDelegate on, SimpleBooleanDelegate req)
        {
            return new Decorator(
                ret => on(ret) != null
                    && SpellManager.HasSpell((int)id)
                    && req(ret),
                new Action(ret =>
                    {
                        WoWSpell spell = WoWSpell.FromId((int)id);
                        if (spell == null)
                            return RunStatus.Failure;

                        if (!SymbCanCast(spell, on(ret)))
                            return RunStatus.Failure;

                        // check we can cast it on target
                        // if (!Spell.CanCastHack(spell, on(ret), false, false, true))
                        //     return RunStatus.Failure;

                        Logger.Write(string.Format("Casting Symbiosis: {0} on {1}", spell.Name, on(ret).SafeName()));
                        if (!SpellManager.Cast(spell, on(ret)))
                        {
                            Logger.WriteDebug(Color.LightPink, "cast of Symbiosis: {0} on {1} failed!", spell.Name, on(ret).SafeName());
                            return RunStatus.Failure;
                        }

                        SingularRoutine.UpdateDiagnosticCastingState();
                        return RunStatus.Success;
                    })
                );
        }
Beispiel #23
0
        /// <summary>
        /// replacement for Spell.CanCastHack() since that does a lookup on SpellManager.Spells and 
        /// ability gained from Druid does not presently appear in that list after buff established (note: class receiving
        /// Symbiosis from Druid does get updated.)
        /// </summary>
        /// <param name="spell"></param>
        /// <param name="unit"></param>
        /// <returns></returns>
        public static bool SymbCanCast(Symbiosis id, WoWUnit unit)
        {
            WoWSpell spell = WoWSpell.FromId((int)id);
            if (spell == null)
                return false;

            return SymbCanCast(spell, unit);
        }
Beispiel #24
0
 public static Composite SymbBuff( Symbiosis id, UnitSelectionDelegate on, SimpleBooleanDelegate req)
 {
     return new Decorator(
         ret => on(ret) != null && !Me.HasAura((int) id),
         SymbCast(id, on, req)
         );
 }
 protected override void EachTestInitialize()
 {
     PreEnterScene();
     Symbiosis.Open();
     EnteredScene();
 }
 protected override void EachTestCleanup()
 {
     PreLeaveScene();
     Symbiosis.Close();
     LeftScene();
 }