-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
803 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace Rappen.XTB.LCG | ||
{ | ||
public class CommonSettings | ||
{ | ||
public CommonSettings() | ||
{ | ||
} | ||
|
||
internal string InlineConfigBegin = @"/***** LCG-configuration-BEGIN *****\"; | ||
internal string InlineConfigEnd = @"\***** LCG-configuration-END *****/"; | ||
public string[] CamelCaseWords { get; set; } = new string[] { "parent", "customer", "owner", "state", "status", "name", "phone", "address", "code", "postal", "mail", "modified", "created", "permission", "type", "method", "verson", "number", "first", "last", "middle", "contact", "account", "system", "user", "fullname", "preferred", "processing", "annual", "plugin", "step", "key", "details", "message", "description", "constructor", "execution", "secure", "configuration", "behalf", "count", "percent", "internal", "external", "trace", "entity", "primary", "secondary", "lastused", "credit", "credited", "donot", "exchange", "import", "invoke", "invoked", "private", "market", "marketing", "revenue", "business", "price", "level", "pricelevel", "territory", "version", "conversion", "workorder", "team" }; | ||
public string[] CamelCaseWordEnds { get; set; } = new string[] { "id" }; | ||
public string[] InternalAttributes { get; set; } = new string[] { "importsequencenumber", "owneridname", "owneridtype", "owneridyominame", "createdbyname", "createdbyyominame", "createdonbehalfby", "createdonbehalfbyname", "createdonbehalfbyyominame", "modifiedbyname", "modifiedbyyominame", "modifiedonbehalfby", "modifiedonbehalfbyname", "modifiedonbehalfbyyominame", "overriddencreatedon", "owningbusinessunit", "owningteam", "owninguser", "regardingobjectidname", "regardingobjectidyominame", "regardingobjecttypecode", "timezoneruleversionnumber", "transactioncurrencyidname", "utcconversiontimezonecode", "versionnumber" }; | ||
} | ||
} | ||
|
||
/* | ||
FileContainer | ||
FileHeader | ||
DataContainer | ||
EntityContainer | ||
EntityDetails | ||
Attributes | ||
Relationships | ||
OptionSets | ||
OptionSetValues | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using McTools.Xrm.Connection; | ||
using System.IO; | ||
|
||
namespace Rappen.XTB.Helper | ||
{ | ||
public static class ConfigurationUtils | ||
{ | ||
public static T GetEmbeddedConfiguration<T>(string filename, string begintoken, string endtoken) | ||
{ | ||
var csfile = File.ReadAllText(filename); | ||
var configstr = csfile.GetTextBetween(begintoken, endtoken, false); | ||
if (string.IsNullOrEmpty(configstr)) | ||
{ | ||
throw new FileLoadException("Could not find configuration token in file.", filename); | ||
} | ||
var configname = GetSimpleClassName<T>(); | ||
configstr = configstr.GetTextBetween($"<{configname}", $"</{configname}>", true); | ||
if (string.IsNullOrEmpty(configstr)) | ||
{ | ||
throw new FileLoadException($"Could not find {configname} XML in file.", filename); | ||
} | ||
var inlinesettings = (T)XmlSerializerHelper.Deserialize(configstr, typeof(T)); | ||
return inlinesettings; | ||
} | ||
|
||
private static string GetSimpleClassName<T>() | ||
{ | ||
var configname = typeof(T).ToString(); | ||
var confignameparts = configname.Split('.'); | ||
configname = confignameparts[confignameparts.Length - 1]; | ||
return configname; | ||
} | ||
|
||
private static string GetTextBetween(this string text, string begin, string end, bool includebeginend) | ||
{ | ||
var beginpos = text.IndexOf(begin); | ||
if (beginpos < 0) | ||
{ | ||
return string.Empty; | ||
} | ||
text = text.Substring(beginpos + (includebeginend ? 0 : begin.Length)); | ||
var endpos = text.IndexOf(end); | ||
if (endpos < 0) | ||
{ | ||
return string.Empty; | ||
} | ||
text = text.Substring(0, endpos + (includebeginend ? end.Length : 0)).Trim(); | ||
return text; | ||
} | ||
} | ||
} |
Oops, something went wrong.