Esempio n. 1
0
            public void ReceiveData(Services.P2PCommunicationsScheme.Data.P2PData data, int P2PPortNumber)
            {
                P2PDataAttributesTable.P2PDataAttribute attr = new P2PDataAttributesTable.P2PDataAttribute();

                if (!data.DataAttributesTable.ContainsAttribute("DATA_TYPE"))
                {
                    throw (new Exception("Can\'t process the Communications data because the attribute \'DATA_TYPE\' is missing"));
                }
                else
                {
                    attr = data.DataAttributesTable.GetAttribute("DATA_TYPE");
                    if (attr.AttrValue != "CommunicationsData")
                    {
                        throw (new Exception("Invalid P2PData in the \'ComponentCommunicationsHandler\' environment"));
                    }
                    data.DataAttributesTable.RemoveAttribute("DATA_TYPE");
                }

                string adresseComponentName = "";

                if (!data.DataAttributesTable.ContainsAttribute("ADDRESSE_COMPONENT"))
                {
                    throw (new Exception("Can\'t process the Communications data because the attribute \'ADDRESSE_COMPONENT\' is missing"));
                }
                else
                {
                    attr = data.DataAttributesTable.GetAttribute("ADDRESSE_COMPONENT");
                    adresseComponentName = attr.AttrValue;
                    data.DataAttributesTable.RemoveAttribute("ADDRESSE_COMPONENT");
                }

                string senderComponentName = "";

                if (!data.DataAttributesTable.ContainsAttribute("SENDER_COMPONENT"))
                {
                    throw (new Exception("Can\'t process the Communications data because the attribute \'SENDER_COMPONENT\' is missing"));
                }
                else
                {
                    attr = data.DataAttributesTable.GetAttribute("SENDER_COMPONENT");
                    senderComponentName = attr.AttrValue;
                    data.DataAttributesTable.RemoveAttribute("SENDER_COMPONENT");
                }

                CommunicationsData commsData = default(CommunicationsData);

                commsData = CommunicationsData.GetCommunicationsDataObject(adresseComponentName, senderComponentName, System.Convert.ToString(data.DataName), data.Value);


                P2PDataAttributesTableEnumerator paramsAttrEnum = default(P2PDataAttributesTableEnumerator);

                paramsAttrEnum = (P2PDataAttributesTableEnumerator)data.DataAttributesTable.GetEnumerator();

                while (paramsAttrEnum.MoveNext())
                {
                    attr = paramsAttrEnum.Current;
                    commsData.AddDataAttribute(attr.AttrName, attr.AttrValue);
                }

                ((CNDCommunicationsEnvironment.Interfaces.IUseCNDCommunicationsScheme) this._componentOwner).ReceiveData(commsData);
            }
            public System.Collections.IEnumerator GetEnumerator()
            {
                P2PDataAttributesTableEnumerator enumm = new P2PDataAttributesTableEnumerator(this._parametersList);

                return(enumm);
            }