Пример #1
0
 public PolynomialLeastSquares(Behaviors.PointSelector.CompressedPointSelectorWrapper selector)
     : base(selector)
 {
     
     _coefs = MathNet.Numerics.Fit.Polynomial(selector.Select(x => (double)x.Value).ToArray(), selector.Select(x => (double)x.Rcs).ToArray(),
         selector.Count() - 1);
 }
Пример #2
0
        protected Line Element(Unit left = default(Unit),
            Unit top = default(Unit),
            Unit innerHeight = default(Unit),
            bool breakable = false,
            bool followLineHeight = false,
            Unit border = default(Unit),
            bool keepWithNextLine = false,
            Behaviors behavior = null,
            IEnumerable<Line> children = null)
        {
            // Top offsets are not allowed in real usage, so we fake one by adding an element
            if (lines.Count == 0 && top > 0.cm())
            {
                lines.Add(new Line(0.cm(), false, new LayoutedElement(new TestSpecification
                {
                    Breakable = true,
                    OrphanHeight = 0.cm(),
                    WidowHeight = 0.cm()
                }, Children.Empty)
                {
                    Name = "Spacer",
                    ForcedInnerHeight = top,
                }));
            }

            var line = ChildElement(left, top, innerHeight, breakable, followLineHeight, border, keepWithNextLine, behavior, children);
            lines.Add(line);
            return line;
        }
Пример #3
0
 internal NotifySpellEvent(Game game, string notification, Behaviors.ICastableSpell spell, string message)
     : base(game, notification)
 {
     Debug.Assert(spell != null);
     Spell = spell;
     Message = message;
 }
Пример #4
0
        public SaveForm(string savePath, int fileWidth, int fileHeight, AreaSelector selector, Behaviors.TileCreator.TileOutputType outputType,
            Behaviors.Filters.ImageFilterProxy imageFilter = null, System.Drawing.Imaging.ColorPalette palette = null)
        {

            InitializeComponent();

            _savePath = savePath;
            _fileWidth = fileWidth;
            _fileHeight = fileHeight;
            _imageFilter = imageFilter;
            _palette = palette;

            _selector = selector;

            if (selector.Area.Height != 0)
            {
                radioButton3.Checked = true;
            }

            _outputType = outputType;
            outputTypeCb.SelectedIndex = (int)outputType;

            FormsHelper.AddTbClickEvent<MaskedTextBox>(this.Controls);
            InitControls(selector.Area.Location.X, selector.Area.Location.Y, selector.Area.Width, selector.Area.Height);
        }
Пример #5
0
        public BotControl(Behaviors.Bot bot)
        {
            Bot = bot;
            InitializeComponent();

            bot.CharactersSelected += OnCharacterSelected;
        }
Пример #6
0
        public ReportSettingsForm(Behaviors.ReportGenerator.ReporterSettings reporterSettings = null)
        {
            InitializeComponent();
            reportTypeComboBox.Items.AddRange(Enum.GetNames(typeof(Behaviors.ReportGenerator.Abstract.ReporterTypes)));
            reportTypeComboBox.SelectedIndex = 0;

            if (reporterSettings == null)
            {
                finishAtLastCb.Checked = true;
                areaCb.Checked = true;
                centerCb.Checked = false;
                cornersCb.Checked = true;
                headerInfoCb.Checked = false;
                timeCb.Checked = true;
            }
            else
            {
                finishAtLastCb.Checked = reporterSettings.ReadToEnd;
                areaCb.Checked = reporterSettings.AddArea;
                centerCb.Checked = reporterSettings.AddCenter;
                cornersCb.Checked = reporterSettings.AddCorners;
                headerInfoCb.Checked = reporterSettings.AddParametersTable;
                timeCb.Checked = reporterSettings.AddTimes;
            }
            FormsHelper.AddTbClickEvent<MaskedTextBox>(this.Controls);
        }
Пример #7
0
 public BehaviorBase(GameObject owner)
 {
     _owner = owner;
     _selectedBehavior = _owner.GetComponent<SelectedBehavior>();
     _visual = _owner.GetComponent<Visual>();
     _behaviors = _owner.GetComponent<Behaviors>();
 }
Пример #8
0
    private void stab(Transform enemy)
    {
        // If our approach timed out, retreat to previous behavior

        if (Time.timeSinceLevelLoad - lastStabTime > STABTIMEOUT) {
            currentBehavior = previousBehavior;
            previousBehavior = Behaviors.STAB;
        }

        // If the enemy is out of poke range, approach it

        if (Vector3.Distance(transform.position, enemy.position) > pikeRange) {
            Debug.DrawLine(transform.position, enemy.position, Color.yellow);
            transform.LookAt(enemy);
            transform.position = Vector3.MoveTowards(transform.position, enemy.position, speed * Time.deltaTime);
        }

        // Else we attack!

        else {
            Debug.DrawLine(transform.position, enemy.position, Color.red);
            // play stabbing animation
            // do damage
        }
    }
