public override bool Equals(object obj) { OperationParameterInfo parameter = obj as OperationParameterInfo; if (parameter == null) { return(false); } if (String.Compare(parameter.Name, this.Name, StringComparison.Ordinal) != 0) { return(false); } if (parameter.Attributes != this.Attributes) { return(false); } if (parameter.Position != this.Position) { return(false); } if (parameter.ParameterType != this.ParameterType) { return(false); } return(true); }
internal protected override OperationParameterInfoCollection GetParameters(IServiceProvider provider) { OperationParameterInfoCollection parameters = new OperationParameterInfoCollection(); MethodInfo methodInfo = this.GetMethodInfo(provider); if (methodInfo != null) { foreach (ParameterInfo parameter in methodInfo.GetParameters()) { if (parameters[parameter.Name] == null) { parameters.Add(new OperationParameterInfo(parameter)); } } if (methodInfo.ReturnParameter != null && methodInfo.ReturnParameter.ParameterType != typeof(void)) { if (parameters["(ReturnValue)"] == null) { OperationParameterInfo parameterInfo = new OperationParameterInfo(methodInfo.ReturnParameter); parameterInfo.Name = "(ReturnValue)"; parameters.Add(parameterInfo); } } } return(parameters); }
public OperationParameterInfo Clone() { OperationParameterInfo clonedParameter = new OperationParameterInfo(); clonedParameter.Name = this.Name; clonedParameter.Attributes = this.Attributes; clonedParameter.Position = this.Position; clonedParameter.ParameterType = this.ParameterType; return(clonedParameter); }
public override bool Equals(object obj) { if (!base.Equals(obj)) { return(false); } OperationInfo operationInfo = obj as OperationInfo; if (operationInfo == null) { return(false); } if (String.Compare(operationInfo.ContractName, this.ContractName, StringComparison.Ordinal) != 0) { return(false); } if (operationInfo.IsOneWay != this.IsOneWay) { return(false); } if (operationInfo.HasProtectionLevel != this.HasProtectionLevel) { return(false); } if (operationInfo.ProtectionLevel != this.ProtectionLevel) { return(false); } if (operationInfo.Parameters.Count != this.Parameters.Count) { return(false); } foreach (OperationParameterInfo parameter in operationInfo.Parameters) { OperationParameterInfo correspondingParameter = this.Parameters[parameter.Name]; if (correspondingParameter == null) { return(false); } if (!parameter.Equals(correspondingParameter)) { return(false); } } return(true); }
internal ContractMethodParameterInfo(ContractMethodInfo member, OperationParameterInfo parameterInfo) { if (member == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("member"); } if (parameterInfo == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("parameterInfo"); } this.AttrsImpl = parameterInfo.Attributes; this.MemberImpl = member; this.PositionImpl = parameterInfo.Position; if (parameterInfo.Position >= 0) { this.NameImpl = parameterInfo.Name; string typeName = parameterInfo.ParameterType.FullName; if ((this.AttrsImpl & ParameterAttributes.Out) > 0) { typeName += '&'; // Append with & for (ref & out) parameter types if (this.Member.DeclaringType is DesignTimeType) { this.ClassImpl = (this.Member.DeclaringType as DesignTimeType).ResolveType(typeName); } else if (parameterInfo.ParameterType is DesignTimeType) { this.ClassImpl = (parameterInfo.ParameterType as DesignTimeType).ResolveType(typeName); } else { typeName += ", " + parameterInfo.ParameterType.Assembly.FullName; this.ClassImpl = Type.GetType(typeName); } } else { this.ClassImpl = parameterInfo.ParameterType; } } else { this.ClassImpl = parameterInfo.ParameterType; } }
public OperationParameterInfo Clone() { OperationParameterInfo clonedParameter = new OperationParameterInfo(); clonedParameter.Name = this.Name; clonedParameter.Attributes = this.Attributes; clonedParameter.Position = this.Position; clonedParameter.ParameterType = this.ParameterType; return clonedParameter; }
internal ContractMethodInfo(ContractType declaringType, OperationInfo operationInfo) { if (declaringType == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("declaringType"); } if (operationInfo == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("operationInfo"); } if (string.IsNullOrEmpty(operationInfo.Name)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("operationInfo", SR2.GetString(SR2.Error_OperationNameNotSpecified)); } this.declaringType = declaringType; this.name = operationInfo.Name; this.methodAttributes = MethodAttributes.Public | MethodAttributes.Abstract | MethodAttributes.Virtual; SortedList<int, ContractMethodParameterInfo> localParameters = new SortedList<int, ContractMethodParameterInfo>(); foreach (OperationParameterInfo operationParameterInfo in operationInfo.Parameters) { ContractMethodParameterInfo parameterInfo = new ContractMethodParameterInfo(this, operationParameterInfo); if (parameterInfo.Position == -1) { this.returnParam = parameterInfo; } else { localParameters.Add(parameterInfo.Position, parameterInfo); } } this.parameters = new ParameterInfo[localParameters.Count]; foreach (ContractMethodParameterInfo paramInfo in localParameters.Values) { this.parameters[paramInfo.Position] = paramInfo; } if (this.returnParam == null) { OperationParameterInfo returnParameterInfo = new OperationParameterInfo(); returnParameterInfo.Position = -1; returnParameterInfo.ParameterType = typeof(void); this.returnParam = new ContractMethodParameterInfo(this, returnParameterInfo); } OperationContractAttribute operationContract = new OperationContractAttribute(); if (operationInfo.HasProtectionLevel && operationInfo.ProtectionLevel != null) { operationContract.ProtectionLevel = (ProtectionLevel) operationInfo.ProtectionLevel; } operationContract.IsOneWay = operationInfo.IsOneWay; this.attributes = new Attribute[] { operationContract }; declaringType.AddMethod(this); }
internal ContractMethodInfo(ContractType declaringType, OperationInfo operationInfo) { if (declaringType == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("declaringType"); } if (operationInfo == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("operationInfo"); } if (string.IsNullOrEmpty(operationInfo.Name)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("operationInfo", SR2.GetString(SR2.Error_OperationNameNotSpecified)); } this.declaringType = declaringType; this.name = operationInfo.Name; this.methodAttributes = MethodAttributes.Public | MethodAttributes.Abstract | MethodAttributes.Virtual; SortedList <int, ContractMethodParameterInfo> localParameters = new SortedList <int, ContractMethodParameterInfo>(); foreach (OperationParameterInfo operationParameterInfo in operationInfo.Parameters) { ContractMethodParameterInfo parameterInfo = new ContractMethodParameterInfo(this, operationParameterInfo); if (parameterInfo.Position == -1) { this.returnParam = parameterInfo; } else { localParameters.Add(parameterInfo.Position, parameterInfo); } } this.parameters = new ParameterInfo[localParameters.Count]; foreach (ContractMethodParameterInfo paramInfo in localParameters.Values) { this.parameters[paramInfo.Position] = paramInfo; } if (this.returnParam == null) { OperationParameterInfo returnParameterInfo = new OperationParameterInfo(); returnParameterInfo.Position = -1; returnParameterInfo.ParameterType = typeof(void); this.returnParam = new ContractMethodParameterInfo(this, returnParameterInfo); } OperationContractAttribute operationContract = new OperationContractAttribute(); if (operationInfo.HasProtectionLevel && operationInfo.ProtectionLevel != null) { operationContract.ProtectionLevel = (ProtectionLevel)operationInfo.ProtectionLevel; } operationContract.IsOneWay = operationInfo.IsOneWay; this.attributes = new Attribute[] { operationContract }; declaringType.AddMethod(this); }