Example #1
0
        public void CreateStub_WhenComponentIsNull_Throws()
        {
            var componentId = "componentId";
            var traits      = new DummyTraits();

            Assert.Throws <ArgumentNullException>(() => ComponentHandle.CreateStub <DummyService, DummyTraits>(componentId, null, traits));
        }
        /// <summary>
        /// Creates a test runner manager.
        /// </summary>
        /// <param name="factoryHandles">The factory handles.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="factoryHandles"/> is null.</exception>
        public DefaultTestRunnerManager(ComponentHandle<ITestRunnerFactory, TestRunnerFactoryTraits>[] factoryHandles)
        {
            if (factoryHandles == null)
                throw new ArgumentNullException("factoryHandles");

            this.factoryHandles = factoryHandles;
        }
        /// <summary>
        /// Creates a test kind manager.
        /// </summary>
        /// <param name="testKindHandles">The test kind handles.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="testKindHandles"/> is null.</exception>
        public DefaultTestKindManager(ComponentHandle<ITestKind, TestKindTraits>[] testKindHandles)
        {
            if (testKindHandles == null || Array.IndexOf(testKindHandles, null) >= 0)
                throw new ArgumentNullException("testKindHandles");

            this.testKindHandles = testKindHandles;
        }
Example #4
0
        public void CreateStub_WhenArgumentsValid_ReturnsHandleWithStubbedDescriptor()
        {
            var componentId = "componentId";
            var component   = MockRepository.GenerateStub <DummyService>();
            var traits      = new DummyTraits();

            var handle = ComponentHandle.CreateStub <DummyService, DummyTraits>(componentId, component, traits);

            Assert.Multiple(() =>
            {
                Assert.AreEqual(componentId, handle.Id);
                Assert.AreEqual(typeof(DummyService), handle.ServiceType);
                Assert.AreEqual(typeof(DummyTraits), handle.TraitsType);
                Assert.AreSame(component, handle.GetComponent());
                Assert.AreSame(traits, handle.GetTraits());

                object x = null;
                Assert.Throws <NotSupportedException>(() => x = handle.Descriptor.Plugin);
                Assert.Throws <NotSupportedException>(() => x = handle.Descriptor.Service);
                Assert.AreEqual(componentId, handle.Descriptor.ComponentId);
                Assert.AreEqual(new TypeName(component.GetType()), handle.Descriptor.ComponentTypeName);
                Assert.Throws <NotSupportedException>(() => x = handle.Descriptor.ComponentHandlerFactory);
                Assert.Throws <NotSupportedException>(() => x = handle.Descriptor.ComponentProperties);
                Assert.Throws <NotSupportedException>(() => x = handle.Descriptor.TraitsProperties);
                Assert.IsFalse(handle.Descriptor.IsDisabled);
                Assert.Throws <InvalidOperationException>(() => x = handle.Descriptor.DisabledReason);
                Assert.AreEqual(component.GetType(), handle.Descriptor.ResolveComponentType());
                Assert.Throws <NotSupportedException>(() => handle.Descriptor.ResolveComponentHandler());
                Assert.AreSame(component, handle.Descriptor.ResolveComponent());
                Assert.Throws <NotSupportedException>(() => handle.Descriptor.ResolveTraitsHandler());
                Assert.AreSame(traits, handle.Descriptor.ResolveTraits());
            });
        }
