/// <inheritdoc />
        public override void OnDestroy()
        {
            _isValid  = null;
            _selected = null;

            base.OnDestroy();
        }
        public static void Run(Logger log)
        {
            object validator = ValidatorFactory.GetValidator();

            string password = "******";

            MethodInfo isValidMethod = validator
                                       .GetType()
                                       .GetMethod("IsValid");

            // only works if you can cache the call to a specific object instance
            IsValidDelegate callIsValid = (IsValidDelegate)isValidMethod.CreateDelegate(
                typeof(IsValidDelegate),
                validator);

            int       iterations = 20000000;
            Stopwatch timer      = new Stopwatch();

            timer.Start();

            for (int i = 0; i < iterations; i++)
            {
                bool isValid = callIsValid(password);
            }

            timer.Stop();

            log.LogMessage(string.Format(
                               "{0:#,##0} iter. in {1:#,##0.00} sec. at {2:#,##0} iter/sec.",
                               iterations,
                               timer.Elapsed.TotalSeconds,
                               iterations / timer.Elapsed.TotalSeconds));
        }
Exemplo n.º 3
0
 public Format(string name, IsValidDelegate isValid, ReadDelegate read, WriteDelegate write)
 {
     Name    = name;
     IsValid = isValid;
     Read    = read;
     Write   = write;
 }
Exemplo n.º 4
0
            static Native()
            {
                //RuntimeCil.Generate(typeof(MemoryMapped).Assembly);

                Create = Marshal.GetDelegateForFunctionPointer <CreateDelegate>(PlatformApi.NativeLibrary.GetExport(KokkosLibrary.ModuleHandle, "Create"));

                CreateAndOpen = Marshal.GetDelegateForFunctionPointer <CreateAndOpenDelegate>(PlatformApi.NativeLibrary.GetExport(KokkosLibrary.ModuleHandle, "CreateAndOpen"));

                Destory = Marshal.GetDelegateForFunctionPointer <DestoryDelegate>(PlatformApi.NativeLibrary.GetExport(KokkosLibrary.ModuleHandle, "Destory"));

                Open = Marshal.GetDelegateForFunctionPointer <OpenDelegate>(PlatformApi.NativeLibrary.GetExport(KokkosLibrary.ModuleHandle, "Open"));

                Close = Marshal.GetDelegateForFunctionPointer <CloseDelegate>(PlatformApi.NativeLibrary.GetExport(KokkosLibrary.ModuleHandle, "Close"));

                At = Marshal.GetDelegateForFunctionPointer <AtDelegate>(PlatformApi.NativeLibrary.GetExport(KokkosLibrary.ModuleHandle, "At"));

                GetData = Marshal.GetDelegateForFunctionPointer <GetDataDelegate>(PlatformApi.NativeLibrary.GetExport(KokkosLibrary.ModuleHandle, "GetData"));

                IsValid = Marshal.GetDelegateForFunctionPointer <IsValidDelegate>(PlatformApi.NativeLibrary.GetExport(KokkosLibrary.ModuleHandle, "IsValid"));

                Size = Marshal.GetDelegateForFunctionPointer <SizeDelegate>(PlatformApi.NativeLibrary.GetExport(KokkosLibrary.ModuleHandle, "Size"));

                MappedSize = Marshal.GetDelegateForFunctionPointer <MappedSizeDelegate>(PlatformApi.NativeLibrary.GetExport(KokkosLibrary.ModuleHandle, "MappedSize"));

                Remap = Marshal.GetDelegateForFunctionPointer <RemapDelegate>(PlatformApi.NativeLibrary.GetExport(KokkosLibrary.ModuleHandle, "Remap"));
            }
 public void NormalCases(IsValidDelegate isValid)
 {
     Assert.False(isValid("[(])"));
     Assert.False(isValid("[)"));
     Assert.True(isValid("[](){}"));
     Assert.True(isValid("[(){([])}](){}"));
 }
 public void CornerCases(IsValidDelegate isValid)
 {
     Assert.False(isValid(null));
     Assert.False(isValid(""));
     Assert.False(isValid("["));
     Assert.False(isValid("]"));
     Assert.True(isValid("[]"));
 }
        private AssetSearchPopup(IsValidDelegate isValid, Action <AssetItem> selected)
        {
            _isValid  = isValid;
            _selected = selected;

            ItemClicked += OnItemClicked;

            // TODO: use async thread to search workspace items
            FindAssets(Editor.Instance.ContentDatabase.ProjectContent.Folder);
            SortChildren();
        }
