public void Explore()
        {
            if (!_assembly.ReferencedAssembliesNames.Any(x => String.Equals(
#if RESHARPER_6
                                                             x.Name,
#else
                                                             x.AssemblyName.Name,
#endif
                                                             typeof(It).Assembly.GetName().Name,
                                                             StringComparison.InvariantCultureIgnoreCase)))
            {
                return;
            }

            _assembly.GetTypes().Where(type => type.IsContext()).ForEach(type =>
            {
                var contextElement = _contextFactory.CreateContext(type);
                _consumer(contextElement);

                type
                .GetSpecifications()
                .ForEach(x => _consumer(_contextSpecificationFactory.CreateContextSpecification(contextElement, x)));

                type.GetBehaviors().ForEach(x =>
                {
                    var behaviorElement = _behaviorFactory.CreateBehavior(contextElement, x);
                    _consumer(behaviorElement);

                    _behaviorSpecificationFactory
                    .CreateBehaviorSpecificationsFromBehavior(behaviorElement, x)
                    .ForEach(y => _consumer(y));
                });
            });
        }
Ejemplo n.º 2
0
        private static void Main(string[] args)
        {
            Pokemon pokemon = PokemonFactory.CreateInstance(1);

            pokemon.attackBehavior = BehaviorFactory.CreateBehavior("魯夫橡膠戰斧");
            pokemon.Attack(pokemon);
        }
Ejemplo n.º 3
0
        public IEnumerable <UnitTestElementDisposition> AcceptElement(IElement element, IFile file)
        {
            IDeclaration declaration     = (IDeclaration)element;
            var          behaviorElement = _behaviorFactory.CreateBehavior(declaration.DeclaredElement);

            if (behaviorElement == null)
            {
                yield break;
            }

            yield return(new UnitTestElementDisposition(behaviorElement,
                                                        file.ProjectFile,
                                                        declaration.GetNavigationRange().TextRange,
                                                        declaration.GetDocumentRange().TextRange));

            var behaviorSpecifications =
                _behaviorSpecificationFactory.CreateBehaviorSpecificationsFromBehavior(behaviorElement,
                                                                                       declaration.DeclaredElement);

            foreach (var behaviorSpecificationElement in behaviorSpecifications)
            {
                yield return(new UnitTestElementDisposition(new UnitTestElementLocation[0],
                                                            behaviorSpecificationElement));
            }
        }
Ejemplo n.º 4
0
        public Behavior AddBehavior(BehaviorType type)
        {
            LinkedListNode <Behavior> curNode = _ActiveBehaviorList.First;

            while (curNode != null)
            {
                Behavior b = curNode.Value;
                if (b.Type == type)
                {
                    if (b.IsInCallback)
                    {
                        b.ReActive = true;
                    }

                    return(b);
                }

                curNode = curNode.Next;
            }

            curNode = _InactiveBehaviorList.First;
            while (curNode != null)
            {
                Behavior b = curNode.Value;
                if (b.Type == type)
                {
                    _ActiveBehaviorList.AddLast(b);

                    if (b.Type == BehaviorType.Turn)
                    {
                        _ActiveTurnBehaviorList.Add(b);
                    }
                    _InactiveBehaviorList.Remove(b);
                    b.IsInCallback = false;
                    return(b);
                }
                curNode = curNode.Next;
            }

            Behavior newb = BehaviorFactory.CreateBehavior(type);

            newb.Init(gameObject.transform, ObjType);
            _ActiveBehaviorList.AddLast(newb);

            if (newb.Type == BehaviorType.Turn)
            {
                _ActiveTurnBehaviorList.Add(newb);
            }

            return(newb);
        }
Ejemplo n.º 5
0
        public IEnumerable <UnitTestElementDisposition> AcceptElement(ITreeNode element, IFile file)
        {
            var declaration = (IDeclaration)element;
            var behavior    = _factory.CreateBehavior(declaration.DeclaredElement);

            if (behavior == null)
            {
                yield break;
            }

            yield return(new UnitTestElementDisposition(behavior,
                                                        file.GetSourceFile().ToProjectFile(),
                                                        declaration.GetNavigationRange().TextRange,
                                                        declaration.GetDocumentRange().TextRange));

            var behaviorContainer = declaration.DeclaredElement.GetFirstGenericArgument();

            if (!behaviorContainer.IsBehaviorContainer())
            {
                yield break;
            }

            foreach (var field in behaviorContainer.Fields)
            {
                if (!field.IsSpecification())
                {
                    continue;
                }

                var behaviorSpecification = _behaviorSpecifications.CreateBehaviorSpecification(behavior, field);

                var projectFile = GetProjectFile(field);
                if (projectFile != null)
                {
                    yield return(new UnitTestElementDisposition(behaviorSpecification,
                                                                projectFile,
                                                                new TextRange(),
                                                                GetTextRange(field)));
                }
                else
                {
                    yield return(new UnitTestElementDisposition(new UnitTestElementLocation[] {}, behaviorSpecification));
                }
            }
        }
Ejemplo n.º 6
0
 protected Duck(Flock flock, BehaviorFactory behavior)
 {
     Behavior = behavior.CreateBehavior(this);
     Flock    = flock;
 }
Ejemplo n.º 7
0
 public override void SetThought(String Thought)
 {
     _RootGoal = BehaviorFactory.CreateBehavior(Thought);
 }