Ejemplo n.º 1
0
        /// <summary>
        /// Can only call before openning the host
        /// </summary>
        public void EnableMetadataExchange(bool enableHttpGet = true)
        {
            if (State == CommunicationState.Opened)
            {
                throw new InvalidOperationException("Host is already opened");
            }

            ServiceMetadataBehavior metadataBehavior;

            metadataBehavior = Description.Behaviors.Find <ServiceMetadataBehavior>();

            if (metadataBehavior == null)
            {
                metadataBehavior = new ServiceMetadataBehavior();
                Description.Behaviors.Add(metadataBehavior);

                if (BaseAddresses.Any((uri) => uri.Scheme == "http"))
                {
                    metadataBehavior.HttpGetEnabled = enableHttpGet;
                }

                if (BaseAddresses.Any((uri) => uri.Scheme == "https"))
                {
                    metadataBehavior.HttpsGetEnabled = enableHttpGet;
                }
            }
            AddAllMexEndPoints();
        }
Ejemplo n.º 2
0
        public void Open()
        {
            try
            {
                // Step 4 of the hosting procedure: Enable metadata exchange.
                //var smb = new ServiceMetadataBehavior();
                //smb.HttpGetEnabled = true;

#if NET461
                serviceHost = new ServiceHost(SingletonInstance, BaseAddresses.ToArray());
                serviceHost.AddServiceEndpoint(
                    ContractType,
                    TheBinding,
                    SingletonInstance.GetType().Name);

                if (ServiceBehaviors != null)
                {
                    foreach (var item in ServiceBehaviors)
                    {
                        serviceHost.Description.Behaviors.Add(item);
                    }
                }
                serviceHost.Open();
#endif
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                throw ex;
            }
        }