Example #5
0
        public void CreateStub_WhenComponentIdIsNull_Throws()
        {
            var component = MockRepository.GenerateStub <DummyService>();
            var traits    = new DummyTraits();

            Assert.Throws <ArgumentNullException>(() => ComponentHandle.CreateStub <DummyService, DummyTraits>(null, component, traits));
        }
 public CommandPresentation(ComponentHandle <ICommand, CommandTraits> commandHandle,
                            Command vsCommand, CommandBarButton[] vsCommandBarButtons)
 {
     this.commandHandle       = commandHandle;
     this.vsCommand           = vsCommand;
     this.vsCommandBarButtons = vsCommandBarButtons;
 }
        /// <summary>
        /// Creates a report manager.
        /// </summary>
        /// <param name="formatterHandles">The report formatter handles.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="formatterHandles"/> is null.</exception>
        public DefaultReportManager(ComponentHandle<IReportFormatter, ReportFormatterTraits>[] formatterHandles)
        {
            if (formatterHandles == null)
                throw new ArgumentNullException("formatterResolver");

            this.formatterHandles = formatterHandles;
        }
        /// <summary>
        /// Creates a test framework manager.
        /// </summary>
        /// <param name="testFrameworkHandles">The test framework handles.</param>
        /// <param name="fallbackTestFrameworkHandle">The fallback test framework handle.</param>
        /// <param name="fileTypeManager">The file type manager.</param>
        /// <param name="logger">The logger.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="testFrameworkHandles"/>, <paramref name="fallbackTestFrameworkHandle"/> or <paramref name="fileTypeManager "/> or <paramref name="logger"/>is null.</exception>
        public DefaultTestFrameworkManager(ComponentHandle <ITestFramework, TestFrameworkTraits>[] testFrameworkHandles, ComponentHandle <ITestFramework, TestFrameworkTraits> fallbackTestFrameworkHandle, IFileTypeManager fileTypeManager, ILogger logger)
        {
            if (testFrameworkHandles == null || Array.IndexOf(testFrameworkHandles, null) >= 0)
            {
                throw new ArgumentNullException("testFrameworkHandles");
            }
            if (fallbackTestFrameworkHandle == null)
            {
                throw new ArgumentNullException("fallbackTestFrameworkHandle");
            }
            if (fileTypeManager == null)
            {
                throw new ArgumentNullException("fileTypeManager");
            }
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }

            this.testFrameworkHandles        = testFrameworkHandles;
            this.fallbackTestFrameworkHandle = fallbackTestFrameworkHandle;
            this.fileTypeManager             = fileTypeManager;
            this.logger = logger;

            testFrameworkHandlesWithoutFallback = new List <ComponentHandle <ITestFramework, TestFrameworkTraits> >(testFrameworkHandles.Length);
            foreach (var testFrameworkHandle in testFrameworkHandles)
            {
                if (testFrameworkHandle.Id != fallbackTestFrameworkHandle.Id)
                {
                    testFrameworkHandlesWithoutFallback.Add(testFrameworkHandle);
                }
            }
        }
        /// <summary>
        /// Initializes the command manager.
        /// </summary>
        /// <param name="commandHandles">The command handles.</param>
        /// <param name="shell">The shell.</param>
        public DefaultCommandManager(ComponentHandle<ICommand, CommandTraits>[] commandHandles, IShell shell)
        {
            this.commandHandles = commandHandles;
            this.shell = (DefaultShell) shell;

            commandPresentations = new Dictionary<string, CommandPresentation>();
        }
Example #10
0
        public void CreateInstanceGeneric_WhenTraitsTypeDoesNotMatchDescriptor_Throws()
        {
            var componentDescriptor = CreateStubComponentDescriptor <DummyService, DummyTraits>();

            var ex = Assert.Throws <ArgumentException>(() => ComponentHandle.CreateInstance <ServiceDescriptor, Traits>(componentDescriptor));

            Assert.Contains(ex.Message, "The component descriptor is not compatible with the requested component handle type because it has a different service type or traits type.");
        }
Example #11
0
 private static ComponentHandle <IFileTypeRecognizer, FileTypeRecognizerTraits>[] CreateRecognizerHandles(
     params RecognizerInfo[] recognizerInfos)
 {
     return(GenericCollectionUtils.ConvertAllToArray(recognizerInfos, recognizerInfo =>
                                                     ComponentHandle.CreateStub("component",
                                                                                recognizerInfo.Recognizer ?? MockRepository.GenerateStub <IFileTypeRecognizer>(),
                                                                                recognizerInfo.Traits ?? new FileTypeRecognizerTraits("Dummy", "Dummy"))));
 }
