Ejemplo n.º 1
0
 private IEnumerable <StatementSyntax> FillInputParametersStatements(CimPropertyDeclarationExtensions.NameAndType p)
 {
     if (p.IsNullableValueType)
     {
         yield return(SyntaxFactory.IfStatement(SyntaxFactory.ParseExpression($"in{p.Name}.HasValue"),
                                                SyntaxFactory.ParseStatement($"parameters.Add(CimMethodParameter.Create(\"{p.Name}\", in{p.Name}.Value, CimFlags.None));")));
     }
     else if (p.IsCimObject)
     {
         yield return(SyntaxFactory.ParseStatement($"if (in{p.Name} != null) parameters.Add(CimMethodParameter.Create(\"{p.Name}\", in{p.Name}.AsCimInstance(), CimType.{p.CimType} , in{p.Name} == null? CimFlags.NullValue : CimFlags.None));"));
     }
     else
     {
         yield return(SyntaxFactory.ParseStatement($"if (in{p.Name} != null) parameters.Add(CimMethodParameter.Create(\"{p.Name}\", in{p.Name}, CimType.{p.CimType}, in{p.Name} == null? CimFlags.NullValue : CimFlags.None));"));
     }
 }
Ejemplo n.º 2
0
 private ArgumentSyntax ReturnStatementSyntax(CimPropertyDeclarationExtensions.NameAndType p)
 {
     if (p.IsCimObject)
     {
         if (p.IsEnumerable)
         {
             return(SyntaxFactory.Argument(SyntaxFactory.ParseExpression($"({p.Type}) InfrastuctureObjectScope.Mapper.CreateMany<{p.EnumeratedType}>(InfrastuctureObjectScope, (IEnumerable<CimInstance>) result.OutParameters[\"{p.Name}\"].Value)")));
         }
         else
         {
             return(SyntaxFactory.Argument(SyntaxFactory.ParseExpression($"({p.Type}) InfrastuctureObjectScope.Mapper.Create(InfrastuctureObjectScope, (CimInstance) result.OutParameters[\"{p.Name}\"].Value)")));
         }
     }
     else
     {
         return(SyntaxFactory.Argument(SyntaxFactory.ParseExpression($"({p.Type}) result.OutParameters[\"{p.Name}\"].Value")));
     }
 }