Пример #1
0
 public DebugInfo(MessageDirection Direction, string FromID, string FromIP, Message Content)
 {
     this.FromID = FromID;
     this.FromIP = FromIP;
     this.Content = Content;
     this.Direction = Direction;
 }
 public WSSecurityOneDotZeroSendSecurityHeader(Message message, string actor, bool mustUnderstand, bool relay,
     SecurityStandardsManager standardsManager,
     SecurityAlgorithmSuite algorithmSuite,
     MessageDirection direction)
     : base(message, actor, mustUnderstand, relay, standardsManager, algorithmSuite, direction)
 {
 }
Пример #3
0
 public QueuedMessage(MessageDirection direction, int chunk_stream_id, RTMPMessage msg)
 {
   this.Direction     = direction;
   this.ChunkStreamId = chunk_stream_id;
   this.Message       = msg;
   this.TimeStamp     = Stopwatch.Elapsed;
 }
Пример #4
0
 public GmailEmail(DateTimeOffset timestamp, MessageDirection direction, string subject, string deeplink)
 {
     _timestamp = timestamp;
     _direction = direction;
     _subject = subject;
     _deepLink = deeplink;
 }
 public GmailEmail(DateTimeOffset timestamp, MessageDirection direction, string subject, string content)
 {
     _timestamp = timestamp;
     _direction = direction;
     _subject = subject;
     _content = content;
 }
Пример #6
0
		public UserCommandMessage(StringDictionary StringResources, MessageDirection Direction, byte[] Buffer, int StartIndex = 0) 
            : base () 
        {
            this.TransferDirection = Direction;
            this.StringResources = StringResources;
            ReadFrom(Buffer, StartIndex);
        }
 public WSSecurityOneDotOneReceiveSecurityHeader(Message message, string actor, bool mustUnderstand, bool relay,
     SecurityStandardsManager standardsManager,
     SecurityAlgorithmSuite algorithmSuite,
     int headerIndex, MessageDirection direction)
     : base(message, actor, mustUnderstand, relay, standardsManager, algorithmSuite, headerIndex, direction)
 {
 }
            internal MethodInfoOperationSelector(ContractDescription description, MessageDirection directionThatRequiresClientOpSelection)
            {
                operationMap = new Dictionary<object, string>();

                for (int i = 0; i < description.Operations.Count; i++)
                {
                    OperationDescription operation = description.Operations[i];
                    if (operation.Messages[0].Direction == directionThatRequiresClientOpSelection)
                    {
                        if (operation.SyncMethod != null)
                        {
                            if (!operationMap.ContainsKey(operation.SyncMethod.MethodHandle))
                                operationMap.Add(operation.SyncMethod.MethodHandle, operation.Name);
                        }
    
                        if (operation.BeginMethod != null)
                        {
                            if (!operationMap.ContainsKey(operation.BeginMethod.MethodHandle))
                            {
                                operationMap.Add(operation.BeginMethod.MethodHandle, operation.Name);
                                operationMap.Add(operation.EndMethod.MethodHandle, operation.Name);                    
                            }
                        }

                        if (operation.TaskMethod != null)
                        {
                            if (!operationMap.ContainsKey(operation.TaskMethod.MethodHandle))
                            {
                                operationMap.Add(operation.TaskMethod.MethodHandle, operation.Name);
                            }
                        }
                    }
                }
            }
Пример #9
0
        public Message()
        {
            this._headNumber = 1;
            this._messageNumber = 1;
            this._messageTitle = DateTime.Now.Ticks.ToString().Substring(0, 8);

            this._generalParametersPresent = true;
            this._messageTestPresent = true;
            this._numberOfCounters = 0;
            this._numberOfPostdates = 0;
            this._presentTimeCodes = false;
            this._numberOfBarcodes = 0;

            this._messageDirection = MessageDirection.Normal;
            this._horizontalDirection = HorizontalDirection.Normal;
            this._verticalDirection = VerticalDirection.Normal;
            this._tachoMode = TachoMode.No;
            this._manualTrigger = ManualTrigger.Yes;
            this._triggerMode = TriggerMode.Object;
            this._unitForMargins = UnitForMargins.Millimeters;
            this._dinMode = DINMode.No;

            this._mulitTopValue = 0;
            this._objectTopFilter = 1;
            this._tachoDivision = 1;
            this._forwardMargin = 3;
            this._returnMargin = 3;
            this._interval = 3;
            this._printingSpeed = 100;
            this._algorithmNumber = 0;

            this.Lines = new List<Line>();
        }
Пример #10
0
 public MessageBufferEventArgs(byte[] MessageBuffer, int Length, IntPtr MemoryAddress, MessageDirection Direction = MessageDirection.ServerToClient)
 {
     this.MessageBuffer = MessageBuffer;
     this.Length = Length;
     this.MemoryAddress = MemoryAddress;
     this.Direction = Direction;
 }
 internal override void InferMessageDescription(OperationDescription operation, object owner, MessageDirection direction)
 {
     ContractInferenceHelper.CheckForDisposableParameters(operation, this.InternalDeclaredMessageType);
     string overridingAction = null;
     SerializerOption dataContractSerializer = SerializerOption.DataContractSerializer;
     Receive receive = owner as Receive;
     if (receive != null)
     {
         overridingAction = receive.Action;
         dataContractSerializer = receive.SerializerOption;
     }
     else
     {
         ReceiveReply reply = owner as ReceiveReply;
         overridingAction = reply.Action;
         dataContractSerializer = reply.Request.SerializerOption;
     }
     if (direction == MessageDirection.Input)
     {
         ContractInferenceHelper.AddInputMessage(operation, overridingAction, this.InternalDeclaredMessageType, dataContractSerializer);
     }
     else
     {
         ContractInferenceHelper.AddOutputMessage(operation, overridingAction, this.InternalDeclaredMessageType, dataContractSerializer);
     }
 }
