Example #1
0
 private MessagePartDescription CreateMessagePartDescription(Type bodyType, System.ServiceModel.Description.XmlName name, string ns, int index)
 {
     return(new MessagePartDescription(name.EncodedName, ns)
     {
         SerializationPosition = index, MemberInfo = null, Type = bodyType, Index = index
     });
 }
Example #2
0
        private MessageDescription CreateParameterMessageDescription(ContractDescription contract, ParameterInfo[] parameters, Type returnType, ICustomAttributeProvider returnCustomAttributes, System.ServiceModel.Description.XmlName returnValueName, string methodName, string ns, string action, MessageDirection direction, bool allowReferences)
        {
            MessageDescription description = new MessageDescription(action, direction)
            {
                Body = { WrapperNamespace = ns }
            };

            for (int i = 0; i < parameters.Length; i++)
            {
                ParameterInfo parameterInfo = parameters[i];
                Type          parameterType = TypeLoader.GetParameterType(parameterInfo);
                if (!ComPlusTypeValidator.IsValidParameter(parameterType, parameterInfo, allowReferences))
                {
                    throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ListenerInitFailed(System.ServiceModel.SR.GetString("InvalidWebServiceParameter", new object[] { parameterInfo.Name, parameterType.Name, methodName, contract.Name })));
                }
                MessagePartDescription item = this.CreateMessagePartDescription(parameterType, new System.ServiceModel.Description.XmlName(parameterInfo.Name), ns, i);
                description.Body.Parts.Add(item);
            }
            System.ServiceModel.Description.XmlName operationName = new System.ServiceModel.Description.XmlName(methodName);
            if (returnType == null)
            {
                description.Body.WrapperName = operationName.EncodedName;
                return(description);
            }
            description.Body.WrapperName = TypeLoader.GetBodyWrapperResponseName(operationName).EncodedName;
            if (!ComPlusTypeValidator.IsValidParameter(returnType, returnCustomAttributes, allowReferences))
            {
                throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ListenerInitFailed(System.ServiceModel.SR.GetString("InvalidWebServiceReturnValue", new object[] { returnType.Name, methodName, contract.Name })));
            }
            MessagePartDescription description3 = this.CreateMessagePartDescription(returnType, returnValueName, ns, 0);

            description.Body.ReturnValue = description3;
            return(description);
        }
Example #3
0
		public OperationDescription (string name,
			ContractDescription declaringContract)
		{
			this.name = name;
			contract = declaringContract;
			is_initiating = true;
			XmlName = new XmlName (name);
		}
 internal MessagePartDescription(MessagePartDescription other)
 {
     _name = other._name;
     _ns = other._ns;
     _index = other._index;
     _type = other._type;
     _serializationPosition = other._serializationPosition;
     _hasProtectionLevel = other._hasProtectionLevel;
     _protectionLevel = other._protectionLevel;
     _memberInfo = other._memberInfo;
     _multiple = other._multiple;
     _additionalAttributesProvider = other._additionalAttributesProvider;
     _baseType = other._baseType;
     _uniquePartName = other._uniquePartName;
 }
 internal MessagePartDescription(MessagePartDescription other)
 {
     this.name = other.name;
     this.ns = other.ns;
     this.index = other.index;
     this.type = other.type;
     this.serializationPosition = other.serializationPosition;
     this.hasProtectionLevel = other.hasProtectionLevel;
     this.protectionLevel = other.protectionLevel;
     this.memberInfo = other.memberInfo;
     this.multiple = other.multiple;
     this.additionalAttributesProvider = other.additionalAttributesProvider;
     this.baseType = other.baseType;
     this.uniquePartName = other.uniquePartName;
 }
        public MessagePartDescription(string name, string ns)
        {
            if (name == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("name", SR.GetString(SR.SFxParameterNameCannotBeNull));
            }

            this.name = new XmlName(name, true /*isEncoded*/);

            if (!string.IsNullOrEmpty(ns))
            {
                NamingHelper.CheckUriParameter(ns, "ns");
            }

            this.ns = ns;
        }
