public SdkMessageRequestField(SdkMessageRequest request, int index, string name, string clrFormatter, bool isOptional) { _request = request; _clrFormatter = clrFormatter; _name = name; _index = index; _isOptional = isOptional; }
public SdkMessageRequest ToSdk(SdkMessagePair sdk) { var request = new SdkMessageRequest(sdk, Id, Name); foreach (var field in RequestFields) { request.RequestFields[field.Key] = field.Value.ToSdk(request); } return request; }
public MetadataRequest(SdkMessageRequest request) { Id = request.Id; Name = request.Name; RequestFields = new Dictionary<int, MetadataRequestField>(); foreach (var field in request.RequestFields) { RequestFields[field.Key] = new MetadataRequestField(field.Value); } }
internal void Fill(Result result) { if (result.SdkMessageRequestId != Guid.Empty) { if (Request == null) { Request = new SdkMessageRequest(this, result.SdkMessageRequestId, result.SdkMessageRequestName); } Request.Fill(result); } if (result.SdkMessageResponseId != Guid.Empty) { if (Response == null) { Response = new SdkMessageResponse(result.SdkMessageResponseId); } Response.Fill(result); } }
public String GetNameForRequestField( SdkMessageRequest request, SdkMessageRequestField requestField, IServiceProvider services) { return DefaultNamingService.GetNameForRequestField( request, requestField, services); }
static CodeMemberProperty BuildRequestField(SdkMessageRequest request, SdkMessageRequestField field, ServiceProvider serviceProvider) { Trace.TraceInformation("Entering {0}", new object[] {MethodBase.GetCurrentMethod().Name}); var typeForRequestField = serviceProvider.TypeMappingService.GetTypeForRequestField(field, serviceProvider); var property = PropertyGet(typeForRequestField, serviceProvider.NamingService.GetNameForRequestField(request, field, serviceProvider), new CodeStatement[0]); property.HasSet = true; property.HasGet = true; property.GetStatements.Add(BuildRequestFieldGetStatement(field, typeForRequestField)); property.SetStatements.Add(BuildRequestFieldSetStatement(field)); Trace.TraceInformation("Exiting {0}: {1}.Request Property {2} defined", new object[] {MethodBase.GetCurrentMethod().Name, request.Name, property.Name}); return property; }
CodeGenerationType ICodeGenerationService.GetTypeForRequestField(SdkMessageRequest request, SdkMessageRequestField requestField, IServiceProvider services) { return CodeGenerationType.Property; }
static CodeTypeDeclaration BuildMessageRequest(SdkMessagePair messagePair, SdkMessageRequest sdkMessageRequest, ServiceProvider serviceProvider) { Trace.TraceInformation("Entering {0}", new object[] {MethodBase.GetCurrentMethod().Name}); var requestClass = Class(string.Format(CultureInfo.InvariantCulture, "{0}{1}", new object[] {serviceProvider.NamingService.GetNameForMessagePair(messagePair, serviceProvider), RequestClassSuffix}), RequestClassBaseType, new[] {Attribute(typeof (DataContractAttribute), new[] {AttributeArg("Namespace", messagePair.MessageNamespace)}), Attribute(typeof (RequestProxyAttribute), new[] {AttributeArg(null, messagePair.Request.Name)})}); var flag = false; var statements = new CodeStatementCollection(); if ((sdkMessageRequest.RequestFields != null) & (sdkMessageRequest.RequestFields.Count > 0)) { foreach (var field in sdkMessageRequest.RequestFields.Values) { var requestField = BuildRequestField(sdkMessageRequest, field, serviceProvider); if (requestField.Type.Options == CodeTypeReferenceOptions.GenericTypeParameter) { Trace.TraceInformation("Request Field {0} is generic. Adding generic parameter to the {1} class.", new object[] {requestField.Name, requestClass.Name}); flag = true; ConvertRequestToGeneric(messagePair, requestClass, requestField); } requestClass.Members.Add(requestField); if (!field.IsOptional) { statements.Add(AssignProp(requestField.Name, new CodeDefaultValueExpression(requestField.Type))); } } } if (!flag) { var constructor = Constructor(new CodeExpression[0]); constructor.Statements.Add(AssignProp(RequestNamePropertyName, new CodePrimitiveExpression(messagePair.Request.Name))); constructor.Statements.AddRange(statements); requestClass.Members.Add(constructor); } Trace.TraceInformation("Exiting {0}: SDK Request Class {1} defined", new object[] {MethodBase.GetCurrentMethod().Name, requestClass.Name}); return requestClass; }
internal SdkMessageRequestField ToSdk(SdkMessageRequest sdk) { return new SdkMessageRequestField(sdk, Index, Name, CLRFormatter, IsOptional); }
string INamingService.GetNameForRequestField(SdkMessageRequest request, SdkMessageRequestField requestField, IServiceProvider services) { if (_knowNames.ContainsKey(request.Id.ToString() + requestField.Index.ToString(CultureInfo.InvariantCulture))) { return _knowNames[request.Id.ToString() + requestField.Index.ToString(CultureInfo.InvariantCulture)]; } var str = CreateValidName(requestField.Name); _knowNames.Add(request.Id.ToString() + requestField.Index.ToString(CultureInfo.InvariantCulture), str); return str; }
public CodeGenerationType GetTypeForRequestField(SdkMessageRequest request, SdkMessageRequestField requestField, IServiceProvider services) { return GetTypeForRequestFieldInternal(request, requestField, services); }
protected virtual CodeGenerationType GetTypeForRequestFieldInternal(SdkMessageRequest request, SdkMessageRequestField requestField, IServiceProvider services) { return _defaultService.GetTypeForRequestField(request, requestField, services); }