Пример #12
0
        public SecurityHeader(Message message,
            string actor, bool mustUnderstand, bool relay,
            SecurityStandardsManager standardsManager, SecurityAlgorithmSuite algorithmSuite,
            MessageDirection transferDirection)
        {
            if (message == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("message");
            }
            if (actor == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("actor");
            }
            if (standardsManager == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("standardsManager");
            }
            if (algorithmSuite == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("algorithmSuite");
            }

            _message = message;
            _actor = actor;
            _mustUnderstand = mustUnderstand;
            _relay = relay;
            _standardsManager = standardsManager;
            _algorithmSuite = algorithmSuite;
            _transferDirection = transferDirection;
        }
 protected SendSecurityHeader(Message message, string actor, bool mustUnderstand, bool relay,
     SecurityStandardsManager standardsManager,
     SecurityAlgorithmSuite algorithmSuite, 
     MessageDirection transferDirection)
     : base(message, actor, mustUnderstand, relay, standardsManager, algorithmSuite, transferDirection)
 {
     this.elementContainer = new SendSecurityHeaderElementContainer();
 }
 internal static MessageDirection Opposite(MessageDirection d)
 {
     if (d != MessageDirection.Input)
     {
         return MessageDirection.Input;
     }
     return MessageDirection.Output;
 }
 internal static bool IsDefined(MessageDirection value)
 {
     if (value != MessageDirection.Input)
     {
         return (value == MessageDirection.Output);
     }
     return true;
 }
Пример #16
0
 public InterceptedMessage(ulong requestID, int index, Type messageType, MessageDirection direction, byte[] data)
 {
     this.requestID = requestID;
     this.index = index;
     this.messageType = messageType;
     this.direction = direction;
     this.data = data;
 }
 protected SendSecurityHeader(Message message, string actor, bool mustUnderstand, bool relay,
     SecurityStandardsManager standardsManager,
     SecurityAlgorithmSuite algorithmSuite,
     MessageDirection transferDirection)
     : base(message, actor, mustUnderstand, relay, standardsManager, algorithmSuite, transferDirection)
 {
     throw ExceptionHelper.PlatformNotSupported();
 }
        internal MessageDescription(string action, MessageDirection direction, MessageDescriptionItems items)
        {
            if (!MessageDirectionHelper.IsDefined(direction))
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("direction"));

            this.action = action;
            this.direction = direction;
            this.items = items;
        }
Пример #19
0
 protected ReceiveSecurityHeader(Message message, string actor, bool mustUnderstand, bool relay,
     SecurityStandardsManager standardsManager,
     SecurityAlgorithmSuite algorithmSuite,
     int headerIndex,
     MessageDirection direction)
     : base(message, actor, mustUnderstand, relay, standardsManager, algorithmSuite, direction)
 {
     throw ExceptionHelper.PlatformNotSupported();
 }
 /// <summary>
 /// Publish the message to the scaleout so that other servers can receive it
 /// </summary>
 /// <param name="message"></param>
 public override async Task Publish(MessageDirection direction, IMessage message, ScaleOutOrigin scaleOutOrigin)
 {
     if (!InitSuccess) return;
     try
     {
         await ScaleToMongoDb(message);
     }
     catch (Exception ex)
     {
         Composable.GetExport<IXLogger>().Error(ex, "Failed to publish in MongoDB ScaleOut");
     }
 }        
 internal ReceiveSecurityHeader CreateReceiveSecurityHeader(Message message, string actor, SecurityAlgorithmSuite algorithmSuite, MessageDirection direction)
 {
     ReceiveSecurityHeader header = this.TryCreateReceiveSecurityHeader(message, actor, algorithmSuite, direction);
     if (header != null)
     {
         return header;
     }
     if (string.IsNullOrEmpty(actor))
     {
         throw TraceUtility.ThrowHelperError(new MessageSecurityException(System.ServiceModel.SR.GetString("UnableToFindSecurityHeaderInMessageNoActor")), message);
     }
     throw TraceUtility.ThrowHelperError(new MessageSecurityException(System.ServiceModel.SR.GetString("UnableToFindSecurityHeaderInMessage", new object[] { actor })), message);
 }
 internal static void OverrideFlow(BindingParameterCollection parameters, string action, MessageDirection direction, TransactionFlowOption option)
 {
     Dictionary<DirectionalAction, TransactionFlowOption> dictionary = EnsureDictionary(parameters);
     DirectionalAction key = new DirectionalAction(direction, action);
     if (dictionary.ContainsKey(key))
     {
         dictionary[key] = option;
     }
     else
     {
         dictionary.Add(key, option);
     }
 }
 internal ServiceChannelProxy(System.Type interfaceType, System.Type proxiedType, MessageDirection direction, ServiceChannel serviceChannel) : base(proxiedType)
 {
     if (!MessageDirectionHelper.IsDefined(direction))
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("direction"));
     }
     this.interfaceType = interfaceType;
     this.proxiedType = proxiedType;
     this.serviceChannel = serviceChannel;
     this.proxyRuntime = serviceChannel.ClientRuntime.GetRuntime();
     this.methodDataCache = new MethodDataCache();
     this.objectWrapper = new MbrObject(this, proxiedType);
 }
 internal override void InferMessageDescription(OperationDescription operation, object owner, MessageDirection direction)
 {
     ContractInferenceHelper.CheckForDisposableParameters(operation, this.argumentTypes);
     string overridingAction = (owner is Receive) ? ((Receive) owner).Action : ((ReceiveReply) owner).Action;
     if (direction == MessageDirection.Input)
     {
         ContractInferenceHelper.AddInputMessage(operation, overridingAction, this.argumentNames, this.argumentTypes);
     }
     else
     {
         ContractInferenceHelper.AddOutputMessage(operation, overridingAction, this.ArgumentNames, this.ArgumentTypes);
     }
 }
 internal ReceiveSecurityHeader TryCreateReceiveSecurityHeader(Message message, string actor, SecurityStandardsManager standardsManager, SecurityAlgorithmSuite algorithmSuite, MessageDirection direction)
 {
     int headerIndex = message.Headers.FindHeader(this.HeaderName.Value, this.HeaderNamespace.Value, new string[] { actor });
     if ((headerIndex < 0) && string.IsNullOrEmpty(actor))
     {
         headerIndex = message.Headers.FindHeader(this.HeaderName.Value, this.HeaderNamespace.Value, message.Version.Envelope.UltimateDestinationActorValues);
     }
     if (headerIndex < 0)
     {
         return null;
     }
     MessageHeaderInfo info = message.Headers[headerIndex];
     return this.CreateReceiveSecurityHeader(message, info.Actor, info.MustUnderstand, info.Relay, standardsManager, algorithmSuite, direction, headerIndex);
 }
