public void BuildForm(int width, int height)
        {
            var form = new OccVisualForm
            {
                Width  = width,
                Height = height
            };

            var multiview = form.multiviewTableLayoutPanel;

            SetupUtils = new SetupUtils {
                AttachedView = multiview
            };
            SetupUtils.InitializeModifiersSetup();
            SetupUtils.ResetSetupEnvironment();

            Viewer = SetupUtils.Viewer;
            View   = SetupUtils.View;

            Form         = form;
            Form.Paint  += FormPaint;
            Form.Resize += FormResize;

            DefaultInterpreters.Setup();
            var actionsGraph = new ActionsGraph();

            actionsGraph.Register(new FunctionFactoryInput());
            DefaultFunctions.Setup(actionsGraph);

            InitializeSetupUtils();
        }
 private void DefaultsSetup()
 {
     DefaultInterpreters.Setup();
     _actionsGraph = new ActionsGraph();
     _actionsGraph.Register(new FunctionFactoryInput());
     _actionsGraph.Register(new OptionsSetupInput());
     DefaultFunctions.Setup(_actionsGraph);
 }
        private static void Setup()
        {
            DefaultInterpreters.Setup();
            var actionsGraph = new ActionsGraph();

            actionsGraph.Register(new FunctionFactoryInput());
            DefaultFunctions.Setup(actionsGraph);
        }
示例#4
0
        private static void Main(string[] a)
        {
            //2. Define the availability-checking function
            Func <FeatureSetting <Feature, DefaultTenantEnum>, EmptyArgs, bool> fn =
                (f, args) =>
                DefaultFunctions.AvailabilityCheckFunction(f,
                                                           Tuple.Create(FeatureVisibilityMode.Normal,
                                                                        DateTime.Now));

            //3. Take care of feature manifest initialization
            //NOTE: I suggest hiding this ugly initialization logic away in the IOC container configuration
            var featureSettingRepo  = new AppConfigFeatureSettingRepository <Feature>();
            var availabilityChecker = new FeatureSettingAvailabilityChecker <Feature>(fn);
            //from step 2
            var featureSettingService =
                new FeatureSettingService <Feature>(availabilityChecker,
                                                    featureSettingRepo);
            var manifestCreationStrategy =
                new ManifestCreationStrategyDefault <Feature>(featureSettingRepo,
                                                              featureSettingService);
            //we use the default for this example
            var featureManifestService = new FeatureManifestService <Feature>(manifestCreationStrategy);
            var featureManifest        = featureManifestService.GetManifest();

            //4. Configure feature dependencies (see the web.config - we do not specify any dependencies for this demo)

            //5. Add code that is conditional on feature availability. featureManifest ideally supplied via IOC container
            if (Feature.MyFeature.IsAvailable(featureManifest))
            {
                Console.WriteLine("MyFeature is available.");
            }
            else
            {
                throw new FeatureNotAvailableException(
                          "MyFeature is not available. This is unexpected behavior for the default implementation of NFeature.Example.Console.",
                          new[] {
                    "Check your app.config.", "Ensure built DLLs are up to date.",
                    "Ensure you have not modified this application or its configuration."
                });
            }

            //6. Optionally configure feature-specific settings using JSON
            Console.WriteLine(Feature.MyFeature.Setting(MyFeatureSettings.mySetting, featureManifest));
            Console.ReadLine();

            //7. Optionally specify dates for feature availability

            //8. At some future date optionally mark your feature as
            //Established to indicate that it is now integral to your
            //application and cannot be turned off (see footnote 2)

            //9. ...

            //10. Profit!
        }
示例#5
0
        public void Setup()
        {
            DefaultInterpreters.Setup();
            _actionsGraph = new ActionsGraph();
            _actionsGraph.Register(new FunctionFactoryInput());
            _actionsGraph.Register(new OptionsSetupInput());
            _document = TestUtils.DefaultsSetup();
            DefaultFunctions.Setup(_actionsGraph);
            var documentInput = new DocumentInput(_document);

            documentInput.OnConnect();
            _actionsGraph.Register(documentInput);
            _document.Transact();
        }
        public ExternalFunctionTests()
        {
            var funcs = new DefaultFunctions <Maybe <object> >();

            funcs.Register("GetValue", (args, context) =>
            {
                var maybe = context.Value;
                if (maybe.HasValue && maybe.Value is TestObj o)
                {
                    return(o.MemberFunction());
                }

                return("Fail");
            });

            parser = new ExpressionParser <Maybe <object> >(
                new MaybeExpressionFactory(
                    MaybeMonad.Instance,
                    funcs));
        }
        public void EvalLegacyMathFunction(string exprString, object expected)
        {
            var funcs = new DefaultFunctions <object>();

            funcs.Register("GetValue", (a, b) => Convert.ToDouble(a[1]));
            var parseResult = VCExpression.ParseDefault(exprString, funcs);
            var expr        = parseResult.Expression;
            var result      = expr.Evaluate(new { });

            Assert.That(result, Is.EqualTo(expected));

            var funcs2 = new DefaultCSharpFunctions();

            funcs2.Register("GetValue", (a, b) => $"Convert.ToDouble({a[1]})");
            var parseResult2 = CSharpExpression.ParseMethod(exprString, funcs2);
            var expr2        = parseResult2.Expression;
            var result2      = expr2.Evaluate(new { });

            Assert.That(result2, Is.EqualTo(expected));
        }
