public RpcTypeDescriptor(string name, bool value_type, string unmarshal_method, MarshalHelperBuilder marshal_helper,
                          string marshal_method, NdrBaseTypeReference ndr_type, NdrCorrelationDescriptor conformance, NdrCorrelationDescriptor variance,
                          AdditionalArguments additional_marshal_args, AdditionalArguments additional_unmarshal_args)
     : this(new CodeTypeReference(name), value_type, unmarshal_method, marshal_helper, marshal_method, ndr_type,
            conformance, variance, additional_marshal_args, additional_unmarshal_args)
 {
     Constructed = true;
     Union       = ndr_type is NdrUnionTypeReference;
 }
        public RpcTypeDescriptor(CodeTypeReference code_type, bool value_type, string unmarshal_method,
                                 MarshalHelperBuilder marshal_helper, string marshal_method, NdrBaseTypeReference ndr_type,
                                 NdrCorrelationDescriptor conformance, NdrCorrelationDescriptor variance,
                                 AdditionalArguments additional_marshal_args, AdditionalArguments additional_unmarshal_args)
        {
            CodeType        = code_type;
            UnmarshalMethod = unmarshal_method;
            if (additional_marshal_args != null)
            {
                if (marshal_helper == null)
                {
                    throw new ArgumentNullException(nameof(marshal_helper));
                }

                MarshalMethod = marshal_helper.AddGenericMarshal(ndr_type, code_type, marshal_method, additional_marshal_args);
            }
            else
            {
                MarshalMethod = marshal_method;
            }

            if (additional_unmarshal_args != null)
            {
                if (marshal_helper == null)
                {
                    throw new ArgumentNullException(nameof(marshal_helper));
                }

                UnmarshalMethod = marshal_helper.AddGenericUnmarshal(ndr_type, code_type, unmarshal_method, additional_unmarshal_args ?? new AdditionalArguments());
            }
            else
            {
                UnmarshalMethod = unmarshal_method;
            }

            NdrType               = ndr_type;
            ValueType             = value_type;
            ConformanceDescriptor = conformance ?? new NdrCorrelationDescriptor();
            VarianceDescriptor    = variance ?? new NdrCorrelationDescriptor();
        }
Esempio n. 3
0
 public string AddGenericMarshal(NdrBaseTypeReference ndr_type, string type_name, string name, AdditionalArguments additional_args)
 {
     return(AddGenericMarshal(ndr_type, new CodeTypeReference(CodeGenUtils.MakeIdentifier(type_name)), name, additional_args));
 }
Esempio n. 4
0
        public string AddGenericMarshal(NdrBaseTypeReference ndr_type, CodeTypeReference type, string name, AdditionalArguments additional_args)
        {
            CodeTypeReference generic_type = additional_args.Generic ? (additional_args.GenericType ?? type.ToBaseRef()) : null;
            var method = AddMethod(MarshalHelper, $"Write_{_current_marshal_id++}", generic_type, null, name, new[] { type }, additional_args);

            MarshalMethods.Add(ndr_type, method);
            return(method.Name);
        }
Esempio n. 5
0
        public string AddGenericUnmarshal(NdrBaseTypeReference ndr_type, CodeTypeReference type, string name, AdditionalArguments additional_args)
        {
            CodeTypeReference generic_type = additional_args.Generic ? (additional_args.GenericType ?? type.ToBaseRef()) : null;
            var method = AddMethod(UnmarshalHelper, $"Read_{_current_unmarshal_id++}", generic_type, type, name, new CodeTypeReference[0], additional_args);

            UnmarshalMethods.Add(ndr_type, method);
            return(method.Name);
        }
Esempio n. 6
0
        private static CodeMemberMethod AddMethod(CodeTypeDeclaration marshal_type, string method_name, CodeTypeReference generic_type, CodeTypeReference return_type,
                                                  string name, CodeTypeReference[] pre_args, AdditionalArguments additional_args)
        {
            var method = marshal_type.AddMethod(method_name, MemberAttributes.Public | MemberAttributes.Final);

            method.ReturnType = return_type;
            int arg_count = 0;

            List <CodeExpression> arg_names = new List <CodeExpression>(pre_args.Select(a => AddParam(a, arg_count++, method)));

            arg_names.AddRange(additional_args.FixedArgs);
            arg_names.AddRange(additional_args.Params.Select(a => AddParam(a, arg_count++, method)));

            CodeMethodReferenceExpression generic_method = generic_type != null ? new CodeMethodReferenceExpression(null, name, generic_type) : new CodeMethodReferenceExpression(null, name);
            var invoke_method = new CodeMethodInvokeExpression(generic_method, arg_names.ToArray());

            if (return_type != null)
            {
                method.AddReturn(invoke_method);
            }
            else
            {
                method.Statements.Add(invoke_method);
            }

            return(method);
        }
 public RpcTypeDescriptor(Type code_type, string unmarshal_method, MarshalHelperBuilder marshal_helper,
                          string marshal_method, NdrBaseTypeReference ndr_type,
                          NdrCorrelationDescriptor conformance, NdrCorrelationDescriptor variance, AdditionalArguments additional_marshal_args, AdditionalArguments additional_unmarshal_args)
     : this(new CodeTypeReference(code_type), code_type.IsValueType || typeof(NtObject).IsAssignableFrom(code_type),
            unmarshal_method, marshal_helper, marshal_method, ndr_type, conformance, variance, additional_marshal_args, additional_unmarshal_args)
 {
     BuiltinType = code_type;
 }