public void FromElement()
        {
            ServiceElement element   = new ServiceElement(ElementType.Uuid16, (UInt16)0x1105);
            Type           enumClass = new GiveAccess_SdpClassToAttributeIdList().GetAttributeIdEnumType(element);

            Assert.IsNotNull(enumClass);
            Assert.AreEqual("ObexAttributeId", enumClass.Name);
        }
Exemplo n.º 2
0
        public void ParamsArray_ExplicitNone()
        {
            ServiceElement[]     array   = new ServiceElement[0];
            ServiceElement       element = new ServiceElement(ElementType.ElementSequence, array);
            IList_ServiceElement list    = element.GetValueAsElementList();

            Assert.AreEqual(0, list.Count);
        }
Exemplo n.º 3
0
 public void SequenceHoldingSequenceHoldingUInt16_Bad_TestTheTesting()
 {
     byte[] expectedDataValue = { 0x34, 0xF5 };
     DoTest_HackTwoSeqDeep(StackConsts.SDP_Data_Element_Type.UnsignedInteger2Bytes, expectedDataValue,
                           new ServiceElement(ElementType.ElementSequence,
                                              new ServiceElement(ElementType.ElementSequence,
                                                                 ServiceElement.CreateNumericalServiceElement(ElementType.UInt16, 0x6363))));
 }
Exemplo n.º 4
0
        protected sealed override void WriteVariableLength(ServiceElement element, byte[] valueBytes, byte[] buf, ref int offset, out int totalLength)
        {
            var det = ToSDP_Data_Element_Type(element.ElementType);

            SetCurElement(new Structs.SDP_Data_Element__Class_NonInlineByteArray(det,
                                                                                 valueBytes.Length, valueBytes));
            //
            base.WriteVariableLength(element, valueBytes, buf, ref offset, out totalLength);
        }
Exemplo n.º 5
0
 private void DoTest_Invalid(ElementType elementType, object value)
 {
     try {
         ServiceElement.CreateNumericalServiceElement(elementType, value);
         Assert.Fail("Value '" + value + "' should have failed with element type '" + elementType + "'");
     } catch (ArgumentOutOfRangeException ex) {
         Code.AssertIsElementNumericalInvalidError(ex);
     }
 }
Exemplo n.º 6
0
        public void GetChannelElement_Opp()
        {
            ServiceRecord  rcd     = ServiceRecord.CreateServiceRecordFromBytes(Data_CompleteThirdPartyRecords.PalmOsOpp);
            ServiceElement element = ServiceRecordHelper.GetRfcommChannelElement(rcd);

            Assert.IsNotNull(element);
            Assert.AreEqual(ElementType.UInt8, element.ElementType);
            Assert.AreEqual(Data_CompleteThirdPartyRecords.PalmOsOpp_RfcommChannelNumber, element.Value);
        }
Exemplo n.º 7
0
        private static ServiceElement CreateEnglishUtf8PrimaryLanguageServiceElement()
        {
            ServiceElement englishUtf8PrimaryLanguage = LanguageBaseItem.CreateElementSequenceFromList(
                new LanguageBaseItem[] {
                new LanguageBaseItem("en", LanguageBaseItem.Utf8EncodingId, LanguageBaseItem.PrimaryLanguageBaseAttributeId)
            });

            return(englishUtf8PrimaryLanguage);
        }
Exemplo n.º 8
0
    static void chaosaSrb2()
    {
        ushort               u   = 0x37; // the mobile can get the number of  '10' using this
        ServiceElement       se  = new ServiceElement(ElementType.Int32, 10);
        ServiceAttribute     sa  = new ServiceAttribute(u, se);
        ServiceRecordBuilder srb = new ServiceRecordBuilder();

        srb.AddCustomAttribute(sa);
        ServiceRecord rcd = srb.ServiceRecord;
    }
Exemplo n.º 9
0
        public void CanAddUsingIndexer()
        {
            ServiceElement se = new ServiceElement();

            se.ServiceType             = typeof(object);
            collection[se.ServiceType] = se;

            Assert.IsNotNull(collection[typeof(object)]);
            Assert.AreEqual(1, collection.Count);
        }
Exemplo n.º 10
0
 private static void DoAreEqual(ExpectedServiceElement[] expectedAttributes, ServiceElement[] values, int depth)
 {
     Assert.AreEqual(expectedAttributes.Length, values.Length, "Number of elements.");
     for (int i = 0; i < expectedAttributes.Length; ++i)
     {
         ExpectedServiceElement expected = expectedAttributes[i];
         ServiceElement         row      = values[i];
         DoAreEqual(expected, row, depth + 1);
     } //for
 }