Example #12
0
        public void ToString_ReturnsComponentId()
        {
            var componentDescriptor = CreateStubComponentDescriptor <DummyService, DummyTraits>();

            componentDescriptor.Stub(x => x.ComponentId).Return("componentId");
            var componentHandle = ComponentHandle.CreateInstance <DummyService, DummyTraits>(componentDescriptor);

            Assert.AreEqual("componentId", componentHandle.ToString());
        }
        private static void AddImageToCache(ComponentHandle<ITestKind, TestKindTraits> handle)
        {
            var traits = handle.GetTraits();
            
            if (traits.Icon == null)
                return;

            var image = new Icon(traits.Icon, 16, 16).ToBitmap();
            imageCache.Add(traits.Name, image);
        }
Example #14
0
        /// <inheritdoc />
        public ITestRunnerFactory GetFactory(string factoryName)
        {
            if (factoryName == null)
            {
                throw new ArgumentNullException(@"factoryName");
            }

            ComponentHandle <ITestRunnerFactory, TestRunnerFactoryTraits> handle
                = GenericCollectionUtils.Find(factoryHandles, h => string.Compare(h.GetTraits().Name, factoryName, true) == 0);

            return(handle != null?handle.GetComponent() : null);
        }
Example #15
0
        /// <inheritdoc />
        public IReportFormatter GetReportFormatter(string formatterName)
        {
            if (formatterName == null)
            {
                throw new ArgumentNullException("name");
            }

            ComponentHandle <IReportFormatter, ReportFormatterTraits> handle
                = GenericCollectionUtils.Find(formatterHandles, h => string.Compare(h.GetTraits().Name, formatterName, true) == 0);

            return(handle != null?handle.GetComponent() : null);
        }
        private static void AddImageToCache(ComponentHandle <ITestKind, TestKindTraits> handle)
        {
            var traits = handle.GetTraits();

            if (traits.Icon == null)
            {
                return;
            }

            var image = new Icon(traits.Icon, 16, 16).ToBitmap();

            imageCache.Add(traits.Name, image);
        }
Example #17
0
        public void CreateInstanceGeneric_WhenArgumentsValid_ReturnsTypedComponentHandle()
        {
            var componentDescriptor = CreateStubComponentDescriptor <DummyService, DummyTraits>();

            var componentHandle = ComponentHandle.CreateInstance <DummyService, DummyTraits>(componentDescriptor);

            Assert.Multiple(() =>
            {
                Assert.AreSame(componentDescriptor, componentHandle.Descriptor);
                Assert.AreEqual(typeof(DummyService), componentHandle.ServiceType);
                Assert.AreEqual(typeof(DummyTraits), componentHandle.TraitsType);
            });
        }
Example #18
0
        private static ComponentHandle <TService, TTraits> CreateStubComponentHandle <TService, TTraits>()
            where TTraits : Traits
        {
            var serviceDescriptor = MockRepository.GenerateMock <IServiceDescriptor>();

            serviceDescriptor.Stub(x => x.ResolveServiceType()).Return(typeof(TService));
            serviceDescriptor.Stub(x => x.ResolveTraitsType()).Return(typeof(TTraits));

            var componentDescriptor = MockRepository.GenerateMock <IComponentDescriptor>();

            componentDescriptor.Stub(x => x.Service).Return(serviceDescriptor);
            return(ComponentHandle.CreateInstance <TService, TTraits>(componentDescriptor));
        }
        /// <summary>
        /// Creates a test framework selection.
        /// </summary>
        /// <param name="testFrameworkHandle">The selected test framework handle.</param>
        /// <param name="testFrameworkOptions">The test framework options.</param>
        /// <param name="isFallback">True if the selection includes the fallback test
        /// framework because a test file is not supported by any other registered
        /// test framework.  <seealso cref="TestFrameworkSelector.FallbackMode"/></param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="testFrameworkHandle"/>
        /// or <paramref name="testFrameworkOptions"/> is null.</exception>
        public TestFrameworkSelection(
            ComponentHandle<ITestFramework, TestFrameworkTraits> testFrameworkHandle,
            TestFrameworkOptions testFrameworkOptions,
            bool isFallback)
        {
            if (testFrameworkHandle == null)
                throw new ArgumentNullException("testFrameworkHandle");
            if (testFrameworkOptions == null)
                throw new ArgumentNullException("testFrameworkOptions");

            this.testFrameworkHandle = testFrameworkHandle;
            this.testFrameworkOptions = testFrameworkOptions;
            this.isFallback = isFallback;
        }
