private void GenerateServiceClass(string serviceName, Type type, ClassReferenceType classReferenceType, ServiceType serviceTypeEnum) { ClassReferenceInfo classReferenceInfo = new ClassReferenceInfo { ServiceName = serviceName, Name = type.Name, Type = classReferenceType, NameSpace = type.Namespace }; List <Type> services = type.GetTypesByAttribute <ServiceContractAttribute>(x => x.ServiceType == serviceTypeEnum).ToList(); bool justDeclared = false; if (serviceTypeEnum == ServiceType.HttpService && services.Count == 0) { services = new List <Type>() { type }; justDeclared = true; } foreach (Type serviceType in services) { typeGenerated.Add(serviceType); List <MethodInfo> methods = null;; if (justDeclared) { methods = serviceType.GetListOfDeclaredMethods().ToList(); } else { methods = serviceType.GetListOfMethodsWithAllOfBases().Where(x => x.IsPublic && !x.IsStatic).ToList(); } foreach (MethodInfo methodInfo in methods.Where(x => !(x.IsSpecialName && (x.Name.StartsWith("set_") || x.Name.StartsWith("get_"))) && !x.IsStatic)) { GenerateMethod(methodInfo, classReferenceInfo); methodGenerated.Add(methodInfo); } } if (classReferenceInfo.Methods.Count > 0) { NamespaceReferenceInfo.Classes.Add(classReferenceInfo); } }
private static string GetServiceType(ClassReferenceType classReferenceType, string className) { if (classReferenceType == ClassReferenceType.ServiceLevel) { return("ServiceType.ServerService"); } else if (classReferenceType == ClassReferenceType.StreamLevel) { return("ServiceType.StreamService"); } else if (classReferenceType == ClassReferenceType.OneWayLevel) { return("ServiceType.OneWayService"); } else if (classReferenceType == ClassReferenceType.HttpServiceLevel) { return("ServiceType.HttpService"); } return("not suport yet!"); }