Пример #26
0
 /// <summary>
 /// Gets messages filtered by different criteria.
 /// </summary>
 /// <param name="direction">Incoming\outgoing messages.</param>
 /// <param name="offset">Used for paged results.</param>
 /// <param name="count">Count of messages to return.</param>
 /// <param name="filter">MessageFilter to filter messages.</param>
 /// <param name="maxMsgLength">Max message length to load. Pass 0 to load complete messages.</param>
 /// <param name="timeOffset">If specified, returns messages not older than timeOffset seconds.</param>
 /// <returns>List of messages.</returns>
 public List<Message> GetList(MessageDirection direction, int? offset, int? count, MessageFilter filter, int? maxMsgLength, int? timeOffset)
 {
     var request = new Request("messages.get");
     request.Parameters.Add("out", ((int)direction).ToString());
     if (offset.HasValue)
         request.Parameters.Add("offset", offset.ToString());
     if (count.HasValue)
         request.Parameters.Add("count", count.ToString());
     if (filter != MessageFilter.None)
         request.Parameters.Add("filters", ((int)filter).ToString());
     if (maxMsgLength.HasValue)
         request.Parameters.Add("preview_length", maxMsgLength.ToString());
     if (timeOffset.HasValue)
         request.Parameters.Add("time_offset", timeOffset.ToString());
     return Api.Call<MessageListResponse>(request).Messages;
 }
Пример #27
0
		public static void AssertMessageAndBodyDescription (
			string action, MessageDirection dir,
			Type messageType, string bodyWrapperName,
			string bodyWrapperNS, bool bodyHasReturn,
			MessageDescription md, string label)
		{
			Assert.AreEqual (action, md.Action, label + " Action");
			Assert.AreEqual (dir, md.Direction, label + " Direction");
			Assert.AreEqual (messageType, md.MessageType, label + " MessageType");
			Assert.AreEqual (bodyWrapperName, md.Body.WrapperName,
				label + " Body.WrapperName");
			Assert.AreEqual (bodyWrapperNS, md.Body.WrapperNamespace,
				label + " Body.WrapperNamespace");
			Assert.AreEqual (bodyHasReturn, md.Body.ReturnValue != null,
				label + "Body hasReturn");
		}
Пример #28
0
        public static MessageDescription CreateMessageDescription(OperationDescription operation, bool isResponse,
            MessageDirection direction, string overridingAction, Type type, SerializerOption serializerOption)
        {
            MessageDescription result;
            if (type != null && IsMessageContract(type))
            {
                result = CreateFromMessageContract(operation, isResponse, direction, overridingAction, type);
            }
            else
            {
                // For Send/Receive, we do not wrap message
                result = CreateEmptyMessageDescription(operation, isResponse, direction, overridingAction);
                AddMessagePartDescription(operation, isResponse, result, type, serializerOption);
            }

            return result;
        }
 internal MethodInfoOperationSelector(ContractDescription description, MessageDirection directionThatRequiresClientOpSelection)
 {
     for (int i = 0; i < description.Operations.Count; i++)
     {
         OperationDescription description2 = description.Operations[i];
         if (description2.Messages[0].Direction == directionThatRequiresClientOpSelection)
         {
             if ((description2.SyncMethod != null) && !this.operationMap.ContainsKey(description2.SyncMethod.MethodHandle))
             {
                 this.operationMap.Add(description2.SyncMethod.MethodHandle, description2.Name);
             }
             if ((description2.BeginMethod != null) && !this.operationMap.ContainsKey(description2.BeginMethod.MethodHandle))
             {
                 this.operationMap.Add(description2.BeginMethod.MethodHandle, description2.Name);
                 this.operationMap.Add(description2.EndMethod.MethodHandle, description2.Name);
             }
         }
     }
 }
 internal MessageDescription(MessageDescription other)
 {
     this.action = other.action;
     this.direction = other.direction;
     this.Items.Body = other.Items.Body.Clone();
     foreach (MessageHeaderDescription description in other.Items.Headers)
     {
         this.Items.Headers.Add(description.Clone() as MessageHeaderDescription);
     }
     foreach (MessagePropertyDescription description2 in other.Items.Properties)
     {
         this.Items.Properties.Add(description2.Clone() as MessagePropertyDescription);
     }
     this.MessageName = other.MessageName;
     this.MessageType = other.MessageType;
     this.XsdTypeName = other.XsdTypeName;
     this.hasProtectionLevel = other.hasProtectionLevel;
     this.ProtectionLevel = other.ProtectionLevel;
 }