Example #20
0
        protected void DrawEntityList()
        {
            ColumnScroller scroller = root.Q <ColumnScroller>("list-scroller");

            if (chosenWorld != null && scroller != null)
            {
                scroller.Clear();
                bool alternate = false;
                foreach (EntityHandle handle in chosenWorld.LookUpAllEntities())
                {
                    ListItem item = new ListItem(alternate, true, true);
                    item.AddIndent();
                    ListItemImage icon = item.AddImage(entityIcon);
                    icon.AddToClassList("icon");

                    ComponentHandle <Name> nameHandle = handle.GetComponent <Name>();
                    if (name != null)
                    {
                        item.AddTextDisplay(nameHandle.component.name);
                    }
                    else
                    {
                        item.AddTextDisplay(handle.entity.ToString());
                    }

                    scroller.Add(item);
                    alternate = !alternate;

                    item.eventManager.AddListener <MouseClickEvent>(e => {
                        if (e.button != 0)
                        {
                            return;
                        }
                        if (item.ClassListContains("selected"))
                        {
                            ReturnSelection();
                        }
                        else
                        {
                            scroller.Query <ListItem>(null, "selected").ForEach(current => {
                                current.RemoveFromClassList("selected");
                            });
                            item.AddToClassList("selected");
                            chosenKey = handle.entity;
                        }
                    });
                }
            }
        }
Example #21
0
        /* protected override void BeforeAssemblyReload(){
         *  string dir = TableDirectory.GetSubKey("temp-editors",TableDirectoryKey.DIRECTORY);
         *  if(chosenKey != null) Helpers.SerializeAndSaveToFile<Entity>(chosenKey.entity,dir,windowID,".meglo");
         *
         * }
         *
         * protected override void AfterAssemblyReload(){
         *  if(windowID != null){
         *      string dir = TableDirectory.GetSubKey("temp-editors",TableDirectoryKey.DIRECTORY);
         *      string file = windowID + ".meglo";
         *      Entity entity = Helpers.LoadFromSerializedFile<Entity>(dir + file);
         *      if(entity != null) {
         *          EntityHandle entityHandle = ProvenceManager.Instance.LookUpEntity(entity);
         *          if(entityHandle != null) eventManager.Raise<SelectKey<EntityHandle>>(new SelectKey<EntityHandle>(entityHandle));
         *      }
         *      Helpers.Delay(() =>{
         *          Helpers.DeleteFolderContents(dir);
         *      },100);
         *  }
         * } */

        //Data Methods

        protected override void SelectKey(SelectKey <EntityHandle> args)
        {
            if (args.key == null)
            {
                return;
            }
            chosenKey = args.key;

            chosenKeyNameHandle = chosenKey.GetOrCreateComponent <Name>();
            ComponentHandle <UnityGameObject> objectHandle = chosenKey.GetComponent <UnityGameObject>();

            chosenGameObject = objectHandle != null ? objectHandle.component.gameObject : null;
            eventManager.Raise <DrawColumnEventArgs <ProvenceComponent> >(new DrawColumnEventArgs <ProvenceComponent>(0));
            eventManager.Raise <DrawColumnEventArgs <ProvenceComponent> >(new DrawColumnEventArgs <ProvenceComponent>(2));
        }