Exemplo n.º 11
0
        public void CanAddService()
        {
            ServiceElement se = new ServiceElement();

            se.ServiceType = typeof(object);
            collection.Add(se);

            Assert.IsNotNull(collection[typeof(object)]);
            Assert.AreEqual(1, collection.Count);
        }
Exemplo n.º 12
0
        protected bool RemoveEndpointFromServiceOnly(Configuration config, EndpointConfig endpointConfig)
        {
            ServiceModelSectionGroup sg             = ServiceModelSectionGroup.GetSectionGroup(config);
            ServiceElementCollection serviceColl    = sg.Services.Services;
            ServiceElement           serviceElement = null;

            // Find serviceElement
            foreach (ServiceElement el in serviceColl)
            {
                if (endpointConfig.MatchServiceType(el.Name))
                {
                    serviceElement = el;
                    break;
                }
            }

            if (serviceElement == null)
            {
                // Didn't find class
                return(false);
            }

            // Now, check if endpoint already exists..
            foreach (ServiceEndpointElement ee in serviceElement.Endpoints)
            {
                if (endpointConfig.MatchContract(ee.Contract) &&
                    (ee.Address == endpointConfig.Address))
                {
                    // found it !
                    serviceElement.Endpoints.Remove(ee);
                    if (!endpointConfig.IsMexEndpoint)
                    {
                        RemoveComContractIfNotUsedByAnyService(config, ee.Contract);
                    }
                    if (serviceElement.Endpoints.Count == 1)
                    {
                        if (serviceElement.Endpoints[0].Contract == ServiceMetadataBehavior.MexContractName)
                        {
                            serviceElement.Endpoints.Remove(serviceElement.Endpoints[0]); // if Mex endpoint remove it.
                        }
                    }
                    if (serviceElement.Endpoints.Count == 0)
                    {
                        serviceColl.Remove(serviceElement);
                        if (serviceColl.Count == 0)
                        {
                            EnsureComMetaDataExchangeBehaviorRemoved(config);
                            RemoveBinding(config);
                        }
                    }
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 13
0
        public void Uuid128As128()
        {
            ServiceElement element = new ServiceElement(ElementType.Uuid128, CreateBluetoothBasedUuid(0x1105));

            Assert.AreEqual(ElementTypeDescriptor.Uuid, element.ElementTypeDescriptor);
            Assert.AreEqual(ElementType.Uuid128, element.ElementType);
            //Assert.IsInstanceOfType(typeof(Guid), element.Value);
            Guid expected = CreateBluetoothBasedUuid(0x1105);

            Assert.AreEqual(expected, element.GetValueAsUuid());
        }
Exemplo n.º 14
0
        public void TestingPropertiesWithTypeUri()
        {
            String         str     = "http://example.com/foo.html";
            Uri            value   = new Uri(str);
            ServiceElement element = new ServiceElement(ElementType.Url, value);

            Assert.AreEqual(ElementTypeDescriptor.Url, element.ElementTypeDescriptor);
            Assert.AreEqual(ElementType.Url, element.ElementType);
            Assert.AreEqual(new Uri(str), element.Value);
            Assert.AreEqual(new Uri(str), element.GetValueAsUri());
        }
 public DllHostedComPlusServiceHost(Guid clsid,
                                    ServiceElement service,
                                    ComCatalogObject applicationObject,
                                    ComCatalogObject classObject)
 {
     Initialize(clsid,
                service,
                applicationObject,
                classObject,
                HostingMode.ComPlus);
 }
Exemplo n.º 16
0
        public void CanRemoveElement()
        {
            ServiceElement se = new ServiceElement();

            se.ServiceType             = typeof(object);
            collection[se.ServiceType] = se;
            collection.Remove(typeof(object));

            Assert.AreEqual(0, collection.Count);
            Assert.IsNull(collection[typeof(object)]);
        }
Exemplo n.º 17
0
        public void StringUtf8Empty()
        {
            byte[]         bytes   = new byte[0];
            ServiceElement element = new ServiceElement(ElementType.TextString, bytes);

            Assert.AreEqual(ElementTypeDescriptor.TextString, element.ElementTypeDescriptor);
            Assert.AreEqual(ElementType.TextString, element.ElementType);
            Assert.IsInstanceOfType(typeof(byte[]), element.Value);
            Assert.AreEqual(String.Empty, element.GetValueAsStringUtf8());
            Assert.AreEqual(0, element.GetValueAsStringUtf8().Length);
        }
Exemplo n.º 18
0
        public static ServiceInfo FromConfiguration(ServiceElement serviceElement)
        {
            var serviceInfo = new ServiceInfo();

            serviceInfo.ServiceName     = serviceElement.ServiceName;
            serviceInfo.DisplayName     = serviceElement.DisplayName;
            serviceInfo.Description     = serviceElement.Description;
            serviceInfo.StartMode       = serviceElement.StartMode;
            serviceInfo.RecoveryOptions = ServiceRecoveryOptions.FromConfiguration(serviceElement.RecoveryOptions);
            return(serviceInfo);
        }
Exemplo n.º 19
0
        public ActionResult Delete(int Id)
        {
            ServiceElement serviceElement = db.ServiceElements.Find(Id);

            if (serviceElement == null)
            {
                return(HttpNotFound());
            }
            db.ServiceElements.Remove(serviceElement);
            db.SaveChanges();
            return(RedirectToAction("index"));
        }
Exemplo n.º 20
0
        public void TestingPropertiesWithTypeInt64()
        {
            ServiceElement element = new ServiceElement(ElementType.Int64, (Int64)5);

            Assert.AreEqual(ElementTypeDescriptor.TwosComplementInteger, element.ElementTypeDescriptor);
            Assert.AreEqual(ElementType.Int64, element.ElementType);
            Assert.AreEqual(5, element.Value);
            element = new ServiceElement(ElementType.Int64, (Int64)0x01000);
            Assert.AreEqual(ElementTypeDescriptor.TwosComplementInteger, element.ElementTypeDescriptor);
            Assert.AreEqual(ElementType.Int64, element.ElementType);
            Assert.AreEqual(0x01000, element.Value);
        }
Exemplo n.º 21
0
        public void GetChannelByte_Bad_TruncatedBeforeRfcomm()
        {
            var layer0 = new ServiceElement(ElementType.ElementSequence,
                                            new ServiceElement(ElementType.Uuid16, Uuid16_L2CapProto)); // not L2CAP
            ServiceRecord rcd = new ServiceRecord(
                new ServiceAttribute(UniversalAttributeId.ProtocolDescriptorList,
                                     new ServiceElement(ElementType.ElementSequence,
                                                        layer0)));
            int value = ServiceRecordHelper.GetRfcommChannelNumber(rcd);

            Assert.AreEqual(-1, value);
        }
Exemplo n.º 22
0
        public void CreateL2Cap()
        {
            ServiceElement element = ServiceRecordHelper.CreateL2CapProtocolDescriptorList();
            //
            List_ServiceAttribute attrs = new List_ServiceAttribute();

            attrs.Add(new ServiceAttribute(UniversalAttributeId.ProtocolDescriptorList, element));
            ServiceRecord record = new ServiceRecord(attrs);
            String        dump   = ServiceRecordUtilities.Dump(record);

            Assert.AreEqual(ExpectedL2CapDump, dump, "L2CAP ProtoDL dump");
        }
Exemplo n.º 23
0
        public void TestingPropertiesWithTypeBoolean()
        {
            ServiceElement element = new ServiceElement(ElementType.Boolean, true);

            Assert.AreEqual(ElementTypeDescriptor.Boolean, element.ElementTypeDescriptor);
            Assert.AreEqual(ElementType.Boolean, element.ElementType);
            Assert.AreEqual(true, element.Value);
            element = new ServiceElement(ElementType.Boolean, false);
            Assert.AreEqual(ElementTypeDescriptor.Boolean, element.ElementTypeDescriptor);
            Assert.AreEqual(ElementType.Boolean, element.ElementType);
            Assert.AreEqual(false, element.Value);
        }
Exemplo n.º 24
0
        void DoTest_HackOneSeqDeep(StackConsts.SDP_Data_Element_Type expectedET,
                                   byte[] expectedDataValue,
                                   ServiceElement element)
        {
            var r = new ServiceRecord(new ServiceAttribute(0xF234,
                                                           element));

            //==
            r = BluetopiaTesting.HackAddSvcClassList(r);
            //==
            DoTest_HackOneSeqDeep(expectedET, expectedDataValue, r);
        }
Exemplo n.º 25
0
        public ActionResult Edit(ServiceElement serviceElement)
        {
            ServiceElement theServiceElement = db.ServiceElements.FirstOrDefault(w => w.Id == serviceElement.Id);

            if (theServiceElement != null)
            {
                theServiceElement.Answer   = serviceElement.Answer;
                theServiceElement.Question = serviceElement.Question;
                db.SaveChanges();
            }
            return(RedirectToAction("index"));
        }
Exemplo n.º 26
0
        public void StringUtf8WithVariousHighChars()
        {
            String str = "ambds\u2022nbdas\u00FEdlka\U00012004slkda";

            byte[]         bytes   = Encoding.UTF8.GetBytes(str);
            ServiceElement element = new ServiceElement(ElementType.TextString, bytes);

            Assert.AreEqual(ElementTypeDescriptor.TextString, element.ElementTypeDescriptor);
            Assert.AreEqual(ElementType.TextString, element.ElementType);
            Assert.IsInstanceOfType(typeof(byte[]), element.Value);
            Assert.AreEqual(str, element.GetValueAsStringUtf8());
        }
Exemplo n.º 27
0
        public void StringUtf8AllAscii()
        {
            String str = "ambdsanbdasdlkaslkda";

            byte[]         bytes   = Encoding.UTF8.GetBytes(str);
            ServiceElement element = new ServiceElement(ElementType.TextString, bytes);

            Assert.AreEqual(ElementTypeDescriptor.TextString, element.ElementTypeDescriptor);
            Assert.AreEqual(ElementType.TextString, element.ElementType);
            Assert.IsInstanceOfType(typeof(byte[]), element.Value);
            Assert.AreEqual(str, element.GetValueAsStringUtf8());
        }
Exemplo n.º 28
0
        public void TestingPropertiesWithTypeUriLazyCreation()
        {
            String str = "ftp://ftp.example.com/foo/bar.txt";

            byte[]         valueBytes = Encoding.ASCII.GetBytes(str);
            ServiceElement element    = new ServiceElement(ElementType.Url, valueBytes);

            Assert.AreEqual(ElementTypeDescriptor.Url, element.ElementTypeDescriptor);
            Assert.AreEqual(ElementType.Url, element.ElementType);
            Assert.IsInstanceOfType(typeof(byte[]), element.Value);
            Assert.AreEqual(new Uri(str), element.GetValueAsUri());
        }
Exemplo n.º 29
0
        public static void BuildingServiceaBehavior(WCFServiceMeta wCFServiceMeta, ServiceElement serviceElement, SpringServiceHost ssh)
        {
            ServiceBehaviorElement sbe = null;

            if (serviceElement.BehaviorConfiguration != "" && wCFServiceMeta.BehaviorsConfiguration != null)
            {
                if (wCFServiceMeta.BehaviorsConfiguration.ServiceBehaviors.ContainsKey(serviceElement.BehaviorConfiguration))
                {
                    ServiceBehaviorElementCollection sbec = wCFServiceMeta.BehaviorsConfiguration.ServiceBehaviors;
                    foreach (ServiceBehaviorElement o in sbec)
                    {
                        if (o.Name == serviceElement.BehaviorConfiguration)
                        {
                            sbe = o;
                            break;
                        }
                    }
                    if (sbe != null)
                    {
                        //ServiceBehavior smb = new ServiceMetadataBehavior();
                        foreach (var metadata in sbe)
                        {
                            switch (metadata.GetType().FullName)
                            {
                            case "System.ServiceModel.Configuration.DataContractSerializerElement":
                            {
                                DataContractSerializerElement dse = metadata as DataContractSerializerElement;
                                if (dse != null)
                                {
                                    int i = dse.MaxItemsInObjectGraph;

                                    ContractDescription            cd   = ssh.Description.Endpoints.FirstOrDefault(o => o.Name != "IMetadataExchange").Contract;
                                    OperationDescriptionCollection opdc = cd.Operations;
                                    foreach (OperationDescription odp in opdc)
                                    {
                                        DataContractSerializerOperationBehavior dsb = new DataContractSerializerOperationBehavior(odp);
                                        dsb.IgnoreExtensionDataObject = dse.IgnoreExtensionDataObject;
                                        dsb.MaxItemsInObjectGraph     = dse.MaxItemsInObjectGraph;
                                        odp.Behaviors.Remove <DataContractSerializerOperationBehavior>();
                                        odp.Behaviors.Add(dsb);
                                    }

                                    return;
                                }
                                break;
                            }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 30
0
        public void StringGivenString()
        {
            String         str     = "ambds\u2022nbdas\u00FEdlka\U00012004slkda";
            ServiceElement element = new ServiceElement(ElementType.TextString, str);

            //
            Assert.AreEqual(ElementTypeDescriptor.TextString, element.ElementTypeDescriptor);
            Assert.AreEqual(ElementType.TextString, element.ElementType);
            Assert.IsInstanceOfType(typeof(String), element.Value);
            Assert.AreEqual(str, element.GetValueAsStringUtf8());
            Assert.AreEqual(str, element.GetValueAsString(Encoding.ASCII));
            Assert.AreEqual(str, element.GetValueAsString(Encoding.Unicode));
        }
Exemplo n.º 31
0
		/// <summary>
		/// Initializes a new instance of the <see cref="TypeElement"/> class.
		/// </summary>
		/// <param name="typeElement">The type element.</param>
		/// <param name="parent">The parent.</param>
		public TypeElement(XPathNavigator typeElement, ServiceElement parent) :
			base(typeElement, parent) {
			Requires.NotNull(typeElement, "typeElement");
			Requires.NotNull(parent, "parent");
		}
Exemplo n.º 32
0
 public TypeElement(XPathNavigator typeElement, ServiceElement parent)
     : base(typeElement, parent)
 {
 }