示例#8
0
        public static Document DefaultsSetup()
        {
            DefaultInterpreters.Setup();
            AttributeInterpreterFactory.Register <ActionGraphInterpreter>();
            var actionsGraph = new ActionsGraph();

            actionsGraph.Register(new FunctionFactoryInput());
            actionsGraph.Register(new OptionsSetupInput());
            DefaultFunctions.Setup(actionsGraph);
            var constraintsFunctionsSetup = new DefaultConstraintFunctions();

            constraintsFunctionsSetup.Setup(actionsGraph);

            QosCreate();

            var document = new Document();

            document.Transact();
            document.Root.Set <ActionGraphInterpreter>().ActionsGraph = actionsGraph;
            document.Root.Set <DocumentContextInterpreter>().Document = document;
            document.Commit("document setup");
            return(document);
        }
        public void InitializeModifiersSetup()
        {
            ActionGraph            = new ActionsGraph();
            _metaModifierContainer = new CommandList(ActionGraph);
            if (AttachedView == null)
            {
                AttachedView = new MultiViewStub(null);
            }
            InitializeViews();
            InitializeDocument();
            ActionGraph.Register(new FunctionFactoryInput());
            ActionGraph.Register(new OptionsSetupInput());
            ActionGraph.Register(new UiBuilderInputFake());
            DefaultFunctions.Setup(ActionGraph);

            InitializeInputs();
            InitializeActions();


            var sketchCreator = new SketchCreator(Document);

            sketchCreator.BuildSketchNode();
        }
示例#10
0
 public void initInventory()
 {
     inventorySkills = new baseSkill[14];
     inventorySkills [0] = new Arrays ();
     inventorySkills [1] = new BreakAndContinue ();
     inventorySkills [2] = new DDOS ();
     inventorySkills [3] = new DefaultFunctions ();
     inventorySkills [4] = new FireWall ();
     inventorySkills [5] = new FunctionsWithInputOutput ();
     inventorySkills [6] = new FunctionsWithOutput ();
     inventorySkills [7] = new Hash ();
     inventorySkills [8] = new IfElse ();
     inventorySkills [9] = new InfiniteLoop ();
     inventorySkills [10] = new Loop ();
     inventorySkills [11] = new PacketSniffing ();
     inventorySkills [12] = new Recursion ();
     inventorySkills [13] = new Stack ();
     Debug.Log ("Finished Loading Inventory");
 }
示例#11
0
        public void Run(IOccContainerMultiView sceneWorkspace, ActionsGraph actionsGraph, PartModelingView newView,
                        ViewInfo viewInfo)
        {
            _attachedView = sceneWorkspace;
            _actionGraph  = actionsGraph;
            var uiItems =
                _actionGraph[InputNames.UiElementsItem].GetData(NotificationNames.GetValue).Get
                <UiElementsItem.Items>();

            _treeView        = uiItems.TreeView;
            _wpfPropertyView = (PropertyGridView)uiItems.WpfPropertyView;
            _wpfLayerView    = (LayerView)uiItems.LayerView;
            _helpView        = uiItems.HelpView;
            _commandLineView =
                _actionGraph[InputNames.CommandLineView].GetData(NotificationNames.GetValue).Get
                <CommandLineView>();
            _metaModifierContainer = new CommandList(_actionGraph);

            _actionGraph.OnSwitchAction += UpdateSwitchAction;

            Application.DoEvents();
            _actionGraph.Register(new FunctionFactoryInput());
            DefaultFunctions.Setup(_actionGraph);
            var defaultConstraintFunctions = new DefaultConstraintFunctions();

            defaultConstraintFunctions.Setup(_actionGraph);

            OccInitialize.Setup(ref _device, ref _viewer, ref _context, out _view, _attachedView);

            InitDocument();

            _solver = new Solver(_document);
            UpdateSolverOptions();
            ViewInfoSetup(viewInfo);
            RegisterModifiers();
            InitializeInputs();
            DefineShapeConcepts();
            SetupChangedShapeEvent();
            ViewInfoPostSetup();
            UserInterfaceSetup();

            SwitchUserAction(ModifierNames.StartUp);
            var optionsSetup = actionsGraph[InputNames.OptionsSetupInput].Get <OptionsSetup>();

            optionsSetup.Register(new AutoSaveOptionsItem());

            var occSection = optionsSetup.UpdateSectionNode(OptionSectionNames.Background);
            var color      = occSection.GetColorValue(0);

            _viewer.SetDefaultBackgroundColor((ShapeUtils.GetOccColor(color)));
            //SetGradientBackground();


            ForceStartupViewUpdate();

            OptionsEventMapping(optionsSetup);

            var presenter = newView.GetPresenter();

            presenter.OnMouseMoveHandler  += MouseMoveHandler;
            presenter.OnMouseDownHandler  += MouseDownHandler;
            presenter.OnMouseUpHandler    += MouseUpHandler;
            presenter.OnMouseWheelHandler += MouseWheelHandler;

            presenter.OnResizeEvent += ResizeView;

            ApplicationNotificationUtils.Instance.ExitingApplication += () => SwitchUserAction(ModifierNames.NaroExit);

            _view.SurfaceDetail = V3dTypeOfSurfaceDetail.V3d_TEX_ALL;
            new SketchSolveUpdater(_document);


            SetOriginalGradientBackground();

            ResumeRunning();
        }
示例#12
0
 public IExprBuilder ResetFunc()
 {
     DefaultFunctions.Clear();
     return(this);
 }
示例#13
0
 public IExprBuilder UnsetFunc(string name)
 {
     DefaultFunctions.Remove(name);
     return(this);
 }