Example #22
0
        protected void DrawComponentListItem(ComponentHandle <ProvenceComponent> handle, DropDownMenu contextMenu, bool alternate)
        {
            ListItem item          = new ListItem(alternate, true);
            string   componentName = System.Text.RegularExpressions.Regex.Replace(handle.component.GetType().Name, @"((?<=\p{Ll})\p{Lu})|((?!\A)\p{Lu}(?>\p{Ll}))", " $0");

            item.AddButton(componentName, false, false, true);

            item.eventManager.AddListener <MouseClickEvent>(e => {
                if (e.element != item)
                {
                    return;
                }
                switch (e.button)
                {
                case 0:
                    if (item.ClassListContains("selected"))
                    {
                        item.RemoveFromClassList("selected");
                    }
                    else
                    {
                        item.AddToClassList("selected");
                    }
                    eventManager.Raise <SelectKey <ProvenceComponent> >(new SelectKey <ProvenceComponent>(handle.component));
                    break;

                case 1:
                    contextMenu.Show(root, e, true);
                    ListItemText removeButton = root.Q <ListItemText>("component-list-context-menu-remove-button");
                    removeButton.eventManager.ClearListeners();
                    removeButton.eventManager.AddListener <MouseClickEvent>(ev => {
                        if (ev.button != 0)
                        {
                            return;
                        }
                        if (chosenComponents.Contains(handle.component))
                        {
                            chosenComponents.Remove(handle.component);
                        }
                        Helpers.InvokeGenericMethod(this, "RemoveComponent", handle.component.GetType());
                        contextMenu.style.display = DisplayStyle.None;
                    });
                    break;
                }
            });

            componentListScroller.Add(item);
        }
Example #23
0
        public void LoadModel(ComponentHandle <Model> modelHandle)
        {
            if (this.ContainsKey(modelHandle.component.manualKey))
            {
                ModelBankEntry entry = this[modelHandle.component.manualKey];

                GameObject entityObj = modelHandle.world.GetOrCreateComponent <UnityGameObject>(modelHandle.entity).component.gameObject;
                entityObj.Clear();

                GameObject asset = this.LoadModel(entry.name);
                if (asset != null)
                {
                    modelHandle.component.root = Object.Instantiate(asset, entityObj.transform.position + entry.positionOffset, entityObj.transform.rotation, entityObj.transform);
                    modelHandle.component.root.transform.Rotate(entry.rotationOffset);
                    Vector3 localScale = modelHandle.component.root.transform.localScale;
                    modelHandle.component.root.transform.localScale = Vector3.Scale(localScale, entry.scaleOffset);

                    foreach (KeyValuePair <string, ModelAnchorData> kvp in entry.anchors)
                    {
                        modelHandle.component.anchors[kvp.Key] = kvp.Value.hierarchy.ToArray();
                        GameObject anchor = GetChildByHierarhcy(modelHandle.component.root, kvp.Value.hierarchy.ToArray());
                        //if(anchor != null) modelHandle.component.anchors[kvp.Key] = anchor;
                    }

                    Animator animatorComponent = modelHandle.component.root.GetComponent <Animator>();
                    if (animatorComponent != null)
                    {
                        modelHandle.component.animatorComponent = animatorComponent;
                        modelHandle.component.animationData     = entry.animationData;

                        AnimationEventReciever reciever = modelHandle.component.root.AddComponent <AnimationEventReciever>();
                        reciever.entity = modelHandle.entity;
                        reciever.world  = modelHandle.world;
                    }

                    modelHandle.component.renderers = modelHandle.component.root.GetComponentsInChildren <Renderer>().ToSet();
                }
                else
                {
                    Debug.LogWarning("Model Asset Missing, key: " + modelHandle.component.manualKey);
                }
            }
            else
            {
                Debug.LogWarning("Model Entry Missing, key: " + modelHandle.component.manualKey);
            }
        }
        /// <summary>
        /// Creates a test framework selection.
        /// </summary>
        /// <param name="testFrameworkHandle">The selected test framework handle.</param>
        /// <param name="testFrameworkOptions">The test framework options.</param>
        /// <param name="isFallback">True if the selection includes the fallback test
        /// framework because a test file is not supported by any other registered
        /// test framework.  <seealso cref="TestFrameworkSelector.FallbackMode"/></param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="testFrameworkHandle"/>
        /// or <paramref name="testFrameworkOptions"/> is null.</exception>
        public TestFrameworkSelection(
            ComponentHandle <ITestFramework, TestFrameworkTraits> testFrameworkHandle,
            TestFrameworkOptions testFrameworkOptions,
            bool isFallback)
        {
            if (testFrameworkHandle == null)
            {
                throw new ArgumentNullException("testFrameworkHandle");
            }
            if (testFrameworkOptions == null)
            {
                throw new ArgumentNullException("testFrameworkOptions");
            }

            this.testFrameworkHandle  = testFrameworkHandle;
            this.testFrameworkOptions = testFrameworkOptions;
            this.isFallback           = isFallback;
        }