Example #7
0
        private OperationDescription CreateOperationDescription(ContractDescription contract, System.Reflection.MethodInfo methodInfo, ComContractElement config, bool allowReferences)
        {
            System.ServiceModel.Description.XmlName methodName      = new System.ServiceModel.Description.XmlName(ServiceReflector.GetLogicalName(methodInfo));
            System.ServiceModel.Description.XmlName returnValueName = TypeLoader.GetReturnValueName(methodName);
            if (ServiceReflector.IsBegin(methodInfo))
            {
                throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.NoAsyncOperationsAllowed());
            }
            if (contract.Operations.FindAll(methodName.EncodedName).Count != 0)
            {
                throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.DuplicateOperation());
            }
            OperationDescription description = new OperationDescription(methodName.EncodedName, contract)
            {
                SyncMethod    = methodInfo,
                IsInitiating  = true,
                IsTerminating = false
            };

            description.KnownTypes.Add(typeof(Array));
            description.KnownTypes.Add(typeof(DBNull));
            description.KnownTypes.Add(typeof(CurrencyWrapper));
            description.KnownTypes.Add(typeof(ErrorWrapper));
            if (allowReferences)
            {
                description.KnownTypes.Add(typeof(PersistStreamTypeWrapper));
            }
            foreach (ComUdtElement element in config.UserDefinedTypes)
            {
                Type type;
                Guid typeLibId = Fx.CreateGuid(element.TypeLibID);
                TypeCacheManager.Provider.FindOrCreateType(typeLibId, element.TypeLibVersion, Fx.CreateGuid(element.TypeDefID), out type, false);
                this.info.AddUdt(type, typeLibId);
                description.KnownTypes.Add(type);
            }
            string             ns           = contract.Namespace;
            XmlQualifiedName   contractName = new XmlQualifiedName(contract.Name, ns);
            string             action       = NamingHelper.GetMessageAction(contractName, methodName.DecodedName, null, false);
            string             str3         = NamingHelper.GetMessageAction(contractName, methodName.DecodedName, null, true);
            MessageDescription item         = this.CreateIncomingMessageDescription(contract, methodInfo, ns, action, allowReferences);
            MessageDescription description3 = this.CreateOutgoingMessageDescription(contract, methodInfo, returnValueName, ns, str3, allowReferences);

            description.Messages.Add(item);
            description.Messages.Add(description3);
            return(description);
        }
        internal FaultContractInfo(string action, Type detail, XmlName elementName, string ns, IList<Type> knownTypes)
        {
            if (action == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("action");
            }
            if (detail == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("detail");
            }

            _action = action;
            _detail = detail;
            if (elementName != null)
                _elementName = elementName.EncodedName;
            _ns = ns;
            _knownTypes = knownTypes;
        }
 internal FaultContractInfo(string action, Type detail, XmlName elementName, string ns, IList<Type> knownTypes)
 {
     if (action == null)
     {
         throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("action");
     }
     if (detail == null)
     {
         throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("detail");
     }
     this.action = action;
     this.detail = detail;
     if (elementName != null)
     {
         this.elementName = elementName.EncodedName;
     }
     this.ns = ns;
     this.knownTypes = knownTypes;
 }
 public OperationDescription(string name, ContractDescription declaringContract)
 {
     if (name == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("name");
     }
     if (name.Length == 0)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
             new ArgumentOutOfRangeException("name", SR.SFxOperationDescriptionNameCannotBeEmpty));
     }
     _name = new XmlName(name, true /*isEncoded*/);
     if (declaringContract == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("declaringContract");
     }
     _declaringContract = declaringContract;
     _isInitiating = true;
     _faults = new FaultDescriptionCollection();
     _messages = new MessageDescriptionCollection();
     _behaviors = new KeyedByTypeCollection<IOperationBehavior>();
     _knownTypes = new Collection<Type>();
 }
Example #11
0
 internal void SetNameAndElement(XmlName name)
 {
     _elementName = _name = name;
 }
 public void AddMemberAttributes(XmlName messageName, MessagePartDescription part, CodeAttributeDeclarationCollection importedAttributes, CodeAttributeDeclarationCollection typeAttributes, CodeAttributeDeclarationCollection fieldAttributes)
 {
     if (importedAttributes != null)
         fieldAttributes.AddRange(importedAttributes);
 }
Example #13
0
 internal void SetNameAndElement(XmlName name)
 {
     this.elementName = this.name = name;
 }
Example #14
0
 internal void SetNameOnly(XmlName name)
 {
     _name = name;
 }