Пример #9
0
 public override Behaviors.CrossAppCommunication.PointSharer.MulticastPointSharer Create(Files.LocatorFile file,
     Behaviors.CrossAppCommunication.ICrossAppExchange server, int guid)
 {
     var header = (Headers.Concrete.Rl8.Rl8Header)file.Header;
     return new Behaviors.CrossAppCommunication.PointSharer.MulticastPointSharer(server, guid,
         header.HeaderStruct.rlParams.sx, header.HeaderStruct.rlParams.sy);
 }
Пример #10
0
        protected Line ChildElement(Unit left = default(Unit),
            Unit top = default(Unit),
            Unit innerHeight = default(Unit),
            bool breakable = false,
            bool followLineHeight = false,
            Unit border = default(Unit),
            bool keepWithNextLine = false,
            Behaviors behavior = null,
            IEnumerable<Line> children = null)
        {
            LayoutedElement element;
            if (children == null)
            {
                element = new LayoutedElement(new TestSpecification(), Children.Empty);
            }
            else
            {
                element = new LayoutedElement(new TestSpecification(), new Children(children.GroupBy(x => x.Top).SelectMany(x => x)));
            }

            element.Left = left;
            element.ForcedInnerHeight = innerHeight;
            element.Specification.FollowLineHeight = followLineHeight;
            element.Specification.Breakable = breakable;
            element.Specification.Margins = new Margins { Bottom = border, Left = border, Right = border, Top = border };
            element.Specification.Behavior = behavior ?? new NullBehavior();

            return new Line(top, keepWithNextLine, element);
        }
Пример #11
0
 public Aligning(Files.LocatorFile file, PointSelector.CompressedPointSelectorWrapper selector,
     Behaviors.ImageAligning.IInterpolationProvider rcsProvider,
     Behaviors.ImageAligning.Surfaces.SurfaceType surfaceType, int baseRadius, int layers, double lambda)
 {
     _file = file;
     _selector = selector;
     _surface = Factories.Surface.SurfaceFactory.CreateSurface(_selector, rcsProvider, surfaceType, baseRadius, layers, lambda);
 }
        internal void NeedInteraction(Behaviors.IBehavior user, int ticket, bool compulsory, Interactions.IQuickInteraction io)
        {
            if (io == null)
            {
                throw new ArgumentNullException("io");
            }

            AddInteractionCondition(user, ticket, compulsory, io, null);
        }
Пример #13
0
        public CastSpell(Behaviors.IBehavior spell)
        {
            if (spell == null)
            {
                throw new ArgumentNullException("spell");
            }

            Spell = spell;
        }
Пример #14
0
        public BehaviorEditor(bool hasNull, Behaviors.IBehaviorModel initialValue)
        {
            InitializeComponent();

            Font = SystemFonts.MessageBoxFont;

            m_hasNull = hasNull;
            EditedBehaviorModel = initialValue;
        }
Пример #15
0
        /// <summary>
        /// Instantiates all the behaviors that this fish knows about
        /// </summary>
        public void BuildBehaviors()
        {
            fleeReaction = new FleeBehavior(this);

            Behaviors fishReactions = new Behaviors();
            fishReactions.Add(new AlignBehavior(this));
            fishReactions.Add(new CohesionBehavior(this));
            fishReactions.Add(new SeparationBehavior(this));
            behaviors.Add(AnimalType.Fish, fishReactions);
        }
Пример #16
0
        public StatisticsForm(Files.LocatorFile file, Behaviors.AreaSelector.AreaSelector areaSelector)
        {
            InitializeComponent();
         
            var dgv = FormsHelper.GetDataGrid(this, "Параметр", "Значение");
            this.Controls.Add(dgv);

            var statsInfo = GetStatistics(file, areaSelector);
            ShowInfo(statsInfo, dgv);
        }
Пример #17
0
        public void AddChild(Behaviors.Bot bot)
        {
            var child = new MdiChild();
            child.Title = "Bot";
            child.Content = new BotControl(bot);

            child.Closed += OnChildClosed;

            MdiContainer.Children.Add(child);
        }