Пример #31
0
 internal SendSecurityHeader CreateSendSecurityHeader(Message message,
                                                      string actor, bool mustUnderstand, bool relay,
                                                      SecurityAlgorithmSuite algorithmSuite, MessageDirection direction)
 {
     return(SecurityVersion.CreateSendSecurityHeader(message, actor, mustUnderstand, relay, this, algorithmSuite, direction));
 }
 public SMS(DateTimeOffset timestamp, MessageDirection direction, string subject)
 {
     _timestamp = timestamp;
     _direction = direction;
     _subject   = subject;
 }
Пример #33
0
 internal ReceiveSecurityHeader TryCreateReceiveSecurityHeader(Message message,
                                                               string actor,
                                                               SecurityAlgorithmSuite algorithmSuite, MessageDirection direction)
 {
     return(SecurityVersion.TryCreateReceiveSecurityHeader(message, actor, this, algorithmSuite, direction));
 }
Пример #34
0
        protected void OnResync(MessageDirection direction, int skipped, int size)
        {
            var handler = Resync;

            handler?.Invoke(direction, skipped, size);
        }
 public static bool IsOutbound(this MessageDirection messageDirection)
 {
     return(messageDirection == MessageDirection.Outbound);
 }
Пример #36
0
 public Message(DateTime time, MessageDirection dir, string hex) : this(time, dir, new ArraySegment <byte>(StringUtils.StringToByteArray(hex)))
 {
 }
Пример #37
0
 internal static MessageDirection Opposite(MessageDirection d)
 {
     return(d == MessageDirection.Input ? MessageDirection.Output : MessageDirection.Input);
 }
Пример #38
0
 public Message(DateTime time, MessageDirection dir, string hex) : this(time, dir, new ArraySegment <byte>(hex.ToByteArrayHex()))
 {
 }
Пример #39
0
 internal abstract void InferMessageDescription(OperationDescription operation, object owner, MessageDirection direction);
Пример #40
0
        public ContractDescription ImportContract(PortType wsdlPortType)
        {
            foreach (IWsdlImportExtension extension in wsdl_extensions)
            {
                extension.BeforeImport(wsdl_documents, xmlschemas, policies);
            }

            ContractDescription cd = new ContractDescription(wsdlPortType.Name, wsdlPortType.ServiceDescription.TargetNamespace);

            foreach (Operation op in wsdlPortType.Operations)
            {
                OperationDescription op_descr = new OperationDescription(op.Name, cd);

                foreach (OperationMessage opmsg in op.Messages)
                {
                    /* OperationMessageCollection */
                    MessageDescription msg_descr;
                    MessageDirection   dir    = MessageDirection.Input;
                    string             action = "";

                    if (opmsg.GetType() == typeof(OperationInput))
                    {
                        dir = MessageDirection.Input;
                    }
                    else if (opmsg.GetType() == typeof(OperationOutput))
                    {
                        dir = MessageDirection.Output;
                    }
                    /* FIXME: OperationFault--> OperationDescription.Faults ? */

                    if (opmsg.ExtensibleAttributes != null)
                    {
                        for (int i = 0; i < opmsg.ExtensibleAttributes.Length; i++)
                        {
                            if (opmsg.ExtensibleAttributes [i].LocalName == "Action" &&
                                opmsg.ExtensibleAttributes [i].NamespaceURI == "http://www.w3.org/2006/05/addressing/wsdl")
                            {
                                /* addressing:Action */
                                action = opmsg.ExtensibleAttributes [i].Value;
                            }
                            /* FIXME: other attributes ? */
                        }
                    }

                    // fill Action from operation binding if required.
                    if (action == "")
                    {
                        if (dir != MessageDirection.Input)
                        {
                            action = GetActionFromOperationBinding(wsdlPortType, op.Name);
                        }
                        else
                        {
                            action = "*";
                        }
                    }

                    msg_descr = new MessageDescription(action, dir);
                    /* FIXME: Headers ? */

                    op_descr.Messages.Add(msg_descr);
                }

                cd.Operations.Add(op_descr);
            }

            WsdlContractConversionContext context = new WsdlContractConversionContext(cd, wsdlPortType);

            foreach (IWsdlImportExtension extension in wsdl_extensions)
            {
                extension.ImportContract(this, context);
            }

            return(cd);
        }
Пример #41
0
 public Message(DateTime time, MessageDirection direction, ArraySegment <byte> data)
 {
     Time      = time;
     Direction = direction;
     Data      = data;
 }
