public static ServiceHost CreateServiceExample(ITaskController taskController)
        {
            ServiceHost <IServiceExample, ServiceExample> host = null;

            try
            {
                var uri = UriFactory.CreateBaseAddress(WcfConfiguration.ServiceExampleName);
                host = new ServiceHost <IServiceExample, ServiceExample>(uri, new ServiceExampleInstanceProvider(taskController));

                var binding = BindingFactory.CreateBinding();
                host.SetBinding(binding);


                var tmp = host;
                host = null;
                return(tmp);
            }
            finally
            {
                if (host != null)
                {
                    host.Close();
                }
            }
        }
Пример #2
0
        public static ServiceExampleClient CreateServiceExample()
        {
            var binding  = BindingFactory.CreateBinding();
            var endPoint = new EndpointAddress(UriFactory.CreateBaseAddress(WcfConfiguration.ServiceExampleName));

            return(new ServiceExampleClient(binding, endPoint));
        }
Пример #3
0
 public static Binding CreateBinding(Endpoint serviceInterface)
 {
     try
     {
         return BindingFactory.CreateBinding(serviceInterface);
     }
     catch (Exception ex)
     {
         throw new InvalidChannelBindingException(string.Format("Error creating binding {0}", serviceInterface.EndpointName),ex);
     }
 }
