public MetadataPair(SdkMessagePair pair)
 {
     Id = pair.Id;
     MessageNamespace = pair.MessageNamespace;
     Request = pair.Request == null ? null : new MetadataRequest(pair.Request);
     Response = pair.Response == null ? null : new MetadataResponse(pair.Response);
 }
Ejemplo n.º 2
0
 public SdkMessageRequest(SdkMessagePair message, Guid id, string name)
 {
     _id = id;
     _name = name;
     _messagePair = message;
     _requestFields = new Dictionary<int, SdkMessageRequestField>();
 }
Ejemplo n.º 3
0
 string INamingService.GetNameForMessagePair(SdkMessagePair messagePair, IServiceProvider services)
 {
     if (_knowNames.ContainsKey(messagePair.Id.ToString()))
     {
         return _knowNames[messagePair.Id.ToString()];
     }
     var str = CreateValidTypeName(messagePair.Request.Name);
     _knowNames.Add(messagePair.Id.ToString(), str);
     return str;
 }
 public SdkMessagePair ToSdk(SdkMessage sdk)
 {
     var pair = new SdkMessagePair(sdk, Id, MessageNamespace);
     pair.Request = Request.ToSdk(pair);
     if (Response != null)
     {
         pair.Response = Response.ToSdk(sdk);
     }
     return pair;
 }
        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;
        }
Ejemplo n.º 6
0
 internal void Fill(Result result)
 {
     if (!SdkMessagePairs.ContainsKey(result.SdkMessagePairId))
     {
         var pair = new SdkMessagePair(this, result.SdkMessagePairId, result.SdkMessagePairNamespace);
         _sdkMessagePairs.Add(pair.Id, pair);
     }
     SdkMessagePairs[result.SdkMessagePairId].Fill(result);
     if (!SdkMessageFilters.ContainsKey(result.SdkMessageFilterId))
     {
         var filter = new SdkMessageFilter(result.SdkMessageFilterId);
         SdkMessageFilters.Add(result.SdkMessageFilterId, filter);
     }
     SdkMessageFilters[result.SdkMessageFilterId].Fill(result);
 }
Ejemplo n.º 7
0
 public String GetNameForMessagePair(
     SdkMessagePair messagePair, IServiceProvider services)
 {
     return DefaultNamingService.GetNameForMessagePair(messagePair, services);
 }
Ejemplo n.º 8
0
 static void ConvertRequestToGeneric(SdkMessagePair messagePair, CodeTypeDeclaration requestClass, CodeMemberProperty requestField)
 {
     var parameter = new CodeTypeParameter(requestField.Type.BaseType)
         {
             HasConstructorConstraint = true
         };
     parameter.Constraints.Add(new CodeTypeReference(EntityClassBaseType));
     requestClass.TypeParameters.Add(parameter);
     requestClass.Members.Add(Constructor(new CodeExpression[] {New(requestField.Type, new CodeExpression[0])}));
     var constructor = Constructor(Param(requestField.Type, "target"), new CodeStatement[] {AssignProp(requestField.Name, VarRef("target"))});
     constructor.Statements.Add(AssignProp(RequestNamePropertyName, new CodePrimitiveExpression(messagePair.Request.Name)));
     requestClass.Members.Add(constructor);
 }
Ejemplo n.º 9
0
 static CodeTypeDeclaration BuildMessageResponse(SdkMessagePair messagePair, SdkMessageResponse sdkMessageResponse, ServiceProvider serviceProvider)
 {
     Trace.TraceInformation("Entering {0}", new object[] {MethodBase.GetCurrentMethod().Name});
     var declaration = Class(string.Format(CultureInfo.InvariantCulture, "{0}{1}", new object[] {serviceProvider.NamingService.GetNameForMessagePair(messagePair, serviceProvider), ResponseClassSuffix}), ResponseClassBaseType, new[] {Attribute(typeof (DataContractAttribute), new[] {AttributeArg("Namespace", messagePair.MessageNamespace)}), Attribute(typeof (ResponseProxyAttribute), new[] {AttributeArg(null, messagePair.Request.Name)})});
     declaration.Members.Add(Constructor(new CodeExpression[0]));
     if ((sdkMessageResponse != null) && ((sdkMessageResponse.ResponseFields != null) & (sdkMessageResponse.ResponseFields.Count > 0)))
     {
         foreach (var field in sdkMessageResponse.ResponseFields.Values)
         {
             declaration.Members.Add(BuildResponseField(sdkMessageResponse, field, serviceProvider));
         }
     }
     else
     {
         Trace.TraceInformation("SDK Response Class {0} has not fields", new object[] {declaration.Name});
     }
     Trace.TraceInformation("Exiting {0}: SDK Response Class {1} defined", new object[] {MethodBase.GetCurrentMethod().Name, declaration.Name});
     return declaration;
 }
Ejemplo n.º 10
0
 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;
 }
Ejemplo n.º 11
0
 CodeGenerationType ICodeGenerationService.GetTypeForMessagePair(SdkMessagePair messagePair, IServiceProvider services)
 {
     return CodeGenerationType.Class;
 }
 protected virtual CodeGenerationType GetTypeForMessagePairInternal(SdkMessagePair messagePair, IServiceProvider services)
 {
     return _defaultService.GetTypeForMessagePair(messagePair, services);
 }
 public CodeGenerationType GetTypeForMessagePair(SdkMessagePair messagePair, IServiceProvider services)
 {
     return GetTypeForMessagePairInternal(messagePair, services);
 }
Ejemplo n.º 14
0
 bool ICodeWriterMessageFilterService.GenerateSdkMessagePair(SdkMessagePair messagePair, IServiceProvider services)
 {
     if (!_generateMessages)
     {
         return false;
     }
     if (_excludedNamespaces.Contains(messagePair.MessageNamespace.ToUpperInvariant()))
     {
         return false;
     }
     return (string.IsNullOrEmpty(_messageNamespace) || string.Equals(_messageNamespace, messagePair.MessageNamespace, StringComparison.OrdinalIgnoreCase));
 }