Example #25
0
        public void GetTraitsTyped_WhenComponentCanBeResolved_ReturnsAndMemoizesIt()
        {
            var traits = new DummyTraits();
            var componentDescriptor = CreateStubComponentDescriptor <DummyService, DummyTraits>();
            var componentHandle     = ComponentHandle.CreateInstance <DummyService, DummyTraits>(componentDescriptor);

            componentDescriptor.Expect(x => x.ResolveTraits()).Return(traits);

            // first time
            DummyTraits result = componentHandle.GetTraits();

            Assert.AreSame(traits, result);

            // second time should be same but method only called once
            result = componentHandle.GetTraits();
            Assert.AreSame(traits, result);

            componentDescriptor.VerifyAllExpectations();
        }
Example #26
0
        public void GetComponentUntyped_WhenComponentCanBeResolved_ReturnsItAndMemoizesIt()
        {
            var component           = MockRepository.GenerateStub <DummyService>();
            var componentDescriptor = CreateStubComponentDescriptor <DummyService, DummyTraits>();
            var componentHandle     = ComponentHandle.CreateInstance(componentDescriptor);

            componentDescriptor.Expect(x => x.ResolveComponent()).Return(component);

            // first time
            object result = componentHandle.GetComponent();

            Assert.AreSame(component, result);

            // second time should be same but method only called once
            result = componentHandle.GetComponent();
            Assert.AreSame(component, result);

            componentDescriptor.VerifyAllExpectations();
        }
Example #27
0
        /// <summary>
        /// Creates a file type manager.
        /// </summary>
        /// <param name="fileTypeRecognizerHandles">The file type recognizer component handles.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="fileTypeRecognizerHandles"/> is null.</exception>
        public FileTypeManager(ComponentHandle<IFileTypeRecognizer, FileTypeRecognizerTraits>[] fileTypeRecognizerHandles)
        {
            if (fileTypeRecognizerHandles == null || Array.IndexOf(fileTypeRecognizerHandles, null) >= 0)
                throw new ArgumentNullException("fileTypeRecognizerHandles");

            unknownFileType = new FileType("Unknown", "File of unknown type.", null);
            fileTypes = new List<FileType>();
            fileTypeInfos = new Dictionary<string, FileTypeInfo>();
            rootFileTypeInfos = new List<FileTypeInfo>();

            Initialize(fileTypeRecognizerHandles);

            // Note: The unknown type is not reachable from the roots so we pay no cost
            //       trying to apply a recognizer to it.  We add it to the other tables for
            //       lookup and enumeration only.
            fileTypes.Add(unknownFileType);
            fileTypeInfos.Add(unknownFileType.Id, new FileTypeInfo()
            {
                FileType = unknownFileType
            });
        }