Пример #18
0
        public SendBehaviorMessage(Behaviors.IBehavior target, int messageId, object arg)
        {
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }

            Target = target;
            MessageId = messageId;
            Arg = arg;
        }
Пример #19
0
 public SaverParams(string path, Point leftTop, int width, int height, Behaviors.TileCreator.TileOutputType outputType,
     Behaviors.Filters.ImageFilterProxy imageFilter, System.Drawing.Imaging.ColorPalette palette)
 {
     _path = path;
     _leftTop = leftTop;
     _width = width;
     _height = height;
     _outputType = outputType;
     _imageFilter = imageFilter;
     _palette = palette;
 }
Пример #20
0
 public void NeedOptionalTargets(Behaviors.IBehavior user, IEnumerable<CardInstance> candidates, string message)
 {
     var ctx = m_resolveContextStack.Peek();
     var initiativeCmd = ctx.RunningCommand as Commands.IInitiativeCommand;
     if (initiativeCmd == null)
     {
         throw new InvalidOperationException("Running command is not an initiative command.");
     }
     ctx.NeedInteraction(user, DefaultTargetTicket, false,
         new Interactions.SelectCards(initiativeCmd.Initiator, candidates, Interactions.SelectCards.SelectMode.Single, message));
 }
Пример #21
0
        public void RemoveChild(Behaviors.Bot bot)
        {
            var childs = MdiContainer.Children.
                Where(entry => entry.Content is BotControl && ( entry.Content as BotControl ).Bot == bot).ToArray();

            foreach (var child in childs)
            {
                child.Content = null;
                child.Close();
            }
        }
Пример #22
0
        public static ReporterFactory GetFactory(Behaviors.ReportGenerator.Abstract.ReporterTypes reporterType)
        {
            switch(reporterType)
            {
                case Behaviors.ReportGenerator.Abstract.ReporterTypes.Docx:
                    return new Concrete.DocReporterFactory();
                
            }

            throw new NotImplementedException("reporterType");
        }
        protected void Validate(Behaviors.IBehavior behavior)
        {
            if (behavior == null)
            {
                FailValidation("Behavior to be added can't be null.");
            }
            else if (behavior.Host == null)
            {
                FailValidation("Behavior hasn't been bound.");
            }

            Validate(behavior.Host);
        }
Пример #24
0
        private void AddBehaviorToCurrentCardNode(Behaviors.IBehaviorModel bhvModel)
        {
            var cardNode = treeViewCards.SelectedNode.Tag is EditorCardModel
                           ? treeViewCards.SelectedNode
                           : treeViewCards.SelectedNode.Parent;
            var cardModel = cardNode.Tag as EditorCardModel;

            cardModel.Behaviors.Add(bhvModel);
            AddBehavior(bhvModel, cardNode, true);

            m_isModified = true;
            UpdateTitle();
        }
        public static void SetBehaviors(DependencyObject element, Behaviors value)
        {
            if (value == null)
                return;

            value.Owner = element;
            value.Each(x => x.Owner = element);

            element.SetValue(BehaviorsProperty, value);

            var collection = (INotifyCollectionChanged)value;
            collection.CollectionChanged += CollectionChanged;
        }
Пример #26
0
        public AddBehavior(CardInstance target, Behaviors.IBehavior behavior)
        {
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }
            else if (behavior == null)
            {
                throw new ArgumentNullException("behavior");
            }

            Target = target;
            Behavior = behavior;
        }
        public static Behaviors GetBehaviors(DependencyObject element)
        {
            if (element == null)
                throw new ArgumentNullException("element");

            var behaviors = element.GetValue(BehaviorsProperty) as Behaviors;
            if (behaviors == null)
            {
                behaviors = new Behaviors();
                behaviors.Owner = element;
                SetBehaviors(element, behaviors);
            }
            return behaviors;
        }
Пример #28
0
        public LinearLeastSquares(Behaviors.PointSelector.CompressedPointSelectorWrapper selector) : base(selector)
        {


            var points = selector.Select(x => new PointF(x.Value, x.Rcs));

            //var ps = MathNet.Numerics.Fit.Polynomial(selector.Select(x => (double)x.Value).ToArray(), selector.Select(x => (double)x.Rcs).ToArray(),
            //    selector.Count(), MathNet.Numerics.LinearRegression.DirectRegressionMethod.NormalEquations);

            //var p = MathNet.Numerics.LinearRegression.SimpleRegression.Fit(selector.Select(x => (double)x.Value).ToArray(), selector.Select(x => (double)x.Rcs).ToArray());

            _slope = SlopeOfPoints(points); //(float)p.Item2;
            _yIntercept = YInterceptOfPoints(points, _slope); //(float)p.Item1;
        }