Пример #42
0
 protected override Task OnMessageAsync(MessageDirection direction, uint messageId, RfpIdentifier rfp, Memory <byte> data, CancellationToken cancellationToken)
 {
     try
     {
         var ies = data.Slice(14);
         while (!ies.IsEmpty)
         {
             var current = ies.Span[0];
             if (current > SignalType)
             {
                 break;
             }
             if (current >= 128)
             {
                 //fixed length
                 if (current >= 224)
                 {
                     if (ies.Length < 2)
                     {
                         break;
                     }
                     if (current == SignalType)
                     {
                         ies.Span[1] = 0x41;
                         Console.WriteLine("patched alerting pattern");
                     }
                     ies = ies.Slice(2);
                 }
                 else
                 {
                     ies = ies.Slice(1);
                 }
             }
             else
             {
                 if (ies.Length < 2)
                 {
                     break;
                 }
                 var length = ies.Span[1];
                 ies = ies.Slice(2);
                 if (current == (byte)NwkVariableLengthElementType.PortableIdentity)
                 {
                     //portable identity
                     var ie = new NwkIePortableIdentity(ies);
                     if (ie.IdentityType == NwkIePortableIdentity.PortableIdentityType.IPUI)
                     {
                         if (ie.Ipui.Put == NwkIePortableIdentity.IPUITypeCoding.O && ies.Length >= 5)
                         {
                             var span = ies.Slice(3).Span;
                             var emc  = (ushort)((span[0] & 0xf) << 12 | (span[1] << 4) | (span[2] >> 4));
                             if (!EMCs.Contains(emc))
                             {
                                 break;
                             }
                         }
                     }
                 }
                 if (ies.Length < length)
                 {
                     break;
                 }
                 ies = ies.Slice(length);
             }
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
     }
     return(WriteAsync(direction, messageId, rfp, data, cancellationToken));
 }
Пример #43
0
        public static MessageDescription CreateFromMessageContract(OperationDescription operation, bool isResponse, MessageDirection direction, string overridingAction, Type messageContractType)
        {
            string     action = overridingAction ?? NamingHelper.GetMessageAction(operation, isResponse);
            TypeLoader loader = new TypeLoader();

            return(loader.CreateTypedMessageDescription(messageContractType, null, null, operation.DeclaringContract.Namespace, action, direction));
        }
Пример #44
0
        /// <summary>
        /// Get the message prototype in the specified direction
        /// </summary>
        /// <param name="channelInfo">The channel information</param>
        /// <param name="direction">The direction</param>
        /// <param name="marginalPrototypeExpression">The marginal prototype expression</param>
        /// <param name="path">Path name of message</param>
        /// <param name="queryTypes">The set of queries to support.  Only used for marginal channels.</param>
        /// <returns>An expression for the method prototype</returns>
        public override IExpression GetMessagePrototype(
            ChannelInfo channelInfo, MessageDirection direction,
            IExpression marginalPrototypeExpression, string path, IList <QueryType> queryTypes)
        {
            Type        t       = null;
            Type        messTyp = null;
            IExpression mp      = null;
            CodeBuilder Builder = CodeBuilder.Instance;

            if (channelInfo.IsMarginal)
            {
                // We want the marginal variable to be a GibbsEstimator over the appropriate
                // distribution type
                if (direction == MessageDirection.Forwards && !UseSideChannels)
                {
                    bool estimateMarginal = false;
                    bool collectSamples = false, collectDistributions = false;
                    foreach (QueryType qt in queryTypes)
                    {
                        if (qt.Name == "Marginal")
                        {
                            estimateMarginal = true;
                        }
                        else if (qt.Name == "Samples")
                        {
                            collectSamples = true;
                        }
                        else if (qt.Name == "Conditionals")
                        {
                            collectDistributions = true;
                        }
                    }
                    Type innermostMessageType = marginalPrototypeExpression.GetExpressionType();
                    Type innermostElementType = Distribution.GetDomainType(innermostMessageType);
                    //t = MessageExpressionTransform.GetDistributionType(channelInfo.varInfo.varType, channelInfo.varInfo.innermostElementType, innermostMessageType, true);
                    t       = MessageTransform.GetDistributionType(channelInfo.varInfo.varType, innermostElementType, innermostMessageType, true);
                    messTyp = typeof(GibbsMarginal <,>).MakeGenericType(t, channelInfo.varInfo.varType);
                    mp      = Builder.NewObject(
                        messTyp, (t == innermostMessageType) ? marginalPrototypeExpression : Builder.DefaultExpr(t), Quoter.Quote(this.BurnIn), Quoter.Quote(this.Thin),
                        Quoter.Quote(estimateMarginal), Quoter.Quote(collectSamples), Quoter.Quote(collectDistributions));
                }
                else
                {
                    mp = marginalPrototypeExpression;
                }
                return(mp);
            }
            else
            {
                // Default is sample
                t = marginalPrototypeExpression.GetExpressionType();
                bool useSample = (path != "Distribution");
                if (useSample)
                {
                    messTyp = Distribution.GetDomainType(t);
                    while (messTyp.IsArray)
                    {
                        messTyp = messTyp.GetElementType();
                    }
                    mp = Builder.DefaultExpr(messTyp);
                }
                else
                {
                    messTyp = t;
                    mp      = marginalPrototypeExpression;
                }
                return(mp);
            }
        }
Пример #45
0
        internal override void InferMessageDescription(OperationDescription operation, object owner, MessageDirection direction)
        {
            ContractInferenceHelper.CheckForDisposableParameters(operation, this.ArgumentTypes);
            string overridingAction = (owner is Send) ? ((Send)owner).Action : ((SendReply)owner).Action;

            if (direction == MessageDirection.Input)
            {
                ContractInferenceHelper.AddInputMessage(operation, overridingAction, this.ArgumentNames, this.ArgumentTypes);
            }
            else
            {
                ContractInferenceHelper.AddOutputMessage(operation, overridingAction, this.ArgumentNames, this.ArgumentTypes);
            }
        }
Пример #46
0
 internal abstract void ValidateContract(NativeActivityContext context, OperationDescription targetOperation, object owner, MessageDirection direction);
 private static bool IsResponseCollection(Type type, MessageDirection messageDirection, out Type elementType)
 {
     return(type.IsCollection(out elementType) && messageDirection == MessageDirection.Output);
 }
Пример #48
0
 public MessageEventArgs(Message msg, MessageDirection dir)
 {
     Direction = dir;
     Message   = msg;
 }
Пример #49
0
 public MessageBufferEventArgs(byte[] MessageBuffer, int Length, IntPtr MemoryAddress, MessageDirection Direction = MessageDirection.ServerToClient)
 {
     this.MessageBuffer = MessageBuffer;
     this.Length        = Length;
     this.MemoryAddress = MemoryAddress;
     this.Direction     = Direction;
 }
Пример #50
0
        public static MessageDescription CreateMessageDescription(OperationDescription operation, bool isResponse, MessageDirection direction, string overridingAction, string[] argumentNames, Type[] argumentTypes)
        {
            MessageDescription description;

            if ((argumentTypes.Length == 1) && (argumentTypes[0] == MessageDescription.TypeOfUntypedMessage))
            {
                description = CreateEmptyMessageDescription(operation, isResponse, direction, overridingAction);
                AddMessagePartDescription(operation, isResponse, description, argumentNames, argumentTypes);
                return(description);
            }
            if ((argumentTypes.Length == 1) && IsMessageContract(argumentTypes[0]))
            {
                return(CreateFromMessageContract(operation, isResponse, direction, overridingAction, argumentTypes[0]));
            }
            description = CreateEmptyMessageDescription(operation, isResponse, direction, overridingAction);
            AddMessagePartDescription(operation, isResponse, description, argumentNames, argumentTypes);
            SetWrapperName(operation, isResponse, description);
            return(description);
        }
Пример #51
0
 public MessageDescription(string action,
                           MessageDirection direction)
 {
     this.action    = action;
     this.direction = direction;
 }
Пример #52
0
 internal static bool IsDefined(MessageDirection value)
 {
     return(value == MessageDirection.Input || value == MessageDirection.Output);
 }
Пример #53
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ZWaveLib.ZWaveMessage"/> class.
        /// </summary>
        /// <param name="message">Message.</param>
        /// <param name="direction">Direction.</param>
        /// <param name="generateCallback">If set to <c>true</c> generate callback.</param>
        public ZWaveMessage(byte[] message, MessageDirection direction = MessageDirection.Outbound, bool generateCallback = false)
        {
            Direction = direction;
            Header    = (FrameHeader)message[0];
            RawData   = message;

            if (direction == MessageDirection.Outbound)
            {
                if (generateCallback)
                {
                    CallbackId = GenerateCallbackId();
                    RawData[RawData.Length - 2] = CallbackId;
                }
                // Insert checksum
                RawData[RawData.Length - 1] = GenerateChecksum(RawData);
            }

            if (Header == FrameHeader.SOF)
            {
                if (message.Length > 4)
                {
                    Enum.TryParse <MessageType>(message[2].ToString(), out Type);
                    Enum.TryParse <ZWaveFunction>(message[3].ToString(), out Function);
                }
                switch (Type)
                {
                case MessageType.Request:
                    if (Function == ZWaveFunction.SendData && message.Length == 6)
                    {
                        Enum.TryParse <CallbackStatus>(message[4].ToString(), out CallbackStatus);
                    }
                    else if (Function == ZWaveFunction.SendData && (message.Length == 7 || message.Length == 9))
                    {
                        CallbackId = message[4];
                        Enum.TryParse <CallbackStatus>(message[5].ToString(), out CallbackStatus);
                    }
                    else if (Function == ZWaveFunction.SendData && message.Length == 8)
                    {
                        Enum.TryParse <CommandClass>(message[6].ToString(), out CommandClass);
                    }
                    else if (Function == ZWaveFunction.SendData && message.Length > 6)
                    {
                        NodeId = message[4];
                        Enum.TryParse <CommandClass>(message[6].ToString(), out CommandClass);
                    }
                    else if (Function == ZWaveFunction.ApplicationCommandHandler && message.Length > 7)
                    {
                        NodeId = message[5];
                        Enum.TryParse <CommandClass>(message[7].ToString(), out CommandClass);
                    }
                    else if ((Function == ZWaveFunction.RequestNodeNeighborsUpdate || Function == ZWaveFunction.RequestNodeNeighborsUpdateOptions) &&
                             message.Length >= 6)
                    {
                        if (Direction == MessageDirection.Outbound)
                        {
                            NodeId     = message[4];
                            CallbackId = (Function == ZWaveFunction.RequestNodeNeighborsUpdate) ? message[5] : message[6];
                        }
                        else
                        {
                            CallbackId = message[4];
                        }
                    }
                    else if ((Function == ZWaveFunction.NodeAdd || Function == ZWaveFunction.NodeRemove) &&
                             message.Length == 9)
                    {
                        CallbackId = message[4];
                    }
                    else if (Function == ZWaveFunction.RequestNodeInfo || Function == ZWaveFunction.GetNodeProtocolInfo || Function == ZWaveFunction.GetRoutingInfo)
                    {
                        NodeId = message[4];
                    }
                    break;

                case MessageType.Response:
                    if (message.Length == 6)
                    {
                        Enum.TryParse <CallbackStatus>(message[4].ToString(), out CallbackStatus);
                    }
                    break;
                }
            }

            if (seqNumber == long.MaxValue)
            {
                seqNumber = 0;
            }
            Seq = ++seqNumber;

            Utility.logger.Debug("ZWaveMessage (RawData={0})", BitConverter.ToString(RawData));
            if (Direction == MessageDirection.Inbound)
            {
                Utility.logger.Debug("ZWaveMessage (Direction={0}, Header={1}, NodeId={2}, Type={3}, Function={4}, CommandClass={5})",
                                     Direction, Header, NodeId, Type, Function, CommandClass);
            }
            else
            {
                Utility.logger.Debug("ZWaveMessage (Direction={0}, Header={1}, NodeId={2}, Type={3}, Function={4}, CommandClass={5}, CallbackId={6}, CallbackStatus={7})",
                                     Direction, Header, NodeId, Type, Function, CommandClass, CallbackId, CallbackStatus);
            }
        }
Пример #54
0
 internal static object CreateProxy(Type interfaceType, Type proxiedType, MessageDirection direction, ServiceChannel serviceChannel)
 {
     throw ExceptionHelper.PlatformNotSupported();
 }
Пример #55
0
        //XmlQualifiedName xsdType;

        public MessageDescription(string action, MessageDirection direction) : this(action, direction, null)
        {
        }
Пример #56
0
        public static MessageDescription CreateMessageDescription(OperationDescription operation, bool isResponse, MessageDirection direction, string overridingAction, Type type, SerializerOption serializerOption)
        {
            if ((type != null) && IsMessageContract(type))
            {
                return(CreateFromMessageContract(operation, isResponse, direction, overridingAction, type));
            }
            MessageDescription message = CreateEmptyMessageDescription(operation, isResponse, direction, overridingAction);

            AddMessagePartDescription(operation, isResponse, message, type, serializerOption);
            return(message);
        }
 internal override SendSecurityHeader CreateSendSecurityHeader(Message message, string actor, bool mustUnderstand, bool relay, SecurityStandardsManager standardsManager, SecurityAlgorithmSuite algorithmSuite, MessageDirection direction)
 {
     return(new WSSecurityOneDotZeroSendSecurityHeader(message, actor, mustUnderstand, relay, standardsManager, algorithmSuite, direction));
 }
 internal override ReceiveSecurityHeader CreateReceiveSecurityHeader(Message message, string actor, bool mustUnderstand, bool relay, SecurityStandardsManager standardsManager, SecurityAlgorithmSuite algorithmSuite, MessageDirection direction, int headerIndex)
 {
     return(new WSSecurityOneDotOneReceiveSecurityHeader(message, actor, mustUnderstand, relay, standardsManager, algorithmSuite, headerIndex, direction));
 }
        // Determine the message type of target from the message type of the factor arguments
        protected void ProcessFactor(IExpression factor, MessageDirection direction)
        {
            NodeInfo info = GetNodeInfo(factor);
            // fill in argumentTypes
            Dictionary <string, Type>        argumentTypes = new Dictionary <string, Type>();
            Dictionary <string, IExpression> arguments     = new Dictionary <string, IExpression>();

            for (int i = 0; i < info.info.ParameterNames.Count; i++)
            {
                string parameterName = info.info.ParameterNames[i];
                // Create message info. 'isForward' says whether the message
                // out is in the forward or backward direction
                bool        isChild    = info.isReturnOrOut[i];
                IExpression arg        = info.arguments[i];
                bool        isConstant = !CodeRecognizer.IsStochastic(context, arg);
                if (isConstant)
                {
                    arguments[parameterName] = arg;
                    Type inwardType = arg.GetExpressionType();
                    argumentTypes[parameterName] = inwardType;
                }
                else if (!isChild)
                {
                    IExpression msgExpr = GetMessageExpression(arg, fwdMessageVars);
                    if (msgExpr == null)
                    {
                        return;
                    }
                    arguments[parameterName] = msgExpr;
                    Type inwardType = msgExpr.GetExpressionType();
                    if (inwardType == null)
                    {
                        Error("inferred an incorrect message type for " + arg);
                        return;
                    }
                    argumentTypes[parameterName] = inwardType;
                }
                else if (direction == MessageDirection.Backwards)
                {
                    IExpression msgExpr = GetMessageExpression(arg, bckMessageVars);
                    if (msgExpr == null)
                    {
                        //Console.WriteLine("creating backward message for "+arg);
                        CreateBackwardMessageFromForward(arg, null);
                        msgExpr = GetMessageExpression(arg, bckMessageVars);
                        if (msgExpr == null)
                        {
                            return;
                        }
                    }
                    arguments[parameterName] = msgExpr;
                    Type inwardType = msgExpr.GetExpressionType();
                    if (inwardType == null)
                    {
                        Error("inferred an incorrect message type for " + arg);
                        return;
                    }
                    argumentTypes[parameterName] = inwardType;
                }
            }
            IAlgorithm alg     = algorithm;
            Algorithm  algAttr = context.InputAttributes.Get <Algorithm>(info.imie);

            if (algAttr != null)
            {
                alg = algAttr.algorithm;
            }
            List <ICompilerAttribute> factorAttributes = context.InputAttributes.GetAll <ICompilerAttribute>(info.imie);
            string methodSuffix = alg.GetOperatorMethodSuffix(factorAttributes);

            // infer types of children
            for (int i = 0; i < info.info.ParameterNames.Count; i++)
            {
                string parameterName = info.info.ParameterNames[i];
                bool   isChild       = info.isReturnOrOut[i];
                if (isChild != (direction == MessageDirection.Forwards))
                {
                    continue;
                }
                IExpression target     = info.arguments[i];
                bool        isConstant = !CodeRecognizer.IsStochastic(context, target);
                if (isConstant)
                {
                    continue;
                }
                IVariableDeclaration ivd = Recognizer.GetVariableDeclaration(target);
                if (ivd == null)
                {
                    continue;
                }
                Type           targetType = null;
                MessageFcnInfo fcninfo    = null;
                if (direction == MessageDirection.Forwards)
                {
                    try
                    {
                        fcninfo = GetMessageFcnInfo(info.info, "Init", parameterName, argumentTypes);
                    }
                    catch (Exception)
                    {
                        try
                        {
                            fcninfo = GetMessageFcnInfo(info.info, methodSuffix + "Init", parameterName, argumentTypes);
                        }
                        catch (Exception ex)
                        {
                            //Error("could not determine message type of "+ivd.Name, ex);
                            try
                            {
                                fcninfo = GetMessageFcnInfo(info.info, methodSuffix, parameterName, argumentTypes);
                                if (fcninfo.PassResult)
                                {
                                    throw new MissingMethodException(StringUtil.MethodFullNameToString(fcninfo.Method) +
                                                                     " is not suitable for initialization since it takes a result parameter.  Please provide a separate Init method.");
                                }
                                if (fcninfo.PassResultIndex)
                                {
                                    throw new MissingMethodException(StringUtil.MethodFullNameToString(fcninfo.Method) +
                                                                     " is not suitable for initialization since it takes a resultIndex parameter.  Please provide a separate Init method.");
                                }
                            }
                            catch (Exception ex2)
                            {
                                if (direction == MessageDirection.Forwards)
                                {
                                    Error("could not determine " + direction + " message type of " + ivd.Name + ": " + ex.Message, ex2);
                                    continue;
                                }
                                fcninfo = null;
                            }
                        }
                    }
                    if (fcninfo != null)
                    {
                        targetType = fcninfo.Method.ReturnType;
                        if (targetType.IsGenericParameter)
                        {
                            if (direction == MessageDirection.Forwards)
                            {
                                Error("could not determine " + direction + " message type of " + ivd.Name + " in " + StringUtil.MethodFullNameToString(fcninfo.Method));
                                continue;
                            }
                            fcninfo = null;
                        }
                    }
                    if (fcninfo != null)
                    {
                        VariableInformation vi = VariableInformation.GetVariableInformation(context, ivd);
                        try
                        {
                            targetType = MessageTransform.GetDistributionType(ivd.VariableType.DotNetType, target.GetExpressionType(), targetType, true);
                        }
                        catch (Exception ex)
                        {
                            if (direction == MessageDirection.Forwards)
                            {
                                Error("could not determine " + direction + " message type of " + ivd.Name, ex);
                                continue;
                            }
                            fcninfo = null;
                        }
                    }
                }
                Dictionary <IVariableDeclaration, IVariableDeclaration> messageVars = (direction == MessageDirection.Forwards) ? fwdMessageVars : bckMessageVars;
                if (fcninfo != null)
                {
                    string name = ivd.Name + (direction == MessageDirection.Forwards ? "_F" : "_B");
                    IVariableDeclaration msgVar;
                    if (!messageVars.TryGetValue(ivd, out msgVar))
                    {
                        msgVar = Builder.VarDecl(name, targetType);
                    }
                    if (true)
                    {
                        // construct the init expression
                        List <IExpression> args       = new List <IExpression>();
                        ParameterInfo[]    parameters = fcninfo.Method.GetParameters();
                        foreach (ParameterInfo parameter in parameters)
                        {
                            string argName = parameter.Name;
                            if (IsFactoryType(parameter.ParameterType))
                            {
                                IVariableDeclaration factoryVar = GetFactoryVariable(parameter.ParameterType);
                                args.Add(Builder.VarRefExpr(factoryVar));
                            }
                            else
                            {
                                FactorEdge factorEdge          = fcninfo.factorEdgeOfParameter[parameter.Name];
                                string     factorParameterName = factorEdge.ParameterName;
                                bool       isOutgoingMessage   = factorEdge.IsOutgoingMessage;
                                if (!arguments.ContainsKey(factorParameterName))
                                {
                                    if (direction == MessageDirection.Forwards)
                                    {
                                        Error(StringUtil.MethodFullNameToString(fcninfo.Method) + " is not suitable for initialization since it requires '" + parameter.Name +
                                              "'.  Please provide a separate Init method.");
                                    }
                                    fcninfo = null;
                                    break;
                                }
                                IExpression arg = arguments[factorParameterName];
                                args.Add(arg);
                            }
                        }
                        if (fcninfo != null)
                        {
                            IMethodInvokeExpression imie = Builder.StaticMethod(fcninfo.Method, args.ToArray());
                            //IExpression initExpr = MessageTransform.GetDistributionArrayCreateExpression(ivd.VariableType.DotNetType, target.GetExpressionType(), imie, vi);
                            IExpression initExpr = imie;
                            KeyValuePair <IVariableDeclaration, IExpression> key = new KeyValuePair <IVariableDeclaration, IExpression>(msgVar, factor);
                            messageInitExprs[key] = initExpr;
                        }
                    }
                    if (fcninfo != null)
                    {
                        messageVars[ivd] = msgVar;
                    }
                }
                if (fcninfo == null)
                {
                    if (direction == MessageDirection.Forwards)
                    {
                        continue;
                    }
                    //Console.WriteLine("creating backward message for "+target);
                    CreateBackwardMessageFromForward(target, factor);
                }
                IExpression msgExpr = GetMessageExpression(target, messageVars);
                arguments[parameterName] = msgExpr;
                Type inwardType = msgExpr.GetExpressionType();
                argumentTypes[parameterName] = inwardType;
            }
        }
Пример #60
0
 public static MessageDescription CreateEmptyMessageDescription(OperationDescription operation, bool isResponse, MessageDirection direction, string overridingAction)
 {
     return(new MessageDescription(overridingAction ?? NamingHelper.GetMessageAction(operation, isResponse), direction)
     {
         Body = { WrapperName = null, WrapperNamespace = null }
     });
 }