-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscratchpad.cs
More file actions
145 lines (122 loc) · 4.27 KB
/
Copy pathscratchpad.cs
File metadata and controls
145 lines (122 loc) · 4.27 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
var builder = new SearchControlBuilder();
builder.Configure()
.AddRequestFilters(
Filter.ExcludeBin(),
Filter.ExcludeDocument(),
Filter.OmitStructureAttributes(),
Filter.AllowPaging(),
Filter.PageSize(2))
.SpecifyReturnedAttributes(
Attribute.WithDefinitionId(31),
Attribute.WithName("foo"))
.ConfigureReferenceHandling(
Options.UseChannel(3),
Options.ResolveAttributes(),
Options.ResolveSpecialCharacters()
Options.ReturnValueOnly());
var builder = new AqlQueryBuilder();
builder.BasePath("/foo/bar")
.QueryType(AqlQueryTypes.Below) // Enum of types
.ObjectTypeToFind(12) // Optional, can be string
.QueryString("\"objectId\" <= \"10\"")
.ConfigureSearchControls()
.AddRequestFilters(
Filter.ExcludeBin(),
Filter.ExcludeDocument(),
Filter.OmitStructureAttributes(),
Filter.AllowPaging(),
Filter.PageSize(2))
.ReturnAttributes(
Attribute.WithDefinitionId(31),
Attribute.WithName("foo"))
.ReturnLanguages(
Language.WithId(10),
Language.WithId(11))
.ConfigureReferenceHandling(
RefOptions.UseChannel(3),
RefOptions.ResolveAttributes(),
RefOptions.ResolveSpecialCharacters()
RefOptions.ReturnValueOnly());
var query = builder.Build();
var builder = new CreateRequestBuilder();
builder.NewContextName("/foo/bar")
.ObjectTypeToCreate("Produkt")
.FailOnError()
.AttributesToSet(() => new List<IAdsmlAttribute> {
StructureAttribute.New(215, new StructureValue(10, "foo")),
RelationAttribute.New(31, 1779))
})
.ConfigureLookupControls()
.AddRequestFilters(
Filter.ReturnRelationsAsAttributes(),
Filter.ResolveContextReferences())
.ReturnAttributes(
Attribute.WithDefinitionId(31),
Attribute.WithName("foo"))
.ReturnLanguages(
Language.WithId(10),
Language.WithId(11))
.ConfigureReferenceHandling(
RefOptions.UseChannel(3),
RefOptions.ResolveAttributes(),
RefOptions.ResolveSpecialCharacters()
RefOptions.ReturnValueOnly());
// OR
IList<StructureAttribute> attributes = new List<StructureAttribute>();
// Fill collection
builder.NewContextName("/foo/bar")
.ObjectTypeToCreate("Produkt")
.FailOnError()
.AttributesToSet(attributes)
.ConfigureLookupControls()
/*----------------------------------------------------------------------*/
/* MODIFY OPERATION */
/*----------------------------------------------------------------------*/
var builder = new ModifyRequestBuilder();
builder.Context("/foo/bar")
.ReturnNoAttributes()
.FailOnError()
.AddModification<SAttr>(
Modifications.ReplaceAttribute,
() => /*...*/)
.ConfigureLookupControls()
.Foo();
/*----------------------------------------------------------------------*/
/* LINK OPERATION */
/*----------------------------------------------------------------------*/
var builder = new LinkRequestBuilder();
builder.Context("foo")
.Target("bar")
.ReturnNoAttributes()
.CopyControls()
.CopyLocalAttributesFromSource()
.LookupControls()
.Foo();
public interface IResponseConverter<TOutput> : Converter<XElement, out TOutput> where TOutput : class
{
TOutput GetResponse(XElement source);
}
public class DeleteResponse : AdsmlResult { }
public class AdsmlResult
{
public IEnumerable<string> Messages { get; set; }
public string Code { get; set; }
public string Description { get; set; }
}
public class AdsmlResponseConverter : IResponseConverter
{
TOutput GetResponse<TOutput>(XElement source) where TOutput : class, AdsmlResult {
var result = new AdsmlResult();
// fill properties
return (TOutput) result;
}
}
/*
<xsd:complexType name="ADSMLResult">
<xsd:sequence>
<xsd:element name="Message" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="code" type="xsd:string" use="required"/>
<xsd:attribute name="description" type="xsd:string"/>
</xsd:complexType>
*/