Пример #29
0
 protected ElementSpecification Element(Unit innerWidth = default(Unit),
     Unit innerHeight = default(Unit),
     bool breakable = false,
     bool followLineHeight = false,
     FlowStyle flow = FlowStyle.Float,
     Unit border = default(Unit),
     bool keepWithNextLine = false,
     Behaviors behavior = null,
     IEnumerable<ElementSpecification> children = null)
 {
     var line = ChildElement(innerWidth, innerHeight, breakable, followLineHeight, flow, border, keepWithNextLine, behavior, children);
     elements.Add(line);
     return line;
 }
Пример #30
0
        public SpecialEnemy(SpecialScreen parent, int row, int x, int y, int shootingrate, int behavior, int speed, int amplitude, int time, bool track)
        {
            this.parent = parent;
            graphicsRow = row;
            location = new Vector2(x, y);
            next_loc = location;

            shootingRate = shootingrate;
            currentBehavior = (Behaviors)behavior;
            this.speed = speed;
            this.amplitude = amplitude;
            this.time = time;
            this.track = track;
        }
Пример #31
0
 /// <summary>
 ///     Fetches all entities using the given scan specification from the database.
 /// </summary>
 /// <param name="entityType">
 ///     The entity type.
 /// </param>
 /// <param name="scanSpec">
 ///     The scan specification.
 /// </param>
 /// <param name="behaviors">
 ///     The behaviors.
 /// </param>
 /// <returns>
 ///     The entities fetched.
 /// </returns>
 public IEnumerable Fetch(Type entityType, ScanSpec scanSpec, Behaviors behaviors)
 {
     this.ThrowIfDisposed();
     return(this.entityContext.Fetch(entityType, scanSpec, this.CheckBehaviors(behaviors)));
 }
Пример #32
0
 /// <summary>
 ///     Gets a value indicating whether the behavior is create always.
 /// </summary>
 /// <return>
 ///     <c>true</c> if create always behaviors, otherwise <c>false</c>.
 /// </return>
 public static bool IsCreateAlways(this Behaviors behaviors)
 {
     return((behaviors & Behaviors.CreateBehaviors) == Behaviors.CreateAlways);
 }
Пример #33
0
        private void PopulateElementSavesFromReferences(string projectRootDirectory, GumLoadResult result)
        {
            string errors = "";

            Screens.Clear();
            Components.Clear();
            StandardElements.Clear();
            Behaviors.Clear();

            foreach (ElementReference reference in ScreenReferences)
            {
                ScreenSave toAdd = null;
                try
                {
                    toAdd = reference.ToElementSave <ScreenSave>(projectRootDirectory, ScreenExtension, result);
                }
                catch (Exception e)
                {
                    errors += "\nError loading " + reference.Name + ":\n" + e.Message;
                }
                if (toAdd != null)
                {
                    Screens.Add(toAdd);
                }
            }

            foreach (ElementReference reference in ComponentReferences)
            {
                ComponentSave toAdd = null;

                try
                {
                    toAdd = reference.ToElementSave <ComponentSave>(projectRootDirectory, ComponentExtension, result);
                }
                catch (Exception e)
                {
                    errors += "\nError loading " + reference.Name + ":\n" + e.Message;
                }
                if (toAdd != null)
                {
                    Components.Add(toAdd);
                }
            }

            foreach (ElementReference reference in StandardElementReferences)
            {
                StandardElementSave toAdd = null;
                try
                {
                    toAdd = reference.ToElementSave <StandardElementSave>(projectRootDirectory, StandardExtension, result);
                }
                catch (Exception e)
                {
                    errors += "\nError loading " + reference.Name + ":\n" + e.Message;
                }
                if (toAdd != null)
                {
                    StandardElements.Add(toAdd);
                }
            }

            foreach (var reference in BehaviorReferences)
            {
                BehaviorSave toAdd = null;

                try
                {
                    toAdd = reference.ToBehaviorSave(projectRootDirectory);
                }
                catch (Exception e)
                {
                    errors += "\nError loading " + reference.Name + ":\n" + e.Message;
                }
                if (toAdd != null)
                {
                    Behaviors.Add(toAdd);
                }
            }

            result.ErrorMessage += errors;
        }
Пример #34
0
 /// <summary>
 /// Gets behavior by type.
 /// </summary>
 /// <typeparam name="T">Behavior type</typeparam>
 /// <returns>Behavior of type or null.</returns>
 public T GetBehavior <T>() where T : Behavior
 {
     return(Behaviors.OfType <T>().FirstOrDefault());
 }