Ejemplo n.º 3
0
        public void MoveToMemoryList(BasicOperations function, BaseAddresses fromValue, BaseAddresses toValue, TextBox[] textBoxes)
        {
            var disp = DispTextBox.Text;

            switch (function)
            {
            case BasicOperations.MOV:
                textBoxes[1].Text = textBoxes[0].Text;
                if (fromValue == BaseAddresses.BX || fromValue == BaseAddresses.BP)
                {
                    MemoryCells.Add(new MemoryCell {
                        Data             = textBoxes[0].Text,
                        EffectiveAddress = $"{textBoxes[0].Text}"
                    });
                }
                else
                {
                    MemoryCells.Add(new MemoryCell {
                        Data             = textBoxes[1].ToString(),
                        EffectiveAddress = $"{textBoxes[1]}"
                    });
                }
                break;

            case BasicOperations.ECHG:
                var toText = textBoxes[1].Text;
                textBoxes[1].Text = textBoxes[0].Text;
                textBoxes[0].Text = toText;
                if (fromValue == BaseAddresses.BX || fromValue == BaseAddresses.BP)
                {
                    MemoryCells.Add(new MemoryCell {
                        Data             = textBoxes[0].Text.ToString(),
                        EffectiveAddress = $"{textBoxes[0].Text}"
                    });
                }
                else
                {
                    MemoryCells.Add(new MemoryCell {
                        Data             = textBoxes[1].Text,
                        EffectiveAddress = $"{textBoxes[1].Text}"
                    });
                }
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        protected override void OnOpen(TimeSpan timeout)
        {
            var instancing = Description.Behaviors.Find <DelegateInstanceProviderServiceBehavior>();

            if (instancing == null)
            {
                instancing = new Func <object>(() => new RelayService(_server.CreateClient(), _loggerFactory));
                Description.Behaviors.Add(instancing);
            }

            var mode    = BaseAddresses.Single().Scheme == Uri.UriSchemeHttps ? EndToEndWebHttpSecurityMode.Transport : EndToEndWebHttpSecurityMode.None;
            var binding = new WebHttpRelayBinding(mode, RelayClientAuthenticationType.None);
            //binding.TransferMode = TransferMode.Streamed;

            var endpoint = AddServiceEndpoint(typeof(RelayService), binding, string.Empty);

            endpoint.Behaviors.Add(new WebHttpBehavior());
            endpoint.Behaviors.Add(new TransportClientEndpointBehavior(_serverOptions.SharedAccessKey));

            base.OnOpen(timeout);
        }
Ejemplo n.º 5
0
        private TextBox[] GetMemoryOperationsWithBaseAddressesTypeCheckedTextBoxes(BaseAddresses toValue,
                                                                                   BaseAddresses fromValue)
        {
            TextBox toTextBox = toValue switch {
                BaseAddresses.BP => BpTextBox,
                BaseAddresses.AX => AxTextBox,
                BaseAddresses.BX => BxTextBox,
                BaseAddresses.CX => CxTextBox,
                BaseAddresses.DX => DxTextBox,
                BaseAddresses.AH => AhTextBox,
                BaseAddresses.BH => BhTextBox,
                BaseAddresses.CH => ChTextBox,
                BaseAddresses.DH => DhTextBox,
                BaseAddresses.AL => AlTextBox,
                BaseAddresses.BL => BlTextBox,
                BaseAddresses.CL => ClTextBox,
                BaseAddresses.DL => DlTextBox,
                _ => throw new ArgumentOutOfRangeException()
            };
            TextBox fromTextBox = fromValue switch {
                BaseAddresses.BP => BpTextBox,
                BaseAddresses.AX => AxTextBox,
                BaseAddresses.BX => BxTextBox,
                BaseAddresses.CX => CxTextBox,
                BaseAddresses.DX => DxTextBox,
                BaseAddresses.AH => AhTextBox,
                BaseAddresses.BH => BhTextBox,
                BaseAddresses.CH => ChTextBox,
                BaseAddresses.DH => DhTextBox,
                BaseAddresses.AL => AlTextBox,
                BaseAddresses.BL => BlTextBox,
                BaseAddresses.CL => ClTextBox,
                BaseAddresses.DL => DlTextBox,
                _ => throw new ArgumentOutOfRangeException()
            };

            return(new TextBox[2] {
                fromTextBox, toTextBox
            });
        }
 public void EnableServiceBusDiscovery(Uri scope, bool enableMEX = true)
 {
     EnableServiceBusDiscovery(scope, enableMEX, BaseAddresses.ToArray());
 }
Ejemplo n.º 7
0
 public T AddBaseAddresses(params Uri[] baseAddresses)
 {
     BaseAddresses.AddAll(baseAddresses);
     return((T)this);
 }
Ejemplo n.º 8
0
        private void Configure()
        {
            this.Credentials.UseIdentityConfiguration = true;
            this.Credentials.IdentityConfiguration    = new IdentityConfiguration()
            {
                ClaimsAuthenticationManager = new AuthenticationManager(ServiceAuthenticators, BaseAddresses.ToArray()),
                ClaimsAuthorizationManager  = new AuthorizationManager(ServiceAuthorizers, BaseAddresses.ToArray()),
                IssuerNameRegistry          = new X509CertIssuerNameRegistry(),
                CertificateValidationMode   = X509CertificateValidationMode.None
            };
            this.Description.Behaviors.Find <ServiceAuthorizationBehavior>().PrincipalPermissionMode = PrincipalPermissionMode.Always;

            foreach (var serviceSecurityMode in serviceSecurityModes)
            {
                if (serviceSecurityMode is NoneServiceSecurityMode)
                {
                    Logger.WarnFormat("*** Security mode is set to None which is insecure! ***");
                }
                var endpoints = this.AddServiceEndpoints(serviceSecurityMode);
                foreach (var serviceEndpoint in endpoints)
                {
                    Logger.InfoFormat("Endpoint {0} added, security mode {1}, uri {2}", serviceEndpoint.Contract.ContractType.FullName, serviceSecurityMode, serviceEndpoint.Address.Uri);
                }
            }
            this.SetServiceHostSecurity(serviceSecurityModes);
            this.EnableMetadataExchange();

            this.AddDependencyInjectionBehavior <T>(hostContainer);
            this.EnableTransactionFlowAndReliableMessaging();
            this.IncludeExceptionDetailInFaults = DebugHelper.IncludeExceptionDetailInFaults;
            this.AddErrorHandler(new ErrorHandler(Logger));
            this.SecurityAuditEnabled = true;

            this.Description.Behaviors.Find <ServiceBehaviorAttribute>().InstanceContextMode =
                InstanceContextMode.PerCall;
            this.Description.Behaviors.Add(new AuditInterceptorServiceBehavior());
            this.TypesToResolve = RootScope.ComponentRegistry.Registrations.Select(r => r.Activator.LimitType).ToArray();
        }