forked from ServiceStack/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTranslateAttribute.cs
More file actions
40 lines (35 loc) · 1.32 KB
/
TranslateAttribute.cs
File metadata and controls
40 lines (35 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
using System.Collections.Generic;
using System.Text;
namespace ServiceStack.Translators
{
/// <summary>
/// This instructs the generator tool to generate translator methods for the types supplied.
/// A {TypeName}.generated.cs partial class will be generated that contains the methods required
/// to generate to and from that type.
/// </summary>
[AttributeUsage(AttributeTargets.Class)]
public class TranslateAttribute : Attribute
{
public string SourceMethodPrefix { get; set; }
public string TargetMethodPrefix { get; set; }
public Type SourceType { get; set; }
public Type TargetType { get; set; }
public TranslateAttribute(Type targetType)
: this(null, targetType) {}
public TranslateAttribute(string sourceExtensionPrefix, Type targetType, string targetExtensionPrefix)
: this(null, sourceExtensionPrefix, targetType, targetExtensionPrefix) { }
protected TranslateAttribute(Type sourceType, Type targetType)
{
this.SourceType = sourceType;
this.TargetType = targetType;
}
protected TranslateAttribute(Type sourceType, string sourceExtensionPrefix, Type targetType, string targetExtensionPrefix)
{
this.SourceType = sourceType;
this.SourceMethodPrefix = sourceExtensionPrefix;
this.TargetType = targetType;
this.TargetMethodPrefix = targetExtensionPrefix;
}
}
}