/// <returns></returns> public TranslationModel AddTranslation(string key, string name, string target) { if (string.IsNullOrEmpty(key)) { throw new ArgumentException("Value may not be null or empty", "key"); } if (string.IsNullOrEmpty(target)) { throw new ArgumentException("Value may not be null or empty", "target"); } var model = new TranslationModel(key, name, target); translations.Add(model); index.Add(model.Key, model); return(model); }
/// <summary> /// Gets the code for passing the specified model as parameter to a trampoline method. /// </summary> /// <param name="model">The model.</param> /// <returns>The code.</returns> public string GetTrampolineParameterCode(ParameterModel model) { if (model.Flags.HasFlag(ParameterModelFlags.IsOutput)) { return(string.Format("ref _{0}", model.Name)); } TranslationModel translationModel = model.Type as TranslationModel; if (translationModel != null) { var type = Type.GetType(translationModel.TargetType); if (Marshal.SizeOf(type) > sizeof(long)) { return(string.Format("new System.IntPtr(&{0})", model.Name)); } } return(model.Name); }
/// <summary> /// Initializes the <see cref="ApiModel"/> class. /// </summary> static ApiModel() { VoidModel = new TranslationModel("void", "void", "System.Void"); }