Пример #35
0
 public static BComponent Build(XmlNode xmlDoc, BComponent parent, Behaviors behaviorManager)
 {
     return(new UntilTrue(parent, behaviorManager, xmlDoc));
 }
Пример #36
0
 /// <summary>
 ///     Find the entities in the database using the key providers specified.
 /// </summary>
 /// <param name="entityType">
 ///     The entity type.
 /// </param>
 /// <param name="keyProviders">
 ///     The key providers.
 /// </param>
 /// <param name="entitySink">
 ///     The entity sink, receives the entities fetched.
 /// </param>
 /// <param name="behaviors">
 ///     The behaviors.
 /// </param>
 public void FindMany(Type entityType, IEnumerable keyProviders, Action <object> entitySink, Behaviors behaviors)
 {
     this.ThrowIfDisposed();
     this.entityContext.FindMany(entityType, keyProviders, entitySink, this.CheckBehaviors(behaviors));
 }
Пример #37
0
 /// <summary>
 ///     Gets a value indicating whether the behavior is bypass write cache.
 /// </summary>
 /// <return>
 ///     <c>true</c> if bypass write cache behaviors, otherwise <c>false</c>.
 /// </return>
 public static bool BypassWriteCache(this Behaviors behaviors)
 {
     return((behaviors & Behaviors.BypassWriteCache) > 0);
 }
Пример #38
0
 /// <summary>
 ///     Fetches all entities using the given  scan specification from the database.
 /// </summary>
 /// <param name="scanSpec">
 ///     The scan specification.
 /// </param>
 /// <param name="entitySink">
 ///     The entity sink, receives the entities fetched.
 /// </param>
 /// <param name="behaviors">
 ///     The behaviors.
 /// </param>
 /// <typeparam name="T">
 ///     Type of the entities to fetch.
 /// </typeparam>
 public void Fetch <T>(ScanSpec scanSpec, Action <T> entitySink, Behaviors behaviors) where T : class
 {
     this.Fetch(typeof(T), scanSpec, OfType <T>(entitySink), this.CheckBehaviors(behaviors));
 }
Пример #39
0
 /// <summary>
 ///     Find the entities in the database using the key providers specified.
 /// </summary>
 /// <param name="keyProviders">
 ///     The key providers.
 /// </param>
 /// <param name="behaviors">
 ///     The behaviors.
 /// </param>
 /// <typeparam name="T">
 ///     Type of the entities to find.
 /// </typeparam>
 /// <returns>
 ///     The entities found.
 /// </returns>
 public IEnumerable <T> FindMany <T>(IEnumerable keyProviders, Behaviors behaviors) where T : class
 {
     return(OfType <T>(this.FindMany(typeof(T), keyProviders, this.CheckBehaviors(behaviors))));
 }
Пример #40
0
 /// <summary>
 ///     Gets a value indicating whether the behavior is create new.
 /// </summary>
 /// <return>
 ///     <c>true</c> if create new behaviors, otherwise <c>false</c>.
 /// </return>
 public static bool IsCreateNew(this Behaviors behaviors)
 {
     return((behaviors & Behaviors.CreateBehaviors) == Behaviors.CreateNew);
 }
Пример #41
0
 public SteeringBehavior GetBehavior(SteeringBehavior.Type_ type)
 {
     return(Behaviors.GetBehavior(type).Behavior);
 }
Пример #42
0
 /// <summary>
 ///     Find an entity in the database using the key provider specified.
 /// </summary>
 /// <param name="keyProvider">
 ///     The key provider.
 /// </param>
 /// <param name="behaviors">
 ///     The behaviors.
 /// </param>
 /// <typeparam name="T">
 ///     Type of the entity to find.
 /// </typeparam>
 /// <returns>
 ///     The found entity instance or null if the entity does not exist.
 /// </returns>
 public T Find <T>(object keyProvider, Behaviors behaviors) where T : class
 {
     return((T)this.Find(typeof(T), keyProvider, this.CheckBehaviors(behaviors)));
 }
Пример #43
0
 public void BehaviorOff(SteeringBehavior.Type_ type)
 {
     Behaviors.GetBehavior(type).Behavior.ActiveOff();
 }
Пример #44
0
 /// <summary>
 ///     Gets a value indicating whether the behavior is default.
 /// </summary>
 /// <return>
 ///     <c>true</c> if default behaviors, otherwise <c>false</c>.
 /// </return>
 public static bool IsDefault(this Behaviors behaviors)
 {
     return((behaviors & Behaviors.CreateBehaviors) == Behaviors.Default);
 }