Example #28
0
    private bool OnPass(object _ignore)
    {
        string componentType = ComponentHandle.componentType.ToString();

        if ((componentType.Length > 4) && (componentType.Substring(0, 5).Equals("Needy")))
        {
            return(false);
        }

        if (_delegatedSolveUserNickName != null && _delegatedSolveResponseNotifier != null)
        {
            AwardSolve(_delegatedSolveUserNickName, _delegatedSolveResponseNotifier);
            _delegatedSolveUserNickName     = null;
            _delegatedSolveResponseNotifier = null;
        }
        else if (_currentUserNickName != null && _currentResponseNotifier != null)
        {
            AwardSolve(_currentUserNickName, _currentResponseNotifier);
        }

        BombCommander._bombSolvedModules++;
        BombMessageResponder.moduleCameras.UpdateSolves();

        if (_turnQueued)
        {
            Debug.LogFormat("[ComponentSolver] Activating queued turn for completed module {0}.", Code);
            _readyToTurn = true;
            _turnQueued  = false;
        }

        ComponentHandle.OnPass();

        BombMessageResponder.moduleCameras.DetachFromModule(BombComponent, true);

        return(false);
    }
    protected bool SendToTwitchChat(string message, string userNickName)
    {
        // Within the messages, allow variables:
        // {0} = user’s nickname
        // {1} = Code (module number)
        if (message.RegexMatch(out Match match, @"^senddelayedmessage ([0-9]+(?:\.[0-9])?) (\S(?:\S|\s)*)$") && float.TryParse(match.Groups[1].Value, out float messageDelayTime))
        {
            ComponentHandle.StartCoroutine(SendDelayedMessage(messageDelayTime, string.Format(match.Groups[3].Value, userNickName, ComponentHandle.Code)));
            return(true);
        }

        if (!message.RegexMatch(out match, @"^(sendtochat|sendtochaterror|strikemessage) +(\S(?:\S|\s)*)$"))
        {
            return(false);
        }

        var chatMsg = string.Format(match.Groups[2].Value, userNickName, ComponentHandle.Code);

        switch (match.Groups[1].Value)
        {
        case "sendtochat":
            IRCConnection.Instance.SendMessage(chatMsg);
            return(true);

        case "sendtochaterror":
            ComponentHandle.CommandError(userNickName, chatMsg);
            return(true);

        case "strikemessage":
            StrikeMessage = chatMsg;
            return(true);

        default:
            return(false);
        }
    }
 /// <summary>
 /// Creates the installer manager.
 /// </summary>
 /// <param name="installerHandles">The installer handles, not null.</param>
 /// <param name="elevationManager">The elevation manager, not null.</param>
 public DefaultInstallerManager(ComponentHandle<IInstaller, InstallerTraits>[] installerHandles,
     IElevationManager elevationManager)
 {
     this.installerHandles = installerHandles;
     this.elevationManager = elevationManager;
 }
 public CommandPresentation(ComponentHandle<ICommand, CommandTraits> commandHandle,
     Command vsCommand, CommandBarButton[] vsCommandBarButtons)
 {
     this.commandHandle = commandHandle;
     this.vsCommand = vsCommand;
     this.vsCommandBarButtons = vsCommandBarButtons;
 }
 /// <summary>
 /// Creates a utility command manager.
 /// </summary>
 /// <param name="commandHandles">The command handles, not null.</param>
 public DefaultUtilityCommandManager(ComponentHandle<IUtilityCommand, UtilityCommandTraits>[] commandHandles)
 {
     this.commandHandles = commandHandles;
 }
 /// <summary>
 /// Creates a test runner extension manager.
 /// </summary>
 /// <param name="factoryHandles">The factory handles, not null.</param>
 /// <param name="runtime">The runtime, not null.</param>
 public DefaultTestRunnerExtensionManager(ComponentHandle<ITestRunnerExtensionFactory, TestRunnerExtensionFactoryTraits>[] factoryHandles, IRuntime runtime)
 {
     this.factoryHandles = factoryHandles;
     this.runtime = runtime;
 }
Example #34
0
        public ListItemText AddEntitySelector(World world, Entity value = null)
        {
            ListItemText el = new ListItemText();

            el.AddToClassList("list-item-text-display");
            el.AddToClassList("hoverable");
            el.AddToClassList("selectable");
            if (value != null)
            {
                el.text = value.ToString();
            }

            EntityHandle handle = world.LookUpEntity((Entity)el.text);

            if (handle == null)
            {
                el.text = "";
                eventManager.Raise <ListItemInputChange>(new ListItemInputChange(el));
            }
            el.eventManager.AddListener <MouseClickEvent>(e => {
                handle = world.LookUpEntity((Entity)el.text);
                if (handle != null)
                {
                    ComponentHandle <UnityGameObject> objectHandle = handle.GetComponent <UnityGameObject>();
                    GameObject go = objectHandle != null ? objectHandle.component.gameObject : null;
                    if (go != null)
                    {
                        Selection.objects = new UnityEngine.Object[] { go }
                    }
                    ;
                }
            });

            ListItemImage button = new ListItemImage("Assets/Icons/caret-down.png");

            button.AddToClassList("hoverable");
            button.AddToClassList("selectable");
            button.eventManager.AddListener <MouseClickEvent>(e => {
                EntitySelector.Open(world, args => {
                    el.text = args.value.ToString();
                    eventManager.Raise <ListItemInputChange>(new ListItemInputChange(el));
                });
            });

            ListItemImage clearButton = new ListItemImage("Assets/Icons/times.png");

            clearButton.AddToClassList("hoverable");
            clearButton.AddToClassList("selectable");
            clearButton.eventManager.AddListener <MouseClickEvent>(e => {
                if (el.text.Equals(""))
                {
                    return;
                }
                el.text = "";
                eventManager.Raise <ListItemInputChange>(new ListItemInputChange(el));
            });

            this.Add(el);
            this.Add(button);
            this.Add(clearButton);
            return(el);
        }