Exemplo n.º 8
0
        private ActorSearchPopup(IsValidDelegate isValid, Action <Actor> selected)
        {
            _isValid  = isValid;
            _selected = selected;

            ItemClicked += OnItemClicked;

            // TODO: use async thread to search scenes
            for (int i = 0; i < Level.ScenesCount; i++)
            {
                Find(Level.GetScene(i));
            }
            SortChildren();
        }
Exemplo n.º 9
0
        private AssetSearchPopup(IsValidDelegate isValid, Action <AssetItem> selected)
        {
            _isValid  = isValid;
            _selected = selected;

            ItemClicked += OnItemClicked;

            // TODO: use async thread to search workspace items
            foreach (var project in Editor.Instance.ContentDatabase.Projects)
            {
                if (project.Content != null)
                {
                    FindAssets(project.Content.Folder);
                }
            }
            SortItems();
        }
Exemplo n.º 10
0
        private TypeSearchPopup(IsValidDelegate isValid, Action <ScriptType> selected)
        {
            _isValid  = isValid;
            _selected = selected;

            ItemClicked += OnItemClicked;

            // TODO: use async thread to search types without UI stall
            var allTypes = Editor.Instance.CodeEditing.All.Get();

            for (int i = 0; i < allTypes.Count; i++)
            {
                var type = allTypes[i];
                if (_isValid(type))
                {
                    var attributes = type.GetAttributes(true);
                    if (attributes.FirstOrDefault(x => x is HideInEditorAttribute) == null)
                    {
                        AddItem(new TypeItemView(type, attributes));
                    }
                }
            }
            SortChildren();
        }
        /// <summary>
        /// Shows the popup.
        /// </summary>
        /// <param name="showTarget">The show target.</param>
        /// <param name="showTargetLocation">The show target location.</param>
        /// <param name="isValid">Event called to check if a given asset item is valid to be used.</param>
        /// <param name="selected">Event called on asset item pick.</param>
        /// <returns>The dialog.</returns>
        public static AssetSearchPopup Show(Control showTarget, Vector2 showTargetLocation, IsValidDelegate isValid, Action <AssetItem> selected)
        {
            var popup = new AssetSearchPopup(isValid, selected);

            popup.Show(showTarget, showTargetLocation);
            return(popup);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Shows the popup.
        /// </summary>
        /// <param name="showTarget">The show target.</param>
        /// <param name="showTargetLocation">The show target location.</param>
        /// <param name="isValid">Event called to check if a given asset item is valid to be used.</param>
        /// <param name="selected">Event called on asset item pick.</param>
        /// <returns>The dialog.</returns>
        public static TypeSearchPopup Show(Control showTarget, Vector2 showTargetLocation, IsValidDelegate isValid, Action <ScriptType> selected)
        {
            var popup = new TypeSearchPopup(isValid, selected);

            popup.Show(showTarget, showTargetLocation);
            return(popup);
        }
Exemplo n.º 13
0
 public FileFormat(string extension, IsValidDelegate isValid)
 {
     Extension = extension;
     IsValid   = isValid;
 }
Exemplo n.º 14
0
        /// <summary>
        /// Shows the popup.
        /// </summary>
        /// <param name="showTarget">The show target.</param>
        /// <param name="showTargetLocation">The show target location.</param>
        /// <param name="isValid">Event called to check if a given script item is valid to be used.</param>
        /// <param name="selected">Event called on script item pick.</param>
        /// <returns>The dialog.</returns>
        public static ScriptSearchPopup Show(Control showTarget, Float2 showTargetLocation, IsValidDelegate isValid, Action <Script> selected)
        {
            var popup = new ScriptSearchPopup(isValid, selected);

            popup.Show(showTarget, showTargetLocation);
            return(popup);
        }