2021-02-25 09:34:03 +08:00
|
|
|
|
using Microsoft.AnalysisServices.Tabular;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Metadata_Translator
|
|
|
|
|
{
|
|
|
|
|
public class MetadataObjectContainer
|
|
|
|
|
{
|
|
|
|
|
public virtual NamedMetadataObject TabularObject { get; protected set; }
|
|
|
|
|
public TranslatedProperty TranslatedProperty { get; protected set; }
|
2021-03-25 03:10:17 +08:00
|
|
|
|
|
|
|
|
|
public Guid TemporaryObjectId { get; protected set; }
|
2021-02-25 09:34:03 +08:00
|
|
|
|
public MetadataObjectContainer(NamedMetadataObject metadataObject, TranslatedProperty translatedProperty)
|
|
|
|
|
{
|
|
|
|
|
TabularObject = metadataObject;
|
|
|
|
|
TranslatedProperty = translatedProperty;
|
2021-03-25 03:10:17 +08:00
|
|
|
|
TemporaryObjectId = Guid.NewGuid();
|
2021-02-25 09:34:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
switch(TranslatedProperty)
|
|
|
|
|
{
|
|
|
|
|
case TranslatedProperty.Caption:
|
|
|
|
|
return $"{TabularObject.ObjectType} - Caption";
|
|
|
|
|
case TranslatedProperty.Description:
|
|
|
|
|
return $"{TabularObject.ObjectType} - Description";
|
|
|
|
|
case TranslatedProperty.DisplayFolder:
|
|
|
|
|
return $"{TabularObject.ObjectType} - DisplayFolder";
|
|
|
|
|
default:
|
|
|
|
|
return TabularObject.ObjectType.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-04-07 08:20:08 +08:00
|
|
|
|
|
|
|
|
|
public virtual string GetUniqueName(string namePrefix)
|
|
|
|
|
{
|
|
|
|
|
return (string.IsNullOrEmpty(namePrefix)) ? TemporaryObjectId.ToString() : $"{namePrefix}{GetFullName(TabularObject)}#{TranslatedProperty}";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual string GetFullName(MetadataObject metadataObject)
|
|
|
|
|
{
|
|
|
|
|
string fullName = string.Empty;
|
|
|
|
|
|
|
|
|
|
if(metadataObject is NamedMetadataObject tabularObject)
|
|
|
|
|
{
|
|
|
|
|
string parentName = (tabularObject.Parent != null) ? GetFullName(tabularObject.Parent) : string.Empty;
|
|
|
|
|
fullName = string.Concat(parentName, "#", tabularObject.Name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return fullName;
|
|
|
|
|
}
|
2021-02-25 09:34:03 +08:00
|
|
|
|
}
|
|
|
|
|
}
|