Example #15
0
        static internal XmlReflectionMember GetXmlReflectionMember(XmlName memberName, XmlName elementName, string ns, Type type, MemberInfo additionalAttributesProvider, bool isMultiple, bool isWrapped)
        {
            XmlReflectionMember member = new XmlReflectionMember();

            member.MemberName = (memberName ?? elementName).DecodedName;
            member.MemberType = type;
            if (member.MemberType.IsByRef)
            {
                member.MemberType = member.MemberType.GetElementType();
            }
            if (isMultiple)
            {
                member.MemberType = member.MemberType.MakeArrayType();
            }
            if (additionalAttributesProvider != null)
            {
                member.XmlAttributes = XmlAttributesHelper.CreateXmlAttributes(additionalAttributesProvider);
            }

            if (member.XmlAttributes == null)
            {
                member.XmlAttributes = new XmlAttributes();
            }
            else
            {
                Type invalidAttributeType = null;
                if (member.XmlAttributes.XmlAttribute != null)
                {
                    invalidAttributeType = typeof(XmlAttributeAttribute);
                }
                else if (member.XmlAttributes.XmlAnyAttribute != null && !isWrapped)
                {
                    invalidAttributeType = typeof(XmlAnyAttributeAttribute);
                }
                else if (member.XmlAttributes.XmlChoiceIdentifier != null)
                {
                    invalidAttributeType = typeof(XmlChoiceIdentifierAttribute);
                }
                else if (member.XmlAttributes.XmlIgnore)
                {
                    invalidAttributeType = typeof(XmlIgnoreAttribute);
                }
                else if (member.XmlAttributes.Xmlns)
                {
                    invalidAttributeType = typeof(XmlNamespaceDeclarationsAttribute);
                }
                else if (member.XmlAttributes.XmlText != null)
                {
                    invalidAttributeType = typeof(XmlTextAttribute);
                }
                else if (member.XmlAttributes.XmlEnum != null)
                {
                    invalidAttributeType = typeof(XmlEnumAttribute);
                }
                if (invalidAttributeType != null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(isWrapped ? SR.SFxInvalidXmlAttributeInWrapped : SR.SFxInvalidXmlAttributeInBare, invalidAttributeType, elementName.DecodedName)));
                }
                if (member.XmlAttributes.XmlArray != null && isMultiple)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.SFxXmlArrayNotAllowedForMultiple, elementName.DecodedName, ns)));
                }
            }


            bool isArray = member.MemberType.IsArray;

            if ((isArray && !isMultiple && member.MemberType != typeof(byte[])) ||
                (!isArray && typeof(IEnumerable).IsAssignableFrom(member.MemberType) && member.MemberType != typeof(string) && !typeof(XmlNode).IsAssignableFrom(member.MemberType) && !typeof(IXmlSerializable).IsAssignableFrom(member.MemberType)))
            {
                if (member.XmlAttributes.XmlArray != null)
                {
                    if (member.XmlAttributes.XmlArray.ElementName == String.Empty)
                    {
                        member.XmlAttributes.XmlArray.ElementName = elementName.DecodedName;
                    }
                    if (member.XmlAttributes.XmlArray.Namespace == null)
                    {
                        member.XmlAttributes.XmlArray.Namespace = ns;
                    }
                }
                else if (HasNoXmlParameterAttributes(member.XmlAttributes))
                {
                    member.XmlAttributes.XmlArray             = new XmlArrayAttribute();
                    member.XmlAttributes.XmlArray.ElementName = elementName.DecodedName;
                    member.XmlAttributes.XmlArray.Namespace   = ns;
                }
            }
            else
            {
                if (member.XmlAttributes.XmlElements == null || member.XmlAttributes.XmlElements.Count == 0)
                {
                    if (HasNoXmlParameterAttributes(member.XmlAttributes))
                    {
                        XmlElementAttribute elementAttribute = new XmlElementAttribute();
                        elementAttribute.ElementName = elementName.DecodedName;
                        elementAttribute.Namespace   = ns;
                        member.XmlAttributes.XmlElements.Add(elementAttribute);
                    }
                }
                else
                {
                    foreach (XmlElementAttribute elementAttribute in member.XmlAttributes.XmlElements)
                    {
                        if (elementAttribute.ElementName == String.Empty)
                        {
                            elementAttribute.ElementName = elementName.DecodedName;
                        }
                        if (elementAttribute.Namespace == null)
                        {
                            elementAttribute.Namespace = ns;
                        }
                    }
                }
            }

            return(member);
        }
Example #16
0
 internal void SetNameOnly(XmlName name)
 {
     this.name = name;
 }
Example #17
0
 private MessageDescription CreateOutgoingMessageDescription(ContractDescription contract, System.Reflection.MethodInfo methodInfo, System.ServiceModel.Description.XmlName returnValueName, string ns, string action, bool allowReferences)
 {
     ParameterInfo[] outputParameters = ServiceReflector.GetOutputParameters(methodInfo, false);
     return(this.CreateParameterMessageDescription(contract, outputParameters, methodInfo.ReturnType, methodInfo.ReturnTypeCustomAttributes, returnValueName, methodInfo.Name, ns, action, MessageDirection.Output, allowReferences));
 }