Пример #45
0
 public UntilTrue(BComponent parent, Behaviors behaviorManager, XmlNode xmlDoc)
 {
     this.behaviors       = new BComponent[] { GetComponent(this, behaviorManager, xmlDoc) };
     this.parent          = parent;
     this.behaviorManager = behaviorManager;
 }
        private void BuildFromAttributes()
        {
            Behaviors bhvs = new Behaviors();

            // Launch reflexion
            MemberInfo[] memberInfo = GetType().GetMethods(BindingFlags.NonPublic | BindingFlags.Instance);
            foreach (var mi in memberInfo)
            {
#if NETCOREAPP1_1
                BehaviorAttribute deco = mi.GetCustomAttribute <BehaviorAttribute>();
#else
                BehaviorAttribute deco = (BehaviorAttribute)Attribute.GetCustomAttribute(mi, typeof(BehaviorAttribute));
#endif
                if (deco != null)
                {
                    var parameters = ((MethodInfo)mi).GetParameters();
                    switch (parameters.Length)
                    {
                    case 0:
                    {
                        throw new ActorException(MessageCantUseDecoratedActporOnNullMessage);
                    }

                    case 1:
                    {
                        Behavior bhv = new Behavior(
                            s => parameters[0].ParameterType.IsAssignableFrom(s.GetType()),
                            s => ((MethodInfo)mi).Invoke(this, new[] { s }));
                        bhvs.AddBehavior(bhv);
                        break;
                    }

                    case 2:
                    {
                        Behavior bhv = new Behavior(
                            s =>
                            {
                                var ts = s.GetType();
                                return(ts.Name == typeof(MessageParam <,>).Name);
                            },
                            s =>
                            {
                                var ts   = s.GetType();
                                var arg1 = ts.GetProperty("Item1").GetValue(s);
                                var arg2 = ts.GetProperty("Item2").GetValue(s);
                                ((MethodInfo)mi).Invoke(this, new[] { arg1, arg2 });
                            });
                        bhvs.AddBehavior(bhv);
                        break;
                    }

                    case 3:
                    {
                        Behavior bhv = new Behavior(
                            s =>
                            {
                                var ts = s.GetType();
                                return(ts.Name == typeof(MessageParam <, ,>).Name);
                            },
                            s =>
                            {
                                var ts   = s.GetType();
                                var arg1 = ts.GetProperty("Item1").GetValue(s);
                                var arg2 = ts.GetProperty("Item2").GetValue(s);
                                var arg3 = ts.GetProperty("Item3").GetValue(s);
                                ((MethodInfo)mi).Invoke(this, new[] { arg1, arg2, arg3 });
                            });
                        bhvs.AddBehavior(bhv);
                        break;
                    }

                    default:
                    {
                        throw new ActorException("Can't use Decorated Actor on too much arguments");
                    }
                    }
                }
            }
            Become(bhvs);
        }
Пример #47
0
 /// <summary>
 ///     Find the entities in the database using the key providers specified.
 /// </summary>
 /// <param name="keyProviders">
 ///     The key providers.
 /// </param>
 /// <param name="entitySink">
 ///     The entity sink, receives the entities fetched.
 /// </param>
 /// <param name="behaviors">
 ///     The behaviors.
 /// </param>
 /// <typeparam name="T">
 ///     Type of the entities to find.
 /// </typeparam>
 public void FindMany <T>(IEnumerable keyProviders, Action <T> entitySink, Behaviors behaviors) where T : class
 {
     this.FindMany(typeof(T), keyProviders, OfType <T>(entitySink), this.CheckBehaviors(behaviors));
 }
Пример #48
0
 /// <summary>
 ///     Fetches all entities using the given scan specification from the database.
 /// </summary>
 /// <param name="entityType">
 ///     The entity type.
 /// </param>
 /// <param name="scanSpec">
 ///     The scan specification.
 /// </param>
 /// <param name="entitySink">
 ///     The entity sink, receives the entities fetched.
 /// </param>
 /// <param name="behaviors">
 ///     The behaviors.
 /// </param>
 public void Fetch(Type entityType, ScanSpec scanSpec, Action <object> entitySink, Behaviors behaviors)
 {
     this.ThrowIfDisposed();
     this.entityContext.Fetch(entityType, scanSpec, entitySink, this.CheckBehaviors(behaviors));
 }
Пример #49
0
 public ActionEnumerator(BComponent parent, System.Func <IEnumerator <bool> > action, string aName, string cName, Behaviors behaviorManager)
 {
     this.parent          = parent;
     this.action          = action;
     this.actionName      = aName;
     this.componentName   = cName;
     this.behaviorManager = behaviorManager;
     if (action != null)
     {
         enumerator = action();
     }
 }
