Category: xaf
C# Devexpress Xaf Notları
Eğer BusinnesObjects Class XPObject üzerinden inherit oluyorsa (varsayılan BaseObject) Detail viewde oid alanı gelmekte. Bunu gizlemek için Module\Module.cs eklenmeli;
typesInfo.FindTypeInfo(typeof(XPObject)).KeyMember.AddAttribute(new BrowsableAttribute(false));

OnSaving()de otomatik kod ataması için DistributedIdGeneratorHelper.Generate kullanımı;


C# Devexpress xaf snippets


<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>propxaf</Title>
<Shortcut>propxaf</Shortcut>
<Description>Insert a property in XPO</Description>
<Author>Llamachant Technology Ltd.</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>type</ID>
<ToolTip>Property type</ToolTip>
<Default>string</Default>
</Literal>
<Literal>
<ID>property</ID>
<ToolTip>Property name</ToolTip>
<Default>Name</Default>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[
private $type$ _$property$;
public $type$ $property$
{
get { return _$property$;}
set { SetPropertyValue<$type$>(nameof($property$), ref _$property$, value); }
}
$end$]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
propxafCollection.snippet:
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>propxafCollection</Title>
<Shortcut>propxafCollection</Shortcut>
<Description>Insert a collection in XPO</Description>
<Author>Llamachant Technology Ltd.</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>type</ID>
<ToolTip>Remote Property type</ToolTip>
<Default>DomainObject</Default>
</Literal>
<Literal>
<ID>property</ID>
<ToolTip>Collection Property name</ToolTip>
<Default>MyProperty</Default>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[
[Association]
public XPCollection<$type$> $property$ {
get { return GetCollection<$type$>(nameof($property$)); }
}
$end$]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
propxafCollectionAggregated.snippet
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>propxafCollectionAggregated</Title>
<Shortcut>propxafCollectionAggregated</Shortcut>
<Description>Insert an aggregated collection (No link/unlink) in XPO</Description>
<Author>Llamachant Technology Ltd.</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>type</ID>
<ToolTip>Remote Property Type</ToolTip>
<Default>DomainObject</Default>
</Literal>
<Literal>
<ID>property</ID>
<ToolTip>Collection Property Name</ToolTip>
<Default>CollectionName</Default>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[
[DevExpress.Xpo.Aggregated, Association]
public XPCollection<$type$> $property$ {
get { return GetCollection<$type$>(nameof($property$)); }
}
$end$]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
propxafCust.snippet
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>propxafCust</Title>
<Shortcut>propxafCust</Shortcut>
<Description>Insert a custom object with default Name property</Description>
<Author>Llamachant Technology Ltd.</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>class</ID>
<ToolTip>Class Name</ToolTip>
<Default>CustomObject</Default>
</Literal>
<Literal>
<ID>classtype</ID>
<ToolTip>XPO Base Object Type (BaseObject, XPCustomObject, XPLiteObject, etc.)</ToolTip>
<Default>BaseObject</Default>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[
[DefaultProperty("Name")]
public class $class$ : $classtype$
{
public $class$(Session session) : base(session) { }
private string _Name;
public string Name
{
get { return _Name; }
set { SetPropertyValue<string>("Name", ref _Name, value); }
}
}
$end$]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
propxafOne.snippet
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>propxafOne</Title>
<Shortcut>propxafOne</Shortcut>
<Description>Insert a property with a One to Many relationship in XPO</Description>
<Author>Llamachant Technology Ltd.</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>type</ID>
<ToolTip>Property Type</ToolTip>
<Default>DomainObject</Default>
</Literal>
<Literal>
<ID>property</ID>
<ToolTip>Property Name</ToolTip>
<Default>MyProperty</Default>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[
private $type$ _$property$;
[Association]
public $type$ $property$
{
get { return _$property$;}
set { SetPropertyValue<$type$>(nameof($property$), ref _$property$, value); }
}
$end$]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
propxafPersistentAlias.snippet
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>propxafPersistentAlias</Title>
<Shortcut>propxafPersistentAlias</Shortcut>
<Description>Insert a persistent alias property in XPO</Description>
<Author>Llamachant Technology Ltd.</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>expression</ID>
<ToolTip>Alias Expression</ToolTip>
<Default></Default>
</Literal>
<Literal>
<ID>type</ID>
<ToolTip>Property Type</ToolTip>
<Default>string</Default>
</Literal>
<Literal>
<ID>property</ID>
<ToolTip>Property Name</ToolTip>
<Default>Name</Default>
</Literal>
<Literal>
<ID>converttype</ID>
<ToolTip>Convert to Type</ToolTip>
<Default>Int32</Default>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[
[PersistentAlias("$expression$")]
public $type$ $property$
{
get { return Convert.To$converttype$(EvaluateAlias(nameof($property$))); }
}
$end$]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>