Example #18
0
		// introduced for silverlight sdk compatibility
		internal FaultContractInfo (string action, Type detail, XmlName elementName, string ns, IList<Type> knownTypes)
		{
			throw new NotImplementedException ();
		}
 private OperationDescription CreateOperationDescription(ContractDescription contract, System.Reflection.MethodInfo methodInfo, ComContractElement config, bool allowReferences)
 {
     System.ServiceModel.Description.XmlName methodName = new System.ServiceModel.Description.XmlName(ServiceReflector.GetLogicalName(methodInfo));
     System.ServiceModel.Description.XmlName returnValueName = TypeLoader.GetReturnValueName(methodName);
     if (ServiceReflector.IsBegin(methodInfo))
     {
         throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.NoAsyncOperationsAllowed());
     }
     if (contract.Operations.FindAll(methodName.EncodedName).Count != 0)
     {
         throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.DuplicateOperation());
     }
     OperationDescription description = new OperationDescription(methodName.EncodedName, contract) {
         SyncMethod = methodInfo,
         IsInitiating = true,
         IsTerminating = false
     };
     description.KnownTypes.Add(typeof(Array));
     description.KnownTypes.Add(typeof(DBNull));
     description.KnownTypes.Add(typeof(CurrencyWrapper));
     description.KnownTypes.Add(typeof(ErrorWrapper));
     if (allowReferences)
     {
         description.KnownTypes.Add(typeof(PersistStreamTypeWrapper));
     }
     foreach (ComUdtElement element in config.UserDefinedTypes)
     {
         Type type;
         Guid typeLibId = Fx.CreateGuid(element.TypeLibID);
         TypeCacheManager.Provider.FindOrCreateType(typeLibId, element.TypeLibVersion, Fx.CreateGuid(element.TypeDefID), out type, false);
         this.info.AddUdt(type, typeLibId);
         description.KnownTypes.Add(type);
     }
     string ns = contract.Namespace;
     XmlQualifiedName contractName = new XmlQualifiedName(contract.Name, ns);
     string action = NamingHelper.GetMessageAction(contractName, methodName.DecodedName, null, false);
     string str3 = NamingHelper.GetMessageAction(contractName, methodName.DecodedName, null, true);
     MessageDescription item = this.CreateIncomingMessageDescription(contract, methodInfo, ns, action, allowReferences);
     MessageDescription description3 = this.CreateOutgoingMessageDescription(contract, methodInfo, returnValueName, ns, str3, allowReferences);
     description.Messages.Add(item);
     description.Messages.Add(description3);
     return description;
 }
 private MessageDescription CreateParameterMessageDescription(ContractDescription contract, ParameterInfo[] parameters, Type returnType, ICustomAttributeProvider returnCustomAttributes, System.ServiceModel.Description.XmlName returnValueName, string methodName, string ns, string action, MessageDirection direction, bool allowReferences)
 {
     MessageDescription description = new MessageDescription(action, direction) {
         Body = { WrapperNamespace = ns }
     };
     for (int i = 0; i < parameters.Length; i++)
     {
         ParameterInfo parameterInfo = parameters[i];
         Type parameterType = TypeLoader.GetParameterType(parameterInfo);
         if (!ComPlusTypeValidator.IsValidParameter(parameterType, parameterInfo, allowReferences))
         {
             throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ListenerInitFailed(System.ServiceModel.SR.GetString("InvalidWebServiceParameter", new object[] { parameterInfo.Name, parameterType.Name, methodName, contract.Name })));
         }
         MessagePartDescription item = this.CreateMessagePartDescription(parameterType, new System.ServiceModel.Description.XmlName(parameterInfo.Name), ns, i);
         description.Body.Parts.Add(item);
     }
     System.ServiceModel.Description.XmlName operationName = new System.ServiceModel.Description.XmlName(methodName);
     if (returnType == null)
     {
         description.Body.WrapperName = operationName.EncodedName;
         return description;
     }
     description.Body.WrapperName = TypeLoader.GetBodyWrapperResponseName(operationName).EncodedName;
     if (!ComPlusTypeValidator.IsValidParameter(returnType, returnCustomAttributes, allowReferences))
     {
         throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ListenerInitFailed(System.ServiceModel.SR.GetString("InvalidWebServiceReturnValue", new object[] { returnType.Name, methodName, contract.Name })));
     }
     MessagePartDescription description3 = this.CreateMessagePartDescription(returnType, returnValueName, ns, 0);
     description.Body.ReturnValue = description3;
     return description;
 }
 public MessagePartDescription(string name, string ns)
 {
     this.name = name;
     this.ns   = ns;
     XmlName   = new XmlName(name);
 }