Пример #50
0
 /// <summary>
 ///     Fetches all entities of the types specified from the database.
 /// </summary>
 /// <param name="entityType">
 ///     The entity type.
 /// </param>
 /// <param name="queryTypes">
 ///     The query types.
 /// </param>
 /// <param name="entitySink">
 ///     The entity sink, receives the entities fetched.
 /// </param>
 /// <param name="behaviors">
 ///     The behaviors.
 /// </param>
 public void Fetch(Type entityType, IEnumerable <Type> queryTypes, Action <object> entitySink, Behaviors behaviors)
 {
     this.ThrowIfDisposed();
     this.entityContext.Fetch(entityType, queryTypes, entitySink, this.CheckBehaviors(behaviors));
 }
Пример #51
0
 /// <summary>
 ///     Fetches all entities of the types specified from the database.
 /// </summary>
 /// <param name="entityType">
 ///     The entity type.
 /// </param>
 /// <param name="queryTypes">
 ///     The query types.
 /// </param>
 /// <param name="behaviors">
 ///     The behaviors.
 /// </param>
 /// <returns>
 ///     The entities fetched.
 /// </returns>
 public IEnumerable Fetch(Type entityType, IEnumerable <Type> queryTypes, Behaviors behaviors)
 {
     this.ThrowIfDisposed();
     return(this.entityContext.Fetch(entityType, queryTypes, this.CheckBehaviors(behaviors)));
 }
Пример #52
0
 /* ----------------------------------------------------------------- */
 ///
 /// MainForm
 ///
 /// <summary>
 /// Initializes a new instance of the MainWindow class.
 /// </summary>
 ///
 /* ----------------------------------------------------------------- */
 public MainWindow()
 {
     InitializeComponent();
     Behaviors.Add(CreateTooltip());
     ExitButton.Click += (s, e) => Close();
 }
Пример #53
0
 /// <summary>
 ///     Find an entity in the database using the key provider specified.
 /// </summary>
 /// <param name="entityType">
 ///     The entity type.
 /// </param>
 /// <param name="keyProvider">
 ///     The key provider.
 /// </param>
 /// <param name="behaviors">
 ///     The behaviors.
 /// </param>
 /// <returns>
 ///     The found entity instance or null if the entity does not exist.
 /// </returns>
 public object Find(Type entityType, object keyProvider, Behaviors behaviors)
 {
     this.ThrowIfDisposed();
     return(this.entityContext.Find(entityType, keyProvider, this.CheckBehaviors(behaviors)));
 }
Пример #54
0
 /// <summary>
 ///     Gets a value indicating whether the behavior is don't cache.
 /// </summary>
 /// <return>
 ///     <c>true</c> if don't cache behaviors, otherwise <c>false</c>.
 /// </return>
 public static bool DoNotCache(this Behaviors behaviors)
 {
     return((behaviors & Behaviors.DoNotCache) > 0);
 }
Пример #55
0
 /// <summary>
 ///     Fetches all entities using the given  scan specification from the database.
 /// </summary>
 /// <param name="scanSpec">
 ///     The scan specification.
 /// </param>
 /// <param name="behaviors">
 ///     The behaviors.
 /// </param>
 /// <typeparam name="T">
 ///     Type of the entities to fetch.
 /// </typeparam>
 /// <returns>
 ///     The entities fetched.
 /// </returns>
 public IEnumerable <T> Fetch <T>(ScanSpec scanSpec, Behaviors behaviors) where T : class
 {
     return(OfType <T>(this.Fetch(typeof(T), scanSpec, this.CheckBehaviors(behaviors))));
 }
Пример #56
0
 /// <summary>
 ///     Find the entities in the database using the key providers specified.
 /// </summary>
 /// <param name="entityType">
 ///     The entity type.
 /// </param>
 /// <param name="keyProviders">
 ///     The key providers.
 /// </param>
 /// <param name="behaviors">
 ///     The behaviors.
 /// </param>
 /// <returns>
 ///     The entities found.
 /// </returns>
 public IEnumerable FindMany(Type entityType, IEnumerable keyProviders, Behaviors behaviors)
 {
     this.ThrowIfDisposed();
     return(this.entityContext.FindMany(entityType, keyProviders, this.CheckBehaviors(behaviors)));
 }
Пример #57
0
 private void Awake()
 {
     agentTransform = transform;
     behaviors      = GetComponent <Behaviors>();
 }