Example #35
0
 public void IsComponentHandleType_WhenTypeIsNull_Throws()
 {
     Assert.Throws <ArgumentNullException>(() => ComponentHandle.IsComponentHandleType(null));
 }
Example #36
0
 public void IsComponentHandleType_WhenTypeIsGenericComponentHandle_ReturnsTrue()
 {
     Assert.IsTrue(ComponentHandle.IsComponentHandleType(typeof(ComponentHandle <DummyService, DummyTraits>)));
 }
 private static Func<ControlPanelTab> GetControlPanelTabFactory(ComponentHandle<IControlPanelTabProvider, ControlPanelTabProviderTraits> controlPanelTabProviderHandle)
 {
     return () => controlPanelTabProviderHandle.GetComponent().CreateControlPanelTab();
 }
 private static Func<PreferencePane> GetPreferencePaneFactory(ComponentHandle<IPreferencePaneProvider, PreferencePaneProviderTraits> preferencePaneProviderHandle)
 {
     return () => preferencePaneProviderHandle.GetComponent().CreatePreferencePane();
 }
Example #39
0
 public void IsComponentHandleType_WhenTypeIsNotAComponentHandleComponentHandle_ReturnsFalse()
 {
     Assert.IsFalse(ComponentHandle.IsComponentHandleType(typeof(object)));
 }
 private static GallioFunc <ControlPanelTab> GetControlPanelTabFactory(ComponentHandle <IControlPanelTabProvider, ControlPanelTabProviderTraits> controlPanelTabProviderHandle)
 {
     return(() => controlPanelTabProviderHandle.GetComponent().CreateControlPanelTab());
 }
Example #41
0
 public void CreateInstance_WhenDescriptorIsNull_Throws()
 {
     Assert.Throws <ArgumentNullException>(() => ComponentHandle.CreateInstance(null));
 }
 /// <summary>
 /// Creates a control panel tab provider for preference panes.
 /// </summary>
 /// <param name="preferencePaneProviderHandles">The preference page provider handles, not null.</param>
 public PreferenceControlPanelTabProvider(ComponentHandle<IPreferencePaneProvider, PreferencePaneProviderTraits>[] preferencePaneProviderHandles)
 {
     this.preferencePaneProviderHandles = preferencePaneProviderHandles;
 }
Example #43
0
 public void CreateInstanceGeneric_WhenDescriptorIsNull_Throws()
 {
     Assert.Throws <ArgumentNullException>(() => ComponentHandle.CreateInstance <DummyService, DummyTraits>(null));
 }
Example #44
0
 public void IsComponentHandleType_WhenTypeIsNonGenericComponentHandle_ReturnsTrue()
 {
     Assert.IsTrue(ComponentHandle.IsComponentHandleType(typeof(ComponentHandle)));
 }
 /// <summary>
 /// Creates a control panel presenter.
 /// </summary>
 /// <param name="controlPanelTabProviderHandles">The preference page provider handles, not null.</param>
 /// <param name="elevationManager">The elevation manager, not null.</param>
 public ControlPanelPresenter(ComponentHandle<IControlPanelTabProvider, ControlPanelTabProviderTraits>[] controlPanelTabProviderHandles,
     IElevationManager elevationManager)
 {
     this.controlPanelTabProviderHandles = controlPanelTabProviderHandles;
     this.elevationManager = elevationManager;
 }