void cb_Checked(object sender, RoutedEventArgs e)
        {
            AddInToken     token = (AddInToken)((FrameworkElement)sender).Tag;
            CalculatorBase calc  = token.Activate <CalculatorBase>(AddInSecurityLevel.Internet);

            _calcs.Add(calc);
            ((FrameworkElement)sender).Tag = calc;
            InitAddIn(calc, false);
        }
        void cb_Unchecked(object sender, RoutedEventArgs e)
        {
            CalculatorBase  calc       = (CalculatorBase)((CheckBox)sender).Tag;
            AddInController controller = AddInController.GetAddInController(calc);
            AddInToken      token      = controller.Token;

            ((CheckBox)sender).Tag = token;
            UnloadAddIn(calc);
            calc = null;
            _toUnload.Add(controller.AppDomain);
        }
 void InitAddIn(CalculatorBase calc, bool addMenu)
 {
     Actions.Items.Add(new ActionLayout(calc, this));
     if (addMenu)
     {
         CheckBox cb = new CheckBox();
         cb.Content    = calc.Name;
         cb.IsChecked  = true;
         cb.Tag        = calc;
         cb.Checked   += new RoutedEventHandler(cb_Checked);
         cb.Unchecked += new RoutedEventHandler(cb_Unchecked);
         this.AddInMenuList.Items.Add(cb);
     }
 }
Пример #4
0
 public ActionLayout(CalculatorBase calc, CalculatorHost application) : this()
 {
     _calc           = calc;
     _app            = application;
     this.Title.Text = calc.Name;
     foreach (Operation op in calc.Operations)
     {
         Button b = new Button();
         b.Tag     = op;
         b.Content = op.Name;
         b.Click  += new RoutedEventHandler(b_Click);
         Actions.Children.Add(b);
     }
     ValidateButtons(application.Stack.Items.Count);
     application.StackChanged += _stackChangedHandler;
 }
        void UnloadAddIn(CalculatorBase calc)
        {
            ActionLayout calcsAl = null;

            foreach (ActionLayout al in Actions.Items)
            {
                if (al.Calculator.Equals(calc))
                {
                    calcsAl = al;
                    break;
                }
            }
            calcsAl.Calculator = null;
            Actions.Items.Remove(calcsAl);
            _calcs.Remove(calc);
            CalculatorVisual.Children.Clear();
        }
 internal void Operate(CalculatorBase calc, Operation op)
 {
     double[] operands = new double[op.NumOperands];
     for (int i = 0; i < op.NumOperands; i++)
     {
         ListViewItem item = (ListViewItem)Stack.Items[0];
         operands[i] = double.Parse(item.Content.ToString());
         Stack.Items.RemoveAt(0);
     }
     if (typeof(Calculator).IsAssignableFrom(calc.GetType()))
     {
         double       result  = ((Calculator)calc).Operate(op, operands);
         ListViewItem newItem = new ListViewItem();
         newItem.Content = result;
         Stack.Items.Insert(0, newItem);
     }
     else
     {
         UIElement visual = ((VisualCalculator)calc).Operate(op, operands);
         CalculatorVisual.Children.Clear();
         CalculatorVisual.Children.Add(visual);
     }
     UpdateStack();
 }
Пример #7
0
 /// <summary>Creates service definition that can be registered with a server</summary>
 /// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
 public static grpc::ServerServiceDefinition BindService(CalculatorBase serviceImpl)
 {
     return(grpc::ServerServiceDefinition.CreateBuilder()
            .AddMethod(__Method_Sum, serviceImpl.Sum).Build());
 }
Пример #8
0
 public Recursive()
 {
     calculator = Mock.Of <CalculatorBase, ICustomFormatter, IDisposable>();
 }
Пример #9
0
 public void Setup()
 {
     calculator = new CalculatorBase();
 }
Пример #10
0
 /// <summary>Register service method with a service binder with or without implementation. Useful when customizing the  service binding logic.
 /// Note: this method is part of an experimental API that can change or be removed without any prior notice.</summary>
 /// <param name="serviceBinder">Service methods will be bound by calling <c>AddMethod</c> on this object.</param>
 /// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
 public static void BindService(grpc::ServiceBinderBase serviceBinder, CalculatorBase serviceImpl)
 {
     serviceBinder.AddMethod(__Method_Addition, serviceImpl == null ? null : new grpc::UnaryServerMethod <global::GrpcGreeter.OperationRequest, global::GrpcGreeter.OperationReply>(serviceImpl.Addition));
     serviceBinder.AddMethod(__Method_Subtraction, serviceImpl == null ? null : new grpc::UnaryServerMethod <global::GrpcGreeter.OperationRequest, global::GrpcGreeter.OperationReply>(serviceImpl.Subtraction));
 }
Пример #11
0
 /// <summary>Register service method with a service binder with or without implementation. Useful when customizing the  service binding logic.
 /// Note: this method is part of an experimental API that can change or be removed without any prior notice.</summary>
 /// <param name="serviceBinder">Service methods will be bound by calling <c>AddMethod</c> on this object.</param>
 /// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
 public static void BindService(grpc::ServiceBinderBase serviceBinder, CalculatorBase serviceImpl)
 {
     serviceBinder.AddMethod(__Method_Add, serviceImpl == null ? null : new grpc::UnaryServerMethod <global::CalculatorService.InputData, global::CalculatorService.Result>(serviceImpl.Add));
 }