Пример #58
0
 /// <summary>
 ///     Fetches all entities of the types specified from the database.
 /// </summary>
 /// <param name="queryTypes">
 ///     The query types.
 /// </param>
 /// <param name="entitySink">
 ///     The entity sink, receives the entities fetched.
 /// </param>
 /// <param name="behaviors">
 ///     The behaviors.
 /// </param>
 /// <typeparam name="T">
 ///     Type of the entities to fetch.
 /// </typeparam>
 public void Fetch <T>(IEnumerable <Type> queryTypes, Action <T> entitySink, Behaviors behaviors) where T : class
 {
     this.Fetch(typeof(T), queryTypes, OfType <T>(entitySink), this.CheckBehaviors(behaviors));
 }
Пример #59
0
        public static Settings Parse(Settings settings, XElement rootElement)
        {
            if (rootElement == null)
            {
                return(settings);
            }

            string behaviorAttribute = rootElement.GetAttributeValue(nameof(Behavior));

            if (behaviorAttribute != null)
            {
                Behaviors behavior = Behaviors.None;
                foreach (string value in behaviorAttribute.Split(','))
                {
                    if (Enum.TryParse(value, out Behaviors @enum))
                    {
                        behavior |= @enum;
                    }
                }
                settings.Behavior = behavior;
            }

            if (bool.TryParse(rootElement.GetAttributeValue(nameof(AutoInit)) ?? bool.TrueString,
                              out bool autoInit))
            {
                settings.AutoInit = autoInit;
            }

            if (bool.TryParse(rootElement.GetAttributeValue(nameof(GenerateRegistrations)) ?? bool.TrueString,
                              out bool generateRegistrations))
            {
                settings.GenerateRegistrations = generateRegistrations;
            }

            if (Enum.TryParse(rootElement.GetAttributeValue(nameof(DebugLogLevel)) ?? nameof(DebugLogLevel.Default),
                              out DebugLogLevel debugLogLevel))
            {
                settings.DebugLogLevel = debugLogLevel;
            }

            foreach (XElement assemblyNode in rootElement.DescendantNodes().OfType <XElement>()
                     .Where(x => string.Equals(x.Name.LocalName, "Assembly", StringComparison.OrdinalIgnoreCase)))
            {
                string assemblyName = assemblyNode.GetAttributeValue("Name");
                if (string.IsNullOrWhiteSpace(assemblyName))
                {
                    continue;
                }

                settings.Assemblies.Add(new MatchAssembly(assemblyName));
            }

            foreach (XElement typeNode in rootElement.DescendantNodes().OfType <XElement>()
                     .Where(x => string.Equals(x.Name.LocalName, "Type", StringComparison.OrdinalIgnoreCase)))
            {
                string typePattern = typeNode.GetAttributeValue("Name");
                if (string.IsNullOrWhiteSpace(typePattern))
                {
                    continue;
                }
                string createStr = typeNode.GetAttributeValue("Lifetime");
                if (createStr == null || !Enum.TryParse(createStr, out Lifetime lifetime))
                {
                    lifetime = Lifetime.LazySingleton;
                }

                settings.Types.Add(new MatchType(typePattern, lifetime));
            }

            foreach (XElement mapNode in rootElement.DescendantNodes().OfType <XElement>()
                     .Where(x => string.Equals(x.Name.LocalName, "Map", StringComparison.OrdinalIgnoreCase)))
            {
                string from = mapNode.GetAttributeValue("From");
                if (string.IsNullOrWhiteSpace(from))
                {
                    continue;
                }
                string to = mapNode.GetAttributeValue("To");
                if (string.IsNullOrWhiteSpace(to))
                {
                    continue;
                }
                if (!bool.TryParse(mapNode.GetAttributeValue("Force") ?? bool.FalseString, out bool force))
                {
                    force = false;
                }
                settings.Maps.Add(new Map(from, to, force));
            }

            return(settings);
        }
Пример #60
0
 /// <summary>
 ///     Fetches all entities of the types specified from the database.
 /// </summary>
 /// <param name="queryTypes">
 ///     The query types.
 /// </param>
 /// <param name="behaviors">
 ///     The behaviors.
 /// </param>
 /// <typeparam name="T">
 ///     Type of the entities to fetch.
 /// </typeparam>
 /// <returns>
 ///     The entities fetched.
 /// </returns>
 public IEnumerable <T> Fetch <T>(IEnumerable <Type> queryTypes, Behaviors behaviors) where T : class
 {
     return(OfType <T>(this.Fetch(typeof(T), queryTypes, this.CheckBehaviors(behaviors))));
 }