Пример #4
0
        public void when_resolving_binding_then_resolves_type()
        {
            var config = new BindingConfiguration(typeof(GenerateCode))
            {
                Properties =
                {
                    new PropertyBindingConfiguration("TargetFileName")
                    {
                        ValueProvider = new BindingConfiguration(typeof(ExpressionValueProvider))
                        {
                            Properties =
                            {
                                new PropertyBindingConfiguration("Expression")
                                {
                                    ValueProvider = new BindingConfiguration(typeof(ExpressionValueProvider))
                                    {
                                        Properties =
                                        {
                                            new PropertyBindingConfiguration("Expression")
                                            {
                                                Value = "{Name}Controller",
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    new PropertyBindingConfiguration("TargetPath")
                    {
                        Value = "~",
                    },
                }
            };

            var context = new ComponentContext();
            var factory = new BindingFactory();
            var binding = factory.CreateBinding<GenerateCode>(context, config);

            var command = (GenerateCode)binding.Instance;

            binding.Refresh();

            Assert.Equal("~", command.TargetPath);
            Assert.Equal("{Name}Controller11", command.TargetFileName);

            binding.Refresh();

            Assert.Equal("~", command.TargetPath);

            Assert.Equal("{Name}Controller22", command.TargetFileName);
        }
        protected override void OnStart(string[] args)
        {
            base.OnStart(args);

            Logger.LogDebug("Starting HPCR Simulation Proxy Service");

            Binding binding = BindingFactory.CreateBinding(MessageTransferType.CompressedHttp);

            _hpcrProxy = new ServiceHost(typeof(HpcrSimulationProxy), HpcrProxyUri.LocalHost);
            _hpcrProxy.AddServiceEndpoint(typeof(IHpcrConfigurationProxyService).FullName, binding, string.Empty);
            _hpcrProxy.AddServiceEndpoint(typeof(IHpcrExecutionProxyService).FullName, binding, string.Empty);
            _hpcrProxy.Open();
        }
Пример #6
0
            public void Advance(object target, string expression)
            {
                if (!ExpressionEvaluation.IsMatch(expression))
                {
                    throw new ArgumentException(String.Format(
                                                    System.Globalization.CultureInfo.CurrentCulture,
                                                    Properties.Resources.ExpressionEvaluationService_InvalidReference, expression));
                }

                // Don't process null targets.
                if (target == null)
                {
                    return;
                }

                // If we find a null, we exit.
                for (Match segmentmatch = ExpressionEvaluation.Match(expression);
                     segmentmatch.Success && target != null;
                     segmentmatch = segmentmatch.NextMatch())
                {
                    // Catch all reflection-generated exceptions and throw the inner one.
                    try
                    {
                        currentBinding = BindingFactory.CreateBinding(target,
                                                                      segmentmatch.Groups[GroupPart],
                                                                      segmentmatch.Groups[GroupParameters]);
                        target = currentBinding.GetValue();
                    }
                    catch (ArgumentException aex)
                    {
                        // Rethrow with a more meaningful message.
                        throw new ArgumentException(String.Format(
                                                        System.Globalization.CultureInfo.CurrentCulture,
                                                        Properties.Resources.ExpressionEvaluationService_CantEvaluate,
                                                        expression, segmentmatch.Value, aex.Message), aex);
                    }
                    catch (TargetInvocationException tiex)
                    {
                        // Rethrow with a more meaningful message.
                        throw new ArgumentException(String.Format(
                                                        System.Globalization.CultureInfo.CurrentCulture,
                                                        Properties.Resources.ExpressionEvaluationService_CantEvaluate,
                                                        expression, segmentmatch.Value, tiex.InnerException.Message), tiex);
                    }
                }
            }
Пример #7
0
        public RasterControl(EventBox parent)
        {
            ParentBox = parent;

            disablerPanel             = new DrawingArea();//{ Opacit = Color.Transparent, Visible = false, Curso = Cursors.No };
            disablerPanel.TooltipText = "Overlay out of sync. WYSIWYG editing is disabled";
            //toolTip1.SetToolTip(disablerPanel, "Overlay out of sync. WYSIWYG editing is disabled");
            //        this.PackStart(disablerPanel, true, true,0);


            //toolTip1.SetToolTip(this, "The WYSIWYG area");
            //toolTip1.Popup += new PopupEventHandler(toolTip1_Popup);
            //toolTip1.ReshowDelay = 50;
            //toolTip1.InitialDelay = 100;
            //toolTip1.ShowAlways = true;
            toolTip1.Active = true;

            //todo this.MouseHover += new EventHandler(RasterControl_MouseHover);



            CreateContextMenu();

            //this.CanFocus = true;
            //this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer | ControlStyles.Selectable, true);
            DoubleBuffered = true;

            TheRasterModel = new RasterControlModel(this);

            TheDisplayModel = new TikzDisplayModel <Cairo.ImageSurface>(this, new PdfToBmpExtGTK());

            TheOverlayModel = new PdfOverlayModel(this, this);

            MarkObject_Timer.Interval = 500;
            MarkObject_Timer.Tick    += new EventHandler(MarkObject_Timer_Tick);

            // listen to Bitmap changes
            MyBindings.Add(BindingFactory.CreateBinding(TheDisplayModel, "Bmp", (o) => this.Invalidate(), null));

            parent.ButtonPressEvent   += OnButtonPress;
            parent.ButtonReleaseEvent += OnButtonRelease;
            parent.MotionNotifyEvent  += OnMotionNotify;
            parent.KeyPressEvent      += OnKeyPress;
            parent.KeyReleaseEvent    += OnKeyRelease;
        }
Пример #8
0
        protected virtual void OpenConnection()
        {
            String hostUrl = GetHostString();

            Binding binding;

            if (BindingFactory != null)
            {
                binding = BindingFactory.CreateBinding(typeof(I), ServiceName, hostUrl);
            }
            else
            {
                binding = CreateDefaultBinding();
            }

            if (ServiceName != null)
            {
                hostUrl += "/" + ServiceName;
            }

            ChannelFactory = ExtendChannelFactory(new ChannelFactory <I>(binding, new EndpointAddress(hostUrl)));
        }
Пример #9
0
 protected Binding CreateBinding(IEnumerable <IChannelController> controllers)
 {
     return(BindingFactory.CreateBinding(CameraAddress, controllers));
 }
Пример #10
0
        /// <summary>
        /// Wire controls to viewmodels (etc).
        /// </summary>
        void SetupBindings()
        {
            cmbEdgeStyle.Changed += (s, e) => TheVM.TheDocument.EdgeStyle = cmbEdgeStyle.ActiveText;
            cmbNodeStyle.Changed += (s, e) => TheVM.TheDocument.NodeStyle = cmbNodeStyle.ActiveText;
            // todo!!
            cmbEdgeStyle.PopupMenu += (s, e) => { cmbEdgeStyle.Clear(); TheVM.TheDocument.TikzStyles.Each((s2, i) => cmbEdgeStyle.AppendText(s2)); };
            cmbNodeStyle.PopupMenu += (s, e) => { cmbNodeStyle.Clear(); TheVM.TheDocument.TikzStyles.Each((s2, i) => cmbNodeStyle.AppendText(s2)); };


            /*splitContainer2.Panel2.ClientSizeChanged += new EventHandler(Panel2_Resize);
             *
             * //rasterControl1.Resize += new EventHandler(Panel2_Resize);
             * rasterControl1.SizeChanged += new EventHandler(Panel2_Resize);
             * rasterControl1.MouseMove += new MouseEventHandler(rasterControl1_MouseMove);
             * rasterControl1.MouseWheel += new MouseEventHandler(rasterControl1_MouseWheel);
             *
             * rasterControl1.JumpToSource += new EventHandler<RasterControl.JumpToSourceEventArgs>(rasterControl1_JumpToSource);
             * rasterControl1.ReplaceText += new EventHandler<TikzEdt.Overlay.ReplaceTextEventArgs>(rasterControl1_ReplaceText);
             *
             *
             *
             *
             * dynamicPreamble.PreambleChanged += (s, e) => TheVM.DynamicPreamble = dynamicPreamble.Preamble;
             * TheVM.DynamicPreamble = dynamicPreamble.Preamble;
             *
             * //TheVM.NewCommandHandler(this, new System.Windows.Input.ExecutedRoutedEventArgs()) ;
             *
             *
             * // add bindings
             * rasterControl1.DataBindings.Add("ShowOverlay", cmdShowOverlay, "Checked");
             * rasterControl1.DataBindings.Add("UsePolarCoordinates", chkUsePolar, "Checked");
             *
             * // Note that the TheDocument.Document property is bound "automatically" by the hack described in the TextEditorDocumentWrapper class.
             * var sp = BindingFactory.CreateProvider(TheVM, "TheDocument", vm => vm.TheDocument);
             * BindingFactory.CreateBindingSP(sp, "ParseTree", doc => rasterControl1.ParseTree = doc.ParseTree, () => rasterControl1.ParseTree = null);
             *
             * BindingFactory.CreateBindingSP(sp, "PdfPath", doc => rasterControl1.PdfPath = doc.PdfPath, () => rasterControl1.PdfPath = "");
             * BindingFactory.CreateBindingSP(sp, "ReloadPdf", doc => rasterControl1.ReloadPdf = doc.ReloadPdf, null);
             * BindingFactory.CreateBindingSP(sp, "Resolution", doc => rasterControl1.Resolution = doc.Resolution, null);
             * BindingFactory.CreateBindingSP(sp, "CurrentBB", doc => rasterControl1.BB = doc.CurrentBB, null);
             * BindingFactory.CreateBindingSP(sp, "AllowEditing", doc => rasterControl1.AllowEditing = doc.AllowEditing, null);
             * BindingFactory.CreateBindingSP(sp, "EdgeStyle", doc => rasterControl1.EdgeStyle = doc.EdgeStyle, null);
             * BindingFactory.CreateBindingSP(sp, "NodeStyle", doc => rasterControl1.NodeStyle = doc.NodeStyle, null);
             * BindingFactory.CreateBindingSP(sp, "Resolution", doc => toolStripZoomCtrlItem1.ZoomCtrl.Value = Convert.ToInt32(doc.Resolution), null);
             * toolStripZoomCtrlItem1.ZoomCtrl.ValueChanged += (s, e) => TheVM.TheDocument.Resolution = toolStripZoomCtrlItem1.ZoomCtrl.Value;
             * BindingFactory.CreateBindingSP(sp, "DisplayString", doc => this.Text = "TikzEdt - " + doc.DisplayString, () => this.Text = "TikzEdt");
             * BindingFactory.CreateBindingSP(sp, "IsStandAlone", doc => lblStandAlone.Visible = doc.IsStandAlone, () => lblStandAlone.Visible = false);
             *
             *
             * BindingFactory.CreateBinding(TheVM, "RasterRadialOffset", vm =>
             * { txtRadialOffset.TextBox.Text = vm.RasterRadialOffset.ToString(); rasterControl1.RadialOffset = vm.RasterRadialOffset; }, null);
             * BindingFactory.CreateBinding(TheVM, "RasterSteps", vm =>
             * { txtRadialSteps.TextBox.Text = vm.RasterSteps.ToString(); rasterControl1.RasterRadialSteps = (uint)vm.RasterSteps; }, null);
             * BindingFactory.CreateBinding(TheVM, "RasterWidth", vm =>
             * { cmbGrid.ComboBox.Text = vm.RasterWidth.ToString(); rasterControl1.RasterWidth = vm.RasterWidth; }, null);
             * txtRadialOffset.TextChanged += (s, e) =>
             * {
             *  double d;
             *  if (Double.TryParse(txtRadialOffset.TextBox.Text, out d))
             *      TheVM.RasterRadialOffset = d;
             * };
             * txtRadialSteps.TextChanged += (s, e) =>
             * {
             *  uint d;
             *  if (UInt32.TryParse(txtRadialSteps.TextBox.Text, out d))
             *      TheVM.RasterSteps = (int)d;
             * };
             * cmbGrid.ComboBox.TextChanged += (s, e) =>
             * {
             *  double d;
             *  if (Double.TryParse(cmbGrid.ComboBox.Text, out d))
             *      TheVM.RasterWidth = d;
             * };
             *
             * rasterControl1.ToolChanged += (sender, e) => TheVM.CurrentTool = rasterControl1.Tool;
             *
             * BindingFactory.CreateBinding(TheVM, "EditorMode", vm =>
             * {
             *  wYSIWYGToolStripMenuItem.Checked = vm.EditorMode == TEMode.Wysiwyg;
             *  productionToolStripMenuItem.Checked = vm.EditorMode == TEMode.Production;
             *  previewToolStripMenuItem.Checked = vm.EditorMode == TEMode.Preview;
             * }, null);
             *
             * var errlistsp = BindingFactory.CreateProviderSP(sp, "TexErrors", doc => doc.TexErrors);
             * BindingFactory.CreateCollectionBindingSP(errlistsp, (s, e) => FillErrorsList());
             *
             * BindingFactory.CreateBinding(TheVM, "CurrentTool",
             *  vm =>
             *  {
             *      ToolButtons.Each((tsb, i) => tsb.Checked = ((int)vm.CurrentTool == i));
             *      rasterControl1.Tool = vm.CurrentTool;
             *  }, null);
             *
             * BindingFactory.CreateBinding(TheCompiler.Instance, "Compiling",
             *  (c) => { cmdAbortCompile.Enabled = abortCompilationToolStripMenuItem.Enabled = c.Compiling; },
             *  () => { cmdAbortCompile.Enabled = abortCompilationToolStripMenuItem.Enabled = true; });
             *
             *
             * // load settings
             * var S = Properties.Settings.Default;
             * Width = S.Window_Width;
             * Height = S.Window_Height;
             * SizeChanged += (s, e) => { Properties.Settings.Default.Window_Height = Height; Properties.Settings.Default.Window_Width = Width; };
             *
             * this.Left = S.Window_Left;
             * this.Top = S.Window_Top;
             * LocationChanged += (s, e) => { Properties.Settings.Default.Window_Top = Top; Properties.Settings.Default.Window_Left = Left; };
             *
             * WindowState = S.Window_State;
             * ClientSizeChanged += (s, e) => Properties.Settings.Default.Window_State = this.WindowState;
             *
             * try
             * {
             *  splitContainer2.SplitterDistance = S.OverlayCanvasCol2WidthSetting;
             *  splitContainer1.SplitterDistance = S.LeftToolsColWidthSetting;
             * }
             * catch (Exception) { }
             * splitContainer2.SplitterMoved += (s, e) => Properties.Settings.Default.OverlayCanvasCol2WidthSetting = splitContainer2.SplitterDistance;
             * splitContainer1.SplitterMoved += (s, e) => Properties.Settings.Default.LeftToolsColWidthSetting = splitContainer1.SplitterDistance;
             *
             * BindingFactory.CreateBinding(S, "Editor_ShowLineNumbers", s => txtCode.ShowLineNumbers = s.Editor_ShowLineNumbers, null);
             * BindingFactory.CreateBinding(S, "Editor_Font", s => txtCode.Font = s.Editor_Font, null);
             * BindingFactory.CreateBinding(S, "Snippets_ShowThumbs", s => snippetList1.ShowThumbnails = s.Snippets_ShowThumbs, null);
             *
             * BindingFactory.CreateBinding(S, "Snippets_ShowThumbs", s =>
             * {
             *  autoCompilationOnChangeToolStripMenuItem.Checked = s.AutoCompileOnDocumentChange;
             *  TheVM.AutoCompileOnDocumentChange = s.AutoCompileOnDocumentChange;
             * }, null);
             * autoCompilationOnChangeToolStripMenuItem.CheckedChanged += (s, e) =>
             * {
             *  S.AutoCompileOnDocumentChange = TheVM.AutoCompileOnDocumentChange = autoCompilationOnChangeToolStripMenuItem.Checked;
             * };*/

            // Note that the TheDocument.Document property is bound "automatically" by the hack described in the TextEditorDocumentWrapper class.
            var sp = BindingFactory.CreateProvider(TheVM, "TheDocument", vm => vm.TheDocument);

            BindingFactory.CreateBindingSP(sp, "ParseTree", doc => rasterControl1.ParseTree = doc.ParseTree, () => rasterControl1.ParseTree = null);

            BindingFactory.CreateBindingSP(sp, "PdfPath", doc => rasterControl1.PdfPath           = doc.PdfPath, () => rasterControl1.PdfPath = "");
            BindingFactory.CreateBindingSP(sp, "ReloadPdf", doc => rasterControl1.ReloadPdf       = doc.ReloadPdf, null);
            BindingFactory.CreateBindingSP(sp, "Resolution", doc => rasterControl1.Resolution     = doc.Resolution, null);
            BindingFactory.CreateBindingSP(sp, "CurrentBB", doc => rasterControl1.BB              = doc.CurrentBB, null);
            BindingFactory.CreateBindingSP(sp, "AllowEditing", doc => rasterControl1.AllowEditing = doc.AllowEditing, null);
            BindingFactory.CreateBindingSP(sp, "EdgeStyle", doc => rasterControl1.EdgeStyle       = doc.EdgeStyle, null);
            BindingFactory.CreateBindingSP(sp, "NodeStyle", doc => rasterControl1.NodeStyle       = doc.NodeStyle, null);
            BindingFactory.CreateBindingSP(sp, "Resolution", doc => scZoom.Value = Convert.ToInt32(doc.Resolution), null);
            scZoom.ValueChanged += (s, e) => TheVM.TheDocument.Resolution = scZoom.Value;
            BindingFactory.CreateBindingSP(sp, "DisplayString", doc => this.Title           = "TikzEdt - " + doc.DisplayString, () => this.Title = "TikzEdt");
            BindingFactory.CreateBindingSP(sp, "IsStandAlone", doc => lblStandAlone.Visible = doc.IsStandAlone, () => lblStandAlone.Visible = false);


            BindingFactory.CreateBinding(TheVM, "RasterRadialOffset", vm =>
                                         { txtRadialOffset.Value = vm.RasterRadialOffset; rasterControl1.RadialOffset = vm.RasterRadialOffset; }, null);
            BindingFactory.CreateBinding(TheVM, "RasterSteps", vm =>
                                         { txtRadialSteps.Value = vm.RasterSteps; rasterControl1.RasterRadialSteps = (uint)vm.RasterSteps; }, null);
            BindingFactory.CreateBinding(TheVM, "RasterWidth", vm =>
                                         { cmbGrid.Entry.Text = vm.RasterWidth.ToString(); rasterControl1.RasterWidth = vm.RasterWidth; }, null);
            txtRadialOffset.ValueChanged += (s, e) =>
            {
                //double d;
                //if (Double.TryParse(txtRadialOffset.TextBox.Text, out d))
                TheVM.RasterRadialOffset = txtRadialOffset.Value;
            };
            txtRadialSteps.ValueChanged += (s, e) =>
            {
                //uint d;
                //if (UInt32.TryParse(txtRadialSteps.TextBox.Text, out d))
                TheVM.RasterSteps = txtRadialSteps.ValueAsInt;
            };
            cmbGrid.Changed += (s, e) =>
            {
                double d;
                if (Double.TryParse(cmbGrid.ActiveText, out d))
                {
                    TheVM.RasterWidth = d;
                }
            };

            rasterControl1.ToolChanged += (sender, e) => TheVM.CurrentTool = rasterControl1.Tool;

            BindingFactory.CreateBinding(TheVM, "CurrentTool",
                                         vm =>
            {
                ToolButtons.Each((tsb, i) => tsb.SetChecked((int)vm.CurrentTool == i));
                rasterControl1.Tool = vm.CurrentTool;
            }, null);

            BindingFactory.CreateBinding(TheCompiler.Instance, "Compiling",
                                         (c) => { cmdAbortCompile.Sensitive = abortCompilationToolStripMenuItem.Sensitive = c.Compiling; },
                                         () => { cmdAbortCompile.Sensitive = abortCompilationToolStripMenuItem.Sensitive = true; });
        }